Add a configuration to disconnect on deinit if WoWLAN is enabled

Commit 02c21c02d0 ("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>
This commit is contained in:
Sunil Dutt 2021-01-19 18:30:32 +05:30 committed by Jouni Malinen
parent f34493f2a8
commit 62657365f8
4 changed files with 19 additions and 2 deletions

View 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

View 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;
};

View 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 */

View 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);