Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: mac80211: copy the operation elements in cfg80211_beacon_dup()
@ 2026-11-29 16:48 Ho Jie Feng
  0 siblings, 0 replies; only message in thread
From: Ho Jie Feng @ 2026-11-29 16:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Ho Jie Feng

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 <hjf3108@gmail.com>
---
 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 <linux/nl80211.h>
 #include <linux/rtnetlink.h>
 #include <linux/slab.h>
+#include <linux/util_macros.h>
 #include <net/net_namespace.h>
 #include <linux/rcupdate.h>
 #include <linux/fips.h>
@@ -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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-29 16:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 16:48 [PATCH wireless] wifi: mac80211: copy the operation elements in cfg80211_beacon_dup() Ho Jie Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox