]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - net/core/filter.c
sched: consistently handle layer3 header accesses in the presence of VLANs
[mirror_ubuntu-focal-kernel.git] / net / core / filter.c
index a0a492f7cf9ce4699a27f5ed8c7cfb084669bd1b..bd1e46d61d8a1f78a02715c954f7566d1311fbd7 100644 (file)
@@ -5730,12 +5730,16 @@ BPF_CALL_1(bpf_skb_ecn_set_ce, struct sk_buff *, skb)
 {
        unsigned int iphdr_len;
 
-       if (skb->protocol == cpu_to_be16(ETH_P_IP))
+       switch (skb_protocol(skb, true)) {
+       case cpu_to_be16(ETH_P_IP):
                iphdr_len = sizeof(struct iphdr);
-       else if (skb->protocol == cpu_to_be16(ETH_P_IPV6))
+               break;
+       case cpu_to_be16(ETH_P_IPV6):
                iphdr_len = sizeof(struct ipv6hdr);
-       else
+               break;
+       default:
                return 0;
+       }
 
        if (skb_headlen(skb) < iphdr_len)
                return 0;