From patchwork Sun Jan 19 08:35:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duan Jiong X-Patchwork-Id: 312365 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 6FF8B2C009F for ; Sun, 19 Jan 2014 19:36:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbaASIgU (ORCPT ); Sun, 19 Jan 2014 03:36:20 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:37794 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750774AbaASIgS (ORCPT ); Sun, 19 Jan 2014 03:36:18 -0500 X-IronPort-AV: E=Sophos;i="4.95,684,1384272000"; d="scan'208";a="9432369" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 19 Jan 2014 16:32:15 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s0J8ZtiL001589; Sun, 19 Jan 2014 16:35:55 +0800 Received: from [10.167.225.86] ([10.167.225.86]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014011916343644-1196521 ; Sun, 19 Jan 2014 16:34:36 +0800 Message-ID: <52DB8E4A.7050809@cn.fujitsu.com> Date: Sun, 19 Jan 2014 16:35:22 +0800 From: Duan Jiong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: David Miller CC: Daniel Borkmann , netdev@vger.kernel.org Subject: [PATCH] net: gre: don't pull skb if dealing with icmp message X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/19 16:34:36, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/19 16:34:36, Serialize complete at 2014/01/19 16:34:36 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When dealing with icmp messages, the skb->data points the ip header that triggered the sending of the icmp message. In gre_cisco_err(), the parse_gre_header() is called, and the iptunnel_pull_header() is called to pull the skb at the end of the parse_gre_header(). Unfortunately, the ipgre_err still needs the skb->data points the ip header following the icmp layer, and those ip addresses in ip header will be used to look up tunnel by ip_tunnel_lookup(). Signed-off-by: Duan Jiong --- net/ipv4/gre_demux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index 5893e99..35bfba4 100644 --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c @@ -116,7 +116,7 @@ static __sum16 check_checksum(struct sk_buff *skb) } static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, - bool *csum_err) + bool *csum_err, bool in_err) { unsigned int ip_hlen = ip_hdrlen(skb); const struct gre_base_hdr *greh; @@ -160,6 +160,9 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, } else tpi->seq = 0; + if (in_err) + return 0; + /* WCCP version 1 and 2 protocol decoding. * - Change protocol to IP * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header @@ -182,7 +185,7 @@ static int gre_cisco_rcv(struct sk_buff *skb) int i; bool csum_err = false; - if (parse_gre_header(skb, &tpi, &csum_err) < 0) + if (parse_gre_header(skb, &tpi, &csum_err, false) < 0) goto drop; rcu_read_lock(); @@ -229,7 +232,7 @@ static void gre_cisco_err(struct sk_buff *skb, u32 info) bool csum_err = false; int i; - if (parse_gre_header(skb, &tpi, &csum_err)) { + if (parse_gre_header(skb, &tpi, &csum_err, true)) { if (!csum_err) /* ignore csum errors. */ return; }