* [TCP]: Account skb overhead in tcp_fragment
@ 2006-04-20 1:01 Herbert Xu
2006-04-20 3:26 ` Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2006-04-20 1:01 UTC (permalink / raw)
To: David S. Miller, netdev
[-- Attachment #1: Type: text/plain, Size: 536 bytes --]
Hi Dave:
Since sk_stream_alloc_pskb takes an extra argument that accounts for
paged data all we need to do to account sk_buff overhead correctly
is to use that instead of sk_stream_alloc_skb.
This patch does just that for both tcp_fragment and tso_fragment.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
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-charge.patch --]
[-- Type: text/plain, Size: 1062 bytes --]
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 44df1db..fb40d32 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -548,12 +548,10 @@
return -ENOMEM;
/* Get a new skb... force flag on. */
- buff = sk_stream_alloc_skb(sk, nsize, GFP_ATOMIC);
+ buff = sk_stream_alloc_pskb(sk, nsize, skb->len - len - nsize, GFP_ATOMIC);
if (buff == NULL)
return -ENOMEM; /* We'll just try again later. */
-
- buff->truesize = skb->len - len;
- skb->truesize -= buff->truesize;
+ sk_charge_skb(sk, buff);
/* Correct the sequence numbers. */
TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
@@ -1035,12 +1033,10 @@
if (skb->len != skb->data_len)
return tcp_fragment(sk, skb, len, mss_now);
- buff = sk_stream_alloc_pskb(sk, 0, 0, GFP_ATOMIC);
+ buff = sk_stream_alloc_pskb(sk, 0, nlen, GFP_ATOMIC);
if (unlikely(buff == NULL))
return -ENOMEM;
-
- buff->truesize = nlen;
- skb->truesize -= nlen;
+ sk_charge_skb(sk, buff);
/* Correct the sequence numbers. */
TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [TCP]: Account skb overhead in tcp_fragment
2006-04-20 1:01 [TCP]: Account skb overhead in tcp_fragment Herbert Xu
@ 2006-04-20 3:26 ` Herbert Xu
2006-04-20 4:31 ` David S. Miller
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2006-04-20 3:26 UTC (permalink / raw)
To: David S. Miller, netdev
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]
On Thu, Apr 20, 2006 at 11:01:11AM +1000, herbert wrote:
> Hi Dave:
>
> Since sk_stream_alloc_pskb takes an extra argument that accounts for
> paged data all we need to do to account sk_buff overhead correctly
> is to use that instead of sk_stream_alloc_skb.
Here is a better version that does not double-count the paged bits
that get moved across.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
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-charge-2.patch --]
[-- Type: text/plain, Size: 890 bytes --]
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 44df1db..a28ae59 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -533,6 +533,7 @@
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *buff;
int nsize, old_factor;
+ int nlen;
u16 flags;
BUG_ON(len > skb->len);
@@ -552,8 +553,10 @@
if (buff == NULL)
return -ENOMEM; /* We'll just try again later. */
- buff->truesize = skb->len - len;
- skb->truesize -= buff->truesize;
+ sk_charge_skb(sk, buff);
+ nlen = skb->len - len - nsize;
+ buff->truesize += nlen;
+ skb->truesize -= nlen;
/* Correct the sequence numbers. */
TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
@@ -1039,7 +1042,8 @@
if (unlikely(buff == NULL))
return -ENOMEM;
- buff->truesize = nlen;
+ sk_charge_skb(sk, buff);
+ buff->truesize += nlen;
skb->truesize -= nlen;
/* Correct the sequence numbers. */
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [TCP]: Account skb overhead in tcp_fragment
2006-04-20 3:26 ` Herbert Xu
@ 2006-04-20 4:31 ` David S. Miller
0 siblings, 0 replies; 3+ messages in thread
From: David S. Miller @ 2006-04-20 4:31 UTC (permalink / raw)
To: herbert; +Cc: netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 20 Apr 2006 13:26:02 +1000
> On Thu, Apr 20, 2006 at 11:01:11AM +1000, herbert wrote:
> > Hi Dave:
> >
> > Since sk_stream_alloc_pskb takes an extra argument that accounts for
> > paged data all we need to do to account sk_buff overhead correctly
> > is to use that instead of sk_stream_alloc_skb.
>
> Here is a better version that does not double-count the paged bits
> that get moved across.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Looks good, I'll apply this.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-20 4:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-20 1:01 [TCP]: Account skb overhead in tcp_fragment Herbert Xu
2006-04-20 3:26 ` Herbert Xu
2006-04-20 4:31 ` 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