[PATCH v4 0/4] hostapd: add ACS support

Felix Liao Felix.Liao
Thu Dec 6 16:29:17 PST 2012


Hi Luis,

I made a test with this ACS patch on hostapd 1.0, it works fine with one configuration file, but failed with more configuration files, did you notice that?

~# ./hostapd -t -K -d ./hostapd1_acs.conf ./hostapd2_acs.conf
1354776027.023046: random: Trying to read entropy from /dev/urandom
1354776027.023279: Configuration file: ./hostapd1_acs.conf
1354776027.023534: eapol_version=1
1354776027.027695: nl80211: interface ath1 in phy phy0
1354776027.027770: rfkill: Cannot open RFKILL control device
1354776027.027791: nl80211: RFKILL status not available
1354776027.028225: nl80211: Using driver-based off-channel TX
1354776027.028256: nl80211: Use separate P2P group interface (driver advertised support)
1354776027.028272: nl80211: TDLS supported
1354776027.028285: nl80211: TDLS external setup
1354776027.028609: nl80211: Interface ath1 is in bridge eth1
1354776027.028700: nl80211: Add own interface ifindex 17
1354776027.028723: nl80211: Add own interface ifindex 13
1354776027.033431: nl80211: Set mode ifindex 13 iftype 3 (AP)
1354776027.033588: nl80211: Create interface iftype 6 (MONITOR)
1354776027.034832: nl80211: New interface mon.ath1 created: ifindex=82
1354776027.034877: nl80211: Add own interface ifindex 82
1354776027.045148: BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
1354776027.045647: nl80211: Regulatory information - country=00
1354776027.045680: nl80211: 2402-2472 @ 40 MHz
1354776027.045700: nl80211: 2457-2482 @ 20 MHz
1354776027.045718: nl80211: 2474-2494 @ 20 MHz
1354776027.045736: nl80211: 5170-5250 @ 40 MHz
1354776027.045756: nl80211: 5735-5835 @ 40 MHz
1354776027.045835: nl80211: Added 802.11b mode based on 802.11g information
1354776027.045877: ACS: automatic channel selection started, this may take a bit
1354776027.045897: ACS: initial scan just to kick off the hw a bit...
1354776027.047218: Scan requested (ret=0) - scan timeout 10 seconds
1354776027.047282: Configuration file: ./hostapd2_acs.conf
1354776027.047461: eapol_version=1
1354776027.050298: nl80211: interface ath2 in phy phy0
1354776027.050352: rfkill: Cannot open RFKILL control device
1354776027.050371: nl80211: RFKILL status not available
1354776027.050665: nl80211: Using driver-based off-channel TX
1354776027.050693: nl80211: Use separate P2P group interface (driver advertised support)
1354776027.050709: nl80211: TDLS supported
1354776027.050723: nl80211: TDLS external setup
1354776027.050971: nl80211: Add own interface ifindex 79
1354776027.050997: nl80211: Add own interface ifindex 14
1354776027.051300: nl80211: Set mode ifindex 14 iftype 3 (AP)
1354776027.051427: nl80211: Create interface iftype 6 (MONITOR)
1354776027.057242: nl80211: New interface mon.ath2 created: ifindex=83
1354776027.057294: nl80211: Add own interface ifindex 83
1354776027.057821: nl80211: Adding interface ath2 into bridge eth4
1354776027.058372: BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
1354776027.058843: nl80211: Regulatory information - country=00
1354776027.058876: nl80211: 2402-2472 @ 40 MHz
1354776027.058895: nl80211: 2457-2482 @ 20 MHz
1354776027.058926: nl80211: 2474-2494 @ 20 MHz
1354776027.058945: nl80211: 5170-5250 @ 40 MHz
1354776027.058964: nl80211: 5735-5835 @ 40 MHz
1354776027.059026: nl80211: Added 802.11b mode based on 802.11g information
1354776027.059054: ACS: automatic channel selection started, this may take a bit
1354776027.059070: ACS: initial scan just to kick off the hw a bit...
1354776027.059258: nl80211: Scan trigger failed: ret=-16 (Device or resource busy)
1354776027.059292: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.059375: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.059405: nl80211: Try mode change after setting interface down
1354776027.060505: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.060660: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.162149: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.162333: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.263628: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.263796: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.365179: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.365345: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.466667: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.466849: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.568247: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.568507: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.669793: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.669981: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.771410: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.771615: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.873008: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.873199: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776027.974500: nl80211: Set mode ifindex 14 iftype 2 (STATION)
1354776027.974687: nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
1354776028.075095: nl80211: Interface mode change to 2 from 3 failed
1354776028.075181: ACS: Failed to request initial scan
Segmentation fault
~#

I trace this issue and found that when we set up the second interface, ACS is failed to request the initial scan, 
the kernel return -EBUSY as the WIPHY is scanning now.

cfg80211: src/net/wireless/nl80211.c
3831 static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
3832 {
...
3849     if (rdev->scan_req)
3850         return -EBUSY;
...
}

I think we should do like as wpa_driver_nl80211_scan(), sleep 10 seconds at least to avoid race conditions between each scanning.

hostapd: src/drivers/driver_nl80211.c
2712 static int wpa_driver_nl80211_scan(void *priv,
2713                    struct wpa_driver_scan_params *params)
...
2812     /* Not all drivers generate "scan completed" wireless event, so try to
2813      * read results after a timeout. */
2814     timeout = 10;
2815     if (drv->scan_complete_events) {
2816         /*
2817          * The driver seems to deliver events to notify when scan is
2818          * complete, so use longer timeout to avoid race conditions
2819          * with scanning and following association request.
2820          */
2821         timeout = 30;
2822     }
2823     wpa_printf(MSG_DEBUG, "Scan requested (ret=%d) - scan timeout %d "
2824            "seconds", ret, timeout);
2825     eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
2826     eloop_register_timeout(timeout, 0, wpa_driver_nl80211_scan_timeout,
2827                    drv, drv->ctx);
...
2835 }

So I just fix the acs_init_scan to sleep some seconds, I have tested some times and seems it works well, 
Do you think it make sense?

==== a/hostapd/1.0/src/ap/acs.c#1 - b/hostapd/1.0/src/ap/acs.c ====
*************** static int acs_init_scan(struct hostapd_
*** 420,425 ****
--- 420,426 ----
               }
  
               iface->scan_cb = acs_init_scan_complete;
+             sleep(10);
               return 1;
  }

Thanks,
- Felix



More information about the Hostap mailing list