wifi: mac80211: replace the CSA beacon before clearing csa_active
PATCH 1/1 wifi: mac80211: replace the CSA beacon before clearing csa_active
From: Mehmet Fide <[email protected]>
__ieee80211_csa_finalize() clears csa_active and only then replaces the CSA beacon with the one for after the switch. A driver that fetches its beacons with ieee80211_beacon_get() and skips them once the countdown is complete, as ath9k does in ath9k_csa_is_finished(), tests csa_active first. A beacon fetched between the two steps passes that test and gets the CSA beacon again, which goes out on the new channel, and ieee80211_beacon_get() reports "beacon TX faster than countdown".
Replace the beacon first, as the finalize work did before the clear was moved ahead of it. csa_active is still cleared when replacing the beacon fails.
---
Notes:
Tested on rtw-next on an i.MX8MP board with an AR9271 as AP, ath9k_htc with "wifi: ath9k_htc: do not fetch the beacon of a finished countdown" v2 (link below), hostapd switching between channel 1 and 6, one sniffer on each channel counting CSA beacons heard on the new channel. Before:
3 in 200 switches with a count of 5, and a print in the driver showed 3 fetches between the two steps. After: none in 200 switches with a count of 5 and 80 with a count of 2. With v1 of that driver patch, back-to-back switches and AP stops in and out of a countdown gave no warning from mac80211. The rtw88 AP channel switch under review (RTL8822BU, RTL8822CE) counts down on the air as before.
https://lore.kernel.org/r/[email protected]/
net/mac80211/cfg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/mac80211/cfg.c +1 -2
@@ -4776,9 +4776,8 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data) &link_data->csa.chanreq.oper))return -EINVAL ; - link_conf->csa_active = false; - err =ieee80211_set_after_csa_beacon (link_data, &changed); + link_conf->csa_active = false;if (err)return err;
base-commit: 5dbf2415ca9821a611d09308e3b29d2c37e7cd77
Signature · 1 line
2.56.0
Johannes Berg
maintainerQuoted 10 lines · Mehmet Fide
From: Mehmet Fide <[email protected]>
__ieee80211_csa_finalize()clearscsa_activeand only then replaces the CSA beacon with the one for after the switch. A driver that fetches its beacons withieee80211_beacon_get()and skips them once the countdown is complete, as ath9k does inath9k_csa_is_finished(), testscsa_activefirst. A beacon fetched between the two steps passes that test and gets the CSA beacon again, which goes out on the new channel, andieee80211_beacon_get()reports "beacon TX faster than countdown".
Quoted 5 lines
Replace the beacon first, as the finalize work did before the clear was moved ahead of it.
csa_activeis still cleared when replacing the beacon fails.Fixes e487eaeb076a ("cfg80211/mac80211/ath6kl: acquire wdev lock outside ch_switch_notify")
I don't see why it would be that?? Please explain that.
johannes
Signature · 1 line
pw-bot: cr
Hi Johannes,
Quoted 3 lines
Quoted 1 line
Fixes e487eaeb076a ("cfg80211/mac80211/ath6kl: acquire wdev lock outside ch_switch_notify")I don't see why it would be that?? Please explain that.
That commit is where the clear moved ahead of the beacon replacement. Before it, ieee80211_csa_finalize_work() assigned next_beacon first and cleared csa_active only after the switch statement. e487eaeb076a added the "goto unlock" error paths and moved the clear up, just before the switch, so ieee80211_assign_beacon() now runs with csa_active already false. 66199506fb91 ("mac80211: split CSA finalize function") and 1a96bb4e8a79 ("wifi: mac80211: start and finalize channel switch on link basis") kept that order.
ath9k already tested csa_active before the countdown since d074e8d54785 ("ath9k: enable CSA functionality in ath9k"), so the window opened for it with e487eaeb076a.
Mehmet