summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_ether.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netgraph/ng_ether.c')
-rw-r--r--sys/netgraph/ng_ether.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
index 09a8615..85fc7fc 100644
--- a/sys/netgraph/ng_ether.c
+++ b/sys/netgraph/ng_ether.c
@@ -72,17 +72,6 @@
#define IFP2NG(ifp) (IFP2AC((ifp))->ac_netgraph)
-static vnet_attach_fn ng_ether_iattach;
-
-#ifdef VIMAGE
-static vnet_modinfo_t vnet_ng_ether_modinfo = {
- .vmi_id = VNET_MOD_NG_ETHER,
- .vmi_name = "ng_ether",
- .vmi_dependson = VNET_MOD_NETGRAPH,
- .vmi_iattach = ng_ether_iattach,
-};
-#endif
-
/* Per-node private data */
struct private {
struct ifnet *ifp; /* associated interface */
@@ -783,11 +772,6 @@ ng_ether_mod_event(module_t mod, int event, void *data)
ng_ether_input_orphan_p = ng_ether_input_orphan;
ng_ether_link_state_p = ng_ether_link_state;
-#ifdef VIMAGE
- vnet_mod_register(&vnet_ng_ether_modinfo);
-#else
- error = ng_ether_iattach(NULL);
-#endif
break;
case MOD_UNLOAD:
@@ -800,10 +784,6 @@ ng_ether_mod_event(module_t mod, int event, void *data)
* is MOD_UNLOAD, so there's no need to detach any nodes.
*/
-#ifdef VIMAGE
- vnet_mod_deregister(&vnet_ng_ether_modinfo);
-#endif
-
/* Unregister function hooks */
ng_ether_attach_p = NULL;
ng_ether_detach_p = NULL;
@@ -821,10 +801,15 @@ ng_ether_mod_event(module_t mod, int event, void *data)
return (error);
}
-static int ng_ether_iattach(const void *unused)
+static void
+vnet_ng_ether_init(const void *unused)
{
struct ifnet *ifp;
+ /* If module load was rejected, don't attach to vnets. */
+ if (ng_ether_attach_p != ng_ether_attach)
+ return;
+
/* Create nodes for any already-existing Ethernet interfaces. */
IFNET_RLOCK();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
@@ -833,6 +818,6 @@ static int ng_ether_iattach(const void *unused)
ng_ether_attach(ifp);
}
IFNET_RUNLOCK();
-
- return (0);
}
+VNET_SYSINIT(vnet_ng_ether_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
+ vnet_ng_ether_init, NULL);
OpenPOWER on IntegriCloud