From owner-freebsd-net@FreeBSD.ORG Wed Jan 5 20:51:49 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8494D106564A for ; Wed, 5 Jan 2011 20:51:49 +0000 (UTC) (envelope-from bschmidt@techwires.net) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 206948FC08 for ; Wed, 5 Jan 2011 20:51:48 +0000 (UTC) Received: by fxm16 with SMTP id 16so15326189fxm.13 for ; Wed, 05 Jan 2011 12:51:48 -0800 (PST) Received: by 10.223.86.3 with SMTP id q3mr624478fal.139.1294260708314; Wed, 05 Jan 2011 12:51:48 -0800 (PST) Received: from maja.lab.techwires.net (p54B4ED89.dip.t-dialin.net [84.180.237.137]) by mx.google.com with ESMTPS id e17sm5641469fak.10.2011.01.05.12.51.46 (version=SSLv3 cipher=RC4-MD5); Wed, 05 Jan 2011 12:51:47 -0800 (PST) Sender: Bernhard Schmidt From: Bernhard Schmidt To: freebsd-net@freebsd.org Date: Wed, 5 Jan 2011 21:51:46 +0100 User-Agent: KMail/1.12.4 (FreeBSD/9.0-CURRENT; KDE/4.3.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_inNJN3LMd8jUArV" Message-Id: <201101052151.46883.bschmidt@freebsd.org> Subject: devd and 802.11 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2011 20:51:49 -0000 --Boundary-00=_inNJN3LMd8jUArV Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, While working on the 'netif restart' issue (kern/153594) I noticed that there are to entries in devd.conf with shady usefulness. detach 0 { media-type "802.11"; action "/etc/pccard_ether $device-name stop"; }; attach 0 { media-type "802.11"; action "/etc/pccard_ether $device-name start"; }; I assume that the general use-case for devd is to automatically configure wireless devices as soon as those are plugged in (PCMCIA, ..). Those are already handled by notify 0 { match "system" "IFNET"; match "type" "ATTACH"; action "/etc/pccard_ether $subsystem start"; }; this will invoke netif which then will create and configure the wlan0 device. While wlan0 is created, devd is poked again and this time the other rule kicks in and starts netif again. This effectively results in 2 'netif start wlan0' calls. Due to the racy nature of this all tries to ensure wpa_supplicant has exclusive access to the wlan device fail, wpa_supplicant gets started twice and each instance is fighting for ownership. That devd entries a quite old (pre-VAP), the media-type might have changed and this was just overlooked, so, I did some tests to figure out if those are really necessary. After removing the 2 entries, I tried 3 things: - plug in PCMCIA card while system is up - remove PCMCIA device while system is up - kldunload if_drv; kldload if_drv in both cases, the wireless device was configure according to the settings in rc.conf. Also, cleaning up after kldunload or removal of the device worked as expected. If I'm not missing an use-case here (pointers?) and there are no complains, the attached diff is worth being committed. -- Bernhard --Boundary-00=_inNJN3LMd8jUArV Content-Type: text/x-patch; charset="ISO-8859-1"; name="devd-80211.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="devd-80211.diff" Index: etc/devd.conf =================================================================== --- etc/devd.conf (revision 217018) +++ etc/devd.conf (working copy) @@ -60,14 +60,6 @@ notify 0 { # they have a different media type. We may want # to exploit this later. # -detach 0 { - media-type "802.11"; - action "/etc/pccard_ether $device-name stop"; -}; -attach 0 { - media-type "802.11"; - action "/etc/pccard_ether $device-name start"; -}; notify 0 { match "system" "IFNET"; match "type" "LINK_UP"; --Boundary-00=_inNJN3LMd8jUArV--