Skip to content

Commit

Permalink
gre_offload: simplify GRE header length calculation in gre_gso_segment()
Browse files Browse the repository at this point in the history
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: Neal Cardwell <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: H.K. Jerry Chu <[email protected]>
Cc: Pravin B Shelar <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
nealcardwell authored and davem330 committed Jan 13, 2014
1 parent 7eb8896 commit b884b1a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions net/ipv4/gre_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
{
struct sk_buff *segs = ERR_PTR(-EINVAL);
netdev_features_t enc_features;
int ghl = GRE_HEADER_SECTION;
int ghl;
struct gre_base_hdr *greh;
u16 mac_offset = skb->mac_header;
int mac_len = skb->mac_len;
Expand All @@ -49,15 +49,11 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,

greh = (struct gre_base_hdr *)skb_transport_header(skb);

if (greh->flags & GRE_KEY)
ghl += GRE_HEADER_SECTION;
if (greh->flags & GRE_SEQ)
ghl += GRE_HEADER_SECTION;
if (greh->flags & GRE_CSUM) {
ghl += GRE_HEADER_SECTION;
csum = true;
} else
csum = false;
ghl = skb_inner_network_header(skb) - skb_transport_header(skb);
if (unlikely(ghl < sizeof(*greh)))
goto out;

csum = !!(greh->flags & GRE_CSUM);

if (unlikely(!pskb_may_pull(skb, ghl)))
goto out;
Expand Down

0 comments on commit b884b1a

Please sign in to comment.