From: Felix Fietkau Date: Sat, 13 Aug 2022 12:55:02 +0000 (+0200) Subject: bpf_skb_utils: fix skb parsing on older kernels X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=3e1d996021c51dbbfeb3121570c115236122858d;p=project%2Funetd.git bpf_skb_utils: fix skb parsing on older kernels Signed-off-by: Felix Fietkau --- diff --git a/bpf_skb_utils.h b/bpf_skb_utils.h index 4953c86..643803d 100644 --- a/bpf_skb_utils.h +++ b/bpf_skb_utils.h @@ -56,6 +56,12 @@ static __always_inline struct ethhdr * skb_parse_ethernet(struct skb_parser_info *info) { struct ethhdr *eth; + int len; + + len = sizeof(*eth) + 2 * sizeof(struct vlan_hdr) + sizeof(struct ipv6hdr); + if (len > info->skb->len) + len = info->skb->len; + bpf_skb_pull_data(info->skb, len); eth = skb_info_ptr(info, sizeof(*eth)); if (!eth)