diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-10-20 16:53:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-20 16:54:51 -0400 |
commit | e9266a02b7e6542355431955075b4e688962fc0a (patch) | |
tree | 931d80e4cf840fc9ed036a3406799a546dda0518 | |
parent | 30d3c128eafd2277ca2bb4b62845f25ad9295c12 (diff) |
tcp: use TCP_DEFAULT_INIT_RCVWND in tcp_fixup_rcvbuf()
Since commit 356f039822b (TCP: increase default initial receive
window.), we allow sender to send 10 (TCP_DEFAULT_INIT_RCVWND) segments.
Change tcp_fixup_rcvbuf() to reflect this change, even if no real change
is expected, since sysctl_tcp_rmem[1] = 87380 and this value
is bigger than tcp_fixup_rcvbuf() computed rcvmem (~23720)
Note: Since commit 356f039822b limited default window to maximum of
10*1460 and 2*MSS, we use same heuristic in this patch.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/tcp_input.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 1e848b26c2b9..e8e6d492f328 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -345,17 +345,24 @@ static void tcp_grow_window(struct sock *sk, struct sk_buff *skb) | |||
345 | 345 | ||
346 | static void tcp_fixup_rcvbuf(struct sock *sk) | 346 | static void tcp_fixup_rcvbuf(struct sock *sk) |
347 | { | 347 | { |
348 | struct tcp_sock *tp = tcp_sk(sk); | 348 | u32 mss = tcp_sk(sk)->advmss; |
349 | int rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER); | 349 | u32 icwnd = TCP_DEFAULT_INIT_RCVWND; |
350 | int rcvmem; | ||
350 | 351 | ||
351 | /* Try to select rcvbuf so that 4 mss-sized segments | 352 | /* Limit to 10 segments if mss <= 1460, |
352 | * will fit to window and corresponding skbs will fit to our rcvbuf. | 353 | * or 14600/mss segments, with a minimum of two segments. |
353 | * (was 3; 4 is minimum to allow fast retransmit to work.) | ||
354 | */ | 354 | */ |
355 | while (tcp_win_from_space(rcvmem) < tp->advmss) | 355 | if (mss > 1460) |
356 | icwnd = max_t(u32, (1460 * TCP_DEFAULT_INIT_RCVWND) / mss, 2); | ||
357 | |||
358 | rcvmem = SKB_TRUESIZE(mss + MAX_TCP_HEADER); | ||
359 | while (tcp_win_from_space(rcvmem) < mss) | ||
356 | rcvmem += 128; | 360 | rcvmem += 128; |
357 | if (sk->sk_rcvbuf < 4 * rcvmem) | 361 | |
358 | sk->sk_rcvbuf = min(4 * rcvmem, sysctl_tcp_rmem[2]); | 362 | rcvmem *= icwnd; |
363 | |||
364 | if (sk->sk_rcvbuf < rcvmem) | ||
365 | sk->sk_rcvbuf = min(rcvmem, sysctl_tcp_rmem[2]); | ||
359 | } | 366 | } |
360 | 367 | ||
361 | /* 4. Try to fixup all. It is made immediately after connection enters | 368 | /* 4. Try to fixup all. It is made immediately after connection enters |