Skip to contentSkip to conversation

IP_GRE: Fix GRE_CSUM case.

PATCH Applied Pravin B Shelar 3 participants 3 messages Feb 25, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 IP_GRE: Fix GRE_CSUM case.

commit "ip_gre: allow CSUM capable devices to handle packets" aa0e51cdda005cd37e2, broke GRE_CSUM case.
GRE_CSUM needs checksum computed for inner packet. Therefore csum-calculation can not be offloaded if tunnel device requires GRE_CSUM. Following patch fixes it by computing inner packet checksum for GRE_CSUM type, for all other type of GRE devices csum is offloaded.

---
 net/ipv4/ip_gre.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
net/ipv4/ip_gre.c +8 -4
index 5ef4da7..9b4996d 100644
@@ -735,7 +735,7 @@ drop:
 	return 0;
 }
 
-static struct sk_buff *handle_offloads(struct sk_buff *skb)
+static struct sk_buff *handle_offloads(struct ip_tunnel *tunnel, struct sk_buff *skb)
 {
 	int err;
 
@@ -745,8 +745,12 @@ static struct sk_buff *handle_offloads(struct sk_buff *skb)
 			goto error;
 		skb_shinfo(skb)->gso_type |= SKB_GSO_GRE;
 		return skb;
-	}
-	if (skb->ip_summed != CHECKSUM_PARTIAL)
+	} else if (skb->ip_summed == CHECKSUM_PARTIAL &&
+		   tunnel->parms.o_flags&GRE_CSUM) {
+		err = skb_checksum_help(skb);
+		if (unlikely(err))
+			goto error;
+	} else if (skb->ip_summed != CHECKSUM_PARTIAL)
 		skb->ip_summed = CHECKSUM_NONE;
 
 	return skb;
@@ -776,7 +780,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
 	int    err;
 	int    pkt_len;
 
-	skb = handle_offloads(skb);
+	skb = handle_offloads(tunnel, skb);
 	if (IS_ERR(skb)) {
 		dev->stats.tx_dropped++;
 		return NETDEV_TX_OK;
Signature · 1 line
1.7.1
Acked-by on v1 1/2
#1 lore raw
Quoted 58 lines

-----Original Message-----
From: Pravin B Shelar [mailto:[email protected]]
Sent: Monday, February 25, 2013 8:05 AM
To: [email protected]
Cc: [email protected]; Dmitry Kravkov; Pravin B Shelar
Subject: [PATCH net-next 1/2] IP_GRE: Fix GRE_CSUM case.

commit "ip_gre: allow CSUM capable devices to handle packets" aa0e51cdda005cd37e2, broke GRE_CSUM case.
GRE_CSUM needs checksum computed for inner packet. Therefore csum-calculation can not be offloaded if tunnel device requires GRE_CSUM. Following patch fixes it by computing inner packet checksum for GRE_CSUM type, for all other type of GRE devices csum is offloaded.

---
 net/ipv4/ip_gre.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
net/ipv4/ip_gre.c +8 -5
index 5ef4da7..9b4996d 100644
@@ -735,7 +735,7 @@ drop:
 	return 0;
 }
 
-static struct sk_buff *handle_offloads(struct sk_buff *skb)
+static struct sk_buff *handle_offloads(struct ip_tunnel *tunnel, struct sk_buff *skb)
 {
 	int err;
 
@@ -745,8 +745,12 @@ static struct sk_buff *handle_offloads(struct sk_buff *skb)
 			goto error;
 		skb_shinfo(skb)->gso_type |= SKB_GSO_GRE;
 		return skb;
-	}
-	if (skb->ip_summed != CHECKSUM_PARTIAL)
+	} else if (skb->ip_summed == CHECKSUM_PARTIAL &&
+		   tunnel->parms.o_flags&GRE_CSUM) {
+		err = skb_checksum_help(skb);
+		if (unlikely(err))
+			goto error;
+	} else if (skb->ip_summed != CHECKSUM_PARTIAL)
 		skb->ip_summed = CHECKSUM_NONE;
 
 	return skb;
@@ -776,7 +780,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
 	int    err;
 	int    pkt_len;
 
-	skb = handle_offloads(skb);
+	skb = handle_offloads(tunnel, skb);
 	if (IS_ERR(skb)) {
 		dev->stats.tx_dropped++;
 		return NETDEV_TX_OK;
--
Quoted 1 line

1.7.1

Tested the series on two different devices

maintainer Applied
#2 lore raw

From: "Dmitry Kravkov" <[email protected]>
Date: Mon, 25 Feb 2013 11:40:06 +0000

Quoted 16 lines
Quoted 16 lines

-----Original Message-----
From: Pravin B Shelar [mailto:[email protected]]
Sent: Monday, February 25, 2013 8:05 AM
To: [email protected]
Cc: [email protected]; Dmitry Kravkov; Pravin B Shelar
Subject: [PATCH net-next 1/2] IP_GRE: Fix GRE_CSUM case.

commit "ip_gre: allow CSUM capable devices to handle packets" aa0e51cdda005cd37e2, broke GRE_CSUM case.
GRE_CSUM needs checksum computed for inner packet. Therefore csum-calculation can not be offloaded if tunnel device requires GRE_CSUM. Following patch fixes it by computing inner packet checksum for GRE_CSUM type, for all other type of GRE devices csum is offloaded.

...

Quoted 5 lines

Tested the series on two different devices

Applied.