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=ZyCuvh+6; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 56D725A061B for ; Mon, 23 Mar 2026 03:50:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1774234219; bh=grR1yCcySixO55/uQvRQaIKHByPg5KyDq/bPO+HDDEU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZyCuvh+6tmYwjnMCxXSlJHtTaj7MsVOb0yBYtuj1KlzoOyNlkxOR2Pwad3au/vqug GokpUzDTQqmKwhQCkOZe4sL1w6Lr5f+EQc4l+nsu6CAzXWSJwdZ1zX+PPK82IjByFn PfEk/5cfDnnBqc4tdjkydhHIL3kmX9xmhI33fpM7ZuHNnSjyx/rp3Zvwhlbn3gj3Pb LP+vK1hk+dMTB+C90UTkNRlg4QumXGZ6tju84z9M/uyg0JXZHq6xI3LkXQbWueNCAN S5lofp7l58l819FrQN1Uc2aQyhk8m6yC6DZnmSrrOUruN2gnMdQLDwrEMU1Ll2qijY h5/tmmotbGlAA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ffHhq1kxZz4wDm; Mon, 23 Mar 2026 13:50:19 +1100 (AEDT) Date: Mon, 23 Mar 2026 11:51:22 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 06/15] fwd: Store forwarding tables indexed by (origin) pif Message-ID: References: <20260319061157.1983818-1-david@gibson.dropbear.id.au> <20260319061157.1983818-7-david@gibson.dropbear.id.au> <20260320215834.791be767@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zBCjsFotbVOHBRW/" Content-Disposition: inline In-Reply-To: <20260320215834.791be767@elisabeth> Message-ID-Hash: WBAJFEY4NHKEKUEHUCNIZPQOIZ2YLS56 X-Message-ID-Hash: WBAJFEY4NHKEKUEHUCNIZPQOIZ2YLS56 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: --zBCjsFotbVOHBRW/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 20, 2026 at 09:58:34PM +0100, Stefano Brivio wrote: > On Thu, 19 Mar 2026 17:11:48 +1100 > David Gibson wrote: >=20 > > Currently we store the inbound (PIF_HOST) and outbound (PIF_SPLICE) > > forwarding tables in separate fields of struct ctx. In a number of pla= ces > > this requires somewhat awkward if or switch constructs to select the > > right table for updates. Conceptually simplify that by using an index = of > > forwarding tables by pif, which as a bonus keeps track generically which > > pifs have implemented forwarding tables so far. > >=20 > > For now this doesn't simplify a lot textually, because many places that > > need this also have other special cases to apply by pif. It does simpl= ify > > a few crucial places though, and we expect it will become more useful as > > the flexibility of the forwarding table is improved. > >=20 > > Signed-off-by: David Gibson > > --- > > conf.c | 53 +++++++++++++++++++++++++++------------------- > > flow.c | 22 +++++++------------ > > fwd.c | 65 ++++++++++++++++++++++++++++++--------------------------- > > fwd.h | 4 ++-- > > passt.h | 3 +-- > > 5 files changed, 77 insertions(+), 70 deletions(-) > >=20 > > diff --git a/conf.c b/conf.c > > index 940fb9e9..6af3c8a5 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -1252,11 +1252,12 @@ dns6: > > } > > } > > =20 > > - info("Inbound forwarding:"); > > - fwd_rules_print(&c->fwd_in); > > - if (c->mode =3D=3D MODE_PASTA) { > > - info("Outbound forwarding:"); > > - fwd_rules_print(&c->fwd_out); > > + for (i =3D 0; i < PIF_NUM_TYPES; i++) { > > + if (!c->fwd[i]) > > + continue; > > + > > + info("Forwarding from %s:", pif_name(i)); >=20 > I don't have a good solution to propose but it's slightly annoying that > we're changing very clear "Inbound forwarding" and "Outbound > forwarding" indications to "Forwarding from: " HOST | TAP | SPLICE. >=20 > Should we perhaps introduce a PIF_INBOUND_MAX value that's the same as > HOST, and then: >=20 > if (i <=3D PIF_INBOUND_MAX) > info("Inbound forwarding:"); > else > info("Outbound forwarding:"); >=20 > ? That will become ambiguous as soon as we add tables for TAP. > I'm fine keeping it as it is, I would just have a slight preference to > make it as clear as it was before. This is something users can now look > at to double check things and I have the feeling we're avoid a bunch of > bug reports as a result. For now I've gone with: {Inbound|Outbound} forwarding rules (): > > diff --git a/passt.h b/passt.h > > index b614bdf0..5fc4e07f 100644 > > --- a/passt.h > > +++ b/passt.h > > @@ -264,8 +264,7 @@ struct ctx { > > unsigned int pasta_ifi; > > int pasta_conf_ns; > > =20 > > - struct fwd_table fwd_in; > > - struct fwd_table fwd_out; > > + struct fwd_table *fwd[PIF_NUM_TYPES]; >=20 > Nit: the struct documentation should be updated accordingly. Fixed. --=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 --zBCjsFotbVOHBRW/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmnAjokACgkQzQJF27ox 2GfPFA/8C4N+vkDs+R8FJjGesHlnfORiX2TY4U70hQYDzJRqZ976ff6TaSXhahCY 21fCESLgI+UsPl3Fxbws0s0sv7pzQ+OMhehFyHd94vhUxDCnP1UzATjsN7YYf4E+ sMD1jgla4Sn9sfb+BMjxPhH6/Xta7WCifYTci6ZLQlFFs/yJzH2LNmWBoeqenbFs 9jtXUtMSMpKe/57p5FfRsVivirLxax4FPU1iVIMN5FCMhyosvaE1Jv/t1b6ual4l jdtGaxn9n8SeULkDgN+TJ3UcJd3pmcOeoH2S7O1A/Z8OO6V4ZKyNrfd3NqnP4IL6 fYWcX/l/7ikwtbtFXdsnUgT596aK7bOOZpedREN1brliB+qFxagYAfFSitztvYQZ hKwlqvPD6mdf+p4c4MjrouUz0R6niD+AJc41PKoLMTxC8KWHlQN3AJLYJov23uZP CeOkdvk+c4rwiFLg3ghZ2slZAw3cjfpmiKlWuFHEOSxSolyusyQAi7w7h4xmcFQz 0/zpTIrgwOM7n0e6rSm5lQeXXuMIpRsV5HKwkyxQ7Ju3y2igSwvmVUTKY+jWMrGK MrEz7stoiYhm1AG1Os2Pc/KPfLf0Y645SMi3UulrpABHdFpR007H9IJSPIExMRmm JTbNHiTY4oHHZ6Eod2/91/2ezYl8mnoamkRFygLfdsdhrBVgJEc= =Yr80 -----END PGP SIGNATURE----- --zBCjsFotbVOHBRW/--