diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-07-23 20:46:49 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-07-23 20:46:49 +0000 |
commit | b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b (patch) | |
tree | 0191b21173debdadfbf9f7565dfc5a8b9eefe94a /sys/net/route.c | |
parent | fc8defe5dd957eaee1f1c841d45804df5bbf20f5 (diff) | |
download | FreeBSD-src-b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b.zip FreeBSD-src-b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b.tar.gz |
Introduce and use a sysinit-based initialization scheme for virtual
network stacks, VNET_SYSINIT:
- Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will
occur each time a network stack is instantiated and destroyed. In the
!VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT.
For the VIMAGE case, we instead use SYSINIT's to track their order and
properties on registration, using them for each vnet when created/
destroyed, or immediately on module load for already-started vnets.
- Remove vnet_modinfo mechanism that existed to serve this purpose
previously, as well as its dependency scheme: we now just use the
SYSINIT ordering scheme.
- Implement VNET_DOMAIN_SET() to allow protocol domains to declare that
they want init functions to be called for each virtual network stack
rather than just once at boot, compiling down to DOMAIN_SET() in the
non-VIMAGE case.
- Walk all virtualized kernel subsystems and make use of these instead
of modinfo or DOMAIN_SET() for init/uninit events. In some cases,
convert modular components from using modevent to using sysinit (where
appropriate). In some cases, do minor rejuggling of SYSINIT ordering
to make room for or better manage events.
Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup)
Discussed with: jhb, bz, julian, zec
Reviewed by: bz
Approved by: re (VIMAGE blanket)
Diffstat (limited to 'sys/net/route.c')
-rw-r--r-- | sys/net/route.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index de677bc..544c3b6 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -99,17 +99,6 @@ VNET_DEFINE(struct rtstat, rtstat); static void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); -static int vnet_route_iattach(const void *); -#ifdef VIMAGE -static int vnet_route_idetach(const void *); - -static const vnet_modinfo_t vnet_rtable_modinfo = { - .vmi_id = VNET_MOD_RTABLE, - .vmi_name = "rtable", - .vmi_iattach = vnet_route_iattach, - .vmi_idetach = vnet_route_idetach -}; -#endif /* compare two sockaddr structures */ #define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) @@ -174,6 +163,10 @@ rt_tables_get_rnh(int table, int fam) return (*rt_tables_get_rnh_ptr(table, fam)); } +/* + * route initialization must occur before ip6_init2(), which happenas at + * SI_ORDER_MIDDLE. + */ static void route_init(void) { @@ -184,16 +177,11 @@ route_init(void) if (rt_numfibs == 0) rt_numfibs = 1; rn_init(); /* initialize all zeroes, all ones, mask table */ - -#ifdef VIMAGE - vnet_mod_register(&vnet_rtable_modinfo); -#else - vnet_route_iattach(NULL); -#endif } +SYSINIT(route_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, route_init, 0); -static int -vnet_route_iattach(const void *unused __unused) +static void +vnet_route_init(const void *unused __unused) { struct domain *dom; struct radix_node_head **rnh; @@ -229,13 +217,13 @@ vnet_route_iattach(const void *unused __unused) } } } - - return (0); } +VNET_SYSINIT(vnet_route_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, + vnet_route_init, 0); #ifdef VIMAGE -static int -vnet_route_idetach(const void *unused __unused) +static void +vnet_route_uninit(const void *unused __unused) { int table; int fam; @@ -259,8 +247,9 @@ vnet_route_idetach(const void *unused __unused) } } } - return (0); } +VNET_SYSUNINIT(vnet_route_uninit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, + vnet_route_uninit, 0); #endif #ifndef _SYS_SYSPROTO_H_ @@ -1510,6 +1499,3 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) fib = -1; return (rtinit1(ifa, cmd, flags, fib)); } - -/* This must be before ip6_init2(), which is now SI_ORDER_MIDDLE */ -SYSINIT(route, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, route_init, 0); |