From owner-freebsd-net@FreeBSD.ORG Sun Oct 21 19:37:31 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 91D0A93B; Sun, 21 Oct 2012 19:37:31 +0000 (UTC) (envelope-from zec@fer.hr) Received: from mail.zvne.fer.hr (mail.zvne.fer.hr [161.53.66.5]) by mx1.freebsd.org (Postfix) with ESMTP id 11D058FC0A; Sun, 21 Oct 2012 19:37:29 +0000 (UTC) Received: from munja.zvne.fer.hr (161.53.66.248) by mail.zvne.fer.hr (161.53.66.5) with Microsoft SMTP Server id 14.2.298.4; Sun, 21 Oct 2012 21:36:19 +0200 Received: from sluga.fer.hr ([161.53.66.244]) by munja.zvne.fer.hr with Microsoft SMTPSVC(6.0.3790.4675); Sun, 21 Oct 2012 21:36:18 +0200 Received: from localhost ([161.53.19.8]) by sluga.fer.hr over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 21 Oct 2012 21:36:18 +0200 From: Marko Zec To: Subject: Re: VIMAGE crashes on 9.x with hotplug net80211 devices Date: Sun, 21 Oct 2012 21:36:12 +0200 User-Agent: KMail/1.9.10 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <201210212136.12788.zec@fer.hr> X-OriginalArrivalTime: 21 Oct 2012 19:36:18.0437 (UTC) FILETIME=[5774D350:01CDAFC3] Cc: freebsd-hackers@freebsd.org, Adrian Chadd X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Oct 2012 19:37:31 -0000 On Sunday 21 October 2012 21:04:41 Adrian Chadd wrote: > Hi all, > > I have some crashes in the VIMAGE code on releng_9. Specifically, when > I enable VIMAGE and then hotplug some cardbus ath(4) NICs. > > The panics are dereferencing the V_ ifindex and related fields. > > If I start adding CURVNET_SET(vnet0) and CURVNET_RESTORE() around the > ifnet calls (attach, detach) then things stop panicing - however, > things are slightly more complicated than that. > > Since it's possible that the cloned interfaces (and maybe the parent > interface?) are placed into other VNETs, I have to make sure that the > right vnet context is switched to before I free interfaces. > > So, may I please have some help by some VIMAGE-cluey people to sort > out how to _properly_ get VIMAGE up on net80211? I'd like to fix this > in -HEAD and -9 so people are able to use VIMAGEs for hostapd > interfaces (and so I can abuse it for lots of local testing on a > single laptop.) The right approach would be to do a single CURVNET_SET(vnet0) / CURVNET_RESTORE() somewhere near the root of the call graph being triggered by the hotplug attach event. Not having any hotpluggable hardware at hand I cannot be more specific where that place could be... But most certainly doing CURVNET_SET(vnet0) on detach events would be wrong: since ifnets may be assignet to non-default vnets, CURVNET_SET(ifp->if_vnet) should be more appropriate there. Another thing that may help could be turning on options VNET_DEBUG when, as that should reveal excessive (and probably redundant) CURVNET_SET() recursions. Hope this helps, Marko