Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Aug 2007 17:05:30 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 124477 for review
Message-ID:  <200708011705.l71H5Ulh052779@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124477

Change 124477 by zec@zec_tpx32 on 2007/08/01 17:04:33

	Register netgraph as a vnet module from a SYSINIT-triggered
	function, not modevent handler.  This ensures that netgraph
	will be registered as (one of) the last vnet modules,
	regardless whether netgraph is kldloaded at run time,
	kldloaded before booting, or statically compiled in the
	kernel.  In effect, a per vnet module destructor for
	netgsaph will be always invoked before other protocol
	module's destructors, ensuring ng nodes and thus ifnets will
	be gone before other protocol instances begin to vanish.
	
	Before this change, if netgraph were kldloaded before
	booting, netgraph nodes and associated ifnets would still be
	hanging around during network protocols shutting down,
	leading to random panics.

Affected files ...

.. //depot/projects/vimage/src/sys/netgraph/ng_base.c#16 edit

Differences ...

==== //depot/projects/vimage/src/sys/netgraph/ng_base.c#16 (text+ko) ====

@@ -251,7 +251,9 @@
 static vnet_attach_fn vnet_netgraph_iattach;
 #ifdef VIMAGE
 static vnet_detach_fn vnet_netgraph_idetach;
-#endif
+static void netgraph_register(void *);
+SYSINIT(netgraph, SI_SUB_PROTO_END, SI_ORDER_FIRST, netgraph_register, NULL)
+#endif /* VIMAGE */
 
 VNET_MOD_DECLARE(NETGRAPH, netgraph, NULL, vnet_netgraph_iattach,
     vnet_netgraph_idetach)
@@ -3189,11 +3191,9 @@
 		uma_zone_set_max(ng_qzone, maxalloc);
 		netisr_register(NETISR_NETGRAPH, (netisr_t *)ngintr, NULL,
 		    NETISR_MPSAFE);
-#ifdef VIMAGE
-		vnet_mod_register(&vnet_netgraph_modinfo);
-#else
+#ifndef VIMAGE
 		vnet_netgraph_iattach(NULL);
-#endif
+#endif /* !VIMAGE */
 		break;
 	case MOD_UNLOAD:
 		/* You can't unload it because an interface may be using it. */
@@ -3215,7 +3215,7 @@
 	return 0;
 }
 
-#ifdef VIMAGE
+#ifdef VIMAGE 
 static int vnet_netgraph_idetach(const void *unused)
 {
 	INIT_VNET_NETGRAPH(curvnet);
@@ -3239,7 +3239,12 @@
 
 	return 0;
 }
-#endif
+
+void netgraph_register(void *unused)
+{
+	vnet_mod_register(&vnet_netgraph_modinfo);
+}
+#endif /* VIMAGE */
 
 static moduledata_t netgraph_mod = {
 	"netgraph",



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