Commit b884b1a4 authored by Neal Cardwell's avatar Neal Cardwell Committed by David S. Miller

gre_offload: simplify GRE header length calculation in gre_gso_segment()

Simplify the GRE header length calculation in gre_gso_segment().
Switch to an approach that is simpler, faster, and more general. The
new approach will continue to be correct even if we add support for
the optional variable-length routing info that may be present in a GRE
header.
Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: H.K. Jerry Chu <hkchu@google.com>
Cc: Pravin B Shelar <pshelar@nicira.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7eb8896d
...@@ -26,7 +26,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, ...@@ -26,7 +26,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
{ {
struct sk_buff *segs = ERR_PTR(-EINVAL); struct sk_buff *segs = ERR_PTR(-EINVAL);
netdev_features_t enc_features; netdev_features_t enc_features;
int ghl = GRE_HEADER_SECTION; int ghl;
struct gre_base_hdr *greh; struct gre_base_hdr *greh;
u16 mac_offset = skb->mac_header; u16 mac_offset = skb->mac_header;
int mac_len = skb->mac_len; int mac_len = skb->mac_len;
...@@ -49,15 +49,11 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, ...@@ -49,15 +49,11 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
greh = (struct gre_base_hdr *)skb_transport_header(skb); greh = (struct gre_base_hdr *)skb_transport_header(skb);
if (greh->flags & GRE_KEY) ghl = skb_inner_network_header(skb) - skb_transport_header(skb);
ghl += GRE_HEADER_SECTION; if (unlikely(ghl < sizeof(*greh)))
if (greh->flags & GRE_SEQ) goto out;
ghl += GRE_HEADER_SECTION;
if (greh->flags & GRE_CSUM) { csum = !!(greh->flags & GRE_CSUM);
ghl += GRE_HEADER_SECTION;
csum = true;
} else
csum = false;
if (unlikely(!pskb_may_pull(skb, ghl))) if (unlikely(!pskb_may_pull(skb, ghl)))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment