diff mbox series

wifi: mac80211: support ieee80211_ext format

Message ID 20230419042009.1058020-1-gilad.itzkovitch@morsemicro.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series wifi: mac80211: support ieee80211_ext format | expand

Commit Message

Gilad Itzkovitch April 19, 2023, 4:20 a.m. UTC
From: Kieran Frewen <kieran.frewen@morsemicro.com>

Ensure S1G beacons use the new ieee80211_ext format when required.

Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
Co-developed-by: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
Signed-off-by: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
---
 net/mac80211/rx.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)


base-commit: 9ae708f00161e1d789268fa9cc05bf6bec2af474

Comments

Johannes Berg Sept. 13, 2023, 11:33 a.m. UTC | #1
Going through all the old patches ...


> +	const u8 *addr;
> +
> +	if (ieee80211_is_s1g_beacon(hdr->frame_control)) {
> +		struct ieee80211_ext *ext_hdr = (struct ieee80211_ext *)skb->data;

nit: can just use void * cast.

for reference below:

> +		addr = ext_hdr->u.s1g_beacon.sa;


> -	if (ieee80211_is_mgmt(fc)) {
> +	if (ieee80211_is_mgmt(fc) || ieee80211_is_ext(fc)) {
>  		/* drop frame if too short for header */
>  		if (skb->len < ieee80211_hdrlen(fc))
> 

I don't understand the addition of this check in this patch.

ieee80211_hdrlen() just ensures that you have _four_ bytes header for an
ext frame. So maybe that makes sense on its own, but above you're
casting to struct ieee80211_ext * and then using the u.s1g_beacon thing,
so you need to ensure many more bytes are present _somewhere_?

johannes
diff mbox series

Patch

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index db3451f5f2fb..74027486a6b9 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -5048,6 +5048,15 @@  static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,
 	struct ieee80211_hdr *hdr = (void *)skb->data;
 	struct sta_info *sta;
 	int link_id = -1;
+	const u8 *addr;
+
+	if (ieee80211_is_s1g_beacon(hdr->frame_control)) {
+		struct ieee80211_ext *ext_hdr = (struct ieee80211_ext *)skb->data;
+
+		addr = ext_hdr->u.s1g_beacon.sa;
+	} else {
+		addr = hdr->addr2;
+	}
 
 	/*
 	 * Look up link station first, in case there's a
@@ -5055,14 +5064,14 @@  static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,
 	 * is identical to the MLD address, that way we'll
 	 * have the link information if needed.
 	 */
-	link_sta = link_sta_info_get_bss(rx->sdata, hdr->addr2);
+	link_sta = link_sta_info_get_bss(rx->sdata, addr);
 	if (link_sta) {
 		sta = link_sta->sta;
 		link_id = link_sta->link_id;
 	} else {
 		struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
 
-		sta = sta_info_get_bss(rx->sdata, hdr->addr2);
+		sta = sta_info_get_bss(rx->sdata, addr);
 		if (status->link_valid)
 			link_id = status->link_id;
 	}
@@ -5102,7 +5111,7 @@  static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
 	if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc))
 		I802_DEBUG_INC(local->dot11ReceivedFragmentCount);
 
-	if (ieee80211_is_mgmt(fc)) {
+	if (ieee80211_is_mgmt(fc) || ieee80211_is_ext(fc)) {
 		/* drop frame if too short for header */
 		if (skb->len < ieee80211_hdrlen(fc))
 			err = -ENOBUFS;