From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 21 21:22:58 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 22A48A3E; Sun, 21 Oct 2012 21:22:58 +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 6ED818FC12; Sun, 21 Oct 2012 21:22:57 +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 23:22:55 +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 23:22:54 +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 23:22:54 +0200 From: Marko Zec To: Adrian Chadd Subject: Re: VIMAGE crashes on 9.x with hotplug net80211 devices Date: Sun, 21 Oct 2012 23:22:48 +0200 User-Agent: KMail/1.9.10 References: <201210212136.12788.zec@fer.hr> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <201210212322.48791.zec@fer.hr> X-OriginalArrivalTime: 21 Oct 2012 21:22:54.0647 (UTC) FILETIME=[3BE50470:01CDAFD2] Cc: freebsd-net@freebsd.org, freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Oct 2012 21:22:58 -0000 On Sunday 21 October 2012 21:50:21 Adrian Chadd wrote: > On 21 October 2012 12:36, Marko Zec wrote: > > 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... > > Right; would that be at the net80211 side, or something higher up (eg > at device_attach, which gets called from the cardbus/pci bridge > enumeration code.) As high as it gets - if you get lucky, as a side effect you might even fix similar issues with USB hotplugging. > > 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. > > Thanks for that. I'll look at adding that in my next debug pass. > > > Another thing that may help could be turning on options VNET_DEBUG > > when, as that should reveal excessive (and probably redundant) > > CURVNET_SET() recursions. > > I've spotted a couple, however the crashing here is the important bit. > :-) > > So - why is it that the V_* variables are NULL pointers at this stage? > I thought the kernel would've been running with a default vnet context > of vnet0? Why doesn't this impact other network device hotplugging? Or > does it, and noone noticed? By design, the kernel is never running "by default" in any of the vnets (vnet0 included). If it were, it would be extremely difficult to spot and catch many cases where a subsystem would be (implicitly) working with vnet0, while in fact it should be working in a different vnet context. Obviously, handling device attach events is an exception from this rule, and up to this date this was never properly addressed... Marko