public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Anders K. Pedersen" <akp@cohaesio.com>
To: linux-kernel@vger.kernel.org
Subject: setsockopt() doubles SO_RCVBUF
Date: Mon, 26 Aug 2002 15:31:34 +0200	[thread overview]
Message-ID: <3D6A2DB6.E7DE78DD@cohaesio.com> (raw)

Hello,

In a project, I'm working on, I need to set the socket receive buffer
size, so I used
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, ...). To make sure, it worked
properly, I read the size back with getsockopt(fd, SOL_SOCKET,
SO_RCVBUF, ...). I was surprised to find, that the value read back was
always twice the size of, what I (tried to) set it to - up to twice the
size of rmem_max.

I found the cause of this behaviour in net/core/sock.c, which contains
the following lines of code in sock_setsockopt:

                case SO_RCVBUF:
                        /* Don't error on this BSD doesn't and if you
think
                           about it this is right. Otherwise apps have
to
                           play 'guess the biggest size' games.
RCVBUF/SNDBUF
                           are treated in BSD as hints */
                          
                        if (val > sysctl_rmem_max)
                                val = sysctl_rmem_max;

                        sk->userlocks |= SOCK_RCVBUF_LOCK;
                        /* FIXME: is this lower bound the right one? */
                        if ((val * 2) < SOCK_MIN_RCVBUF)
                                sk->rcvbuf = SOCK_MIN_RCVBUF;
                        else
                                sk->rcvbuf = (val * 2);
                        break;

Is it intentional, that val is doubled?

Regards,
Anders K. Pedersen

             reply	other threads:[~2002-08-26 13:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-26 13:31 Anders K. Pedersen [this message]
2002-08-27  7:54 ` setsockopt() doubles SO_RCVBUF Chris Wedgwood

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=3D6A2DB6.E7DE78DD@cohaesio.com \
    --to=akp@cohaesio.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox