From patchwork Wed May 11 10:48:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haishuang Yan X-Patchwork-Id: 620995 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3r4XtC6XnJz9t3g for ; Wed, 11 May 2016 20:49:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752367AbcEKKst (ORCPT ); Wed, 11 May 2016 06:48:49 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:8838 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751512AbcEKKsr (ORCPT ); Wed, 11 May 2016 06:48:47 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.1]) by rmmx-syy-dmz-app11-12011 (RichMail) with SMTP id 2eeb57330e02b26-b8d8f; Wed, 11 May 2016 18:48:34 +0800 (CST) X-RM-TRANSID: 2eeb57330e02b26-b8d8f X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.68.205.133]) by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee157330e01333-699e3; Wed, 11 May 2016 18:48:34 +0800 (CST) X-RM-TRANSID: 2ee157330e01333-699e3 From: Haishuang Yan To: "David S. Miller" , Dmitry Kozlov , Alexey Kuznetsov , Patrick McHardy Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Haishuang Yan Subject: [PATCH 2/2] gre: Fix wrong tpi->proto in WCCP Date: Wed, 11 May 2016 18:48:32 +0800 Message-Id: <1462963712-13781-2-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462963712-13781-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1462963712-13781-1-git-send-email-yanhaishuang@cmss.chinamobile.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- include/net/gre.h | 2 +- net/ipv4/gre_demux.c | 6 +++--- net/ipv4/ip_gre.c | 4 ++-- net/ipv6/ip6_gre.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/net/gre.h b/include/net/gre.h index a14093c..5dce30a 100644 --- a/include/net/gre.h +++ b/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, u8 name_assign_type); 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) { diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index d78e2ee..4c39f4f 100644 --- a/net/ipv4/gre_demux.c +++ b/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. */ 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; __be32 *options; @@ -109,11 +109,11 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, tpi->seq = 0; } /* 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 */ if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) { - tpi->proto = htons(ETH_P_IP); + tpi->proto = proto; if ((*(u8 *)options & 0xF0) != 0x40) hdr_len += 4; } diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 2b267e7..aaeb478 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) struct tnl_ptk_info tpi; 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. */ return; } @@ -335,7 +335,7 @@ static int gre_rcv(struct sk_buff *skb) } #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) goto drop; diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 3c25fe6..4541fa5 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) bool csum_err = false; 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) goto drop;