From owner-p4-projects@FreeBSD.ORG Wed Aug 1 01:04:14 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 468DB16A421; Wed, 1 Aug 2007 01:04:14 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0EC916A41F for ; Wed, 1 Aug 2007 01:04:13 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E99CF13C4E9 for ; Wed, 1 Aug 2007 01:04:13 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7114DYN032387 for ; Wed, 1 Aug 2007 01:04:13 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7114DvZ032384 for perforce@freebsd.org; Wed, 1 Aug 2007 01:04:13 GMT (envelope-from zec@FreeBSD.org) Date: Wed, 1 Aug 2007 01:04:13 GMT Message-Id: <200708010104.l7114DvZ032384@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 124447 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2007 01:04:14 -0000 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,