Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jul 2007 11:23:13 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 123637 for review
Message-ID:  <200707171123.l6HBNDhT093102@repoman.freebsd.org>

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

Change 123637 by zec@zec_tca51 on 2007/07/17 11:22:50

	When destroying a vnet instance, walk through per-domain
	protosw instances and call pr_destroy() methods if provided.
	I should have implemented this already in change 123300...
	
	Unlink a vnet instance from the list of all vnets before
	beginning to detach / free its components.
	
	Move the mod_data[] field of struct vnet to its very top, in
	hope that this would reduce the overhead of dereferencing it.

Affected files ...

.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#25 edit
.. //depot/projects/vimage/src/sys/kern/uipc_domain.c#4 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#22 edit

Differences ...

==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#25 (text+ko) ====

@@ -520,6 +520,9 @@
 	struct ifnet *ifp, *nifp;
 	struct vnet_modlink *vml;
 
+	/* XXX should have the vnet list locked here!!! */
+	LIST_REMOVE(vnet, vnet_le);
+
 	CURVNET_SET_QUIET(vnet);
 	INIT_VNET_NET(vnet);
 
@@ -549,7 +552,8 @@
 	/*
 	 * Detach / free per-module state instances.
 	 */
-	TAILQ_FOREACH_REVERSE(vml, &vnet_modlink_head, vnet_modlink_head, mod_le)
+	TAILQ_FOREACH_REVERSE(vml, &vnet_modlink_head,
+			      vnet_modlink_head, mod_le)
 		if (vml->modinfo->i_detach)
 			vml->modinfo->i_detach(vml->iarg);
 
@@ -561,7 +565,6 @@
 	CURVNET_RESTORE();
 
 	/* hopefully, we are finally OK to free the vnet container itself! */
-	LIST_REMOVE(vnet, vnet_le);
 	vnet->vnet_magic_n = -1;
 	free(vnet, M_VNET);
 

==== //depot/projects/vimage/src/sys/kern/uipc_domain.c#4 (text+ko) ====

@@ -68,6 +68,7 @@
     NULL)
 
 static int net_init_domain(void *);
+static int net_detach_domain(void *);
 
 static struct callout pffast_callout;
 static struct callout pfslow_callout;
@@ -109,7 +110,8 @@
 static struct vnet_modinfo vnet_domain_modinfo = {
 	.id		= VNET_MOD_DOMAIN,
 	.name		= "domain",
-	.i_attach	= net_init_domain
+	.i_attach	= net_init_domain,
+	.i_detach	= net_detach_domain
 };      
 #endif
 
@@ -141,9 +143,7 @@
 }
 
 /*
- * Add a new protocol domain to the list of supported domains
- * Note: you cant unload it again because a socket may be using it.
- * XXX can't fail at this time.
+ * Initialize a domain instance.
  */
 static int
 net_init_domain(void *arg)
@@ -166,6 +166,26 @@
 }
 
 /*
+ * Detach / free a domain instance.
+ */
+static int
+net_detach_domain(void *arg)
+{
+	struct domain *dp = arg;
+	struct protosw *pr;
+
+#ifdef NOTYET
+	if (dp->dom_detach)
+		(*dp->dom_detach)();
+#endif
+	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
+		if (pr->pr_destroy)
+			(*pr->pr_destroy)();
+
+	return 0;
+}
+
+/*
  * Add a new protocol domain to the list of supported domains
  * Note: you cant unload it again because a socket may be using it.
  * XXX can't fail at this time.

==== //depot/projects/vimage/src/sys/sys/vimage.h#22 (text+ko) ====

@@ -101,10 +101,10 @@
 #define V_MOD_vprocg		0
 
 struct vnet {
+	void	*mod_data[VNET_MOD_MAX];
+
 	LIST_ENTRY(vnet) vnet_le;
 
-	void	*mod_data[VNET_MOD_MAX];
-
 	int	ifccnt;
 	int	sockcnt;
 



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