Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 May 2010 09:54:01 +0000 (UTC)
From:      Marko Zec <zec@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r207698 - stable/8/sys/netgraph
Message-ID:  <201005060954.o469s1RH034685@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zec
Date: Thu May  6 09:54:01 2010
New Revision: 207698
URL: http://svn.freebsd.org/changeset/base/207698

Log:
  MFC r207572:
    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

Modified:
  stable/8/sys/netgraph/ng_base.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/netgraph/ng_base.c
==============================================================================
--- stable/8/sys/netgraph/ng_base.c	Thu May  6 09:52:32 2010	(r207697)
+++ stable/8/sys/netgraph/ng_base.c	Thu May  6 09:54:01 2010	(r207698)
@@ -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 */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005060954.o469s1RH034685>