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=suPzmpYT; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 656305A0619 for ; Wed, 29 Oct 2025 01:23:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1761697387; bh=DcXmZX/rjOC3r3ZWuX88uUgKMDePNTxV/xZ9YDxO9cA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=suPzmpYTLcb/BlCcdTyZvmtYFNV7fS/75cZw6LuIkyHztW85IoX/GH++iybm8fFpb MpjaulPW80dYkxkMs8A5F65HuxQ1ZT/LVPxSQWzy/wfBcjJBVyuQPh9M4AJWPVgBb5 3qZAqkFzXZGTtVL3e9zvrbmq/ocmsx20LTqDfyjiBWfN+DtvtShg+ibUO6mhCJTAnn XQz87lN4Z0lnecjusgTkdnoZxdSWjyQJNfQAtcXqnHR1mjVQ2yHciR8O1BKmX7PghY 4KG0UJEJx/fayzCg/SXS/06wwHDAXqXe/FbfQhr2PUo5TloA/BlrTVVbkKqypLDs4T cGt3V5CIu+JcQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cx7Hv159Nz4wD1; Wed, 29 Oct 2025 11:23:07 +1100 (AEDT) Date: Wed, 29 Oct 2025 11:22:57 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 2/3] udp: Unify some more inbound/outbound parts of udp_sock_init() Message-ID: References: <20251022031527.990033-1-david@gibson.dropbear.id.au> <20251022031527.990033-3-david@gibson.dropbear.id.au> <20251029001338.3e33a58f@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4hmwu1UIqKO8zmIR" Content-Disposition: inline In-Reply-To: <20251029001338.3e33a58f@elisabeth> Message-ID-Hash: LKEDSDPJTRB622F7LRNZJIW5HKT4TD2U X-Message-ID-Hash: LKEDSDPJTRB622F7LRNZJIW5HKT4TD2U 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: --4hmwu1UIqKO8zmIR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 29, 2025 at 12:13:38AM +0100, Stefano Brivio wrote: > Sorry for the delay but... >=20 > On Wed, 22 Oct 2025 14:15:26 +1100 > David Gibson wrote: >=20 > > udp_sock_init() takes an 'ns' parameter determining if it creates a soc= ket > > in the guest namespace or host namespace. Alter it to take a pif > > parameter instead, like tcp_sock_init(), and use that change to slightly > > reduce code duplication between the HOST and SPLICE cases. > >=20 > > Signed-off-by: David Gibson > > --- > > conf.c | 2 +- > > udp.c | 65 +++++++++++++++++++++++++++++++--------------------------- > > udp.h | 5 +++-- > > 3 files changed, 39 insertions(+), 33 deletions(-) > >=20 > > diff --git a/conf.c b/conf.c > > index 26f1bcc0..08cb50aa 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -171,7 +171,7 @@ static void conf_ports_range_except(const struct ct= x *c, char optname, > > if (optname =3D=3D 't') > > 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); > > + ret =3D udp_sock_init(c, PIF_HOST, addr, ifname, i); > > else > > /* No way to check in advance for -T and -U */ > > ret =3D 0; > > diff --git a/udp.c b/udp.c > > index 86585b7e..7f5faf20 100644 > > --- a/udp.c > > +++ b/udp.c > > @@ -1093,64 +1093,68 @@ int udp_tap_handler(const struct ctx *c, uint8_= t pif, > > /** > > * udp_sock_init() - Initialise listening sockets for a given port > > * @c: Execution context > > - * @ns: In pasta mode, if set, bind with loopback address in namespace > > + * @pif: Interface to open the socket for (PIF_HOST or PIF_SPLICE) > > * @addr: Pointer to address for binding, NULL if not configured > > * @ifname: Name of interface to bind to, NULL if not configured > > * @port: Port, host order > > * > > * Return: 0 on (partial) success, negative error code on (complete) f= ailure > > */ > > -int udp_sock_init(const struct ctx *c, int ns, const union inany_addr = *addr, > > - const char *ifname, in_port_t port) > > +int udp_sock_init(const struct ctx *c, uint8_t pif, > > + const union inany_addr *addr, const char *ifname, > > + in_port_t port) > > { > > union udp_listen_epoll_ref uref =3D { > > - .pif =3D ns ? PIF_SPLICE : PIF_HOST, > > + .pif =3D pif, > > .port =3D port, > > }; > > int r4 =3D FD_REF_MAX + 1, r6 =3D FD_REF_MAX + 1; > > + int (*socks)[NUM_PORTS]; > > =20 > > ASSERT(!c->no_udp); > > + ASSERT(pif_is_socket(pif)) >=20 > ...this doesn't build. If I add the missing semicolon everything is > fine. Should I? Worth double checking on your side? Oh. Wow. Don't know how I missed that. I'll fix it. I need to respin to add the fallback for kernels without BINDTODEVICE anyway. --=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 --4hmwu1UIqKO8zmIR Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkBXlIACgkQzQJF27ox 2Ge2yxAAjTSX5vamgaYFEVzmUob02+f1lkzCshuMS11tt4KUCdMTG8E6hkwJxKtz ADJEJjNFv7Z2vWcmPoyh3uLZ4PQwd9Rl90SjSdr0g6kn/sa3Tgm7p4EQksO+Msly 8v4BX8+bPMJq+Xf6ZTYAMt2lq+62GJGWFvbuYBngOckVRrvUYPPCfyEUQdo5VmHn jG4KyD+g1OmdxMkSNOsm0PMeeLHlHcyEtE0WrG+dBgoQxEC6saEV0j77ea+gn3nj c+AgYOUYmBze3IfYNIHvdrWgV4j1i1zKhg3soqhmNvJulWEpPyQwrhyDHIgeZE8S nU3IJCYuIzQrcQkf8Q9v+tEQlBMU1TN7dsgetqo5dX5MZl9aIHLC90FxoRXtVxBx MOiXntHj2jAoiNgkAsEV9RiogStov1yiEk2pRtNhX1Oy8sW+8kk4QH1lF9jeB7Dk PiYvgA074WoYxJ/oVZNLUmDzVhowES0cNNTG2iwWAzyLTHfi3N/SgyKYpQDY4ciT cZ6PX3GZUtyWsraBcJIBhR3tRi5tMEaQJtRVUqf6Dl+SKHWG6qQ4pIFDDbzeJXPa cfNB59ankCprnfOiI5CnHuPQUmqNrnY/WY/X6bKugt4SQZ55hescO17B3cMLrw4V wJRQvsxvYMVizBPyrpSUlt9UCC8B5VpP/rlwUTsqHnWmK+B+Yco= =sQZl -----END PGP SIGNATURE----- --4hmwu1UIqKO8zmIR--