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/netinet6 | |
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/netinet6')
-rw-r--r-- | sys/netinet6/in6_proto.c | 2 | ||||
-rw-r--r-- | sys/netinet6/mld6.c | 53 |
2 files changed, 13 insertions, 42 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 57253f7..8c4094d 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -375,7 +375,7 @@ struct domain inet6domain = { .dom_ifdetach = in6_domifdetach }; -DOMAIN_SET(inet6); +VNET_DOMAIN_SET(inet6); /* * Internet configuration info diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index f47671e..e23dea3 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -117,8 +117,6 @@ static char * mld_rec_type_to_str(const int); #endif static void mld_set_version(struct mld_ifinfo *, const int); static void mld_slowtimo_vnet(void); -static void mld_sysinit(void); -static void mld_sysuninit(void); static int mld_v1_input_query(struct ifnet *, const struct ip6_hdr *, /*const*/ struct mld_hdr *); static int mld_v1_input_report(struct ifnet *, const struct ip6_hdr *, @@ -147,9 +145,6 @@ static int mld_v2_process_group_query(struct in6_multi *, static int sysctl_mld_gsr(SYSCTL_HANDLER_ARGS); static int sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS); -static vnet_attach_fn vnet_mld_iattach; -static vnet_detach_fn vnet_mld_idetach; - /* * Normative references: RFC 2710, RFC 3590, RFC 3810. * @@ -3201,7 +3196,7 @@ mld_rec_type_to_str(const int type) #endif static void -mld_sysinit(void) +mld_init(void *unused __unused) { CTR1(KTR_MLD, "%s: initializing", __func__); @@ -3213,50 +3208,39 @@ mld_sysinit(void) mld_po.ip6po_prefer_tempaddr = IP6PO_TEMPADDR_NOTPREFER; mld_po.ip6po_flags = IP6PO_DONTFRAG; } +SYSINIT(mld_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, mld_init, NULL); static void -mld_sysuninit(void) +mld_uninit(void *unused __unused) { CTR1(KTR_MLD, "%s: tearing down", __func__); MLD_LOCK_DESTROY(); } +SYSUNINIT(mld_uninit, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, mld_uninit, NULL); -/* - * Initialize an MLDv2 instance. - * VIMAGE: Assumes curvnet set by caller and called per vimage. - */ -static int -vnet_mld_iattach(const void *unused __unused) +static void +vnet_mld_init(const void *unused __unused) { CTR1(KTR_MLD, "%s: initializing", __func__); LIST_INIT(&V_mli_head); - - return (0); } +VNET_SYSINIT(vnet_mld_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_mld_init, + NULL); -static int -vnet_mld_idetach(const void *unused __unused) +static void +vnet_mld_uninit(const void *unused __unused) { CTR1(KTR_MLD, "%s: tearing down", __func__); KASSERT(LIST_EMPTY(&V_mli_head), ("%s: mli list not empty; ifnets not detached?", __func__)); - - return (0); } - -#ifdef VIMAGE -static vnet_modinfo_t vnet_mld_modinfo = { - .vmi_id = VNET_MOD_MLD, - .vmi_name = "mld", - .vmi_iattach = vnet_mld_iattach, - .vmi_idetach = vnet_mld_idetach -}; -#endif +VNET_SYSUNINIT(vnet_mld_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_mld_uninit, + NULL); static int mld_modevent(module_t mod, int type, void *unused __unused) @@ -3264,20 +3248,7 @@ mld_modevent(module_t mod, int type, void *unused __unused) switch (type) { case MOD_LOAD: - mld_sysinit(); -#ifdef VIMAGE - vnet_mod_register(&vnet_mld_modinfo); -#else - vnet_mld_iattach(NULL); -#endif - break; case MOD_UNLOAD: -#ifdef VIMAGE - vnet_mod_deregister(&vnet_mld_modinfo); -#else - vnet_mld_idetach(NULL); -#endif - mld_sysuninit(); break; default: return (EOPNOTSUPP); |