netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [TCP]: Fix truesize underflow
@ 2006-04-18 12:32 Herbert Xu
  2006-04-18 16:29 ` Ingo Oeser
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Herbert Xu @ 2006-04-18 12:32 UTC (permalink / raw)
  To: Boris B. Zhmurov, Phil Oester, Mark Nipper, David S. Miller,
	jesse.brandeburg, jrlundgren, cat, djani22, yoseph.basri, mykleb,
	olel, michal, chris, netdev, jesse.brandeburg, Andi Kleen,
	Jeff Garzik

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

Hi Dave:

You're absolutely right about there being a problem with the TSO packet
trimming code.  The cause of this lies in the tcp_fragment() function.

When we allocate a fragment for a completely non-linear packet the
truesize is calculated for a payload length of zero.  This means that
truesize could in fact be less than the real payload length.

When that happens the TSO packet trimming can cause truesize to become
negative.  This in turn can cause sk_forward_alloc to be -n * PAGE_SIZE
which would trigger the warning.

I've copied the code you used in tso_fragment which should work here.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Everyone who's having the sk_forward_alloc warning problem should give
this patch a go to see if it cures things.

Just in case this still doesn't fix it, could everyone please also verify
whether disabling SMP has any effect on reproducing this?

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: tcp-fragment.patch --]
[-- Type: text/plain, Size: 484 bytes --]

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index b871db6..44df1db 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -551,7 +551,9 @@
 	buff = sk_stream_alloc_skb(sk, nsize, GFP_ATOMIC);
 	if (buff == NULL)
 		return -ENOMEM; /* We'll just try again later. */
-	sk_charge_skb(sk, buff);
+
+	buff->truesize = skb->len - len;
+	skb->truesize -= buff->truesize;
 
 	/* Correct the sequence numbers. */
 	TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;

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

end of thread, other threads:[~2006-04-19 21:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-18 12:32 [TCP]: Fix truesize underflow Herbert Xu
2006-04-18 16:29 ` Ingo Oeser
2006-04-18 20:19   ` David S. Miller
2006-04-18 20:22 ` David S. Miller
2006-04-18 23:27   ` Herbert Xu
2006-04-19  6:04     ` Boris B. Zhmurov
2006-04-19  6:40       ` Herbert Xu
2006-04-19 16:07       ` Jesse Brandeburg
2006-04-19 21:29         ` Krzysztof Oledzki
2006-04-19 16:53 ` Stephen Hemminger
2006-04-19 20:07   ` David S. 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).