linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: mac80211: warn on insufficient antennas for injected HT frames
@ 2025-07-14  9:44 WangYuli
  2025-07-14  9:47 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: WangYuli @ 2025-07-14  9:44 UTC (permalink / raw)
  To: johannes
  Cc: linux-wireless, linux-kernel, zhanjun, niecheng1, guanwentao,
	WangYuli

When injecting frames via radiotap, an HT MCS rate can be specified.
The number of chains for that MCS implies a minimum number of
antennas that must be enabled in the antenna bitmap. Previously,
if the antenna bitmap specified fewer antennas than required by the
MCS, the bitmap was silently cleared. This makes it hard to debug
issues with injected frames.

Add a WARN_ONCE() to log a descriptive error when this happens, make
it clear that the antenna configuration was insufficient and has
been reset.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 net/mac80211/tx.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index d58b80813bdd..e1464ef7397d 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2251,14 +2251,21 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
 		if (rate_flags & IEEE80211_TX_RC_MCS) {
 			/* reset antennas if not enough */
 			if (IEEE80211_HT_MCS_CHAINS(rate) >
-					hweight8(info->control.antennas))
+					hweight8(info->control.antennas)) {
+				WARN_ONCE(1, "Not enough antennas set for HT MCS chains (required: %d, set: %d), resetting antennas bitmap to 0\n",
+					  IEEE80211_HT_MCS_CHAINS(rate),
+					  hweight8(info->control.antennas));
 				info->control.antennas = 0;
+			}
 
 			info->control.rates[0].idx = rate;
 		} else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) {
 			/* reset antennas if not enough */
-			if (vht_nss > hweight8(info->control.antennas))
+			if (vht_nss > hweight8(info->control.antennas)) {
+				WARN_ONCE(1, "Not enough antennas set for VHT MCS chains (required: %d, set: %d), resetting antennas bitmap to 0\n",
+					  vht_nss, hweight8(info->control.antennas));
 				info->control.antennas = 0;
+			}
 
 			ieee80211_rate_set_vht(info->control.rates, vht_mcs,
 					       vht_nss);
-- 
2.50.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] wifi: mac80211: warn on insufficient antennas for injected HT frames
  2025-07-14  9:44 [PATCH] wifi: mac80211: warn on insufficient antennas for injected HT frames WangYuli
@ 2025-07-14  9:47 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2025-07-14  9:47 UTC (permalink / raw)
  To: WangYuli; +Cc: linux-wireless, linux-kernel, zhanjun, niecheng1, guanwentao

On Mon, 2025-07-14 at 17:44 +0800, WangYuli wrote:
> When injecting frames via radiotap, an HT MCS rate can be specified.
> The number of chains for that MCS implies a minimum number of
> antennas that must be enabled in the antenna bitmap. Previously,
> if the antenna bitmap specified fewer antennas than required by the
> MCS, the bitmap was silently cleared. This makes it hard to debug
> issues with injected frames.
> 
> Add a WARN_ONCE() to log a descriptive error when this happens, make
> it clear that the antenna configuration was insufficient and has
> been reset.
> 

No. We shouldn't WARN on userspace misbehaviour.

johannes

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-14  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14  9:44 [PATCH] wifi: mac80211: warn on insufficient antennas for injected HT frames WangYuli
2025-07-14  9:47 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).