git: 61c5d5679ba8 - releng/14.0 - net80211: introduce two extra ieee80211_notify_scan_done()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 09 Oct 2023 23:16:08 UTC
The branch releng/14.0 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=61c5d5679ba8e9075f3486a08eb0bdfd507d1108

commit 61c5d5679ba8e9075f3486a08eb0bdfd507d1108
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-09-21 11:51:23 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-10-09 23:14:52 +0000

    net80211: introduce two extra ieee80211_notify_scan_done()
    
    We have multiple problems with scanning currently, one being that
    an initial scan restarts itself and we are unable to start another
    scan.  wpa_supplicant in that case never shows scan results.
    Starting wpa_cli you may see: <3>CTRL-EVENT-SCAN-FAILED ret=-1 retry=1
    messages.
    Add two extra calls to ieee80211_notify_scan_done() at the end of scans
    (before possible restarts).  That will get wpa_supplicant to get
    scan results and possibly start associating to a BSSID and get us out
    of scan.  This is kind-of a bandaid but on short notice may help to
    improve the situation for some.
    
    Based on analysis by:   enweiwu
    Submitted by:           enweiwu (initial version)
    Sponsored by:           The FreeBSD Foundation
    Approved by:            re (gjb)
    Tested by:              cy, (others I cannot find email/PR for anymore)
    Reviewed by:            cy
    Differential Revision: https://reviews.freebsd.org/D38661
    
    (cherry picked from commit 3f382eb23b9fee75d05276a44feb5351d956238e)
    (cherry picked from commit 6104a9f9c5206c9ba23eec29217dff642f26722c)
---
 sys/net80211/ieee80211_scan_sw.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/net80211/ieee80211_scan_sw.c b/sys/net80211/ieee80211_scan_sw.c
index ac97b7c14cbc..744c8f6bf28e 100644
--- a/sys/net80211/ieee80211_scan_sw.c
+++ b/sys/net80211/ieee80211_scan_sw.c
@@ -388,9 +388,10 @@ ieee80211_swscan_bg_scan(const struct ieee80211_scanner *scan,
 				 *     scan_start method to populate it.
 				 */
 				ss->ss_next = 0;
-				if (ss->ss_last != 0)
+				if (ss->ss_last != 0) {
+					ieee80211_notify_scan_done(vap);
 					ss->ss_ops->scan_restart(ss, vap);
-				else {
+				} else {
 					ss->ss_ops->scan_start(ss, vap);
 #ifdef IEEE80211_DEBUG
 					if (ieee80211_msg_scan(vap))
@@ -857,6 +858,7 @@ scan_end(struct ieee80211_scan_state *ss, int scandone)
 		else
 			vap->iv_stats.is_scan_passive++;
 
+		ieee80211_notify_scan_done(vap);
 		ss->ss_ops->scan_restart(ss, vap);	/* XXX? */
 		ieee80211_runtask(ic, &ss_priv->ss_scan_start);
 		IEEE80211_UNLOCK(ic);