From patchwork Sat Mar 23 05:29:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amerigo Wang X-Patchwork-Id: 230314 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 D48932C00C4 for ; Sat, 23 Mar 2013 16:30:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755641Ab3CWFaS (ORCPT ); Sat, 23 Mar 2013 01:30:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4613 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755535Ab3CWFaR (ORCPT ); Sat, 23 Mar 2013 01:30:17 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2N5UCo0016046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 23 Mar 2013 01:30:14 -0400 Received: from cr0.redhat.com (vpn1-114-20.nay.redhat.com [10.66.114.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2N5U22X005171; Sat, 23 Mar 2013 01:30:03 -0400 From: Cong Wang To: netdev@vger.kernel.org Cc: Pravin B Shelar , Eric Dumazet , "David S. Miller" , Cong Wang Subject: [PATCH net-next] ip_gre: increase inner ip header ID only for IPv4 Date: Sat, 23 Mar 2013 13:29:44 +0800 Message-Id: <1364016584-7189-1-git-send-email-amwang@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Cong Wang Pravin pointed out the inner network header of a GRE tunnel packet could be IPv6, where there is no ID. So we should check the version. Cc: Pravin B Shelar Cc: Eric Dumazet Cc: "David S. Miller" Signed-off-by: Cong Wang --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c index e20631c..a2516f5 100644 --- a/net/ipv4/gre.c +++ b/net/ipv4/gre.c @@ -128,7 +128,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, struct iphdr *iph; int mac_len = skb->mac_len; int tnl_hlen, id; - bool csum; + bool csum, ipv4; if (unlikely(skb_shinfo(skb)->gso_type & ~(SKB_GSO_TCPV4 | @@ -172,7 +172,12 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, skb->mac_len = skb_inner_network_offset(skb); iph = ip_hdr(skb); - id = ntohs(iph->id); + if (iph->version == 4) { + ipv4 = true; + id = ntohs(iph->id); + } else + ipv4 = false; + /* segment inner packet. */ enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); segs = skb_mac_gso_segment(skb, enc_features); @@ -182,8 +187,10 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, skb = segs; tnl_hlen = skb_tnl_header_len(skb); do { - iph = (struct iphdr *)skb->data; - iph->id = htons(id++); + if (ipv4) { + iph = (struct iphdr *)skb->data; + iph->id = htons(id++); + } __skb_push(skb, ghl); if (csum) { __be32 *pcsum;