]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nft_payload: restore vlan q-in-q match support
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 9 May 2024 21:02:24 +0000 (23:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:32:28 +0000 (13:32 +0200)
[ Upstream commit aff5c01fa1284d606f8e7cbdaafeef2511bb46c1 ]

Revert f6ae9f120dad ("netfilter: nft_payload: add C-VLAN support").

f41f72d09ee1 ("netfilter: nft_payload: simplify vlan header handling")
already allows to match on inner vlan tags by subtract the vlan header
size to the payload offset which has been popped and stored in skbuff
metadata fields.

Fixes: f6ae9f120dad ("netfilter: nft_payload: add C-VLAN support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nft_payload.c

index 56f6c05362ae80bdc08a1bbaad616b0d05efb254..fa64b1b8ae9189e7c0621b6268c7141e6dac1a7b 100644 (file)
@@ -44,36 +44,27 @@ nft_payload_copy_vlan(u32 *d, const struct sk_buff *skb, u8 offset, u8 len)
        int mac_off = skb_mac_header(skb) - skb->data;
        u8 *vlanh, *dst_u8 = (u8 *) d;
        struct vlan_ethhdr veth;
-       u8 vlan_hlen = 0;
-
-       if ((skb->protocol == htons(ETH_P_8021AD) ||
-            skb->protocol == htons(ETH_P_8021Q)) &&
-           offset >= VLAN_ETH_HLEN && offset < VLAN_ETH_HLEN + VLAN_HLEN)
-               vlan_hlen += VLAN_HLEN;
 
        vlanh = (u8 *) &veth;
-       if (offset < VLAN_ETH_HLEN + vlan_hlen) {
+       if (offset < VLAN_ETH_HLEN) {
                u8 ethlen = len;
 
-               if (vlan_hlen &&
-                   skb_copy_bits(skb, mac_off, &veth, VLAN_ETH_HLEN) < 0)
-                       return false;
-               else if (!nft_payload_rebuild_vlan_hdr(skb, mac_off, &veth))
+               if (!nft_payload_rebuild_vlan_hdr(skb, mac_off, &veth))
                        return false;
 
-               if (offset + len > VLAN_ETH_HLEN + vlan_hlen)
-                       ethlen -= offset + len - VLAN_ETH_HLEN - vlan_hlen;
+               if (offset + len > VLAN_ETH_HLEN)
+                       ethlen -= offset + len - VLAN_ETH_HLEN;
 
-               memcpy(dst_u8, vlanh + offset - vlan_hlen, ethlen);
+               memcpy(dst_u8, vlanh + offset, ethlen);
 
                len -= ethlen;
                if (len == 0)
                        return true;
 
                dst_u8 += ethlen;
-               offset = ETH_HLEN + vlan_hlen;
+               offset = ETH_HLEN;
        } else {
-               offset -= VLAN_HLEN + vlan_hlen;
+               offset -= VLAN_HLEN;
        }
 
        return skb_copy_bits(skb, offset + mac_off, dst_u8, len) == 0;