IFNET_WLOCK missing from if_reassign_common

James Gritton jamie at gritton.org
Mon Jul 14 22:52:52 UTC 2008


In testing jail_set_vimage, I found that moving a network interface 
cause a assertion failure in ifnet_setbyindex.  It turns out that 
if_reassign_common in kern_vimage.c should be locking IFNET_WLOCK.  I'm 
including a patch that locks it in the same way it's done in if_alloc 
(which seems to be the inspiration for much of this code).

- Jamie
-------------- next part --------------
--- ov/src/sys/kern/kern_vimage.c	Wed Jul  9 14:14:03 2008
+++ src/sys/kern/kern_vimage.c	Mon Jul 14 16:44:18 2008
@@ -283,10 +283,12 @@
 	do {
 		INIT_VNET_NET(curvnet);
 
+		IFNET_WLOCK();
 		ifnet_setbyindex(ifp->if_index, NULL);
 		/* XXX: should be locked with if_findindex() */
 		while (V_if_index > 0 && ifnet_byindex(V_if_index) == NULL)
 			V_if_index--;
+		IFNET_WUNLOCK();
 	} while (0);
 
 	CURVNET_SET_QUIET(new_vnet);
@@ -309,7 +311,9 @@
 		V_if_index = ifp->if_index;
 	if (V_if_index >= V_if_indexlim)
 		if_grow();
+	IFNET_WLOCK();
 	ifnet_setbyindex(ifp->if_index, ifp);
+	IFNET_WUNLOCK();
 
 	/* Rename the ifnet */
 	if (new_vnet == ifp->if_home_vnet) {


More information about the freebsd-virtualization mailing list