net: dsa: tag_8021q: only call skb_push/skb_pull around __skb_vlan_pop
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 15 Feb 2022 20:47:22 +0000 (22:47 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Feb 2022 04:35:35 +0000 (20:35 -0800)
__skb_vlan_pop() needs skb->data to point at the mac_header, while
skb_vlan_tag_present() and skb_vlan_tag_get() don't, because they don't
look at skb->data at all.

So we can avoid uselessly moving around skb->data for the case where the
VLAN tag was offloaded by the DSA master.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20220215204722.2134816-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/dsa/tag_8021q.c

index 27712a81c967d70a1d0b7bc394d7bea319b4be00..114f663332d0454c1e31e302e42941a932a7d811 100644 (file)
@@ -577,14 +577,14 @@ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id)
 {
        u16 vid, tci;
 
-       skb_push_rcsum(skb, ETH_HLEN);
        if (skb_vlan_tag_present(skb)) {
                tci = skb_vlan_tag_get(skb);
                __vlan_hwaccel_clear_tag(skb);
        } else {
+               skb_push_rcsum(skb, ETH_HLEN);
                __skb_vlan_pop(skb, &tci);
+               skb_pull_rcsum(skb, ETH_HLEN);
        }
-       skb_pull_rcsum(skb, ETH_HLEN);
 
        vid = tci & VLAN_VID_MASK;