Index: uipc_socket.c =================================================================== --- uipc_socket.c (revision 317184) +++ uipc_socket.c (working copy) @@ -197,7 +197,8 @@ * NB: The original sysctl somaxconn is still available but hidden * to prevent confusion about the actual purpose of this number. */ -static u_int somaxconn = SOMAXCONN; +static VNET_DEFINE(u_int, somaxconn) = SOMAXCONN; +#define V_somaxconn VNET(somaxconn) static int sysctl_somaxconn(SYSCTL_HANDLER_ARGS) @@ -205,7 +206,7 @@ int error; int val; - val = somaxconn; + val = V_somaxconn; error = sysctl_handle_int(oidp, &val, 0, req); if (error || !req->newptr ) return (error); @@ -219,21 +220,25 @@ if (val < 1 || val > UINT_MAX / 3) return (EINVAL); - somaxconn = val; + V_somaxconn = val; return (0); } -SYSCTL_PROC(_kern_ipc, OID_AUTO, soacceptqueue, CTLTYPE_UINT | CTLFLAG_RW, +SYSCTL_PROC(_kern_ipc, OID_AUTO, soacceptqueue, + CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof(int), sysctl_somaxconn, "I", "Maximum listen socket pending connection accept queue size"); SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_SKIP, + CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_SKIP, 0, sizeof(int), sysctl_somaxconn, "I", "Maximum listen socket pending connection accept queue size (compat)"); -static int numopensockets; -SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD, - &numopensockets, 0, "Number of open sockets"); +static VNET_DEFINE(int, numopensockets); +#define V_numopensockets VNET(numopensockets) +SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, + CTLFLAG_VNET | CTLFLAG_RD, + &VNET_NAME(numopensockets), 0, "Number of open sockets"); + /* * accept_mtx locks down per-socket fields relating to accept queues. See * socketvar.h for an annotation of the protected fields of struct socket. @@ -242,7 +247,7 @@ MTX_SYSINIT(accept_mtx, &accept_mtx, "accept", MTX_DEF); /* - * so_global_mtx protects so_gencnt, numopensockets, and the per-socket + * so_global_mtx protects so_gencnt, V_numopensockets, and the per-socket * so_gencnt field. */ static struct mtx so_global_mtx; @@ -414,7 +419,7 @@ } mtx_lock(&so_global_mtx); so->so_gencnt = ++so_gencnt; - ++numopensockets; + ++V_numopensockets; #ifdef VIMAGE vnet->vnet_sockcnt++; #endif @@ -437,7 +442,7 @@ mtx_lock(&so_global_mtx); so->so_gencnt = ++so_gencnt; - --numopensockets; /* Could be below, but faster here. */ + --V_numopensockets; /* Could be below, but faster here. */ #ifdef VIMAGE VNET_ASSERT(so->so_vnet != NULL, ("%s:%d so_vnet is NULL, so=%p", __func__, __LINE__, so)); @@ -744,8 +749,8 @@ SOCK_LOCK_ASSERT(so); - if (backlog < 0 || backlog > somaxconn) - backlog = somaxconn; + if (backlog < 0 || backlog > V_somaxconn) + backlog = V_somaxconn; so->so_qlimit = backlog; so->so_options |= SO_ACCEPTCONN; }