Patchwork wpa_supplicant: Allow vifs to scan only current channel.

login
register
mail settings
Submitter Ben Greear
Date May 1, 2013, 12:16 a.m.
Message ID <1367367411-21172-2-git-send-email-greearb@candelatech.com>
Download mbox | patch
Permalink /patch/240708/
State Superseded
Headers show

Comments

Ben Greear - May 1, 2013, 12:16 a.m.
From: Ben Greear <greearb@candelatech.com>

If a VIF is already associated, then only scan on the associated
frequency if user requests such.  This is a big help when using
lots of virtual stations.

Signed-hostap: Ben Greear <greearb@candelatech.com>
---
:100644 100644 28c40a1... 0dd951c... M	wpa_supplicant/config.c
:100644 100644 ef95650... 60c6f59... M	wpa_supplicant/config.h
:100644 100644 5ed4097... ad0a83a... M	wpa_supplicant/scan.c
:100644 100644 6aed57a... 0af8e80... M	wpa_supplicant/wpa_supplicant.conf
 wpa_supplicant/config.c            |    2 ++
 wpa_supplicant/config.h            |    7 +++++++
 wpa_supplicant/scan.c              |   17 +++++++++++++++--
 wpa_supplicant/wpa_supplicant.conf |   13 +++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)
Ben Greear - May 1, 2013, 12:32 a.m.
On 04/30/2013 05:16 PM, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
>
> If a VIF is already associated, then only scan on the associated
> frequency if user requests such.  This is a big help when using
> lots of virtual stations.

While testing this patch, I found something a bit strange.  Either my patch is
weird, or something else in supplicant might need some attention.

I had 8 stations associated, and then changed the AP's freq.  I quickly
saw 'iw' events showing that all of the stations disconnected:

...
2013-04-30 17:08:41.520  1.3:  sta5 (phy #0): disconnected (local request)
2013-04-30 17:08:41.520  1.3:  sta6: del station 80:01:02:03:04:05
2013-04-30 17:08:41.520  1.3:  sta6 (phy #0): deauth 00:ab:cd:ef:01:07 -> 80:01:02:03:04:05 reason 4: Disassociated due to inactivity
2013-04-30 17:08:41.520  1.3:  sta6 (phy #0): disconnected (local request)
2013-04-30 17:08:41.520  1.3:  sta7: del station 80:01:02:03:04:05
2013-04-30 17:08:41.521  1.3:  sta7 (phy #0): deauth 00:ab:cd:ef:01:08 -> 80:01:02:03:04:05 reason 4: Disassociated due to inactivity
2013-04-30 17:08:41.521  1.3:  sta7 (phy #0): disconnected (local request)

Then, supplicant started scanning again (with the scan_cur_freq=1 setting).
But, it is scanning on the 'current' operating channel, when actually there
should be no current channel.

2013-04-30 17:09:47.268  1.3:  sta6 (phy #0): scan started
2013-04-30 17:09:47.268  1.3:  sta6 (phy #0): scan finished: 2412, ""
2013-04-30 17:09:52.254  1.3:  wlan0 (phy #0): scan started
2013-04-30 17:09:52.293  1.3:  wlan0 (phy #0): scan finished: 2412, ""
2013-04-30 17:10:02.060  1.3:  sta1 (phy #0): scan started
2013-04-30 17:10:07.143  1.3:  sta1 (phy #0): scan finished: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 5180 5200 5220 5240 5260 5280 5300 5320 5500 
5520 5540 5560 5580 5660 5680 5700 5745 5765 5785 5805 5825, ""
2013-04-30 17:10:07.143  1.3:  sta1: new station 80:01:02:03:04:05
2013-04-30 17:10:07.143  1.3:  sta1 (phy #0): auth 80:01:02:03:04:05 -> 00:ab:cd:ef:01:02 status: 0: Successful
2013-04-30 17:10:07.143  1.3:  sta0 (phy #0): scan started
2013-04-30 17:10:07.443  1.3:  sta0 (phy #0): scan finished: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 5180 5200 5220 5240 5260 5280 5300 5320 5500 
5520 5540 5560 5580 5660 5680 5700 5745 5765 5785 5805 5825, ""
2013-04-30 17:10:07.481  1.1:  vap0: new station 00:ab:cd:ef:01:02
2013-04-30 17:10:07.510  1.3:  sta0: new station 80:01:02:03:04:05
...
2013-04-30 17:10:11.335  1.3:  sta1 (phy #0): assoc 80:01:02:03:04:05 -> 00:ab:cd:ef:01:02 status: 0: Successful
2013-04-30 17:10:11.336  1.3:  sta1 (phy #0): connected to 80:01:02:03:04:05
2013-04-30 17:10:11.336  1.3:  sta0 (phy #0): assoc 80:01:02:03:04:05 -> 00:ab:cd:ef:01:01 status: 0: Successful
2013-04-30 17:10:11.336  1.3:  sta3 (phy #0): scan started
2013-04-30 17:10:11.336  1.3:  sta3 (phy #0): scan finished: 5180, ""

Maybe 5-10 seconds later it scanned everything and re-associated on a new channel.
I'm not 100% sure if my program kicked it or supplicant figured it out on it's own.

Do I need to add some additional event handling so supplicant notices sooner that
stations have disconnected?  Or maybe there were some saved scan list that had to
be used up or time out first?

Thanks,
Ben

Patch

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 28c40a1..0dd951c 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2585,6 +2585,7 @@  struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
 	config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT;
 	config->max_num_sta = DEFAULT_MAX_NUM_STA;
 	config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE;
+	config->scan_cur_freq = DEFAULT_SCAN_CUR_FREQ;
 	config->wmm_ac_params[0] = ac_be;
 	config->wmm_ac_params[1] = ac_bk;
 	config->wmm_ac_params[2] = ac_vi;
@@ -3040,6 +3041,7 @@  static const struct global_parse_data global_fields[] = {
 	{ STR(pcsc_pin), 0 },
 	{ STR(driver_param), 0 },
 	{ FUNC(freq_list), 0 },
+	{ INT(scan_cur_freq), 0 },
 	{ INT(dot11RSNAConfigPMKLifetime), 0 },
 	{ INT(dot11RSNAConfigPMKReauthThreshold), 0 },
 	{ INT(dot11RSNAConfigSATimeout), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index ef95650..60c6f59 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -21,6 +21,7 @@ 
 #define DEFAULT_P2P_INTRA_BSS 1
 #define DEFAULT_P2P_GO_MAX_INACTIVITY (5 * 60)
 #define DEFAULT_BSS_MAX_COUNT 200
+#define DEFAULT_SCAN_CUR_FREQ 0
 #define DEFAULT_BSS_EXPIRATION_AGE 180
 #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2
 #define DEFAULT_MAX_NUM_STA 128
@@ -655,6 +656,12 @@  struct wpa_config {
 	 */
 	int *freq_list;
 
+
+	/* If true, attempt to scan only the current channel if any other
+	 * VIFs on this radio are already associated on a particular channel.
+	 */
+	int scan_cur_freq;
+	 
 	/**
 	 * changed_parameters - Bitmap of changed parameters since last update
 	 */
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 5ed4097..ad0a83a 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -476,6 +476,7 @@  static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s)
 	return 0;
 }
 
+#endif /* CONFIG_P2P */
 
 /*
  * Find the operating frequency of any other virtual interface that is using
@@ -515,8 +516,6 @@  static int shared_vif_oper_freq(struct wpa_supplicant *wpa_s)
 	return 0;
 }
 
-#endif /* CONFIG_P2P */
-
 
 void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
 {
@@ -757,6 +756,20 @@  ssid_list_set:
 		int_array_concat(&params.freqs, wpa_s->conf->freq_list);
 	}
 
+	/* Use current associated channel? */
+	if (wpa_s->conf->scan_cur_freq && !params.freqs) {
+		int freq = shared_vif_oper_freq(wpa_s);
+		if (freq > 0) {
+			wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current "
+				"operating channel (%d MHz) since "
+				"scan_cur_freq is enabled.", freq);
+			params.freqs = os_zalloc(sizeof(int) * 2);
+			if (params.freqs)
+				params.freqs[0] = freq;
+		}
+	}
+
+
 	params.filter_ssids = wpa_supplicant_build_filter_ssids(
 		wpa_s->conf, &params.num_filter_ssids);
 	if (extra_ie) {
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index 6aed57a..0af8e80 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -527,6 +527,11 @@  fast_reauth=1
 # This can also be set on the outside of the network block.  In this case,
 # it limits the frequencies that will be scanned.
 #
+# scan_cur_freq:  Scan current frequency.
+# 0:  Scan all available frequencies. (Default)
+# 1:  Scan current operating frequency if another VIF on the same radio
+#     is already associated.
+#
 # bgscan: Background scanning
 # wpa_supplicant behavior for background scanning can be specified by
 # configuring a bgscan module. These modules are responsible for requesting
@@ -1241,3 +1246,11 @@  freq_list=5180
 network={
 	key_mgmt=NONE
 }
+
+
+# Example config file that will scan on existing frequency if
+# another VIF on the same radio is already associated.
+scan_cur_freq=1
+network={
+	key_mgmt=NONE
+}