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/netgraph/ng_iface.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/netgraph/ng_iface.c')
-rw-r--r-- | sys/netgraph/ng_iface.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 6ed1daf6..49cba25 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -76,6 +76,7 @@ #include <net/bpf.h> #include <net/netisr.h> #include <net/route.h> +#include <net/vnet.h> #include <netinet/in.h> @@ -209,22 +210,9 @@ static struct ng_type typestruct = { }; NETGRAPH_INIT(iface, &typestruct); -static vnet_attach_fn ng_iface_iattach; -static vnet_detach_fn ng_iface_idetach; - static VNET_DEFINE(struct unrhdr *, ng_iface_unit); #define V_ng_iface_unit VNET(ng_iface_unit) -#ifdef VIMAGE -static vnet_modinfo_t vnet_ng_iface_modinfo = { - .vmi_id = VNET_MOD_NG_IFACE, - .vmi_name = "ng_iface", - .vmi_dependson = VNET_MOD_NETGRAPH, - .vmi_iattach = ng_iface_iattach, - .vmi_idetach = ng_iface_idetach -}; -#endif - /************************************************************************ HELPER STUFF ************************************************************************/ @@ -849,18 +837,7 @@ ng_iface_mod_event(module_t mod, int event, void *data) switch (event) { case MOD_LOAD: -#ifdef VIMAGE - vnet_mod_register(&vnet_ng_iface_modinfo); -#else - ng_iface_iattach(NULL); -#endif - break; case MOD_UNLOAD: -#ifdef VIMAGE - vnet_mod_deregister(&vnet_ng_iface_modinfo); -#else - ng_iface_idetach(NULL); -#endif break; default: error = EOPNOTSUPP; @@ -869,18 +846,20 @@ ng_iface_mod_event(module_t mod, int event, void *data) return (error); } -static int ng_iface_iattach(const void *unused) +static void +vnet_ng_iface_init(const void *unused) { V_ng_iface_unit = new_unrhdr(0, 0xffff, NULL); - - return (0); } +VNET_SYSINIT(vnet_ng_iface_init, SI_SUB_PSEUDO, SI_ORDER_ANY, + vnet_ng_iface_init, NULL); -static int ng_iface_idetach(const void *unused) +static void +vnet_ng_iface_uninit(const void *unused) { delete_unrhdr(V_ng_iface_unit); - - return (0); } +VNET_SYSUNINIT(vnet_ng_iface_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY, + vnet_ng_iface_uninit, NULL); |