Thread (12 messages) flat view 12 messages, 2 authors, 2021-01-12
STALE2047d

[PATCH net-next 3/4] tcp: consistently account for overhead in rcv_wscale calculation

From: Heath Caldwell <hidden>
Date: 2021-01-12 00:36:33
Subsystem: networking [general], networking [tcp], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neal Cardwell, Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help