All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value
@ 2017-02-08 13:07 fgao
  2017-02-08 16:00 ` Eric Dumazet
  2017-02-15  1:46   ` [LTP] " kernel test robot
  0 siblings, 2 replies; 9+ messages in thread
From: fgao @ 2017-02-08 13:07 UTC (permalink / raw)
  To: davem, netdev; +Cc: gfree.wind, Gao Feng

From: Gao Feng <fgao@ikuai8.com>

Because the value of SO_SNDBUF and SO_RCVBUF is doubled before
assignment, so the real value of send and recv buffer could be more
than the max sysctl config sysctl_wmem_max and sysctl_rmem_max.

Now use doulbe send/recv buffer value to compare with sysctl_wmem_max
and sysctl_rmem_max, and it keeps consistence with SOCK_MIN_SNDBUF
and SOCK_MIN_RCVBUF.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
 net/core/sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 4eca27d..fa40dff 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -712,7 +712,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 		 * play 'guess the biggest size' games. RCVBUF/SNDBUF
 		 * are treated in BSD as hints
 		 */
-		val = min_t(u32, val, sysctl_wmem_max);
+		val = min_t(u32, val * 2, sysctl_wmem_max);
 set_sndbuf:
 		sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
 		sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF);
@@ -733,7 +733,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 		 * play 'guess the biggest size' games. RCVBUF/SNDBUF
 		 * are treated in BSD as hints
 		 */
-		val = min_t(u32, val, sysctl_rmem_max);
+		val = min_t(u32, val * 2, sysctl_rmem_max);
 set_rcvbuf:
 		sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
 		/*
-- 
1.9.1

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

end of thread, other threads:[~2017-02-15  2:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08 13:07 [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value fgao
2017-02-08 16:00 ` Eric Dumazet
2017-02-09  9:08   ` Gao Feng
2017-02-09 14:34     ` Eric Dumazet
2017-02-15  1:46 ` [lkp-robot] [net] 0148239373: ltp.test_1_to_1_sockopt.fail kernel test robot
2017-02-15  1:46   ` kernel test robot
2017-02-15  1:46   ` [LTP] " kernel test robot
2017-02-15  2:02   ` Gao Feng
2017-02-15  2:02     ` [LTP] " Gao Feng

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.