Re: [PATCH 06/18] fwd: Better split forwarding rule specification from associated sockets

David Gibson
2026-04-08T01:37:13Z

[-- Attachment #1: Type: text/plain, Size: 2337 bytes --]

On Wed, Apr 08, 2026 at 01:14:46AM +0200, Stefano Brivio wrote:
> On Tue, 7 Apr 2026 13:16:18 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > 6dad076df037 ("fwd: Split forwarding rule specification from its
> > implementation state") created struct fwd_rule_state with a forwarding rule
> > plus the table of sockets used for its implementation. It turns out this
> > is quite awkward for sharing rule parsing code between passt and the
> > upcoming configuration client.
>
> Indeed, I hated it, in that short moment I had to fiddle with it. Thanks
> for coming up with a cleaner solution.

Yeah, mea culpa. Seemed like a good idea at the time, but it wasn't.

[snip]
> > /**
> > - * struct fwd_table - Table of forwarding rules (per initiating pif)
> > + * struct fwd_table - Forwarding state (per initiating pif)
> > * @count: Number of forwarding rules
> > * @rules: Array of forwarding rules
> > + * @rulesocks: Pointers to socket arrays per-rule
>
> I don't see this as particularly descriptive (which sockets? What's
> the array size?). I'm thinking of something like:
>
> @socks_ref: Per-rule pointers to associated @socks, @sock_count of them

There are @count of them, not @sock_count... which I guess just
emphasises the need for a better description. How's this:

* struct fwd_table - Forwarding state (per initiating pif)
* @count: Number of forwarding rules
* @rules: Array of forwarding rules
* @rulesocks: Array of @count pointers within @socks giving the start of the
* corresponding rule's listening sockets within the larger array
* @sock_count: Number of entries used in @socks (for all rules combined)
* @socks: Listening sockets for forwarding

> > * @sock_count: Number of entries used in @socks
> > * @socks: Listening sockets for forwarding
> > */
> > struct fwd_table {
> > unsigned count;
> > - struct fwd_rule_state rules[MAX_FWD_RULES];
> > + struct fwd_rule rules[MAX_FWD_RULES];
> > + int *rulesocks[MAX_FWD_RULES];
> > unsigned sock_count;
> > int socks[MAX_LISTEN_SOCKS];
> > };
>
> --
> Stefano
>

--
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]