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=202602 header.b=jhzMZ0Js; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 1FEC95A0271 for ; Wed, 25 Mar 2026 05:44:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1774413865; bh=wNVYhMLFY8pzhS6OTbtwnVhK5Kp0Kz02tvkZ15ZMPZc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jhzMZ0JsPdy22OeHcA2OReQuoEZ+esEwEFxjDRBBqfylCinauven1x8SCuefq3bc2 VtRMS3p4MLbuvY2n2XI71uYraUwxkgTiUGkcz3An/5AmR13rBy3onIBQa/zfdwckRA FNvJr4GocmHwmjrPa00dd0OOLPVmfV2oY77dy/8RFE6R/1ug+o15QXXFaBpShi84aT G3EFxqMBP/n3LfgW9FBEee4jVTv2Lg34g5UX4yoYFkS6apA3+LkA6Wm0pN5vxx9lOQ UAZjd8Z6M0IjSgH+Q9BBmV1QWocgvOsDNSSc6i7cvdVBkMW5xqCUqsPgbhuyifgw92 xZ7RYBxnzsNTg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fgZ7Y2Jhkz4wCB; Wed, 25 Mar 2026 15:44:25 +1100 (AEDT) Date: Wed, 25 Mar 2026 15:07:16 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 08/25] fwd: Allow FWD_DUAL_STACK_ANY flag to be passed directly to fwd_rule_add() Message-ID: References: <20260323073732.3158468-1-david@gibson.dropbear.id.au> <20260323073732.3158468-9-david@gibson.dropbear.id.au> <20260325015432.365f9a6b@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gBOoWaU2yazB7PRW" Content-Disposition: inline In-Reply-To: <20260325015432.365f9a6b@elisabeth> Message-ID-Hash: QZ3ZXGBLRMUIRI3KJ2QZ7H27CGQVY3QE X-Message-ID-Hash: QZ3ZXGBLRMUIRI3KJ2QZ7H27CGQVY3QE 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: --gBOoWaU2yazB7PRW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 25, 2026 at 01:54:33AM +0100, Stefano Brivio wrote: > Nits: >=20 > On Mon, 23 Mar 2026 18:37:15 +1100 > David Gibson wrote: >=20 > > fwd_rule_add() takes a flags parameter, but it only allows the FWD_WEAK > > and FWD_SCAN flags to be specified there. It doesn't allow the > > FWD_DUAL_STACK_ANY flag to be set, instead expecting a [*] address to be > > indicated by passing NULL as @addr. > >=20 > > However, for upcoming dynamic rule updates, it's more convenient to be = able > > to explicitly pass FWD_DUAL_STACK_ANY along with an address of ::. All= ow > > that mode of calling. > >=20 > > Signed-off-by: David Gibson > > --- > > fwd.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > >=20 > > diff --git a/fwd.c b/fwd.c > > index 3395a28e..d73b7ca7 100644 > > --- a/fwd.c > > +++ b/fwd.c > > @@ -362,18 +362,21 @@ void fwd_rule_add(struct fwd_table *fwd, uint8_t = proto, uint8_t flags, > > in_port_t first, in_port_t last, in_port_t to) > > { > > /* Flags which can be set from the caller */ > > - const uint8_t allowed_flags =3D FWD_WEAK | FWD_SCAN; > > + const uint8_t allowed_flags =3D FWD_WEAK | FWD_SCAN | FWD_DUAL_STACK_= ANY; > > unsigned num =3D (unsigned)last - first + 1; > > struct fwd_rule *new; > > unsigned i, port; > > =20 > > assert(!(flags & ~allowed_flags)); > > - >=20 > Spurious change, I think? The extra newline here looks good for > readability. Oops, yes. > Maybe we should group the second assert with this one? Good idea, done. >=20 > > if (fwd->count >=3D ARRAY_SIZE(fwd->rules)) > > die("Too many port forwarding ranges"); > > if ((fwd->sock_count + num) > ARRAY_SIZE(fwd->socks)) > > die("Too many listening sockets"); > > =20 > > + /* Passing a non-wildcard address with DUAL_STACK_ANY is a bug */ >=20 > Extra whitespace after DUAL_STACK_ANY. Fixed. >=20 > > + assert(!(flags & FWD_DUAL_STACK_ANY) || !addr || > > + inany_equals(addr, &inany_any6)); > > + > > /* Check for any conflicting entries */ > > for (i =3D 0; i < fwd->count; i++) { > > char newstr[INANY_ADDRSTRLEN], rulestr[INANY_ADDRSTRLEN]; >=20 > --=20 > Stefano >=20 --=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 --gBOoWaU2yazB7PRW Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmnDX3MACgkQzQJF27ox 2Gem1w//S3OaYTgrcHU7PsA4QfJ/6LqoX+YAWdi2Uf/XOjjAYDF0VM3xWiloEb0T sQBcY47IcMAQSpRW3VcVJ5DcaHYFyySYOhdbMe63ueoGLCY8aaxErHvQCQ9feXdJ GlTlWLOCPQWPqB2ZhN+rwDw1egTzaCUp5S6Z2HtDPT+6zlMi4giyxJZHSQQrNdXd pRDh7E6cS33DwmYC4b+kls3s+kBfp8RAxoKTCWrJbGPNnvWZf84OCTIu08Gff9yV xa3AsIQh14NWa1LPYNGpaedb2P3lVFiMNY3pI68lTqi6nVDVJjpIR/dzuKrvufU1 waJKth2xzUl1ojxG0sAZtL7gVAl3OtBcvy0qm+/WwLIb+7O4Aa8BNLjSIwQcHDLv eztwSestWI2QeJG2htAQjsrzEmVljY+oiQLU5sIQu0hxXEI3w9BZ+yNlC/6QfcVa Gj6ObuLlN6SoNMRjqpSA/a73k0s60RZudO8NGjNkr2fhUbKs8PROc6JCEevZwsUp 02w3vHSYxuv8AIDzzLipHVqCYAt+pv3drCoNQU2cE6YL6G00ibPdlN9fG/ZBPZfH ijfE13t6lAlUqYK6wrkpW2SO1XLgm8dckRXTnc4bNHghBCefltlXTbfYi2GFhmO0 d2Y4Ea6rt+Pov37eSBK7JuDWL+ithUqc9U2F+q97XZW3Os+h24I= =Ed5T -----END PGP SIGNATURE----- --gBOoWaU2yazB7PRW--