Commit 65cfd027 authored by David S. Miller's avatar David S. Miller

[TCP]: Receive buffer moderation fixes.

1) Make window clamp follow receive buffer growth so it
   does not limit window advertisements.  Noticed by John
   Heffner and Stephen Hemminger.
2) Fix rcvmem calculation such that tcp_adv_win_scale is
   taken into account.
parent 104360f2
...@@ -463,6 +463,8 @@ void tcp_rcv_space_adjust(struct sock *sk) ...@@ -463,6 +463,8 @@ void tcp_rcv_space_adjust(struct sock *sk)
tp->rcvq_space.space = space; tp->rcvq_space.space = space;
if (sysctl_tcp_moderate_rcvbuf) { if (sysctl_tcp_moderate_rcvbuf) {
int new_clamp = space;
/* Receive space grows, normalize in order to /* Receive space grows, normalize in order to
* take into account packet headers and sk_buff * take into account packet headers and sk_buff
* structure overhead. * structure overhead.
...@@ -472,10 +474,16 @@ void tcp_rcv_space_adjust(struct sock *sk) ...@@ -472,10 +474,16 @@ void tcp_rcv_space_adjust(struct sock *sk)
space = 1; space = 1;
rcvmem = (tp->advmss + MAX_TCP_HEADER + rcvmem = (tp->advmss + MAX_TCP_HEADER +
16 + sizeof(struct sk_buff)); 16 + sizeof(struct sk_buff));
while (tcp_win_from_space(rcvmem) < tp->advmss)
rcvmem += 128;
space *= rcvmem; space *= rcvmem;
space = min(space, sysctl_tcp_rmem[2]); space = min(space, sysctl_tcp_rmem[2]);
if (space > sk->sk_rcvbuf) if (space > sk->sk_rcvbuf) {
sk->sk_rcvbuf = space; sk->sk_rcvbuf = space;
/* Make the window clamp follow along. */
tp->window_clamp = new_clamp;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment