[PATCH] wpa_supplicant: Notify freq change on CH_SWITCH

Arowa Suliman arowa at chromium.org
Mon Nov 2 20:10:53 EST 2020


wpa_supplicant does not send a D-Bus notification of the BSS frequency
change when a CSA happens. Sending a PropertyChanged signal with the
updated frequency will notify the network manager quickly, instead of
waiting for the next scan results.

Signed-off-by: Arowa Suliman <arowa at chromium.org>
Change-Id: Ic68964d505e4d97334502f1a638394bc57291be3
---
 ...cant-Notify-freq-change-on-CH_SWITCH.patch | 108 ++++++++++++++++++
 wpa_supplicant/bss.c                          |  16 +--
 wpa_supplicant/bss.h                          |  18 +++
 wpa_supplicant/events.c                       |   6 +
 4 files changed, 134 insertions(+), 14 deletions(-)
 create mode 100644 0001-wpa_supplicant-Notify-freq-change-on-CH_SWITCH.patch

diff --git a/0001-wpa_supplicant-Notify-freq-change-on-CH_SWITCH.patch b/0001-wpa_supplicant-Notify-freq-change-on-CH_SWITCH.patch
new file mode 100644
index 000000000..43a167e4c
--- /dev/null
+++ b/0001-wpa_supplicant-Notify-freq-change-on-CH_SWITCH.patch
@@ -0,0 +1,108 @@
+From d57841fd7ef1042646b1f7260d5c8df2595eb180 Mon Sep 17 00:00:00 2001
+From: Arowa Suliman <arowa at google.com>
+Date: Fri, 23 Oct 2020 13:10:29 -0700
+Subject: [PATCH] wpa_supplicant: Notify freq change on CH_SWITCH
+
+wpa_supplicant does not send a D-Bus notification of the BSS frequency
+change when a CSA happens. Sending a PropertyChanged signal with the
+updated frequency will notify the network manager quickly, instead of
+waiting for the next scan results.
+
+Signed-off-by: Arowa Suliman <arowa at chromium.org>
+Change-Id: Ic68964d505e4d97334502f1a638394bc57291be3
+---
+ wpa_supplicant/bss.c    | 16 ++--------------
+ wpa_supplicant/bss.h    | 18 ++++++++++++++++++
+ wpa_supplicant/events.c |  6 ++++++
+ 3 files changed, 26 insertions(+), 14 deletions(-)
+
+diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
+index 4f64a4981..f01b6f799 100644
+--- a/wpa_supplicant/bss.c
++++ b/wpa_supplicant/bss.c
+@@ -18,18 +18,6 @@
+ #include "scan.h"
+ #include "bss.h"
+ 
+-
+-#define WPA_BSS_FREQ_CHANGED_FLAG	BIT(0)
+-#define WPA_BSS_SIGNAL_CHANGED_FLAG	BIT(1)
+-#define WPA_BSS_PRIVACY_CHANGED_FLAG	BIT(2)
+-#define WPA_BSS_MODE_CHANGED_FLAG	BIT(3)
+-#define WPA_BSS_WPAIE_CHANGED_FLAG	BIT(4)
+-#define WPA_BSS_RSNIE_CHANGED_FLAG	BIT(5)
+-#define WPA_BSS_WPS_CHANGED_FLAG	BIT(6)
+-#define WPA_BSS_RATES_CHANGED_FLAG	BIT(7)
+-#define WPA_BSS_IES_CHANGED_FLAG	BIT(8)
+-
+-
+ static void wpa_bss_set_hessid(struct wpa_bss *bss)
+ {
+ #ifdef CONFIG_INTERWORKING
+@@ -497,8 +485,8 @@ static u32 wpa_bss_compare_res(const struct wpa_bss *old,
+ }
+ 
+ 
+-static void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
+-			       const struct wpa_bss *bss)
++void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
++			const struct wpa_bss *bss)
+ {
+ 	if (changes & WPA_BSS_FREQ_CHANGED_FLAG)
+ 		wpas_notify_bss_freq_changed(wpa_s, bss->id);
+diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h
+index b4942272e..f372e5e56 100644
+--- a/wpa_supplicant/bss.h
++++ b/wpa_supplicant/bss.h
+@@ -19,6 +19,22 @@ struct wpa_scan_res;
+ #define WPA_BSS_ASSOCIATED		BIT(5)
+ #define WPA_BSS_ANQP_FETCH_TRIED	BIT(6)
+ 
++#define WPA_BSS_FREQ_CHANGED_FLAG BIT(0)
++#define WPA_BSS_SIGNAL_CHANGED_FLAG BIT(1)
++#define WPA_BSS_PRIVACY_CHANGED_FLAG BIT(2)
++#define WPA_BSS_MODE_CHANGED_FLAG BIT(3)
++#define WPA_BSS_WPAIE_CHANGED_FLAG BIT(4)
++#define WPA_BSS_RSNIE_CHANGED_FLAG BIT(5)
++#define WPA_BSS_WPS_CHANGED_FLAG BIT(6)
++#define WPA_BSS_RATES_CHANGED_FLAG BIT(7)
++#define WPA_BSS_IES_CHANGED_FLAG BIT(8)
++
++struct wpa_bss_anqp_elem {
++	struct dl_list list;
++	u16 infoid;
++	struct wpabuf *payload;
++};
++
+ /**
+  * struct wpa_bss_anqp - ANQP data for a BSS entry (struct wpa_bss)
+  */
+@@ -102,6 +118,8 @@ struct wpa_bss {
+ 	/* followed by beacon_ie_len octets of IEs */
+ };
+ 
++void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
++			const struct wpa_bss *bss);
+ void wpa_bss_update_start(struct wpa_supplicant *wpa_s);
+ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
+ 			     struct wpa_scan_res *res,
+diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
+index d7e769331..009222e10 100644
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -3573,6 +3573,12 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+ 
+ 		wpa_s->assoc_freq = data->ch_switch.freq;
+ 		wpa_s->current_ssid->frequency = data->ch_switch.freq;
++		if (wpa_s->current_bss &&
++		    wpa_s->current_bss->freq != data->ch_switch.freq) {
++			wpa_s->current_bss->freq = data->ch_switch.freq;
++			notify_bss_changes(wpa_s, WPA_BSS_FREQ_CHANGED_FLAG,
++					   wpa_s->current_bss);
++		}
+ 
+ 		if (wpa_s->current_ssid->mode == WPAS_MODE_AP ||
+ 		    wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO ||
+-- 
+2.29.1.341.ge80a0c044ae-goog
+
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index 4f64a4981..f01b6f799 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -18,18 +18,6 @@
 #include "scan.h"
 #include "bss.h"
 
-
-#define WPA_BSS_FREQ_CHANGED_FLAG	BIT(0)
-#define WPA_BSS_SIGNAL_CHANGED_FLAG	BIT(1)
-#define WPA_BSS_PRIVACY_CHANGED_FLAG	BIT(2)
-#define WPA_BSS_MODE_CHANGED_FLAG	BIT(3)
-#define WPA_BSS_WPAIE_CHANGED_FLAG	BIT(4)
-#define WPA_BSS_RSNIE_CHANGED_FLAG	BIT(5)
-#define WPA_BSS_WPS_CHANGED_FLAG	BIT(6)
-#define WPA_BSS_RATES_CHANGED_FLAG	BIT(7)
-#define WPA_BSS_IES_CHANGED_FLAG	BIT(8)
-
-
 static void wpa_bss_set_hessid(struct wpa_bss *bss)
 {
 #ifdef CONFIG_INTERWORKING
@@ -497,8 +485,8 @@ static u32 wpa_bss_compare_res(const struct wpa_bss *old,
 }
 
 
-static void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
-			       const struct wpa_bss *bss)
+void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
+			const struct wpa_bss *bss)
 {
 	if (changes & WPA_BSS_FREQ_CHANGED_FLAG)
 		wpas_notify_bss_freq_changed(wpa_s, bss->id);
diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h
index b4942272e..f372e5e56 100644
--- a/wpa_supplicant/bss.h
+++ b/wpa_supplicant/bss.h
@@ -19,6 +19,22 @@ struct wpa_scan_res;
 #define WPA_BSS_ASSOCIATED		BIT(5)
 #define WPA_BSS_ANQP_FETCH_TRIED	BIT(6)
 
+#define WPA_BSS_FREQ_CHANGED_FLAG BIT(0)
+#define WPA_BSS_SIGNAL_CHANGED_FLAG BIT(1)
+#define WPA_BSS_PRIVACY_CHANGED_FLAG BIT(2)
+#define WPA_BSS_MODE_CHANGED_FLAG BIT(3)
+#define WPA_BSS_WPAIE_CHANGED_FLAG BIT(4)
+#define WPA_BSS_RSNIE_CHANGED_FLAG BIT(5)
+#define WPA_BSS_WPS_CHANGED_FLAG BIT(6)
+#define WPA_BSS_RATES_CHANGED_FLAG BIT(7)
+#define WPA_BSS_IES_CHANGED_FLAG BIT(8)
+
+struct wpa_bss_anqp_elem {
+	struct dl_list list;
+	u16 infoid;
+	struct wpabuf *payload;
+};
+
 /**
  * struct wpa_bss_anqp - ANQP data for a BSS entry (struct wpa_bss)
  */
@@ -102,6 +118,8 @@ struct wpa_bss {
 	/* followed by beacon_ie_len octets of IEs */
 };
 
+void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
+			const struct wpa_bss *bss);
 void wpa_bss_update_start(struct wpa_supplicant *wpa_s);
 void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
 			     struct wpa_scan_res *res,
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index d7e769331..009222e10 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3573,6 +3573,12 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 
 		wpa_s->assoc_freq = data->ch_switch.freq;
 		wpa_s->current_ssid->frequency = data->ch_switch.freq;
+		if (wpa_s->current_bss &&
+		    wpa_s->current_bss->freq != data->ch_switch.freq) {
+			wpa_s->current_bss->freq = data->ch_switch.freq;
+			notify_bss_changes(wpa_s, WPA_BSS_FREQ_CHANGED_FLAG,
+					   wpa_s->current_bss);
+		}
 
 		if (wpa_s->current_ssid->mode == WPAS_MODE_AP ||
 		    wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO ||
-- 
2.29.1.341.ge80a0c044ae-goog




More information about the Hostap mailing list