From owner-freebsd-virtualization@FreeBSD.ORG Mon Jul 14 22:52:52 2008 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7A861065671 for ; Mon, 14 Jul 2008 22:52:52 +0000 (UTC) (envelope-from jamie@gritton.org) Received: from gritton.org (gritton.org [161.58.222.4]) by mx1.freebsd.org (Postfix) with ESMTP id 8B7C88FC1A for ; Mon, 14 Jul 2008 22:52:52 +0000 (UTC) (envelope-from jamie@gritton.org) Received: from guppy.corp.verio.net (fw.oremut02.us.wh.verio.net [198.65.168.24]) (authenticated bits=0) by gritton.org (8.13.6.20060614/8.13.6) with ESMTP id m6EMqpT1019406 for ; Mon, 14 Jul 2008 16:52:51 -0600 (MDT) Message-ID: <487BD8BE.1040609@gritton.org> Date: Mon, 14 Jul 2008 16:52:46 -0600 From: James Gritton User-Agent: Thunderbird 2.0.0.9 (X11/20080228) MIME-Version: 1.0 To: freebsd-virtualization@freebsd.org Content-Type: multipart/mixed; boundary="------------070508040703010508000301" X-Virus-Scanned: ClamAV version 0.93, clamav-milter version 0.93 on gritton.org X-Virus-Status: Clean Subject: IFNET_WLOCK missing from if_reassign_common X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jul 2008 22:52:52 -0000 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--