git: 685de460bc91 - main - Use static initializers for fib algo to shift initialization to ealier stage. This allows to register modules loaded at boot time.
Alexander V. Chernikov
melifaro at FreeBSD.org
Mon Jan 11 00:20:01 UTC 2021
The branch main has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=685de460bc91737331eaf475b0f517517b2ddbd0
commit 685de460bc91737331eaf475b0f517517b2ddbd0
Author: Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-01-11 00:16:54 +0000
Commit: Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-01-11 00:16:54 +0000
Use static initializers for fib algo to shift initialization
to ealier stage. This allows to register modules loaded at
boot time.
Reported by: olivier
---
sys/net/route/fib_algo.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/sys/net/route/fib_algo.c b/sys/net/route/fib_algo.c
index 32bafbaca3d1..5e63535f3926 100644
--- a/sys/net/route/fib_algo.c
+++ b/sys/net/route/fib_algo.c
@@ -169,6 +169,7 @@ struct mtx fib_mtx;
#define FIB_MOD_UNLOCK() mtx_unlock(&fib_mtx)
#define FIB_MOD_LOCK_ASSERT() mtx_assert(&fib_mtx, MA_OWNED)
+MTX_SYSINIT(fib_mtx, &fib_mtx, "algo list mutex", MTX_DEF);
/* Algorithm has to be this percent better than the current to switch */
#define BEST_DIFF_PERCENT (5 * 256 / 100)
@@ -219,7 +220,7 @@ SYSCTL_INT(_net_route_algo, OID_AUTO, debug_level, CTLFLAG_RW | CTLFLAG_RWTUN,
/* List of all registered lookup algorithms */
-static TAILQ_HEAD(, fib_lookup_module) all_algo_list;
+static TAILQ_HEAD(, fib_lookup_module) all_algo_list = TAILQ_HEAD_INITIALIZER(all_algo_list);
/* List of all fib lookup instances in the vnet */
VNET_DEFINE_STATIC(TAILQ_HEAD(fib_data_head, fib_data), fib_data_list);
@@ -1613,13 +1614,3 @@ vnet_fib_destroy(void)
fib_error_clear();
FIB_MOD_UNLOCK();
}
-
-static void
-fib_init(void)
-{
-
- mtx_init(&fib_mtx, "algo list mutex", NULL, MTX_DEF);
- TAILQ_INIT(&all_algo_list);
-}
-SYSINIT(fib_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_SECOND, fib_init, NULL);
-
More information about the dev-commits-src-all
mailing list