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=IHBlMVJ+; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0CC0B5A0262 for ; Wed, 08 Apr 2026 03:37:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1775612229; bh=iTxFbayMiSdNrNjR9FypJZBDkjVZA+w41OlQFMr5Uvs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IHBlMVJ+Ori2cFEc0rprGBpug7pMmcWMxwN9FD3b8z/oAQM9nkDBB8uNCywMRZXwR wrgmEkjoOgTcFj2G9pFEwrkrJ2/u2hjLLE9zyhhDVMAKvBkJ7KUms8vAN6SArzdsB+ 7wz/BwvsLDg3A9nSWaHw3ccuTaShtnJM2VF81Bi9KWw2gGS7iGu2QocgU5YqK9I/h7 bK6i22AR5oAnOWwNbTuWvugp7AjYsyI270jbL8eZoJyfhqPwGKHKd3r/gBLWwzb7cH uxGzQsY6WACnzPdRbmJP6LyY8PXfKQ6aVhtU2rzHuYtI2BoNO+YOEsyruksIqOShW8 qVffIltuIyN3Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fr5K16pXcz4wbr; Wed, 08 Apr 2026 11:37:09 +1000 (AEST) Date: Wed, 8 Apr 2026 11:10:25 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 02/18] conf: Simplify handling of default forwarding mode Message-ID: References: <20260407031630.2457081-1-david@gibson.dropbear.id.au> <20260407031630.2457081-3-david@gibson.dropbear.id.au> <20260408011435.3b425877@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ACYVE88sgcA05ZNE" Content-Disposition: inline In-Reply-To: <20260408011435.3b425877@elisabeth> Message-ID-Hash: SH4H7XJKBSRV36K7SBLGO3MQV2JC4ILG X-Message-ID-Hash: SH4H7XJKBSRV36K7SBLGO3MQV2JC4ILG 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: --ACYVE88sgcA05ZNE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 08, 2026 at 01:14:36AM +0200, Stefano Brivio wrote: > On Tue, 7 Apr 2026 13:16:14 +1000 > David Gibson wrote: >=20 > > For passt, the default forwarding mode is "none", which falls out natur= ally > > from the other handling: if we don't get any options, we get empty > > forwarding tables, which corresponds to "none" behaviour. However, for > > pasta the default is "auto". This is handled a bit oddly: in conf_port= s() > > we set the mode variable, but don't set up the rules we need for "auto" > > mode. Instead we want until nearly the end of conf() and if the mode is > > FWD_MODE_AUTO or unset, we make conf_ports_range_except() calls to set = up > > the "auto" rules. > >=20 > > Simplify this a bit, by creating the rules within conf_ports() itself w= hen > > we parse -[tuTU] auto. For the case of no forwarding options we call > > into conf_ports() itself with synthetic arguments. As well as making t= he > > code a little shorter, this makes it more obvious that giving no argume= nts > > really is equivalent to -[tuTU] auto. > >=20 > > Signed-off-by: David Gibson > > --- > > conf.c | 54 ++++++++++++++++++++++-------------------------------- > > 1 file changed, 22 insertions(+), 32 deletions(-) > >=20 > > diff --git a/conf.c b/conf.c > > index c515480b..7d718f91 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -345,6 +345,10 @@ static void conf_ports(const struct ctx *c, char o= ptname, const char *optarg, > > die("'auto' port forwarding is only allowed for pasta"); > > =20 > > *mode =3D FWD_MODE_AUTO; > > + > > + conf_ports_range_except(c, optname, optarg, fwd, NULL, NULL, > > + 1, NUM_PORTS - 1, NULL, 1, FWD_SCAN); > > + > > return; > > } >=20 > Pre-existing, it goes away in 12/18 of the current series, and it's > harmless unless somebody should ever touch 'enum fwd_mode' in a rather > unlikely way: the code here checks: >=20 > if (*mode) > ... >=20 > relying on the fact that FWD_MODE_UNSPEC is 0 (and we also have a _NONE > value, which makes it somewhat risky) instead of directly checking if > (*mode =3D=3D FWD_MODE_UNSPEC). >=20 > I thought I would note it here in the unlikely case we'd need to back to > mode constants for whatever reason. Right. I noticed this, and my solution was to remove enum fwd_mode entirely in 12/18 as noted :). --=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 --ACYVE88sgcA05ZNE Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmnVqvQACgkQzQJF27ox 2GdqnhAAldyqvS74XR12MgmUP5TSZa8yL+QDVDpFAyPgiO6uzlMashpiaABp42MH tl3mlAk/1kjziCb8/WIOIWbPdDY7KGQx0vo0MzyEL6/FHL62EMe1XliDSbQsyzxt g6rqdHVdjfUEDgZxFps30Ea5UrVJS1BzUTNXYflkg7AZyROjYiOf3wwkONkzSZfI zK5f3q2d9s7LwGbB+C3znx1nGDNr5AqYHO2okZdIRfTH+D++XqLS9gos3PzPcWet cmNxROoBGp8frz3MEkrXfBV2ve5g1rge6eZBmTA9RniLKkWc6tOmVJ+0DKPxdP4Z wHzB1F71bTN+boFed8XV4Zdu641jFNHhME7nefuP08PJcqCL0uKjmzsYKQdJbIvS vAjPWqir3ApfPfOAS7uGy2nYxlapmc8L8muC9G/Z3lprjN9sOzvn8f0dp58z/B3X JxO9bzkvz23kxme+NI/EE/i0uwNzHopIsLPaLrauYB0kRRD7aR3g5zPFm3hQSKBg xsqXXkV5YhDSFugPcheiHmJWQn1cXv5d7fgRxwGa5uKsI5QS13Z/d8lQoO3YwXw6 wBtanbHQYzEljTLZh93NMpEX3gBWwwXCi1tkCvcUPvZxsVPxPDEzB6n9sQFfrqJf 49vGbadgkhjwtggLTfXqZ32zzIjQwUo3c12etegMXqZ9/AeG+WA= =7kEs -----END PGP SIGNATURE----- --ACYVE88sgcA05ZNE--