On Tue, 10 Mar 2026 15:16:00 +1100
David Gibson
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 ? -- Stefano