From owner-svn-src-head@FreeBSD.ORG Mon May 3 16:08:24 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6D113106564A; Mon, 3 May 2010 16:08:24 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 5D3338FC19; Mon, 3 May 2010 16:08:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o43G8OPi027242; Mon, 3 May 2010 16:08:24 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o43G8OKA027240; Mon, 3 May 2010 16:08:24 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <201005031608.o43G8OKA027240@svn.freebsd.org> From: Marko Zec Date: Mon, 3 May 2010 16:08:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207572 - head/sys/netgraph X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 May 2010 16:08:24 -0000 Author: zec Date: Mon May 3 16:08:24 2010 New Revision: 207572 URL: http://svn.freebsd.org/changeset/base/207572 Log: When destroying a vnet, shut down all netgraph nodes tied to that vnet before proceeding with dismantling other protocol domains. This change only affects options VIMAGE builds. Reviewed by: julian, bz MFC after: 3 days Modified: head/sys/netgraph/ng_base.c Modified: head/sys/netgraph/ng_base.c ============================================================================== --- head/sys/netgraph/ng_base.c Mon May 3 15:51:59 2010 (r207571) +++ head/sys/netgraph/ng_base.c Mon May 3 16:08:24 2010 (r207572) @@ -3067,28 +3067,42 @@ ng_mod_event(module_t mod, int event, vo static void vnet_netgraph_uninit(const void *unused __unused) { -#if 0 - node_p node, last_killed = NULL; + node_p node = NULL, last_killed = NULL; + int i; + + do { + /* Find a node to kill */ + mtx_lock(&ng_namehash_mtx); + for (i = 0; i < NG_NAME_HASH_SIZE; i++) { + LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) { + if (node != &ng_deadnode) { + NG_NODE_REF(node); + break; + } + } + if (node != NULL) + break; + } + mtx_unlock(&ng_namehash_mtx); - /* XXXRW: utterly bogus. */ - while ((node = LIST_FIRST(&V_ng_allnodes)) != NULL) { - if (node == last_killed) { - /* This should never happen */ - node->nd_flags |= NGF_REALLY_DIE; - printf("netgraph node %s needs NGF_REALLY_DIE\n", - node->nd_name); + /* Attempt to kill it only if it is a regular node */ + if (node != NULL) { + if (node == last_killed) { + /* This should never happen */ + printf("ng node %s needs" + "NGF_REALLY_DIE\n", node->nd_name); + if (node->nd_flags & NGF_REALLY_DIE) + panic("ng node %s won't die", + node->nd_name); + node->nd_flags |= NGF_REALLY_DIE; + } ng_rmnode(node, NULL, NULL, 0); - /* This must never happen */ - if (node == LIST_FIRST(&V_ng_allnodes)) - panic("netgraph node %s won't die", - node->nd_name); + NG_NODE_UNREF(node); + last_killed = node; } - ng_rmnode(node, NULL, NULL, 0); - last_killed = node; - } -#endif + } while (node != NULL); } -VNET_SYSUNINIT(vnet_netgraph_uninit, SI_SUB_NETGRAPH, SI_ORDER_ANY, +VNET_SYSUNINIT(vnet_netgraph_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, vnet_netgraph_uninit, NULL); #endif /* VIMAGE */