[openwrt/openwrt] mt76: backport fix encap offload ethernet type check

LEDE Commits lede-commits at lists.infradead.org
Sat Aug 27 23:34:32 PDT 2022


ynezz pushed a commit to openwrt/openwrt.git, branch openwrt-21.02:
https://git.openwrt.org/4cb9d08e71a8d4d4f148f29fcbe8554f0815a056

commit 4cb9d08e71a8d4d4f148f29fcbe8554f0815a056
Author: Thibaut VARÈNE <hacks at slashdirt.org>
AuthorDate: Wed Apr 20 17:57:47 2022 +0200

    mt76: backport fix encap offload ethernet type check
    
    The driver needs to check if the format is 802.2 vs 802.3 in order to
    set a tx descriptor flag. skb->protocol can't be used, since it may not
    be properly initialized for packets coming in from a packet socket.  Fix
    misdetection by checking the ethertype from the skb data instead.
    
    Signed-off-by: Thibaut VARÈNE <hacks at slashdirt.org>
    Signed-off-by: Petr Štetiar <ynezz at true.cz> [commit description]
---
 ...101-fix-encap-offload-ethernet-type-check.patch | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/package/kernel/mt76/patches/101-fix-encap-offload-ethernet-type-check.patch b/package/kernel/mt76/patches/101-fix-encap-offload-ethernet-type-check.patch
new file mode 100644
index 0000000000..d81aa4dfa3
--- /dev/null
+++ b/package/kernel/mt76/patches/101-fix-encap-offload-ethernet-type-check.patch
@@ -0,0 +1,63 @@
+From: Felix Fietkau <nbd at nbd.name>
+To: linux-wireless at vger.kernel.org
+Cc: =?utf-8?q?Thibaut_VAR=C3=88NE?= <hacks+kernel at slashdirt.org>
+Subject: [PATCH] mt76: fix encap offload ethernet type check
+Date: Wed, 20 Apr 2022 14:33:08 +0200
+Message-Id: <20220420123308.70104-1-nbd at nbd.name>
+
+The driver needs to check if the format is 802.2 vs 802.3 in order to set
+a tx descriptor flag. skb->protocol can't be used, since it may not be properly
+initialized for packets coming in from a packet socket.
+Fix misdetection by checking the ethertype from the skb data instead
+
+Reported-by: Thibaut VARÈNE <hacks+kernel at slashdirt.org>
+Signed-off-by: Felix Fietkau <nbd at nbd.name>
+---
+ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +++-
+ drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 4 +++-
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+index 5f4a0e811137..e353e8c44d6c 100644
+--- a/mt7915/mac.c
++++ b/mt7915/mac.c
+@@ -1016,6 +1016,7 @@ mt7915_mac_write_txwi_8023(struct mt7915_dev *dev, __le32 *txwi,
+ 
+ 	u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
+ 	u8 fc_type, fc_stype;
++	u16 ethertype;
+ 	bool wmm = false;
+ 	u32 val;
+ 
+@@ -1029,7 +1030,8 @@ mt7915_mac_write_txwi_8023(struct mt7915_dev *dev, __le32 *txwi,
+ 	val = FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_802_3) |
+ 	      FIELD_PREP(MT_TXD1_TID, tid);
+ 
+-	if (be16_to_cpu(skb->protocol) >= ETH_P_802_3_MIN)
++	ethertype = get_unaligned_be16(&skb->data[12]);
++	if (ethertype >= ETH_P_802_3_MIN)
+ 		val |= MT_TXD1_ETH_802_3;
+ 
+ 	txwi[1] |= cpu_to_le32(val);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+index 368e54c53ddd..ac11e8b28f13 100644
+--- a/mt7921/mac.c
++++ b/mt7921/mac.c
+@@ -814,6 +814,7 @@ mt7921_mac_write_txwi_8023(struct mt7921_dev *dev, __le32 *txwi,
+ {
+ 	u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
+ 	u8 fc_type, fc_stype;
++	u16 ethertype;
+ 	bool wmm = false;
+ 	u32 val;
+ 
+@@ -827,7 +828,8 @@ mt7921_mac_write_txwi_8023(struct mt7921_dev *dev, __le32 *txwi,
+ 	val = FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_802_3) |
+ 	      FIELD_PREP(MT_TXD1_TID, tid);
+ 
+-	if (be16_to_cpu(skb->protocol) >= ETH_P_802_3_MIN)
++	ethertype = get_unaligned_be16(&skb->data[12]);
++	if (ethertype >= ETH_P_802_3_MIN)
+ 		val |= MT_TXD1_ETH_802_3;
+ 
+ 	txwi[1] |= cpu_to_le32(val);




More information about the lede-commits mailing list