From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202510 header.b=P0Vp6Yyk; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id EF2B35A0619 for ; Mon, 20 Oct 2025 11:25:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1760952312; bh=HPcMqGFhEEnYzRAZANSi/QAasFq7YsczfwlJpBba7j0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P0Vp6YykH13lN0TSPNvtgtu/pq0iyVdn0SspE2WVXDSgpna+LLDnrdu/pvmComk+o T3Tp/eRtyzW98vQYPkgQYtQWVQIkzMgaYMJqXRGgm486lsOmwajP7nCzzLGXSdjaal IIVT7D2mwFeGWyp0I3GOKeiuCVFfoyhCiMHpXUpGpwiGt8oHN7f9UOOKvquivMpXsL 3p40t4q4FnIa8J/Ho5YkHLXv8C+qRoc9EN64oJRnaFOrXOjCDcGXVu53lLRiIGwPb3 PLfc9z0W8z05UsqmeHXqFsHzvY5kWWUwix9wjT6OlRnou/EpkI63uU9Bbej3aj+IoA iI1NyOfRvi4uQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cqqlX6wzgz4wCJ; Mon, 20 Oct 2025 20:25:12 +1100 (AEDT) Date: Mon, 20 Oct 2025 20:25:10 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 1/3] tcp: Merge tcp_ns_sock_init[46]() into tcp_sock_init_one() Message-ID: References: <20251017003447.414103-1-david@gibson.dropbear.id.au> <20251017003447.414103-2-david@gibson.dropbear.id.au> <20251020080959.13267d1c@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4SdV6Xjw62ZtKE5o" Content-Disposition: inline In-Reply-To: <20251020080959.13267d1c@elisabeth> Message-ID-Hash: ZC27GXHVVALGG2HJU7J5FLYXH6QOEONF X-Message-ID-Hash: ZC27GXHVVALGG2HJU7J5FLYXH6QOEONF X-MailFrom: dgibson@gandalf.ozlabs.org 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: --4SdV6Xjw62ZtKE5o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 20, 2025 at 08:09:59AM +0200, Stefano Brivio wrote: > On Fri, 17 Oct 2025 11:34:45 +1100 > David Gibson wrote: >=20 > > 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. > >=20 > > 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. > >=20 > > Signed-off-by: David Gibson > > --- > > conf.c | 2 +- > > tcp.c | 96 ++++++++++++++++++---------------------------------------- > > tcp.h | 5 +-- > > 3 files changed, 33 insertions(+), 70 deletions(-) > >=20 > > 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 ct= x *c, char optname, > > fwd->delta[i] =3D to - first; > > =20 > > if (optname =3D=3D 't') > > - ret =3D tcp_sock_init(c, addr, ifname, i); > > + ret =3D tcp_sock_init(c, PIF_HOST, addr, ifname, i); > > else if (optname =3D=3D 'u') > > ret =3D 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, unio= n epoll_ref ref, > > /** > > * tcp_sock_init_one() - Initialise listening socket for address and p= ort > > * @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 fai= lure > > + * > > + * If pif =3D=3D PIF_SPLICE, must have already entered the namespace. >=20 > ...I forgot: nit: a subject in this sentence would be nice for > readability. Noted, will adjust. --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --4SdV6Xjw62ZtKE5o Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmj1//UACgkQzQJF27ox 2GcRfg//fmEHB93GNXG2JaaOxjYrtR+sM0rD+iljeqT51HyYCmrxIOOBjugcVaxr +tBGtAv00JGl8cFjvKfPibj5QPX3kevVHNjJs31p8mHWHdHmZ4ZQSo3K9IW1TeQI SAJiBSuuVCdaX/xb2fFNSKJU7xrlAlSbQUzi6rYVrb4TpawlkdV4ZoRyfDkzaQbD MmsDxiuV3t+LhS6+tknJIQxs9J7J65DHetK+QHmwdL6f/nbkp5mxX/3CGs6mTzIH mF8ueCzoHzc+hIWJq41sg6Xkpl0Kpb0vvKLihlXuxdehnIwzdS64t2Mn5dZZa3zl Awh1iMIVx3NLNpkoer3GLAQpNf+wQ9th7ML942jOPjYKN09xB1T/i0oN7HnaAJ8Y thB+ZSCx2C1gj72PFwqwbREbIpH2JsWdHbVOvDHRhdklKCylo1TyWLE63x1jCNAm lw3B84xzHYFh6xRx9xtGvqwTtrkySlIucKyO9BoQ32cyv5opKvyiqSECvA/pnTgd AHEx9Iqq9bFNMC4GI5/bIngcB0po1c6SCJCkS2gyqDcVTaSRf8W/x++TrNxjFhGU PQZlG1qyfx40n8I89j5q9jeSuHspNjjurtG/fkjY079iQ4upto1ia7/DAAj7eo6R aSufzcjJF2ft4zChqloVtRpw0cSFTBd71PlR+oExQD7QcY6ucF8= =vaO7 -----END PGP SIGNATURE----- --4SdV6Xjw62ZtKE5o--