Date: Mon, 14 Jul 2008 16:52:46 -0600 From: James Gritton <jamie@gritton.org> To: freebsd-virtualization@freebsd.org Subject: IFNET_WLOCK missing from if_reassign_common Message-ID: <487BD8BE.1040609@gritton.org>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------070508040703010508000301 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------070508040703010508000301 Content-Type: text/plain; name="kern_vimage.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kern_vimage.diff" --- 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) { --------------070508040703010508000301--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?487BD8BE.1040609>