tcp: use TCP_DEFAULT_INIT_RCVWND in tcp_fixup_rcvbuf()

Since commit 356f039822 (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 356f039822 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>
This commit is contained in:
Eric Dumazet 2011-10-20 16:53:56 -04:00 committed by David S. Miller
parent 30d3c128ea
commit e9266a02b7

View File

@ -345,17 +345,24 @@ static void tcp_grow_window(struct sock *sk, struct sk_buff *skb)
static void tcp_fixup_rcvbuf(struct sock *sk) static void tcp_fixup_rcvbuf(struct sock *sk)
{ {
struct tcp_sock *tp = tcp_sk(sk); u32 mss = tcp_sk(sk)->advmss;
int rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER); u32 icwnd = TCP_DEFAULT_INIT_RCVWND;
int rcvmem;
/* Try to select rcvbuf so that 4 mss-sized segments /* Limit to 10 segments if mss <= 1460,
* will fit to window and corresponding skbs will fit to our rcvbuf. * or 14600/mss segments, with a minimum of two segments.
* (was 3; 4 is minimum to allow fast retransmit to work.)
*/ */
while (tcp_win_from_space(rcvmem) < tp->advmss) if (mss > 1460)
icwnd = max_t(u32, (1460 * TCP_DEFAULT_INIT_RCVWND) / mss, 2);
rcvmem = SKB_TRUESIZE(mss + MAX_TCP_HEADER);
while (tcp_win_from_space(rcvmem) < mss)
rcvmem += 128; rcvmem += 128;
if (sk->sk_rcvbuf < 4 * rcvmem)
sk->sk_rcvbuf = min(4 * rcvmem, sysctl_tcp_rmem[2]); rcvmem *= icwnd;
if (sk->sk_rcvbuf < rcvmem)
sk->sk_rcvbuf = min(rcvmem, sysctl_tcp_rmem[2]);
} }
/* 4. Try to fixup all. It is made immediately after connection enters /* 4. Try to fixup all. It is made immediately after connection enters