diff mbox series

[v2] wpa_supplicant: Should disconnect on deinit whatever WOWLAN is enable or disable

Message ID 20201207061754.16796-1-zhao.chen@mediatek.com
State Superseded
Headers show
Series [v2] wpa_supplicant: Should disconnect on deinit whatever WOWLAN is enable or disable | expand

Commit Message

Zhao Chen Dec. 7, 2020, 6:17 a.m. UTC
Add new configuration option send_deauth_when_down to control whether need send deauth to kernel when 
wifi interface down, this variable control whether wpa_supplicant send deauth to kernel when terminate to
sync disconnect status with kernel.
0 = Not need to send deauth when down, assume the device will be power off(Default)
1 = Need to send deauth to sync disconnect status with kernel to avoid potential unsync
problem when restart wifi

Change-Id: I0974d08fe7d381097a9633af0441fb9e9f184f7e
Signed-off-by: Zhao Chen <zhao.chen@mediatek.com>
---
 wpa_supplicant/config.c         |  1 +
 wpa_supplicant/config.h         | 10 ++++++++++
 wpa_supplicant/config_file.c    |  2 ++
 wpa_supplicant/wpa_supplicant.c |  4 ++--
 4 files changed, 15 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Feb. 6, 2021, 2:44 p.m. UTC | #1
On Mon, Dec 07, 2020 at 02:17:54PM +0800, Zhao Chen wrote:
> Add new configuration option send_deauth_when_down to control whether need send deauth to kernel when 
> wifi interface down, this variable control whether wpa_supplicant send deauth to kernel when terminate to
> sync disconnect status with kernel.
> 0 = Not need to send deauth when down, assume the device will be power off(Default)
> 1 = Need to send deauth to sync disconnect status with kernel to avoid potential unsync
> problem when restart wifi

Sorry, I somehow missed this one when going through another patch that
does practically the same thing with a different name for that
configuration parameter:
https://w1.fi/cgit/hostap/commit/?id=62657365f896108da7bb22d6b0a767337a9624f1
diff mbox series

Patch

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index e1d9824..4697bf6 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -5065,6 +5065,7 @@  static const struct global_parse_data global_fields[] = {
 	{ INT_RANGE(disable_btm, 0, 1), CFG_CHANGED_DISABLE_BTM },
 	{ INT_RANGE(extended_key_id, 0, 1), 0 },
 #endif /* CONFIG_WNM */
+    { INT_RANGE(send_deauth_when_down, 0, 1), 0 },
 };
 
 #undef FUNC
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 0ca27cb..58e09de 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -1590,6 +1590,16 @@  struct wpa_config {
 	 * 1 = use Extended Key ID when possible
 	 */
 	int extended_key_id;
+    /**
+	 * send_deauth_when_down - Whether need to force deauth when terminate
+	 *
+	 * This variable control whether wpa_supplicant send deauth to kernel when terminate to
+	 * sync disconnect status with kernel.
+	 * 0 = Not need to send deauth when down, assume the device will be power off(Default)
+	 * 1 = Need to send deauth to sync disconnect status with kernel to avoid potential unsync
+	 * problem when restart wifi
+	 */
+	int send_deauth_when_down;
 };
 
 
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 52e1372..e25dc59 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -1607,6 +1607,8 @@  static void wpa_config_write_global(FILE *f, struct wpa_config *config)
 	if (config->extended_key_id != DEFAULT_EXTENDED_KEY_ID)
 		fprintf(f, "extended_key_id=%d\n",
 			config->extended_key_id);
+	if (config->send_deauth_when_down)
+	    fprintf(f, "send_deauth_when_down=1\n");
 }
 
 #endif /* CONFIG_NO_CONFIG_WRITE */
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index ea62e59..da92f80 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -6479,8 +6479,8 @@  static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
 
 	wpa_s->disconnected = 1;
 	if (wpa_s->drv_priv) {
-		/* Don't deauthenticate if WoWLAN is enabled */
-		if (!wpa_drv_get_wowlan(wpa_s)) {
+		/* Don't deauthenticate if WoWLAN is enabled and not need to send deauth */
+		if (wpa_s->conf->send_deauth_when_down || !wpa_drv_get_wowlan(wpa_s)) {
 			wpa_supplicant_deauthenticate(
 				wpa_s, WLAN_REASON_DEAUTH_LEAVING);