diff options
author | Eric Dumazet <edumazet@google.com> | 2019-04-19 19:02:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-19 19:42:33 -0400 |
commit | d7cc399e1227e74e44f78847d9732a228b46cc91 (patch) | |
tree | d83b970c017bc2c96286be18e81e20dd43eaaf86 /net/ipv4/tcp.c | |
parent | 0a9798c123d0eee43e55cc9361b0c10314bb2250 (diff) |
tcp: properly reset skb->truesize for tx recycling
tcp sendmsg() and sendpage() normally advance skb->data_len
and skb->truesize by the payload added to an skb.
But sendmsg(fd, ..., MSG_ZEROCOPY) has to account for whole pages,
even if a single byte of payload is used in the page.
This means that we can not assume skb->truesize can be adjusted
by skb->data_len. We must instead overwrite its value.
Otherwise skb->truesize is too big and can hit socket sndbuf limit,
especially if the skb is recycled multiple times :/
Fixes: 472c2e07eef0 ("tcp: add one skb cache for tx")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 603e770d59b3..f7567a3698eb 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -868,7 +868,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, | |||
868 | if (likely(!size)) { | 868 | if (likely(!size)) { |
869 | skb = sk->sk_tx_skb_cache; | 869 | skb = sk->sk_tx_skb_cache; |
870 | if (skb && !skb_cloned(skb)) { | 870 | if (skb && !skb_cloned(skb)) { |
871 | skb->truesize -= skb->data_len; | 871 | skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); |
872 | sk->sk_tx_skb_cache = NULL; | 872 | sk->sk_tx_skb_cache = NULL; |
873 | pskb_trim(skb, 0); | 873 | pskb_trim(skb, 0); |
874 | INIT_LIST_HEAD(&skb->tcp_tsorted_anchor); | 874 | INIT_LIST_HEAD(&skb->tcp_tsorted_anchor); |