Skip to content

Commit a82738a

Browse files
Haishuang Yandavem330
authored andcommitted
ip6_gre: simplify gre header parsing in ip6gre_err
Same as ip_gre, use gre_parse_header to parse gre header in gre error handler code. Signed-off-by: Haishuang Yan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b0350d5 commit a82738a

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

net/ipv6/ip6_gre.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -427,35 +427,17 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
427427
u8 type, u8 code, int offset, __be32 info)
428428
{
429429
struct net *net = dev_net(skb->dev);
430-
const struct gre_base_hdr *greh;
431430
const struct ipv6hdr *ipv6h;
432-
int grehlen = sizeof(*greh);
431+
struct tnl_ptk_info tpi;
433432
struct ip6_tnl *t;
434-
int key_off = 0;
435-
__be16 flags;
436-
__be32 key;
437433

438-
if (!pskb_may_pull(skb, offset + grehlen))
439-
return;
440-
greh = (const struct gre_base_hdr *)(skb->data + offset);
441-
flags = greh->flags;
442-
if (flags & (GRE_VERSION | GRE_ROUTING))
434+
if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IPV6),
435+
offset) < 0)
443436
return;
444-
if (flags & GRE_CSUM)
445-
grehlen += 4;
446-
if (flags & GRE_KEY) {
447-
key_off = grehlen + offset;
448-
grehlen += 4;
449-
}
450437

451-
if (!pskb_may_pull(skb, offset + grehlen))
452-
return;
453438
ipv6h = (const struct ipv6hdr *)skb->data;
454-
greh = (const struct gre_base_hdr *)(skb->data + offset);
455-
key = key_off ? *(__be32 *)(skb->data + key_off) : 0;
456-
457439
t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
458-
key, greh->protocol);
440+
tpi.key, tpi.proto);
459441
if (!t)
460442
return;
461443

0 commit comments

Comments
 (0)