diff options
author | Haishuang Yan <yanhaishuang@cmss.chinamobile.com> | 2016-05-11 06:48:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-12 16:53:58 -0400 |
commit | da73b4e9538b9be96498241ab3f13eab94181e96 (patch) | |
tree | b22bf974053d15e37a25aa8dcf9c18a51bbd0181 /net | |
parent | 23f72215bc030d1eea437713abfef91c635e2e1f (diff) |
gre: Fix wrong tpi->proto in WCCP
When dealing with WCCP in gre6 tunnel, it sets the wrong tpi->protocol,
that is, ETH_P_IP instead of ETH_P_IPV6 for the encapuslated traffic.
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/gre_demux.c | 6 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 4 | ||||
-rw-r--r-- | net/ipv6/ip6_gre.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index d78e2eefc0f7..4c39f4fd332a 100644 --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c | |||
@@ -62,7 +62,7 @@ EXPORT_SYMBOL_GPL(gre_del_protocol); | |||
62 | 62 | ||
63 | /* Fills in tpi and returns header length to be pulled. */ | 63 | /* Fills in tpi and returns header length to be pulled. */ |
64 | int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, | 64 | int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, |
65 | bool *csum_err) | 65 | bool *csum_err, __be16 proto) |
66 | { | 66 | { |
67 | const struct gre_base_hdr *greh; | 67 | const struct gre_base_hdr *greh; |
68 | __be32 *options; | 68 | __be32 *options; |
@@ -109,11 +109,11 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, | |||
109 | tpi->seq = 0; | 109 | tpi->seq = 0; |
110 | } | 110 | } |
111 | /* WCCP version 1 and 2 protocol decoding. | 111 | /* WCCP version 1 and 2 protocol decoding. |
112 | * - Change protocol to IP | 112 | * - Change protocol to IPv4/IPv6 |
113 | * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header | 113 | * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header |
114 | */ | 114 | */ |
115 | if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) { | 115 | if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) { |
116 | tpi->proto = htons(ETH_P_IP); | 116 | tpi->proto = proto; |
117 | if ((*(u8 *)options & 0xF0) != 0x40) | 117 | if ((*(u8 *)options & 0xF0) != 0x40) |
118 | hdr_len += 4; | 118 | hdr_len += 4; |
119 | } | 119 | } |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 2b267e71ebf5..aaeb478b54cd 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -222,7 +222,7 @@ static void gre_err(struct sk_buff *skb, u32 info) | |||
222 | struct tnl_ptk_info tpi; | 222 | struct tnl_ptk_info tpi; |
223 | bool csum_err = false; | 223 | bool csum_err = false; |
224 | 224 | ||
225 | if (gre_parse_header(skb, &tpi, &csum_err) < 0) { | 225 | if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)) < 0) { |
226 | if (!csum_err) /* ignore csum errors. */ | 226 | if (!csum_err) /* ignore csum errors. */ |
227 | return; | 227 | return; |
228 | } | 228 | } |
@@ -335,7 +335,7 @@ static int gre_rcv(struct sk_buff *skb) | |||
335 | } | 335 | } |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | hdr_len = gre_parse_header(skb, &tpi, &csum_err); | 338 | hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)); |
339 | if (hdr_len < 0) | 339 | if (hdr_len < 0) |
340 | goto drop; | 340 | goto drop; |
341 | 341 | ||
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 3c25fe67d3da..4541fa54035e 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -468,7 +468,7 @@ static int gre_rcv(struct sk_buff *skb) | |||
468 | bool csum_err = false; | 468 | bool csum_err = false; |
469 | int hdr_len; | 469 | int hdr_len; |
470 | 470 | ||
471 | hdr_len = gre_parse_header(skb, &tpi, &csum_err); | 471 | hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6)); |
472 | if (hdr_len < 0) | 472 | if (hdr_len < 0) |
473 | goto drop; | 473 | goto drop; |
474 | 474 | ||