netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] IP_GRE: Linearize skb before csum.
@ 2013-01-22 21:20 Pravin B Shelar
  2013-01-22 22:03 ` Eric Dumazet
  0 siblings, 1 reply; 15+ messages in thread
From: Pravin B Shelar @ 2013-01-22 21:20 UTC (permalink / raw)
  To: netdev; +Cc: jesse, Pravin B Shelar

Make copy of skb sharable data by linearizing skb. so that
csum remain consistent when skb is actually transmitted.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 net/ipv4/ip_gre.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 7cdf1fe..20d3d37 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -738,7 +738,7 @@ drop:
 static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct ip_tunnel *tunnel = netdev_priv(dev);
-	const struct iphdr  *old_iph = ip_hdr(skb);
+	const struct iphdr  *old_iph;
 	const struct iphdr  *tiph;
 	struct flowi4 fl4;
 	u8     tos;
@@ -752,9 +752,23 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
 	int    mtu;
 	u8     ttl;
 
-	if (skb->ip_summed == CHECKSUM_PARTIAL &&
-	    skb_checksum_help(skb))
-		goto tx_error;
+	if (skb->ip_summed == CHECKSUM_PARTIAL) {
+		int err;
+
+		/* Pages aren't locked and could change at any time.
+		 * If this happens after we compute the checksum, the
+		 * checksum will be wrong.  We linearize now to avoid
+		 * this problem.
+		 */
+		err = __skb_linearize(skb);
+		if (unlikely(err))
+			goto tx_error;
+
+		err = skb_checksum_help(skb);
+		if (unlikely(err))
+			goto tx_error;
+	}
+	old_iph = ip_hdr(skb);
 
 	if (dev->type == ARPHRD_ETHER)
 		IPCB(skb)->flags = 0;
-- 
1.7.10

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

end of thread, other threads:[~2013-01-23  5:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 21:20 [PATCH 2/2] IP_GRE: Linearize skb before csum Pravin B Shelar
2013-01-22 22:03 ` Eric Dumazet
2013-01-22 22:08   ` David Miller
2013-01-22 22:15     ` Eric Dumazet
2013-01-22 22:30       ` Pravin Shelar
2013-01-22 22:38       ` Jesse Gross
2013-01-22 22:44         ` Eric Dumazet
2013-01-23  0:41           ` David Miller
2013-01-23  1:08             ` Eric Dumazet
2013-01-23  1:46               ` David Miller
2013-01-23  4:22                 ` David Miller
2013-01-23  5:02                   ` Eric Dumazet
2013-01-23  5:19                     ` David Miller
2013-01-23  5:30                       ` Eric Dumazet
2013-01-23  5:36                         ` David Miller

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).