PERFORCE change 124447 for review

Marko Zec zec at FreeBSD.org
Wed Aug 1 01:04:14 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=124447

Change 124447 by zec at 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,


More information about the p4-projects mailing list