[PATCH v2] wpa_supplicant: Should disconnect on deinit whatever WOWLAN is enable or disable
Zhao Chen
zhao.chen at mediatek.com
Mon Dec 7 01:17:54 EST 2020
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 at 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(-)
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);
--
1.9.1
More information about the Hostap
mailing list