mac80211: Prevent AP probing during suspend

Submitting AP probe/null during suspend can cause unexpected
disconnect on resume because of timeout waiting for ack status:

wlan0: Failed to send nullfunc to AP 11:22:33:44:55:66 after 500ms, disconnecting

This is especially the case when we enter suspend when a scan is
ongoing, indeed, scan is cancelled from __ieee80211_suspend, leading
to a corresponding (aborted) scan complete event, which in turn causes
the submission of an immediate monitor null frame (restart_sta_timer).
The corresponding packet or ack will not be processed before resuming,
causing a timeout & disconnect on resume.

Delay the AP probing when suspending/suspended.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Link: https://lore.kernel.org/r/1634805927-1113-1-git-send-email-loic.poulain@linaro.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Loic Poulain 2021-10-21 10:45:27 +02:00 committed by Johannes Berg
parent 63fa042666
commit b33fb28c86
3 changed files with 14 additions and 0 deletions

View File

@ -1241,6 +1241,9 @@ struct ieee80211_local {
*/ */
bool suspended; bool suspended;
/* suspending is true during the whole suspend process */
bool suspending;
/* /*
* Resuming is true while suspended, but when we're reprogramming the * Resuming is true while suspended, but when we're reprogramming the
* hardware -- at that time it's allowed to use ieee80211_queue_work() * hardware -- at that time it's allowed to use ieee80211_queue_work()

View File

@ -2589,6 +2589,13 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata,
goto out; goto out;
} }
if (sdata->local->suspending) {
/* reschedule after resume */
mutex_unlock(&sdata->local->mtx);
ieee80211_reset_ap_probe(sdata);
goto out;
}
if (beacon) { if (beacon) {
mlme_dbg_ratelimited(sdata, mlme_dbg_ratelimited(sdata,
"detected beacon loss from AP (missed %d beacons) - probing\n", "detected beacon loss from AP (missed %d beacons) - probing\n",

View File

@ -27,6 +27,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
if (!local->open_count) if (!local->open_count)
goto suspend; goto suspend;
local->suspending = true;
mb(); /* make suspending visible before any cancellation */
ieee80211_scan_cancel(local); ieee80211_scan_cancel(local);
ieee80211_dfs_cac_cancel(local); ieee80211_dfs_cac_cancel(local);
@ -176,6 +179,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
/* need suspended to be visible before quiescing is false */ /* need suspended to be visible before quiescing is false */
barrier(); barrier();
local->quiescing = false; local->quiescing = false;
local->suspending = false;
return 0; return 0;
} }