All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net] tcp: consider recv buf for the initial window scale
@ 2016-07-29 13:34 Soheil Hassas Yeganeh
  2016-07-29 13:39 ` Neal Cardwell
  2016-07-31  4:22 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Soheil Hassas Yeganeh @ 2016-07-29 13:34 UTC (permalink / raw)
  To: davem, netdev; +Cc: edumazet, ycheng, ncardwell, Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

tcp_select_initial_window() intends to advertise a window
scaling for the maximum possible window size. To do so,
it considers the maximum of net.ipv4.tcp_rmem[2] and
net.core.rmem_max as the only possible upper-bounds.
However, users with CAP_NET_ADMIN can use SO_RCVBUFFORCE
to set the socket's receive buffer size to values
larger than net.ipv4.tcp_rmem[2] and net.core.rmem_max.
Thus, SO_RCVBUFFORCE is effectively ignored by
tcp_select_initial_window().

To fix this, consider the maximum of net.ipv4.tcp_rmem[2],
net.core.rmem_max and socket's initial buffer space.

Fixes: b0573dea1fb3 ("[NET]: Introduce SO_{SND,RCV}BUFFORCE socket options")
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Suggested-by: Neal Cardwell <ncardwell@google.com>
---
 net/ipv4/tcp_output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index b26aa87..bdaef7f 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -236,7 +236,8 @@ void tcp_select_initial_window(int __space, __u32 mss,
 		/* Set window scaling on max possible window
 		 * See RFC1323 for an explanation of the limit to 14
 		 */
-		space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max);
+		space = max_t(u32, space, sysctl_tcp_rmem[2]);
+		space = max_t(u32, space, sysctl_rmem_max);
 		space = min_t(u32, space, *window_clamp);
 		while (space > 65535 && (*rcv_wscale) < 14) {
 			space >>= 1;
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] tcp: consider recv buf for the initial window scale
  2016-07-29 13:34 [PATCH v2 net] tcp: consider recv buf for the initial window scale Soheil Hassas Yeganeh
@ 2016-07-29 13:39 ` Neal Cardwell
  2016-07-31  4:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Neal Cardwell @ 2016-07-29 13:39 UTC (permalink / raw)
  To: Soheil Hassas Yeganeh
  Cc: David Miller, Netdev, Eric Dumazet, Yuchung Cheng, Soheil Hassas Yeganeh

On Fri, Jul 29, 2016 at 9:34 AM, Soheil Hassas Yeganeh
<soheil.kdev@gmail.com> wrote:
> To fix this, consider the maximum of net.ipv4.tcp_rmem[2],
> net.core.rmem_max and socket's initial buffer space.
>
> Fixes: b0573dea1fb3 ("[NET]: Introduce SO_{SND,RCV}BUFFORCE socket options")
> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
> Suggested-by: Neal Cardwell <ncardwell@google.com>

Acked-by: Neal Cardwell <ncardwell@google.com>

Thanks, Soheil.

neal

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] tcp: consider recv buf for the initial window scale
  2016-07-29 13:34 [PATCH v2 net] tcp: consider recv buf for the initial window scale Soheil Hassas Yeganeh
  2016-07-29 13:39 ` Neal Cardwell
@ 2016-07-31  4:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-07-31  4:22 UTC (permalink / raw)
  To: soheil.kdev; +Cc: netdev, edumazet, ycheng, ncardwell, soheil

From: Soheil Hassas Yeganeh <soheil.kdev@gmail.com>
Date: Fri, 29 Jul 2016 09:34:02 -0400

> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> tcp_select_initial_window() intends to advertise a window
> scaling for the maximum possible window size. To do so,
> it considers the maximum of net.ipv4.tcp_rmem[2] and
> net.core.rmem_max as the only possible upper-bounds.
> However, users with CAP_NET_ADMIN can use SO_RCVBUFFORCE
> to set the socket's receive buffer size to values
> larger than net.ipv4.tcp_rmem[2] and net.core.rmem_max.
> Thus, SO_RCVBUFFORCE is effectively ignored by
> tcp_select_initial_window().
> 
> To fix this, consider the maximum of net.ipv4.tcp_rmem[2],
> net.core.rmem_max and socket's initial buffer space.
> 
> Fixes: b0573dea1fb3 ("[NET]: Introduce SO_{SND,RCV}BUFFORCE socket options")
> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
> Suggested-by: Neal Cardwell <ncardwell@google.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-31  4:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-29 13:34 [PATCH v2 net] tcp: consider recv buf for the initial window scale Soheil Hassas Yeganeh
2016-07-29 13:39 ` Neal Cardwell
2016-07-31  4:22 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.