OSDN Git Service

net: tap: check vlan with eth_type_vlan() method
authorMenglong Dong <dong.menglong@zte.com.cn>
Fri, 15 Jan 2021 02:32:38 +0000 (18:32 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 16 Jan 2021 04:13:49 +0000 (20:13 -0800)
Replace some checks for ETH_P_8021Q and ETH_P_8021AD in
drivers/net/tap.c with eth_type_vlan.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/20210115023238.4681-1-dong.menglong@zte.com.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/tap.c

index 3c652c8..ff4aa35 100644 (file)
@@ -713,8 +713,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
        skb_probe_transport_header(skb);
 
        /* Move network header to the right position for VLAN tagged packets */
-       if ((skb->protocol == htons(ETH_P_8021Q) ||
-            skb->protocol == htons(ETH_P_8021AD)) &&
+       if (eth_type_vlan(skb->protocol) &&
            __vlan_get_protocol(skb, skb->protocol, &depth) != 0)
                skb_set_network_header(skb, depth);
 
@@ -1164,8 +1163,7 @@ static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp)
        }
 
        /* Move network header to the right position for VLAN tagged packets */
-       if ((skb->protocol == htons(ETH_P_8021Q) ||
-            skb->protocol == htons(ETH_P_8021AD)) &&
+       if (eth_type_vlan(skb->protocol) &&
            __vlan_get_protocol(skb, skb->protocol, &depth) != 0)
                skb_set_network_header(skb, depth);