]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add a configuration to disconnect on deinit if WoWLAN is enabled
authorSunil Dutt <usdutt@codeaurora.org>
Tue, 19 Jan 2021 13:00:32 +0000 (18:30 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 21 Jan 2021 16:21:30 +0000 (18:21 +0200)
Commit 02c21c02d09f ("wpa_supplicant: Do not disconnect on deinit if
WoWLAN is enabled") prevents the disconnection on deinit if the driver
indicates that WoWLAN is enabled. This is not the expected behavior in
some earlier use cases where the wpa_supplicant process is left running
when going to sleep and killing of the wpa_supplicant process is used
only when there is an expectation of Wi-Fi connection being disabled.

To support the use cases which require the WLAN to disconnect on deinit
even if WoWLAN is enabled, introduce a configuration parameter
wowlan_disconnect_on_deinit. This is set to 0 by default thereby not
impacting the functionality in the above mentioned commit. Setting it to
1 restores the old behavior before the commit identified above.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/wpa_supplicant.c

index 0aa92a28c7f1ca3873f0f1d8201bcd47e00e06f6..4c1e422602a9c3d873f672da066f4e85aaeccc59 100644 (file)
@@ -5148,6 +5148,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(wowlan_disconnect_on_deinit, 0, 1), 0},
 };
 
 #undef FUNC
index d128cd9bf1db5e83db8cb866bbbb835f1f77acb2..611b9931896f56728ebb6ad7a3d31852d5850c32 100644 (file)
@@ -1599,6 +1599,15 @@ struct wpa_config {
         * 1 = use Extended Key ID when possible
         */
        int extended_key_id;
+
+       /**
+        * wowlan_disconnect_on_deinit - Trigger disconnect on wpa_supplicant
+        * interface deinit even if the driver has enabled WoWLAN.
+        *
+        * 0 = Do not disconnect
+        * 1 = Trigger disconnection
+        */
+       int wowlan_disconnect_on_deinit;
 };
 
 
index cb04a78a21fc9eae805adaa1672d039fdb1a72e4..9ddd9ecfdc2c7ae7751c5421af6831ef0119bed7 100644 (file)
@@ -1620,6 +1620,9 @@ 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->wowlan_disconnect_on_deinit)
+               fprintf(f, "wowlan_disconnect_on_deinit=%d\n",
+                       config->wowlan_disconnect_on_deinit);
 }
 
 #endif /* CONFIG_NO_CONFIG_WRITE */
index c3e747260ffe7ea4e5f3a4bebe63e256b7b6cb95..9f474fd0d8516ce0732f315c100263994b19ec29 100644 (file)
@@ -6669,8 +6669,12 @@ 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 enable and not explicitly
+                * been configured to disconnect.
+                */
+               if (!wpa_drv_get_wowlan(wpa_s) ||
+                   wpa_s->conf->wowlan_disconnect_on_deinit) {
                        wpa_supplicant_deauthenticate(
                                wpa_s, WLAN_REASON_DEAUTH_LEAVING);