On Tue, Mar 10, 2026 at 08:33:11PM +0100, Stefano Brivio wrote:
On Tue, 10 Mar 2026 15:16:00 +1100 David Gibson
wrote: The 'mode' field of struct fwd_ports records the overall forwarding mode. Now that runtime forwarding decisions are made based on the forwarding table, this is almost unused outside conf().
The only exception is the auto-port scanning code, which uses it to determine if a port scan is necessary. We can instead derive that from the forwarding table itself by checking if there are any entries with the FWD_SCAN flag.
Once that's done, make the mode purely local to conf(). While we're there rename the constants to FWD_MODE_* to avoid confusion with the forwarding rule flag bits, which are also prefixed with FWD_.
Signed-off-by: David Gibson
--- conf.c | 82 ++++++++++++++++++++++++++++++++++++---------------------- fwd.c | 27 ++++++++++++++----- fwd.h | 10 ------- 3 files changed, 72 insertions(+), 47 deletions(-) diff --git a/conf.c b/conf.c index 11d84536..c436b88e 100644 --- a/conf.c +++ b/conf.c @@ -199,15 +199,27 @@ static void conf_ports_range_except(const struct ctx *c, char optname, } }
+/** + * enum fwd_mode - Overall forwarding mode for a direction and protocol + */
Nit: I'm actually trying to document enums in the matching kerneldoc style when it comes to it, see for example enum udp_iov_idx.
I don't think it's so much of a problem to omit it here, even though "SPEC" and "ALL" might not be that obvious. If you respin, maybe:
* @FWD_MODE_UNSET Initial value, not parsed/configured yet * @FWD_MODE_SPEC Forward specified ports * @FWD_MODE_NONE No forwarded ports * @FWD_MODE_AUTO Automatic detection and forwarding based on bound ports * @FWD_MODE_ALL Bind all free ports
?
Done. -- 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