diff options
author | zec <zec@FreeBSD.org> | 2009-04-26 07:14:50 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2009-04-26 07:14:50 +0000 |
commit | c269cc664ea0bb95561b14b109212e8640c8d53a (patch) | |
tree | a1175fbb0223247a55badf8c425bc6113277d52f /sys/netgraph/ng_base.c | |
parent | 712d9928291fa1fa1a011adcfd08c48ac1a6adc7 (diff) | |
download | FreeBSD-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_base.c')
-rw-r--r-- | sys/netgraph/ng_base.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 0e9f96c..3402a24 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -84,6 +84,8 @@ struct vnet_netgraph vnet_netgraph_0; /* Mutex to protect topology events. */ static struct mtx ng_topo_mtx; +static vnet_attach_fn vnet_netgraph_iattach; + #ifdef NETGRAPH_DEBUG static struct mtx ng_nodelist_mtx; /* protects global node/hook lists */ static struct mtx ngq_mtx; /* protects the queue item list */ @@ -227,7 +229,6 @@ static int ng_mkpeer(node_p node, const char *name, /* Imported, these used to be externally visible, some may go back. */ void ng_destroy_hook(hook_p hook); -node_p ng_name2noderef(node_p node, const char *name); int ng_path2noderef(node_p here, const char *path, node_p *dest, hook_p *lasthook); int ng_make_node(const char *type, node_p *nodepp); @@ -3068,6 +3069,27 @@ ng_mod_event(module_t mod, int event, void *data) return (error); } +#ifndef VIMAGE_GLOBALS +static const vnet_modinfo_t vnet_netgraph_modinfo = { + .vmi_id = VNET_MOD_NETGRAPH, + .vmi_name = "netgraph", +#ifdef VIMAGE + .vmi_size = sizeof(struct vnet_netgraph), +#endif + .vmi_iattach = vnet_netgraph_iattach +}; +#endif + +static int +vnet_netgraph_iattach(const void *arg __unused) +{ + INIT_VNET_NETGRAPH(curvnet); + + V_nextID = 1; + + return (0); +} + /* * Handle loading and unloading for this code. * The only thing we need to link into is the NETISR strucure. @@ -3082,7 +3104,11 @@ ngb_mod_event(module_t mod, int event, void *data) switch (event) { case MOD_LOAD: /* Initialize everything. */ - V_nextID = 1; +#ifndef VIMAGE_GLOBALS + vnet_mod_register(&vnet_netgraph_modinfo); +#else + vnet_netgraph_iattach(NULL); +#endif NG_WORKLIST_LOCK_INIT(); mtx_init(&ng_typelist_mtx, "netgraph types mutex", NULL, MTX_DEF); |