]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.114/tcp-tcp_grow_window-needs-to-respect-tcp_space.patch
Linux 4.14.114
[thirdparty/kernel/stable-queue.git] / releases / 4.14.114 / tcp-tcp_grow_window-needs-to-respect-tcp_space.patch
1 From foo@baz Tue 23 Apr 2019 05:18:29 PM CEST
2 From: Eric Dumazet <edumazet@google.com>
3 Date: Tue, 16 Apr 2019 10:55:20 -0700
4 Subject: tcp: tcp_grow_window() needs to respect tcp_space()
5
6 From: Eric Dumazet <edumazet@google.com>
7
8 [ Upstream commit 50ce163a72d817a99e8974222dcf2886d5deb1ae ]
9
10 For some reason, tcp_grow_window() correctly tests if enough room
11 is present before attempting to increase tp->rcv_ssthresh,
12 but does not prevent it to grow past tcp_space()
13
14 This is causing hard to debug issues, like failing
15 the (__tcp_select_window(sk) >= tp->rcv_wnd) test
16 in __tcp_ack_snd_check(), causing ACK delays and possibly
17 slow flows.
18
19 Depending on tcp_rmem[2], MTU, skb->len/skb->truesize ratio,
20 we can see the problem happening on "netperf -t TCP_RR -- -r 2000,2000"
21 after about 60 round trips, when the active side no longer sends
22 immediate acks.
23
24 This bug predates git history.
25
26 Signed-off-by: Eric Dumazet <edumazet@google.com>
27 Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
28 Acked-by: Neal Cardwell <ncardwell@google.com>
29 Acked-by: Wei Wang <weiwan@google.com>
30 Signed-off-by: David S. Miller <davem@davemloft.net>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 ---
33 net/ipv4/tcp_input.c | 10 +++++-----
34 1 file changed, 5 insertions(+), 5 deletions(-)
35
36 --- a/net/ipv4/tcp_input.c
37 +++ b/net/ipv4/tcp_input.c
38 @@ -389,11 +389,12 @@ static int __tcp_grow_window(const struc
39 static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb)
40 {
41 struct tcp_sock *tp = tcp_sk(sk);
42 + int room;
43 +
44 + room = min_t(int, tp->window_clamp, tcp_space(sk)) - tp->rcv_ssthresh;
45
46 /* Check #1 */
47 - if (tp->rcv_ssthresh < tp->window_clamp &&
48 - (int)tp->rcv_ssthresh < tcp_space(sk) &&
49 - !tcp_under_memory_pressure(sk)) {
50 + if (room > 0 && !tcp_under_memory_pressure(sk)) {
51 int incr;
52
53 /* Check #2. Increase window, if skb with such overhead
54 @@ -406,8 +407,7 @@ static void tcp_grow_window(struct sock
55
56 if (incr) {
57 incr = max_t(int, incr, 2 * skb->len);
58 - tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr,
59 - tp->window_clamp);
60 + tp->rcv_ssthresh += min(room, incr);
61 inet_csk(sk)->icsk_ack.quick |= 1;
62 }
63 }