net: vlan: don't adjust MAC header in __vlan_insert_inner_tag() unless set
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 20 Apr 2023 22:55:53 +0000 (01:55 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Apr 2023 13:16:44 +0000 (14:16 +0100)
This is a preparatory change for the deletion of skb_reset_mac_header(skb)
from __dev_queue_xmit(). After that deletion, skb_mac_header(skb) will
no longer be set in TX paths, from which __vlan_insert_inner_tag() can
still be called (perhaps indirectly).

If we don't make this change, then an unset MAC header (equal to ~0U)
will become set after the adjustment with VLAN_HLEN.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_vlan.h

index 6864b89ef86818c4c360dc3b2adca1dfe65a21ff..90b76d63c11c2e51660eb71f5b6fcf16f7c4d4ad 100644 (file)
@@ -351,7 +351,8 @@ static inline int __vlan_insert_inner_tag(struct sk_buff *skb,
        /* Move the mac header sans proto to the beginning of the new header. */
        if (likely(mac_len > ETH_TLEN))
                memmove(skb->data, skb->data + VLAN_HLEN, mac_len - ETH_TLEN);
-       skb->mac_header -= VLAN_HLEN;
+       if (skb_mac_header_was_set(skb))
+               skb->mac_header -= VLAN_HLEN;
 
        veth = (struct vlan_ethhdr *)(skb->data + mac_len - ETH_HLEN);