netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ip_gre: increase inner ip header ID only for IPv4
@ 2013-03-23  5:29 Cong Wang
  2013-03-23 15:10 ` Sergei Shtylyov
  2013-03-23 23:36 ` Pravin Shelar
  0 siblings, 2 replies; 5+ messages in thread
From: Cong Wang @ 2013-03-23  5:29 UTC (permalink / raw)
  To: netdev; +Cc: Pravin B Shelar, Eric Dumazet, David S. Miller, Cong Wang

From: Cong Wang <amwang@redhat.com>

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 <pshelar@nicira.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>

---
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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-24  4:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-23  5:29 [PATCH net-next] ip_gre: increase inner ip header ID only for IPv4 Cong Wang
2013-03-23 15:10 ` Sergei Shtylyov
2013-03-23 23:36 ` Pravin Shelar
2013-03-24  2:37   ` Cong Wang
2013-03-24  4:13     ` Pravin Shelar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).