summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_eiface.c
diff options
context:
space:
mode:
authorzec <zec@FreeBSD.org>2009-04-26 07:14:50 +0000
committerzec <zec@FreeBSD.org>2009-04-26 07:14:50 +0000
commitc269cc664ea0bb95561b14b109212e8640c8d53a (patch)
treea1175fbb0223247a55badf8c425bc6113277d52f /sys/netgraph/ng_eiface.c
parent712d9928291fa1fa1a011adcfd08c48ac1a6adc7 (diff)
downloadFreeBSD-src-c269cc664ea0bb95561b14b109212e8640c8d53a.zip
FreeBSD-src-c269cc664ea0bb95561b14b109212e8640c8d53a.tar.gz
In preparation to make options VIMAGE operational, where needed,
initialize / release netgraph related state in iattach() / idetach() functions called via the vnet module registration / initialization framework, instead of initialization / cleanups being done in mod_event handlers. While here, introduce a crude hack aimed at preventing ng_ether to autoattach to ng_eiface ifnets, which are also netgraph nodes already. Reviewed by: bz Approved by: julian (mentor)
Diffstat (limited to 'sys/netgraph/ng_eiface.c')
-rw-r--r--sys/netgraph/ng_eiface.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index eb638fe..615d10d 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -113,10 +113,23 @@ static struct ng_type typestruct = {
};
NETGRAPH_INIT(eiface, &typestruct);
+static vnet_attach_fn ng_eiface_iattach;
+static vnet_detach_fn ng_eiface_idetach;
+
#ifdef VIMAGE_GLOBALS
static struct unrhdr *ng_eiface_unit;
#endif
+#ifndef VIMAGE_GLOBALS
+static vnet_modinfo_t vnet_ng_eiface_modinfo = {
+ .vmi_id = VNET_MOD_NG_EIFACE,
+ .vmi_name = "ng_eiface",
+ .vmi_dependson = VNET_MOD_NETGRAPH,
+ .vmi_iattach = ng_eiface_iattach,
+ .vmi_idetach = ng_eiface_idetach
+};
+#endif
+
/************************************************************************
INTERFACE STUFF
************************************************************************/
@@ -590,10 +603,18 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
- V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
+#ifndef VIMAGE_GLOBALS
+ vnet_mod_register(&vnet_ng_eiface_modinfo);
+#else
+ ng_eiface_iattach(NULL);
+#endif
break;
case MOD_UNLOAD:
- delete_unrhdr(V_ng_eiface_unit);
+#ifndef VIMAGE_GLOBALS
+ vnet_mod_deregister(&vnet_ng_eiface_modinfo);
+#else
+ ng_eiface_idetach(NULL);
+#endif
break;
default:
error = EOPNOTSUPP;
@@ -601,3 +622,21 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
}
return (error);
}
+
+static int ng_eiface_iattach(const void *unused)
+{
+ INIT_VNET_NETGRAPH(curvnet);
+
+ V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
+
+ return (0);
+}
+
+static int ng_eiface_idetach(const void *unused)
+{
+ INIT_VNET_NETGRAPH(curvnet);
+
+ delete_unrhdr(V_ng_eiface_unit);
+
+ return (0);
+}
OpenPOWER on IntegriCloud