Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jan 2023 16:24:57 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 931d322d4082 - stable/13 - LinuxKPI: 802.11: implement ieee80211_get_hdrlen_from_skb()
Message-ID:  <202301181624.30IGOvrR038113@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=931d322d40822180237329cef442278eb078b370

commit 931d322d40822180237329cef442278eb078b370
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-12-31 02:02:01 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-01-18 13:26:02 +0000

    LinuxKPI: 802.11: implement ieee80211_get_hdrlen_from_skb()
    
    Implement ieee80211_get_hdrlen_from_skb() doing basic sanity checks
    on lengths (minimal length or skb data length vs. header length).
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 339119949660916aa40b1d67dbe002dd7eb0d709)
---
 sys/compat/linuxkpi/common/include/net/cfg80211.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index 8d69ff0891d9..b5135f34981e 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -1666,12 +1666,23 @@ ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq)
 	return (linuxkpi_ieee80211_get_channel(wiphy, freq));
 }
 
-static __inline size_t
+static inline size_t
 ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
 {
+	const struct ieee80211_hdr *hdr;
+	size_t len;
 
-	TODO();
-	return (-1);
+	if (skb->len < 10)	/* sizeof(ieee80211_frame_[ack,cts]) */
+		return (0);
+
+	hdr = (const struct ieee80211_hdr *)skb->data;
+	len = ieee80211_hdrlen(hdr->frame_control);
+
+	/* If larger than what is in the skb return. */
+	if (len > skb->len)
+		return (0);
+
+	return (len);
 }
 
 static __inline bool



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202301181624.30IGOvrR038113>