Hide the unfortunate named sysctl kern.ipc.somaxconn from sysctl -a

output and replace it with a new visible sysctl kern.ipc.acceptqueue
of the same functionality.  It specifies the maximum length of the
accept queue on a listen socket.

The old kern.ipc.somaxconn remains available for reading and writing
for compatibility reasons so that existing programs, scripts and
configurations continue to work.  There no plans to ever remove the
orginal and now hidden kern.ipc.somaxconn.
This commit is contained in:
Andre Oppermann 2012-10-20 12:53:14 +00:00
parent 4cf9e21ed8
commit 2bdf61ca29
2 changed files with 25 additions and 5 deletions

View file

@ -28,7 +28,7 @@
.\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93 .\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd August 29, 2005 .Dd October 20, 2012
.Dt LISTEN 2 .Dt LISTEN 2
.Os .Os
.Sh NAME .Sh NAME
@ -102,15 +102,15 @@ of service attacks are no longer necessary.
The The
.Xr sysctl 3 .Xr sysctl 3
MIB variable MIB variable
.Va kern.ipc.somaxconn .Va kern.ipc.soacceptqueue
specifies a hard limit on specifies a hard limit on
.Fa backlog ; .Fa backlog ;
if a value greater than if a value greater than
.Va kern.ipc.somaxconn .Va kern.ipc.soacceptqueue
or less than zero is specified, or less than zero is specified,
.Fa backlog .Fa backlog
is silently forced to is silently forced to
.Va kern.ipc.somaxconn . .Va kern.ipc.soacceptqueue .
.Sh INTERACTION WITH ACCEPT FILTERS .Sh INTERACTION WITH ACCEPT FILTERS
When accept filtering is used on a socket, a second queue will When accept filtering is used on a socket, a second queue will
be used to hold sockets that have connected, but have not yet be used to hold sockets that have connected, but have not yet
@ -168,3 +168,17 @@ at run-time, and to use a negative
.Fa backlog .Fa backlog
to request the maximum allowable value, was introduced in to request the maximum allowable value, was introduced in
.Fx 2.2 . .Fx 2.2 .
The
.Va kern.ipc.somaxconn
.Xr sysctl 3
has been replaced with
.Va kern.ipc.soacceptqueue
in
.Fx 10.0
to prevent confusion its actual functionality.
The original
.Xr sysctl 3
.Va kern.ipc.somaxconn
is still available but hidden from a
.Xr sysctl 3
-a output so that existing applications and scripts continue to work.

View file

@ -185,6 +185,8 @@ MALLOC_DEFINE(M_PCB, "pcb", "protocol control block");
/* /*
* Limit on the number of connections in the listen queue waiting * Limit on the number of connections in the listen queue waiting
* for accept(2). * for accept(2).
* NB: The orginal sysctl somaxconn is still available but hidden
* to prevent confusion about the actually purpose of this number.
*/ */
static int somaxconn = SOMAXCONN; static int somaxconn = SOMAXCONN;
@ -205,9 +207,13 @@ sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
somaxconn = val; somaxconn = val;
return (0); return (0);
} }
SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn, CTLTYPE_UINT | CTLFLAG_RW, SYSCTL_PROC(_kern_ipc, OID_AUTO, soacceptqueue, CTLTYPE_UINT | CTLFLAG_RW,
0, sizeof(int), sysctl_somaxconn, "I", 0, sizeof(int), sysctl_somaxconn, "I",
"Maximum listen socket pending connection accept queue size"); "Maximum listen socket pending connection accept queue size");
SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn,
CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_SKIP,
0, sizeof(int), sysctl_somaxconn, "I",
"Maximum listen socket pending connection accept queue size (compat)");
static int numopensockets; static int numopensockets;
SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD, SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD,