For a copy made by cfg80211_beacon_dup(), such as during a channel switch, the *_oper pointers are not copied over, even though the tail is. Therefore, ieee80211_calc_ap_he_and_lower() finds no operation element and returns 20 MHz, which is inaccurate. It stays there until the next beacon is received, then it is parsed again and corrected. Driver's own rate control or minstrel_ht can run between updates, so it started over at 20 MHz and again at 80 MHz. Point the four pointers of the copy at the same offsets in the copy's tail. Fixes: c9b62ab79133 ("wifi: mac80211: fix per-station PHY capability bandwidth") Fixes: 14b1a85518a1 ("wifi: mac80211: AP: handle DBE for clients") Signed-off-by: Ho Jie Feng --- net/mac80211/cfg.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 9d7c03b6a6..34e5f1764b 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -4601,6 +4602,17 @@ static void ieee80211_end_cac(struct wiphy *wiphy, } } +static const void * +ieee80211_beacon_dup_tail_elem(const struct cfg80211_beacon_data *beacon, + const struct cfg80211_beacon_data *new_beacon, + const void *elem) +{ + const u8 *pos = elem; + + /* nl80211 guarantees it is a valid offset into the source tail */ + return PTR_IF(pos, new_beacon->tail + (pos - beacon->tail)); +} + static struct cfg80211_beacon_data * cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) { @@ -4654,6 +4666,19 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) new_beacon->tail = pos; memcpy(pos, beacon->tail, beacon->tail_len); pos += beacon->tail_len; + + new_beacon->ht_oper = + ieee80211_beacon_dup_tail_elem(beacon, new_beacon, + beacon->ht_oper); + new_beacon->vht_oper = + ieee80211_beacon_dup_tail_elem(beacon, new_beacon, + beacon->vht_oper); + new_beacon->he_oper = + ieee80211_beacon_dup_tail_elem(beacon, new_beacon, + beacon->he_oper); + new_beacon->eht_oper = + ieee80211_beacon_dup_tail_elem(beacon, new_beacon, + beacon->eht_oper); } if (beacon->beacon_ies_len) { new_beacon->beacon_ies_len = beacon->beacon_ies_len; -- 2.53.0