]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mt76: fix encap offload ethernet type check
authorFelix Fietkau <nbd@nbd.name>
Wed, 20 Apr 2022 12:29:00 +0000 (14:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:29:43 +0000 (10:29 +0200)
[ Upstream commit bc98e7fdd80d215b4b55eea001023231eb8ce12e ]

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@slashdirt.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7915/mac.c
drivers/net/wireless/mediatek/mt76/mt7921/mac.c

index a8df65cc115f39c2a8e3671ac2253c31db815512..eaa31f5e0b00ca386434edc205ae291192581ac5 100644 (file)
@@ -1017,6 +1017,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;
 
@@ -1030,7 +1031,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);
index f34070ca7bbee7187ea027a152d3112536c45c78..c5350e7a11e625c0218a38e4b2a7e8ae00a8e9d3 100644 (file)
@@ -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);