Skip to content

Commit da73b4e

Browse files
Haishuang Yandavem330
authored andcommitted
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>
1 parent 23f7221 commit da73b4e

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

include/net/gre.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version);
2626
struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
2727
u8 name_assign_type);
2828
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
29-
bool *csum_err);
29+
bool *csum_err, __be16 proto);
3030

3131
static inline int gre_calc_hlen(__be16 o_flags)
3232
{

net/ipv4/gre_demux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ EXPORT_SYMBOL_GPL(gre_del_protocol);
6262

6363
/* Fills in tpi and returns header length to be pulled. */
6464
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
65-
bool *csum_err)
65+
bool *csum_err, __be16 proto)
6666
{
6767
const struct gre_base_hdr *greh;
6868
__be32 *options;
@@ -109,11 +109,11 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
109109
tpi->seq = 0;
110110
}
111111
/* WCCP version 1 and 2 protocol decoding.
112-
* - Change protocol to IP
112+
* - Change protocol to IPv4/IPv6
113113
* - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
114114
*/
115115
if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) {
116-
tpi->proto = htons(ETH_P_IP);
116+
tpi->proto = proto;
117117
if ((*(u8 *)options & 0xF0) != 0x40)
118118
hdr_len += 4;
119119
}

net/ipv4/ip_gre.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
222222
struct tnl_ptk_info tpi;
223223
bool csum_err = false;
224224

225-
if (gre_parse_header(skb, &tpi, &csum_err) < 0) {
225+
if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)) < 0) {
226226
if (!csum_err) /* ignore csum errors. */
227227
return;
228228
}
@@ -335,7 +335,7 @@ static int gre_rcv(struct sk_buff *skb)
335335
}
336336
#endif
337337

338-
hdr_len = gre_parse_header(skb, &tpi, &csum_err);
338+
hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP));
339339
if (hdr_len < 0)
340340
goto drop;
341341

net/ipv6/ip6_gre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static int gre_rcv(struct sk_buff *skb)
468468
bool csum_err = false;
469469
int hdr_len;
470470

471-
hdr_len = gre_parse_header(skb, &tpi, &csum_err);
471+
hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6));
472472
if (hdr_len < 0)
473473
goto drop;
474474

0 commit comments

Comments
 (0)