When calculating the window scale to use for the advertised window for a
TCP connection, adjust the size values used to extend the maximum possible
window value so that overhead is properly accounted. In other words:
convert the maximum value candidates from buffer size space into advertised
window space.
This adjustment keeps the scale of the maximum value consistent - that is,
keeps it in window space.
Without this adjustment, the window scale used could be larger than
necessary, reducing granularity for the advertised window.
Signed-off-by: Heath Caldwell <redacted>
---
net/ipv4/tcp_output.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index f322e798a351..1d2773cd02c8 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -240,8 +240,12 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss,
*rcv_wscale = 0;
if (wscale_ok) {
/* Set window scaling on max possible window */
- space = max_t(u32, space, sock_net(sk)->ipv4.sysctl_tcp_rmem[2]);
- space = max_t(u32, space, sysctl_rmem_max);
+ space = max_t(u32, space,
+ tcp_win_from_space(
+ sk,
+ sock_net(sk)->ipv4.sysctl_tcp_rmem[2]));
+ space = max_t(u32, space,
+ tcp_win_from_space(sk, sysctl_rmem_max));
space = min_t(u32, space, *window_clamp);
*rcv_wscale = clamp_t(int, ilog2(space) - 15,
0, TCP_MAX_WSCALE);--
2.28.0