Gutsy Network Manager 0.6.5 and Ndiswrapper fails to connect to hidden AP

Bug #156786 reported by Mark Ferguson
2
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: network-manager

After upgrading to gutsy I could not connect to a hidden wireless through Network Manager using the Ndiswrapper driver.

I am running Kubuntu on IBM laptop Z60t with Atheros wireless card AR5212
My wireless router is a Netgear WGR614.

The problem appears to be a patch that was applied to the original Network Manager 0.6.5 source.

I found a previous bug that relates to this patch.
https://bugs.launchpad.net/baltix/+source/knetworkmanager/+bug/50214
(I added a comment but as it is in 'Fix Released' status I guess it will not be looked at any more.)

Note: Prior to upgrading to gutsy I had download the source for:
wireless-tools 29
Network Manager 0.6.5 (unpatched)
latest ndiswrapper, wpa_supplicat

This was to fix wireless connectivity issues after a kernel upgrade.

Looking in the logs after the gutsy upgrade I noticed in the daemon.log that that AP_SCAN 1 was being used where previously it was AP_SCAN 2

Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) started...
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0/wireless): access point 'ferguson-home' is encrypted, but NO valid key exists. New key needed.
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) New wireless user key requested for network 'ferguson-home'.
Oct 23 09:48:31 localhost NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0) New wireless user key for network 'ferguson-home' received.
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
Oct 23 09:48:32 localhost NetworkManager: <info> Activation (wlan0/wireless): access point 'ferguson-home' is encrypted, and a key exists. No new key needed.
Oct 23 09:48:33 localhost NetworkManager: <info> supplicant_interface_init() - connect to global ctrl socket (0/10).
Oct 23 09:48:33 localhost NetworkManager: <info> supplicant_interface_init() - connect to global ctrl socket (1/10).
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'INTERFACE_ADD wlan0^I^Iwext^I/usr/local/var/run/wpa_supplicant3^I'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> supplicant_init() - connect to device ctrl socket (1/10).
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'AP_SCAN 1'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'ADD_NETWORK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was '0'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 ssid 6665726775736f6e2d686f6d65'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 scan_ssid 1'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 proto WPA'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 key_mgmt WPA-PSK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 psk <key>'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 pairwise TKIP'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 group TKIP'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: sending command 'ENABLE_NETWORK 0'
Oct 23 09:48:33 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:48:33 localhost NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
Oct 23 09:49:33 localhost NetworkManager: <info> Activation (wlan0/wireless): association took too long (>60s), failing activation.
Oct 23 09:49:33 localhost NetworkManager: <info> Activation (wlan0) failure scheduled...
Oct 23 09:49:34 localhost NetworkManager: <info> Activation (wlan0) failed for access point (ferguson-home)
Oct 23 09:49:34 localhost NetworkManager: <info> Activation (wlan0) failed.
Oct 23 09:49:34 localhost NetworkManager: <info> Deactivating device wlan0.
Oct 23 09:49:34 localhost NetworkManager: <info> SUP: sending command 'DISABLE_NETWORK 0'
Oct 23 09:49:34 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:49:34 localhost NetworkManager: <info> SUP: sending command 'AP_SCAN 0'
Oct 23 09:49:34 localhost NetworkManager: <info> SUP: response was 'OK'
Oct 23 09:49:34 localhost NetworkManager: <info> SUP: sending command 'TERMINATE'

To quickly check if this was the problem I ran wpa_supplicant from the command line using the ndiswrapper driver.

wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d

I set ap_scan = 1 in the wpa_supplicant.conf file and wpa_supplicant could not connect to the wireless router. When I set the value back to 2 it could connect.

Note: If I used the madwifi driver then Network Manager could connect fine to my hidden wireless network.

Running the same wpa_supplicant test as above for the madwifi driver I could connect to the wireless router using AP_SCAN 1 or 2

I downloaded the source package unpacked and applied the patches.
 network-manager_0.6.5-0ubuntu16.diff.gz
 network-manager_0.6.5-0ubuntu16.dsc
 network-manager_0.6.5.orig.tar.gz

This file nm-device-802-11-wireless.c is where the AP_SCAN command is set.

I changed this section of the code (approx line 2923):
 if (!strcmp (kernel_driver, "orinoco_cs"))
                 ap_scan = "AP_SCAN 2";
         else if (is_adhoc || !supports_wpa)
   ap_scan = "AP_SCAN 2";
  else
                 ap_scan = "AP_SCAN 1";
to:
 if (!strcmp (kernel_driver, "orinoco_cs"))
                 ap_scan = "AP_SCAN 2";
         else if (is_adhoc || !supports_wpa)
   ap_scan = "AP_SCAN 2";
         else if (!nm_ap_get_broadcast (ap) && !strcmp (kernel_driver, "ndiswrapper"))
   ap_scan = "AP_SCAN 2";
  else
                 ap_scan = "AP_SCAN 1";

I can now use the Ndiswrapper with Network Manager to connect to a hidden wireless network.

In the original non patched version of nm-device-802-11-wireless.c all non broadcast access points had ap_scan = "AP_SCAN 2"

Further down in the same file was this section of code and the comment that explained why AP_SCAN 1 was being used for hidden networks.

 /* For non-broadcast networks, we need to set "scan_ssid 1" to scan with probe request frames.
  * However, don't try to probe Ad-Hoc networks.
  */
 if (!nm_ap_get_broadcast (ap) && !is_adhoc)
 {
  /*
   * since using "AP_SCAN 1" for hidden networks, wpa_supplicant
   * does not seem to bring the essid to the device anymore...
   * perhaps this is a wpa_supplicant/wext/driver issue or perhaps this
   * is simply how it is. We set the ESSID here for now.
   */
  nm_device_802_11_wireless_set_essid(self, essid);

  if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
    "SET_NETWORK %i scan_ssid 1", nwid))
   goto out;
 }

It seems that setting AP_SCAN 1 for all drivers connecting to hidden networks isn't correct though.

This is from the wpa_config Struct Reference

AP scanning/selection.

By default, wpa_supplicant requests driver to perform AP scanning and then uses the scan results to select a suitable AP. Another alternative is to allow the driver to take care of AP scanning and selection and use wpa_supplicant just to process EAPOL frames based on IEEE 802.11 association information from the driver.

1: wpa_supplicant initiates scanning and AP selection (default).

0: Driver takes care of scanning, AP selection, and IEEE 802.11 association parameters (e.g., WPA IE generation); this mode can also be used with non-WPA drivers when using IEEE 802.1X mode; do not try to associate with APs (i.e., external program needs to control association). This mode must also be used when using wired Ethernet drivers.

2: like 0, but associate with APs using security policy and SSID (but not BSSID); this can be used, e.g., with ndiswrapper and NDIS drivers to enable operation with hidden SSIDs and optimized roaming; in this mode, the network blocks in the configuration are tried one by one until the driver reports successful association; each network block should have explicit security policy (i.e., only one option in the lists) for key_mgmt, pairwise, group, proto variables.

My fix was based on how the original nm-device-802-11-wireless.c set AP_SCAN for hidden networks and restricted to the ndiswrapper driver.

Changed in network-manager:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
David Ward (dpward) wrote :

I created a similar patch and attached it to bug 50214. My understanding from reading the ndiswrapper documentation is that ndiswrapper is not supposed to work at all with AP_SCAN 1. For that reason I set it to always use AP_SCAN 2 with the ndiswrapper driver, as it does with the orinoco_cs driver.

Revision history for this message
Alexander Sack (asac) wrote :

please test if latest NM in hardy (0.6.6-0ubuntu5) fixes this for you.

Changed in network-manager:
status: Confirmed → Incomplete
Revision history for this message
Mark Ferguson (markfergy) wrote :

Hi Alexander,

NM in hardy (0.6.6-0ubuntu5) has fixed this issue.

Revision history for this message
Mark Ferguson (markfergy) wrote :

Ok Maybe not quite fixed yet.

I experinced this problem when I first tested 0.6.6-0ubuntu5 though I was not able to replicate it again until now.

Vary rarely on a reconnect (ie a successfull connection was made, then disconnect occurred) it seems that AP_SCAN 1
is being used.

Apr 6 07:26:39 pug NetworkManager: <info> Supplicant state changed: 0

Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0) started...
Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
Apr 6 07:28:18 pug NetworkManager: <info> Activation (wlan0/wireless): access point 'ferguson-home' is encrypted, and a key exists. No new key needed.
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'INTERFACE_ADD wlan0^I^Iwext^I/var/run/wpa_supplicant0^I'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'AP_SCAN 1'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'ADD_NETWORK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was '0'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 ssid 6665726775736f6e2d686f6d65'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 proto WPA'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 key_mgmt WPA-PSK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 psk <key>'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 pairwise TKIP'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'SET_NETWORK 0 group TKIP'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: sending command 'ENABLE_NETWORK 0'
Apr 6 07:28:20 pug NetworkManager: <info> SUP: response was 'OK'
Apr 6 07:28:20 pug NetworkManager: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
Apr 6 07:28:25 pug avahi-daemon[5517]: Registering new address record for fe80::214:a4ff:fe60:fbe7 on wlan0.*.
Apr 6 07:29:20 pug NetworkManager: <info> Activation (wlan0/wireless): association took too long (>60s), failing activation.

Revision history for this message
Alexander Sack (asac) wrote :

is this still a problem in intrepid (with network-manager 0.7)?

Revision history for this message
Mark Ferguson (markfergy) wrote :

Hi Alexander,

Sorry about the delay in getting back about this bug.

Initially when I tried this out on intrepid I was unable to connect to my ap with the ssid hidden using wpa_supplicant.

There must have been some update in the past months that fixed this problem, as I can now connect using wpa_supplicant.

Network Manager seems to be working fine as well.

Revision history for this message
Colin Ian King (colin-king) wrote :

Appears that this bug is now fixed. Marking it as "Fix Committed".

Please reopen if this is an issue in the current Ubuntu release, Jaunty Jackalope 9.04. To reopen the bug, click on the current status, under the Status column, and change the status back to "New". Thanks.

Changed in linux (Ubuntu):
status: Incomplete → Fix Committed
Revision history for this message
Jonathan Thomas (echidnaman) wrote :

The proper status would be fix released.

Changed in linux (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.