From nobody@FreeBSD.org  Thu Jun 21 16:38:11 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 14FF816A400
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 21 Jun 2007 16:38:11 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id EE46313C455
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 21 Jun 2007 16:38:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l5LGcA7r040271
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 21 Jun 2007 16:38:10 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l5LGcArS040270;
	Thu, 21 Jun 2007 16:38:10 GMT
	(envelope-from nobody)
Message-Id: <200706211638.l5LGcArS040270@www.freebsd.org>
Date: Thu, 21 Jun 2007 16:38:10 GMT
From: Scot Hetzel <swhetzel@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ndis wireless driver fails to associate when interface set to WPA
X-Send-Pr-Version: www-3.0

>Number:         113915
>Category:       conf
>Synopsis:       [ndis] [patch] ndis wireless driver fails to associate when interface set to WPA
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 21 16:40:12 GMT 2007
>Closed-Date:    
>Last-Modified:  Sun Feb 24 23:17:45 UTC 2013
>Originator:     Scot Hetzel
>Release:        7.0-CURRENT
>Organization:
>Environment:
FreeBSD hp010 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Tue Jun 19 01:49:53 CDT 2007     swhetzel@hp010:/usr/src/sys/amd64/compile/GENERIC  amd64

>Description:
When I try and boot a system with the NDIS interface configured as:

ifconfig_ndis0="WPA DHCP"

I see it continuously trying to get a DHCP address, but it fails.  I
found the problem is because wpa_supplicant is not realizing that it
had successfully connected to the wireless network, so it continuously
connects/disconnects.

By starting /usr/sbin/ndis_events, then wpa_supplicant will associate,
and the wireless network is accessible.

hp010# dmesg | grep ndis
ndis0: <Broadcom 802.11b/g WLAN> mem 0xc0204000-0xc0205fff irq 21 at device 2.0 on pci6
ndis0: [ITHREAD]
ndis0: NDIS API version: 5.1
ndis0: using obsoleted if_watchdog interface
ndis0: Ethernet address: 00:14:a5:72:68:64
>How-To-Repeat:
set the NDIS interface to "WPA DHCP" and then reboot the system.
>Fix:
Start ndis_events before starting wpa_supplicant for NDIS interfaces.

apply the attached patch which will start ndis_events when the NDIS
interface is set for WPA.

Updated files:

etc/network.subr
etc/rc.d/Makefile

New file

etc/rc.d/ndis_events

Patch attached with submission follows:

Index: etc/network.subr
===================================================================
RCS file: /home/ncvs/src/etc/network.subr,v
retrieving revision 1.180
diff -u -r1.180 network.subr
--- etc/network.subr	23 May 2007 00:18:44 -0000	1.180
+++ etc/network.subr	21 Jun 2007 15:53:12 -0000
@@ -52,6 +52,11 @@
 		if [ $_cfg -ne 0 ] ; then
 			ifconfig $1 up
 		fi
+		case $1 in
+		ndis*)
+			/etc/rc.d/ndis_events start
+			;;
+		esac
 		/etc/rc.d/wpa_supplicant start $1
 		_cfg=0		# XXX: not sure this should count
 	fi
@@ -80,6 +85,11 @@
 
 	if wpaif $1; then
 		/etc/rc.d/wpa_supplicant stop $1
+		case $1 in
+		ndis*)
+			/etc/rc.d/ndis_events stop
+			;;
+		esac
 		_cfg=0
 	fi
 
Index: etc/rc.d/Makefile
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/Makefile,v
retrieving revision 1.81
diff -u -r1.81 Makefile
--- etc/rc.d/Makefile	9 Apr 2007 19:21:27 -0000	1.81
+++ etc/rc.d/Makefile	21 Jun 2007 15:33:26 -0000
@@ -23,7 +23,7 @@
 	ldconfig local localpkg lpd \
 	mixer motd mountcritlocal mountcritremote mountlate \
 	mdconfig mdconfig2 mountd moused mroute6d mrouted msgs \
-	named natd netif netoptions \
+	named natd netif ndis_events netoptions \
 	network_ipv6 newsyslog nfsclient nfsd \
 	nfslocking nfsserver nisdomain nsswitch ntpd ntpdate \
 	othermta \
Index: etc/rc.d/ndis_events
===================================================================
RCS file: etc/rc.d/ndis_events
diff -N etc/rc.d/ndis_events
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/rc.d/ndis_events	21 Jun 2007 15:35:44 -0000
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: ndis_events
+# REQUIRE: mountcritremote
+# BEFORE: wpa_supplicant
+# KEYWORD: nojail nostart
+
+. /etc/rc.subr
+. /etc/network.subr
+
+name="ndis_events"
+rcvar=
+command="/usr/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Jan 14 00:45:29 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113915 

From: Volker <volker@vwsoft.com>
To: bug-followup@FreeBSD.org, swhetzel@gmail.com
Cc:  
Subject: Re: conf/113915: [patch] ndis wireless driver fails to associate
 when interface set to WPA
Date: Sat, 26 Jan 2008 04:44:23 +0100

 Scot,
 
 I've tested wpa_supplicant with an ndis interface and it's working w/o
 your patch using 'ifconfig_ndis0="WPA DHCP"'.
 
 ndis0: <Dell Wireless 1490 Dual Band WLAN Mini-Card> mem
 0xc8000000-0xc8003fff irq 18 at device 0.0 on pci48
 ndis0: [ITHREAD]
 ndis0: NDIS API version: 5.1
 ndis0: using obsoleted if_watchdog interface
 ndis0: Ethernet address: 00:1a:73:ad:a4:67
 ndis0: bssid_list failed
 ndis0: bssid_list failed
 ndis0: link state changed to UP
 
 FreeBSD cesar.sz.vwsoft.com 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #8:
 Tue Jan 22 01:29:52 CET 2008
 root@cesar.sz.vwsoft.com:/usr/obj/usr/src/sys/CESAR  i386
 
 I have been running this system with a 7.0-PRE amd64 kernel lately and
 also haven't seen this problem.
 
 Please check if you can recreate your problem with a recent 7.0
 unpatched system.
 
 Thx!
 
 Volker
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Sat Jan 26 04:17:28 UTC 2008 
State-Changed-Why:  
Note that submitter has been asked for feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113915 

From: "Scot Hetzel" <swhetzel@gmail.com>
To: Volker <volker@vwsoft.com>
Cc: bug-followup@freebsd.org
Subject: Re: conf/113915: [patch] ndis wireless driver fails to associate when interface set to WPA
Date: Thu, 14 Feb 2008 18:03:13 -0600

 On 1/25/08, Volker <volker@vwsoft.com> wrote:
 > Scot,
 >
 >  I've tested wpa_supplicant with an ndis interface and it's working w/o
 >  your patch using 'ifconfig_ndis0="WPA DHCP"'.
 >
 >  ndis0: <Dell Wireless 1490 Dual Band WLAN Mini-Card> mem
 >  0xc8000000-0xc8003fff irq 18 at device 0.0 on pci48
 >  ndis0: [ITHREAD]
 >  ndis0: NDIS API version: 5.1
 >  ndis0: using obsoleted if_watchdog interface
 >  ndis0: Ethernet address: 00:1a:73:ad:a4:67
 >  ndis0: bssid_list failed
 >  ndis0: bssid_list failed
 >  ndis0: link state changed to UP
 >
 >  FreeBSD cesar.sz.vwsoft.com 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #8:
 >  Tue Jan 22 01:29:52 CET 2008
 >  root@cesar.sz.vwsoft.com:/usr/obj/usr/src/sys/CESAR  i386
 >
 >  I have been running this system with a 7.0-PRE amd64 kernel lately and
 >  also haven't seen this problem.
 >
 >  Please check if you can recreate your problem with a recent 7.0
 >  unpatched system.
 >
 
 I can recreate the problem with a recent 8.0 system:
 
 FreeBSD hp010 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Wed Feb 13 11:28:36
 CST 2008     swhetzel@hp010:/usr/src/sys/amd64/compile/DV8135NR  amd64
 
 When I don't have ndis_event start, then I don't get an IP address
 using DHCP.  With it running, I am able to receive an IP address.
 
 ndis0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
         ether 00:14:a5:72:68:64
         inet6 fe80::214:a5ff:fe72:6864%ndis0 prefixlen 64 scopeid 0x1
         inet 10.65.108.188 netmask 0xfffffc00 broadcast 10.65.111.255
         media: IEEE 802.11 Wireless Ethernet autoselect (OFDM/54Mbps)
         status: associated
         ssid campuswpa channel 6 (2437 Mhz 11g) bssid 00:0b:0e:19:33:42
         authmode OPEN privacy OFF bmiss 7 scanvalid 60 protmode CTS
         roaming MANUAL bintval 0
 
 I have tested it on 3 different networks (2 - secure, 1 - open).
 
 Scot

From: "Scot Hetzel" <swhetzel@gmail.com>
To: Volker <volker@vwsoft.com>
Cc: bug-followup@freebsd.org
Subject: Re: conf/113915: [patch] ndis wireless driver fails to associate when interface set to WPA
Date: Thu, 14 Feb 2008 18:07:47 -0600

 On 2/14/08, Scot Hetzel <swhetzel@gmail.com> wrote:
 > On 1/25/08, Volker <volker@vwsoft.com> wrote:
 >  > Scot,
 >  >
 >  >  I've tested wpa_supplicant with an ndis interface and it's working w/o
 >  >  your patch using 'ifconfig_ndis0="WPA DHCP"'.
 >  >
 >  >  ndis0: <Dell Wireless 1490 Dual Band WLAN Mini-Card> mem
 >  >  0xc8000000-0xc8003fff irq 18 at device 0.0 on pci48
 >  >  ndis0: [ITHREAD]
 >  >  ndis0: NDIS API version: 5.1
 >  >  ndis0: using obsoleted if_watchdog interface
 >  >  ndis0: Ethernet address: 00:1a:73:ad:a4:67
 >  >  ndis0: bssid_list failed
 >  >  ndis0: bssid_list failed
 >  >  ndis0: link state changed to UP
 >  >
 >  >  FreeBSD cesar.sz.vwsoft.com 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #8:
 >  >  Tue Jan 22 01:29:52 CET 2008
 >  >  root@cesar.sz.vwsoft.com:/usr/obj/usr/src/sys/CESAR  i386
 >  >
 >  >  I have been running this system with a 7.0-PRE amd64 kernel lately and
 >  >  also haven't seen this problem.
 >  >
 >  >  Please check if you can recreate your problem with a recent 7.0
 >  >  unpatched system.
 >  >
 >
 >
 > I can recreate the problem with a recent 8.0 system:
 >
 >  FreeBSD hp010 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Wed Feb 13 11:28:36
 >  CST 2008     swhetzel@hp010:/usr/src/sys/amd64/compile/DV8135NR  amd64
 >
 >  When I don't have ndis_event start, then I don't get an IP address
 >  using DHCP.  With it running, I am able to receive an IP address.
 >
 >  ndis0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
 >         ether 00:14:a5:72:68:64
 >         inet6 fe80::214:a5ff:fe72:6864%ndis0 prefixlen 64 scopeid 0x1
 >         inet 10.65.108.188 netmask 0xfffffc00 broadcast 10.65.111.255
 >         media: IEEE 802.11 Wireless Ethernet autoselect (OFDM/54Mbps)
 >         status: associated
 >         ssid campuswpa channel 6 (2437 Mhz 11g) bssid 00:0b:0e:19:33:42
 >         authmode OPEN privacy OFF bmiss 7 scanvalid 60 protmode CTS
 >         roaming MANUAL bintval 0
 >
 >  I have tested it on 3 different networks (2 - secure, 1 - open).
 >
 
 Feb 14 17:46:40 hp010 kernel: ndis0: <Broadcom 802.11b/g WLAN> mem
 0xc0204000-0xc0205fff irq 21 at device 2.0 on pci6
 Feb 14 17:46:40 hp010 kernel: ndis0: [ITHREAD]
 Feb 14 17:46:40 hp010 kernel: ndis0: NDIS API version: 5.1
 Feb 14 17:46:40 hp010 kernel: ndis0: using obsoleted if_watchdog interface
 Feb 14 17:46:40 hp010 kernel: ndis0: Ethernet address: 00:14:a5:72:68:64
 Feb 14 17:46:47 hp010 kernel: ndis0: link state changed to DOWN
 Feb 14 17:46:54 hp010 kernel: ndis0: link state changed to UP
 Feb 14 17:47:05 hp010 kernel: ndis0: link state changed to DOWN
 Feb 14 17:47:12 hp010 kernel: ndis0: link state changed to UP
 
 Here's what happens after I stop ndis0, and restart it with ndis_event enabled.
 
 Feb 14 17:51:03 hp010 kernel: ndis0: link state changed to DOWN
 Feb 14 17:51:14 hp010 kernel: ndis0: link state changed to DOWN
 Feb 14 17:51:21 hp010 kernel: ndis0: link state changed to UP
 Feb 14 17:51:23 hp010 kernel: ndis0: link state changed to DOWN
 Feb 14 17:51:39 hp010 kernel: ndis0: link state changed to UP
 Feb 14 17:51:51 hp010 dhclient: New IP Address (ndis0): 10.65.108.188
 Feb 14 17:51:51 hp010 dhclient: New Subnet Mask (ndis0): 255.255.252.0
 Feb 14 17:51:51 hp010 dhclient: New Broadcast Address (ndis0): 10.65.111.255
 Feb 14 17:51:51 hp010 dhclient: New Routers (ndis0): 10.65.110.1
 
 Scot
State-Changed-From-To: feedback->open 
State-Changed-By: vwe 
State-Changed-When: Sat May 17 20:13:39 UTC 2008 
State-Changed-Why:  

feedback already received 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113915 
State-Changed-From-To: open->feedback 
State-Changed-By: crees 
State-Changed-When: Sat Oct 27 18:52:19 UTC 2012 
State-Changed-Why:  
Two questions; 1) Is this still a problem with the new wireless network 
RC system in 9.0, and 2) I suspect that it is, so please would you give 
this patch a spin? http://www.bayofrum.net/~crees/patches/113915  It's 
mostly based on yours, and cleans up wpa_supplicant a bit. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113915 
>Unformatted:
