Date: Wed, 1 Aug 2007 01:04:13 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124447 for review Message-ID: <200708010104.l7114DvZ032384@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124447 Change 124447 by zec@zec_tpx32 on 2007/08/01 01:03:22 Clean up all private netgraph nodes when destroying a vnet instance. Given that other existing code chunks should ensure that in a dying vnet we would have no physical or cloning ifnets, now that we can also expect for all netgraph ifnets to be gone, an assert checking that lo0 is the only ifnet left standing is not necessary any more before proceeding with per-module cleanups. If by the time an instance of vnet_net should be destroyed there would still be some ifnets hanging arround, an assert in net/if.c:vnet_net_idetach() would catch this. Affected files ... .. //depot/projects/vimage/src/sys/kern/kern_vimage.c#29 edit .. //depot/projects/vimage/src/sys/netgraph/ng_base.c#12 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#29 (text+ko) ==== @@ -567,21 +567,7 @@ if_clone_destroy(ifp->if_xname); } - /* - * XXX TODO: kill all netgraph ifnets - */ - - /* - * At this point only lo0 should be attached - */ - TAILQ_FOREACH(ifp, &V_ifnet, if_link) - if (ifp != V_loif) - panic("non-loif ifnet %s still attached", - ifp->if_xname); - - /* - * Detach / free per-module state instances. - */ + /* Detach / free per-module state instances. */ TAILQ_FOREACH_REVERSE(vml, &vnet_modlink_head, vnet_modlink_head, vml_mod_le) vnet_mod_destructor(vml); ==== //depot/projects/vimage/src/sys/netgraph/ng_base.c#12 (text+ko) ==== @@ -249,8 +249,12 @@ mtx_unlock(&ng_worklist_mtx) static vnet_attach_fn vnet_netgraph_iattach; +#ifdef VIMAGE +static vnet_attach_fn vnet_netgraph_idetach; +#endif -VNET_MOD_DECLARE(NETGRAPH, netgraph, NULL, vnet_netgraph_iattach, NULL) +VNET_MOD_DECLARE(NETGRAPH, netgraph, NULL, vnet_netgraph_iattach, + vnet_netgraph_idetach) #ifdef NETGRAPH_DEBUG /*----------------------------------------------*/ /* @@ -3211,6 +3215,23 @@ return 0; } +#ifdef VIMAGE +static int vnet_netgraph_idetach(const void *unused) +{ + INIT_VNET_NETGRAPH(curvnet); + node_p node, last_killed = NULL; + + while ((node = LIST_FIRST(&V_ng_nodelist)) != NULL) { + if (node == last_killed) + panic("netgraph node %s won't die", node->nd_name); + ng_rmnode(node, NULL, NULL, 0); + last_killed = node; + } + + return 0; +} +#endif + static moduledata_t netgraph_mod = { "netgraph", ngb_mod_event,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708010104.l7114DvZ032384>