aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-04-18 12:20:00 +0000
committerMark Johnston <markj@FreeBSD.org>2026-04-18 12:26:16 +0000
commit2b264cb802b9b45306b1f3dfd3e9d4edfb23b2f6 (patch)
tree33844a5743b974617c2cafc2f13e80adf901ed65
parentba94d75749721fae999f756cb227638f9d4398a8 (diff)
routing: Initialize V_rt_numfibs earlier during boot
V_rt_numfibs can be set at compile time (with the ROUTETABLES kernel config option) or boot time (with the net.fibs tunable). vnet_rtables_init(), running during SI_PROTO_DOMAIN, was checking the tunable and updating V_rt_numfibs accordingly, but that means that earlier SYSINITs, such as vnet_mroute_init(), see the compile-time value for V_rt_numfibs before it gets corrected in vnet_rtables_init(). Fix this by initializing V_rt_numfibs earlier, so that SYSINITs are less likely to use the wrong value. Add a comment describing the weird, preexisting semantic of resetting rt_numfibs to 1 in VNET jails. PR: 294510 Reviewed by: glebius, zlei, pouria MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56473
-rw-r--r--sys/net/route/route_tables.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/net/route/route_tables.c b/sys/net/route/route_tables.c
index 571f1db9c40d..0a865079f6f2 100644
--- a/sys/net/route/route_tables.c
+++ b/sys/net/route/route_tables.c
@@ -83,7 +83,7 @@ VNET_DEFINE_STATIC(struct sx, rtables_lock);
VNET_DEFINE_STATIC(struct rib_head **, rt_tables);
#define V_rt_tables VNET(rt_tables)
-VNET_DEFINE(uint32_t, _rt_numfibs) = RT_NUMFIBS;
+VNET_DEFINE(uint32_t, _rt_numfibs) = 1;
/*
* Handler for net.my_fibnum.
@@ -290,17 +290,25 @@ grow_rtables(uint32_t num_tables)
}
static void
-vnet_rtables_init(const void *unused __unused)
+rtnumfibs_init(const void *unused __unused)
{
int num_rtables_base;
- if (IS_DEFAULT_VNET(curvnet)) {
- num_rtables_base = RT_NUMFIBS;
- TUNABLE_INT_FETCH("net.fibs", &num_rtables_base);
- V_rt_numfibs = normalize_num_rtables(num_rtables_base);
- } else
- V_rt_numfibs = 1;
+ /*
+ * Set the number of FIBs based on compile-time and boot-time settings.
+ * For some reason, VNET jails do not inherit this parameter, so they
+ * must set net.fibs manually.
+ */
+ num_rtables_base = RT_NUMFIBS;
+ TUNABLE_INT_FETCH("net.fibs", &num_rtables_base);
+ V_rt_numfibs = normalize_num_rtables(num_rtables_base);
+}
+SYSINIT(rtnumfibs_init, SI_SUB_PROTO_BEGIN, SI_ORDER_FIRST, rtnumfibs_init,
+ NULL);
+static void
+vnet_rtables_init(const void *unused __unused)
+{
vnet_rtzone_init();
#ifdef FIB_ALGO
vnet_fib_init();