Patchwork [1/2] IP_GRE: Fix kernel panic in IP_GRE with GRE csum.

login
register
mail settings
Submitter Pravin B Shelar
Date Jan. 22, 2013, 9:20 p.m.
Message ID <1358889636-1651-1-git-send-email-pshelar@nicira.com>
Download mbox | patch
Permalink /patch/214664/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Pravin B Shelar - Jan. 22, 2013, 9:20 p.m.
Due to GSO support, gre can recieve non linear skb which
results in panic in case of GRE_CSUM.
Following patch fixes it by using correct csum API.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 net/ipv4/ip_gre.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
David Miller - Jan. 22, 2013, 9:25 p.m.
From: Pravin B Shelar <pshelar@nicira.com>
Date: Tue, 22 Jan 2013 13:20:36 -0800

> -			*(__sum16 *)ptr = ip_compute_csum((void *)(iph+1), skb->len - sizeof(struct iphdr));
> +			*(__sum16 *)ptr = csum_fold(skb_checksum(skb,
> +						skb_transport_offset(skb),
> +						skb->len - skb_transport_offset(skb),
> +						0));

This is not the correct way to indent a multi-line function call.

The second and subsequent lines should be indented by a combination of
TAB and space characters, as needed, to make the first non-space
character line up with the first column after the openning parenthesis
of the first line.
--
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

Patch

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 303012a..7cdf1fe 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -964,7 +964,10 @@  static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
 		}
 		if (tunnel->parms.o_flags&GRE_CSUM) {
 			*ptr = 0;
-			*(__sum16 *)ptr = ip_compute_csum((void *)(iph+1), skb->len - sizeof(struct iphdr));
+			*(__sum16 *)ptr = csum_fold(skb_checksum(skb,
+						skb_transport_offset(skb),
+						skb->len - skb_transport_offset(skb),
+						0));
 		}
 	}