diff options
author | Tom Herbert <therbert@google.com> | 2014-09-08 11:29:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-08 18:23:05 -0400 |
commit | 1e701f16982a9d15488a5aa8c7f5c41444b1de67 (patch) | |
tree | ffd2de95a203e68a1f070e80955738f1006dd826 /net/ipv4/gre_demux.c | |
parent | db91b724b53b1cfd0e258d7cf3a03a062a89fe2d (diff) |
net: Fix GRE RX to use skb_transport_header for GRE header offset
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>
Diffstat (limited to 'net/ipv4/gre_demux.c')
-rw-r--r-- | net/ipv4/gre_demux.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index 7e0756da8737..4a7b5b2a1ce3 100644 --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c | |||
@@ -98,7 +98,6 @@ EXPORT_SYMBOL_GPL(gre_build_header); | |||
98 | static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, | 98 | static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, |
99 | bool *csum_err) | 99 | bool *csum_err) |
100 | { | 100 | { |
101 | unsigned int ip_hlen = ip_hdrlen(skb); | ||
102 | const struct gre_base_hdr *greh; | 101 | const struct gre_base_hdr *greh; |
103 | __be32 *options; | 102 | __be32 *options; |
104 | int hdr_len; | 103 | int hdr_len; |
@@ -106,7 +105,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, | |||
106 | if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr)))) | 105 | if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr)))) |
107 | return -EINVAL; | 106 | return -EINVAL; |
108 | 107 | ||
109 | greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen); | 108 | greh = (struct gre_base_hdr *)skb_transport_header(skb); |
110 | if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING))) | 109 | if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING))) |
111 | return -EINVAL; | 110 | return -EINVAL; |
112 | 111 | ||
@@ -116,7 +115,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, | |||
116 | if (!pskb_may_pull(skb, hdr_len)) | 115 | if (!pskb_may_pull(skb, hdr_len)) |
117 | return -EINVAL; | 116 | return -EINVAL; |
118 | 117 | ||
119 | greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen); | 118 | greh = (struct gre_base_hdr *)skb_transport_header(skb); |
120 | tpi->proto = greh->protocol; | 119 | tpi->proto = greh->protocol; |
121 | 120 | ||
122 | options = (__be32 *)(greh + 1); | 121 | options = (__be32 *)(greh + 1); |