Skip to content

Commit

Permalink
net: Fix GRE RX to use skb_transport_header for GRE header offset
Browse files Browse the repository at this point in the history
GRE assumes that the GRE header is at skb_network_header +
ip_hrdlen(skb). It is more general to use skb_transport_header
and this allows the possbility of inserting additional header
between IP and GRE (which is what we will done in Generic UDP
Encapsulation for GRE).

Signed-off-by: Tom Herbert <therbert@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Herbert authored and David S. Miller committed Sep 8, 2014
1 parent db91b72 commit 1e701f1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/ipv4/gre_demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ EXPORT_SYMBOL_GPL(gre_build_header);
static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
bool *csum_err)
{
unsigned int ip_hlen = ip_hdrlen(skb);
const struct gre_base_hdr *greh;
__be32 *options;
int hdr_len;

if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr))))
return -EINVAL;

greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
greh = (struct gre_base_hdr *)skb_transport_header(skb);
if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
return -EINVAL;

Expand All @@ -116,7 +115,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
if (!pskb_may_pull(skb, hdr_len))
return -EINVAL;

greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
greh = (struct gre_base_hdr *)skb_transport_header(skb);
tpi->proto = greh->protocol;

options = (__be32 *)(greh + 1);
Expand Down

0 comments on commit 1e701f1

Please sign in to comment.