summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_iface.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_iface.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_iface.c')
-rw-r--r--sys/netgraph/ng_iface.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index 6ee5e89..385750c 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -209,10 +209,23 @@ static struct ng_type typestruct = {
};
NETGRAPH_INIT(iface, &typestruct);
+static vnet_attach_fn ng_iface_iattach;
+static vnet_detach_fn ng_iface_idetach;
+
#ifdef VIMAGE_GLOBALS
static struct unrhdr *ng_iface_unit;
#endif
+#ifndef VIMAGE_GLOBALS
+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
************************************************************************/
@@ -836,10 +849,18 @@ ng_iface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
- V_ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
+#ifndef VIMAGE_GLOBALS
+ vnet_mod_register(&vnet_ng_iface_modinfo);
+#else
+ ng_iface_iattach(NULL);
+#endif
break;
case MOD_UNLOAD:
- delete_unrhdr(V_ng_iface_unit);
+#ifndef VIMAGE_GLOBALS
+ vnet_mod_deregister(&vnet_ng_iface_modinfo);
+#else
+ ng_iface_idetach(NULL);
+#endif
break;
default:
error = EOPNOTSUPP;
@@ -847,3 +868,21 @@ ng_iface_mod_event(module_t mod, int event, void *data)
}
return (error);
}
+
+static int ng_iface_iattach(const void *unused)
+{
+ INIT_VNET_NETGRAPH(curvnet);
+
+ V_ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
+
+ return (0);
+}
+
+static int ng_iface_idetach(const void *unused)
+{
+ INIT_VNET_NETGRAPH(curvnet);
+
+ delete_unrhdr(V_ng_iface_unit);
+
+ return (0);
+}
OpenPOWER on IntegriCloud