From owner-freebsd-current@FreeBSD.ORG Fri Sep 25 03:16:17 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59BBA1065670 for ; Fri, 25 Sep 2009 03:16:17 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from ebb.errno.com (ebb.errno.com [69.12.149.25]) by mx1.freebsd.org (Postfix) with ESMTP id 147CD8FC1D for ; Fri, 25 Sep 2009 03:16:16 +0000 (UTC) Received: from Macintosh-4.local ([10.0.0.198]) (authenticated bits=0) by ebb.errno.com (8.13.6/8.12.6) with ESMTP id n8P3GFMX079722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 24 Sep 2009 20:16:16 -0700 (PDT) (envelope-from sam@freebsd.org) Message-ID: <4ABC35FF.60107@freebsd.org> Date: Thu, 24 Sep 2009 20:16:15 -0700 From: Sam Leffler Organization: FreeBSD Project User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: David Horn References: <25ff90d60909230922h22db6493u525cad33a047ccc@mail.gmail.com> In-Reply-To: <25ff90d60909230922h22db6493u525cad33a047ccc@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-DCC-sonic.net-Metrics: ebb.errno.com; whitelist Cc: freebsd-current@freebsd.org Subject: Re: lagg + wlan0 boot timing (EBUSY) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 03:16:17 -0000 David Horn wrote: > Tracking 8/stable branch on this particular machine (although I do > have access to -current for testing as needed) uname -a: > > FreeBSD lagg 8.0-RC1 FreeBSD 8.0-RC1 #11 r197417: Wed Sep 23 01:05:15 > EDT 2009 root@lagg:/usr/obj/usr/src/sys/GENERIC amd64 > > I have been trying to track down a problem with my lagg connection > sometimes not properly enabling wlan as fallback on boot. It would > work properly about 60% of the time. The other times, it would fail > with SIOCSLAGGPORT: Device busy > > Here is the relevant rc.conf entries: > > ifconfig_bfe0="up" > wlans_iwn0="wlan0" > ifconfig_wlan0="WPA" > ifconfig_iwn0="ether 00:1c:23:98:2c:5d" > cloned_interfaces="lagg0" > ipv6_network_interfaces="lagg0" > ifconfig_lagg0="laggproto failover laggport bfe0 laggport wlan0 DHCP" > ipv6_enable="YES" > > So, I turned on some logging of all ifconfig commands with timestamps > and stdout/stderr/returncode, and noticed this: > > Wed Sep 23 01:39:56 EDT 2009 ifconfig: lagg0 create ; > ;; Wed Sep 23 01:39:56 EDT 2009 lagg0 rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: -l ; > iwn0 bfe0 fwe0 fwip0 lo0 lagg0 > ;; Wed Sep 23 01:39:56 EDT 2009 -l rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: -l ; > iwn0 bfe0 fwe0 fwip0 lo0 lagg0 > ;; Wed Sep 23 01:39:56 EDT 2009 -l rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: lo0 inet 127.0.0.1 ; > ;; Wed Sep 23 01:39:56 EDT 2009 lo0 rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: lo0 up ; > ;; Wed Sep 23 01:39:56 EDT 2009 lo0 rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: iwn0 ether 00:1c:23:98:2c:5d ; > ;; Wed Sep 23 01:39:56 EDT 2009 iwn0 rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: iwn0 up ; > ;; Wed Sep 23 01:39:56 EDT 2009 iwn0 rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: wlan0 create wlandev iwn0 ; > ;; Wed Sep 23 01:39:56 EDT 2009 wlan0 rc='0' end. > Wed Sep 23 01:39:56 EDT 2009 ifconfig: wlan0 ; > wlan0: flags=8802 metric 0 mtu 1500 > ether 00:1c:23:98:2c:5d > media: IEEE 802.11 Wireless Ethernet autoselect (autoselect) > status: no carrier > ssid "" channel 1 (2412 Mhz 11b) > country US authmode OPEN privacy OFF txpower 14 bmiss 10 scanvalid 60 > wme bintval 0 > ;; Wed Sep 23 01:39:56 EDT 2009 wlan0 rc='0' end. > Wed Sep 23 01:39:57 EDT 2009 ifconfig: lagg0 laggproto failover > laggport bfe0 laggport wlan0 ; > ifconfig.real: SIOCSLAGGPORT: Device busy > ;; Wed Sep 23 01:39:57 EDT 2009 lagg0 rc='1' end. > > So, I started looking at the /sys/net/if_lagg.c source, and found the > EBUSY response cases: > > This one > > /* New lagg port has to be in an idle state */ > if (ifp->if_drv_flags & IFF_DRV_OACTIVE) > return (EBUSY); > > seems to be the culprit, but unfortunately, I'm not familiar enough > with the code to take this much further. I did build a kernel without > this check, and everything seems to be fixed, but this is obviously > not a real fix to the problem. So, I would say the fact that > wpa_supplicant is talking to wlan0 (trying to scan/associate/auth) > while lagg is trying to add wlan0 to the portlist is the timing issue. > > I confirmed this behavior as follows: > > ifconfig wlan0 destroy > ifconfig lagg0 destroy > ifconfig lagg0 create > ifconfig wlan0 create wlandev iwn0 & ; ifconfig lagg0 laggproto > failover laggport bfe0 laggport wlan0 > results in: > ifconfig: SIOCSLAGGPORT: Device busy > > Someone more clueful than me know of a correct way to fix this > contention issue ? > Want me to file a PR for tracking purposes ? OACTIVE is marked on wlan0 if packets come down the tx path before the ifnet reaches RUN state. This is done to block traffic and should have no effect except to cause packets to be queued in the snd q. This probably happens when IPV6 is enabled because NDP kicks in on link state change (though that should happen only after reaching RUN state). I've no idea why lagg is treating OACTIVE as it is; I'd need to read the code. Sam