All of lore.kernel.org
 help / color / mirror / Atom feed
From: fgao@ikuai8.com
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: gfree.wind@gmail.com, Gao Feng <fgao@ikuai8.com>
Subject: [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value
Date: Wed,  8 Feb 2017 21:07:15 +0800	[thread overview]
Message-ID: <1486559235-13633-1-git-send-email-fgao@ikuai8.com> (raw)

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

             reply	other threads:[~2017-02-08 13:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 13:07 fgao [this message]
2017-02-08 16:00 ` [PATCH net 1/1] net: sock: Use double send/recv buff value to compare with max value 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486559235-13633-1-git-send-email-fgao@ikuai8.com \
    --to=fgao@ikuai8.com \
    --cc=davem@davemloft.net \
    --cc=gfree.wind@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.