[PATCH] Toggle to flush BSS entries when interface is disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, bss entries are cleared out whenever the interface goes down.
This is the right thing to do most of the time, but this flush is unnecessary
when we are intentionally bringing the interface down and up as it takes
~3 seconds to re-scan all channels and fill up the bss entries again.

For Connected MAC Randomization, we have to bring the interface down,
change MAC address, bring the interface back up, and then start associating
(and we are observing ~3 scan delay here due to re-scanning).
Thus, we would like to have an option to not flush the cache when the
interface is disabled.

Do let me know if there would be a better way to avoid this delay. Thanks.

Signed-off-by: Jong Wook Kim <jongwook@xxxxxxxxxx>
---
 wpa_supplicant/config.c      | 1 +
 wpa_supplicant/config.h      | 8 ++++++++
 wpa_supplicant/config_file.c | 3 +++
 wpa_supplicant/events.c      | 4 +++-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index a22434cb..87161481 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -4642,6 +4642,7 @@ static const struct global_parse_data global_fields[] = {
  { INT(gas_rand_addr_lifetime), 0 },
  { INT_RANGE(gas_rand_mac_addr, 0, 2), 0 },
  { INT_RANGE(dpp_config_processing, 0, 2), 0 },
+ { INT_RANGE(bss_no_flush_when_down, 0, 1), 0 },
 };

 #undef FUNC
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 07b67e6b..c63ef1d6 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -1418,6 +1418,14 @@ struct wpa_config {
  * profile automatically
  */
  int dpp_config_processing;
+
+ /**
+ * bss_no_flush_when_down - Whether to flush BSS entries when the
interface is disabled
+ *
+ * 0 = Flush BSS entries when the interface becomes disabled (Default)
+ * 1 = Do not flush BSS entries when the interface becomes disabled
+ */
+ int bss_no_flush_when_down;
 };


diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 1fd432d1..d219c3da 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -1490,6 +1490,9 @@ static void wpa_config_write_global(FILE *f,
struct wpa_config *config)
  if (config->dpp_config_processing)
  fprintf(f, "dpp_config_processing=%d\n",
  config->dpp_config_processing);
+ if (config->bss_no_flush_when_down)
+ fprintf(f, "bss_no_flush_when_down=%d\n",
+ config->bss_no_flush_when_down);

 }

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 63cf7737..708c6fc3 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -4390,7 +4390,9 @@ void wpa_supplicant_event(void *ctx, enum
wpa_event_type event,
  wpa_s, WLAN_REASON_DEAUTH_LEAVING, 1);
  }
  wpa_supplicant_mark_disassoc(wpa_s);
- wpa_bss_flush(wpa_s);
+ if (wpa_s->conf->bss_no_flush_when_down == 0)
+ wpa_bss_flush(wpa_s);
+
  radio_remove_works(wpa_s, NULL, 0);

  wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
-- 
2.16.2.395.g2e18187dfd-goog
From 127153e35d70f82d0d00e77063c1d35212caf249 Mon Sep 17 00:00:00 2001
From: Jong Wook Kim <jongwook@xxxxxxxxxx>
Date: Thu, 15 Feb 2018 12:23:44 -0800
Subject: [PATCH] Toggle to flush BSS entries when interface is disabled

Add bss_no_flush_when_down toggle to decide whether to delete BSS entries
when the interface is disabled. In default case, we want to flush the
BSS entries as the data will become stale. However, when we are manually
bringing the interface down and up (for Connected MAC Randomization), we
want to keep the data to prevent scanning the channels again and waste
~3 seconds.

Bug: 73301881
Test: Manual check that cache is not flushed with toggle on
Change-Id: I4caef6792789e351e649e6fd2dca61e867df2b1a
---
 wpa_supplicant/config.c      | 1 +
 wpa_supplicant/config.h      | 8 ++++++++
 wpa_supplicant/config_file.c | 3 +++
 wpa_supplicant/events.c      | 4 +++-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index a22434cb..87161481 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -4642,6 +4642,7 @@ static const struct global_parse_data global_fields[] = {
 	{ INT(gas_rand_addr_lifetime), 0 },
 	{ INT_RANGE(gas_rand_mac_addr, 0, 2), 0 },
 	{ INT_RANGE(dpp_config_processing, 0, 2), 0 },
+	{ INT_RANGE(bss_no_flush_when_down, 0, 1), 0 },
 };
 
 #undef FUNC
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 07b67e6b..c63ef1d6 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -1418,6 +1418,14 @@ struct wpa_config {
 	 *	profile automatically
 	 */
 	int dpp_config_processing;
+
+	/**
+	 * bss_no_flush_when_down - Whether to flush BSS entries when the interface is disabled
+	 *
+	 * 0 = Flush BSS entries when the interface becomes disabled (Default)
+	 * 1 = Do not flush BSS entries when the interface becomes disabled
+	 */
+	int bss_no_flush_when_down;
 };
 
 
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 1fd432d1..d219c3da 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -1490,6 +1490,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
 	if (config->dpp_config_processing)
 		fprintf(f, "dpp_config_processing=%d\n",
 			config->dpp_config_processing);
+	if (config->bss_no_flush_when_down)
+		fprintf(f, "bss_no_flush_when_down=%d\n",
+			config->bss_no_flush_when_down);
 
 }
 
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 63cf7737..708c6fc3 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -4390,7 +4390,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 				wpa_s, WLAN_REASON_DEAUTH_LEAVING, 1);
 		}
 		wpa_supplicant_mark_disassoc(wpa_s);
-		wpa_bss_flush(wpa_s);
+		if (wpa_s->conf->bss_no_flush_when_down == 0)
+			wpa_bss_flush(wpa_s);
+
 		radio_remove_works(wpa_s, NULL, 0);
 
 		wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
-- 
2.16.2.395.g2e18187dfd-goog

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux