Browse Source

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>
Haishuang Yan 9 years ago
parent
commit
da73b4e953
4 changed files with 7 additions and 7 deletions
  1. 1 1
      include/net/gre.h
  2. 3 3
      net/ipv4/gre_demux.c
  3. 2 2
      net/ipv4/ip_gre.c
  4. 1 1
      net/ipv6/ip6_gre.c

+ 1 - 1
include/net/gre.h

@@ -26,7 +26,7 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version);
 struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
 struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
 				       u8 name_assign_type);
 				       u8 name_assign_type);
 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		     bool *csum_err);
+		     bool *csum_err, __be16 proto);
 
 
 static inline int gre_calc_hlen(__be16 o_flags)
 static inline int gre_calc_hlen(__be16 o_flags)
 {
 {

+ 3 - 3
net/ipv4/gre_demux.c

@@ -62,7 +62,7 @@ EXPORT_SYMBOL_GPL(gre_del_protocol);
 
 
 /* Fills in tpi and returns header length to be pulled. */
 /* Fills in tpi and returns header length to be pulled. */
 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		     bool *csum_err)
+		     bool *csum_err, __be16 proto)
 {
 {
 	const struct gre_base_hdr *greh;
 	const struct gre_base_hdr *greh;
 	__be32 *options;
 	__be32 *options;
@@ -109,11 +109,11 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		tpi->seq = 0;
 		tpi->seq = 0;
 	}
 	}
 	/* WCCP version 1 and 2 protocol decoding.
 	/* WCCP version 1 and 2 protocol decoding.
-	 * - Change protocol to IP
+	 * - Change protocol to IPv4/IPv6
 	 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
 	 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
 	 */
 	 */
 	if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) {
 	if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) {
-		tpi->proto = htons(ETH_P_IP);
+		tpi->proto = proto;
 		if ((*(u8 *)options & 0xF0) != 0x40)
 		if ((*(u8 *)options & 0xF0) != 0x40)
 			hdr_len += 4;
 			hdr_len += 4;
 	}
 	}

+ 2 - 2
net/ipv4/ip_gre.c

@@ -222,7 +222,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
 	struct tnl_ptk_info tpi;
 	struct tnl_ptk_info tpi;
 	bool csum_err = false;
 	bool csum_err = false;
 
 
-	if (gre_parse_header(skb, &tpi, &csum_err) < 0) {
+	if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)) < 0) {
 		if (!csum_err)		/* ignore csum errors. */
 		if (!csum_err)		/* ignore csum errors. */
 			return;
 			return;
 	}
 	}
@@ -335,7 +335,7 @@ static int gre_rcv(struct sk_buff *skb)
 	}
 	}
 #endif
 #endif
 
 
-	hdr_len = gre_parse_header(skb, &tpi, &csum_err);
+	hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP));
 	if (hdr_len < 0)
 	if (hdr_len < 0)
 		goto drop;
 		goto drop;
 
 

+ 1 - 1
net/ipv6/ip6_gre.c

@@ -468,7 +468,7 @@ static int gre_rcv(struct sk_buff *skb)
 	bool csum_err = false;
 	bool csum_err = false;
 	int hdr_len;
 	int hdr_len;
 
 
-	hdr_len = gre_parse_header(skb, &tpi, &csum_err);
+	hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6));
 	if (hdr_len < 0)
 	if (hdr_len < 0)
 		goto drop;
 		goto drop;