Re: [PATCH] ip6_gre: simplify gre header parsing in ip6gre_err
From: Jiri Benc
Date: Mon Sep 10 2018 - 11:36:49 EST
On Mon, 10 Sep 2018 16:25:09 +0800, Haishuang Yan wrote:
> + if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6),
> + offset) < 0) {
> + if (!csum_err) /* ignore csum errors. */
> + return;
> }
gre_parse_header stops parsing when csum_err is encountered. Which
means tpi.key is undefined...
>
> - if (!pskb_may_pull(skb, offset + grehlen))
> - return;
> ipv6h = (const struct ipv6hdr *)skb->data;
> - greh = (const struct gre_base_hdr *)(skb->data + offset);
> - key = key_off ? *(__be32 *)(skb->data + key_off) : 0;
> -
> t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
> - key, greh->protocol);
> + tpi.key, tpi.proto);
...and can't be used here.
Jiri