aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-04-20 00:35:00 -0400
committerDavid S. Miller <davem@davemloft.net>2006-04-20 00:35:00 -0400
commitb60b49ea6a3e1f8dcaf4148dad0daab61ab766d2 (patch)
tree83a18b5188d632692da34f9ed8265fcecb4d9f35 /net
parentd47f3640fe2ac4da8a8e713a549e6eaf23ac2084 (diff)
[TCP]: Account skb overhead in tcp_fragment
Make sure that we get the full sizeof(struct sk_buff) plus the data size accounted for in skb->truesize. This will create invariants that will allow adding assertion checks on skb->truesize. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_output.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 44df1db726a3..a28ae593b976 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -533,6 +533,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
533 struct tcp_sock *tp = tcp_sk(sk); 533 struct tcp_sock *tp = tcp_sk(sk);
534 struct sk_buff *buff; 534 struct sk_buff *buff;
535 int nsize, old_factor; 535 int nsize, old_factor;
536 int nlen;
536 u16 flags; 537 u16 flags;
537 538
538 BUG_ON(len > skb->len); 539 BUG_ON(len > skb->len);
@@ -552,8 +553,10 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
552 if (buff == NULL) 553 if (buff == NULL)
553 return -ENOMEM; /* We'll just try again later. */ 554 return -ENOMEM; /* We'll just try again later. */
554 555
555 buff->truesize = skb->len - len; 556 sk_charge_skb(sk, buff);
556 skb->truesize -= buff->truesize; 557 nlen = skb->len - len - nsize;
558 buff->truesize += nlen;
559 skb->truesize -= nlen;
557 560
558 /* Correct the sequence numbers. */ 561 /* Correct the sequence numbers. */
559 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len; 562 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
@@ -1039,7 +1042,8 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
1039 if (unlikely(buff == NULL)) 1042 if (unlikely(buff == NULL))
1040 return -ENOMEM; 1043 return -ENOMEM;
1041 1044
1042 buff->truesize = nlen; 1045 sk_charge_skb(sk, buff);
1046 buff->truesize += nlen;
1043 skb->truesize -= nlen; 1047 skb->truesize -= nlen;
1044 1048
1045 /* Correct the sequence numbers. */ 1049 /* Correct the sequence numbers. */