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 */
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to