sysctl kern.ipc.somaxconn limit 65535 why?

Adrian Chadd adrian at freebsd.org
Wed Oct 3 20:06:12 UTC 2012


On 3 October 2012 13:01, Garrett Cooper <yanegomi at gmail.com> wrote:
>
> Here's where it's being held at 65535 (sys/kern/kern_uipc.c):
>
> 3276 static int
> 3277 sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
> 3278 {
> 3279         int error;
> 3280         int val;
> 3281
> 3282         val = somaxconn;
> 3283         error = sysctl_handle_int(oidp, &val, 0, req);
> 3284         if (error || !req->newptr )
> 3285                 return (error);
> 3286
> 3287         if (val < 1 || val > USHRT_MAX)
> 3288                 return (EINVAL);
> 3289
>
> More details about the need for this limit are in
> http://svnweb.freebsd.org/base?view=revision&revision=140730 .
>
> It looks like this needs to be enhanced to support more than
> USHRT_MAX, which will require socket structure changes and other fun
> things, but should be possible... I've CCed glebius for comment on
> this.

Again, somaxconn is _not the number of sockets_. It's the backlog
allowed in the incoming connection queue for a given socket. That's
it.

If you pass listen a backlog value of -1 or greater than somaxconn,
then the queue depth gets pinned at somaxconn.

There's something else going on..


Adrian


More information about the freebsd-current mailing list