From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HqHUxLUS; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id F36455A0619 for ; Mon, 20 Oct 2025 08:10:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760940604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PowyO1AyCtHLIRQvAklajXpJu1NPAFo/FeaS9eUUGds=; b=HqHUxLUS44KyocJ0UBznt9DPVn4SjxJjrMoTGYIZV8TmnUVbbWpfOGCtFWtm9+cn/TzAiY WAUiaM7snkk6BpVLB1DYsi4qxbvHePxJTIy2kArgMz3CV0PeMAnW0ZsgHJ9/tdHPAbwNRz Uquu1VWPzRxjJB5BwYVASTKGCTBOsGc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-481-KsN9RZKUMLmtUXa0IHXKmQ-1; Mon, 20 Oct 2025 02:10:02 -0400 X-MC-Unique: KsN9RZKUMLmtUXa0IHXKmQ-1 X-Mimecast-MFC-AGG-ID: KsN9RZKUMLmtUXa0IHXKmQ_1760940601 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-47113538d8cso22131605e9.1 for ; Sun, 19 Oct 2025 23:10:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760940601; x=1761545401; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PowyO1AyCtHLIRQvAklajXpJu1NPAFo/FeaS9eUUGds=; b=NauXJ6rDLzWOiym3fnFt34e+Tkv8Z20jNzfz7vOLVSFL+ZqucHt9KwSdLfS2zs+5eT SUYeH2kmndigbmVyHaLUzNNHa41cuY9uy158tIVIAs8JkzC335B1p7lO3ohg4DSu7UkG p1Tx7k7mEmVkuF3xpSq+v1BXd03HVvFGJym6Emtd/sEO0A4c8of2cCINfHiUu7UNJ+1Z XinPNpTS2XD5mOorIUuwPpyCw6NrhWiJOXkTmDqOnl5ngZ/VOjgpjngP8qW28lBt66zU mUSwNGdYWPizGB0YsMiLKGiBd5MrSHglOa/VeT36GT9H1D83Eu0h0TEjaEfBF0TzAAUF CpCg== X-Gm-Message-State: AOJu0YxAD1tRyElu3Xs6+ecEVI3Yom5k2/a6UNltzh3aOtgQ0YDuiryw RVzjkvFcpus+74ORcgreEjqgB4KhNHLt5ycSh070DXE52+ZS/MwrQiobLm4ElzZTjsfNXITFkbQ HTMW8RUCz6FyNccqPELwYDoeUQLfMVVNSlsRZFkzSSjqaRpyjJicENA== X-Gm-Gg: ASbGnctQjaGX4M1cvQYQo+9QSjCY22gZqBBB0ECARJBBsxlcWm2lMiyETyBHvcrDcZx 3ppHCl6Nw1YGfdDzywLk7OHA4aT567vpY84jr/ytwIWVUZtJ/hf7tHhU1XeSBAU+Yc5S0trrcOk IkR6lhr7YUFlrR8utKZkb7PcDhZO1/KwKQPgQSL+LwdjYCFT3IbCtzlDNzv0N6HI1z5RT5mROZf P5SleDCqa2i7TJFYAGtwow63z3Ncg7gwWjAD9vSKKxQi8q6wMImVQ/6d5ube8dmuUvMckkPP+6W 7Pm2sTrr3zGM39ZHaUrxpSxVHfJxi06KqyDvtWY0tT+2OEoB6VYT1WBG9qhGQMXfb007OpFVy/7 SFmWcsZlKpA== X-Received: by 2002:a05:600c:4e0a:b0:456:13b6:4b18 with SMTP id 5b1f17b1804b1-4711791cb96mr90798075e9.31.1760940601300; Sun, 19 Oct 2025 23:10:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF84FbnmfhLo09YUxw51GhEPq/ioIxBwqVky4Qy1mB4tnoF05bbHwgEhi+teYY+X7LDaL7LA== X-Received: by 2002:a05:600c:4e0a:b0:456:13b6:4b18 with SMTP id 5b1f17b1804b1-4711791cb96mr90797825e9.31.1760940600885; Sun, 19 Oct 2025 23:10:00 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4710ed4b47fsm107867395e9.4.2025.10.19.23.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Oct 2025 23:10:00 -0700 (PDT) Date: Mon, 20 Oct 2025 08:09:59 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 1/3] tcp: Merge tcp_ns_sock_init[46]() into tcp_sock_init_one() Message-ID: <20251020080959.13267d1c@elisabeth> In-Reply-To: <20251017003447.414103-2-david@gibson.dropbear.id.au> References: <20251017003447.414103-1-david@gibson.dropbear.id.au> <20251017003447.414103-2-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: g1QlFcZ5BbqLI9XPnrleSqxK7AFxfkS1795AUko-TFk_1760940601 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: SGJVQJN65Z3FZ3ZMMQAI3LBIWSUGNG2K X-Message-ID-Hash: SGJVQJN65Z3FZ3ZMMQAI3LBIWSUGNG2K X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 17 Oct 2025 11:34:45 +1100 David Gibson wrote: > Surprisingly little logic is shared between the path for creating a > listen()ing socket in the guest namespace versus in the host namespace. > Improve this, by extending tcp_sock_init_one() to take a pif parameter > indicating where it should open the socket. This allows > tcp_ns_sock_init[46]() to be removed entirely. > > We generalise tcp_sock_init() in the same way, although we don't use it > yet, due to some subtle differences in how we bind for -t versus -T. > > Signed-off-by: David Gibson > --- > conf.c | 2 +- > tcp.c | 96 ++++++++++++++++++---------------------------------------- > tcp.h | 5 +-- > 3 files changed, 33 insertions(+), 70 deletions(-) > > diff --git a/conf.c b/conf.c > index 66b9e634..26f1bcc0 100644 > --- a/conf.c > +++ b/conf.c > @@ -169,7 +169,7 @@ static void conf_ports_range_except(const struct ctx *c, char optname, > fwd->delta[i] = to - first; > > if (optname == 't') > - ret = tcp_sock_init(c, addr, ifname, i); > + ret = tcp_sock_init(c, PIF_HOST, addr, ifname, i); > else if (optname == 'u') > ret = udp_sock_init(c, 0, addr, ifname, i); > else > diff --git a/tcp.c b/tcp.c > index 0f9e9b3f..15c012d7 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2515,29 +2515,38 @@ void tcp_sock_handler(const struct ctx *c, union epoll_ref ref, > /** > * tcp_sock_init_one() - Initialise listening socket for address and port > * @c: Execution context > + * @pif: Interface to open the socket for (PIF_HOST or PIF_SPLICE) > * @addr: Pointer to address for binding, NULL for dual stack any > * @ifname: Name of interface to bind to, NULL if not configured > * @port: Port, host order > * > * Return: fd for the new listening socket, negative error code on failure > + * > + * If pif == PIF_SPLICE, must have already entered the namespace. ...I forgot: nit: a subject in this sentence would be nice for readability. -- Stefano