View | Details | Raw Unified | Return to bug 219655
Collapse All | Expand All

(-)uipc_socket.c (-13 / +18 lines)
Lines 197-203 Link Here
197
 * NB: The original sysctl somaxconn is still available but hidden
197
 * NB: The original sysctl somaxconn is still available but hidden
198
 * to prevent confusion about the actual purpose of this number.
198
 * to prevent confusion about the actual purpose of this number.
199
 */
199
 */
200
static u_int somaxconn = SOMAXCONN;
200
static VNET_DEFINE(u_int, somaxconn) = SOMAXCONN;
201
#define	V_somaxconn		VNET(somaxconn)
201
202
202
static int
203
static int
203
sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
204
sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
Lines 205-211 Link Here
205
	int error;
206
	int error;
206
	int val;
207
	int val;
207
208
208
	val = somaxconn;
209
	val = V_somaxconn;
209
	error = sysctl_handle_int(oidp, &val, 0, req);
210
	error = sysctl_handle_int(oidp, &val, 0, req);
210
	if (error || !req->newptr )
211
	if (error || !req->newptr )
211
		return (error);
212
		return (error);
Lines 219-239 Link Here
219
	if (val < 1 || val > UINT_MAX / 3)
220
	if (val < 1 || val > UINT_MAX / 3)
220
		return (EINVAL);
221
		return (EINVAL);
221
222
222
	somaxconn = val;
223
	V_somaxconn = val;
223
	return (0);
224
	return (0);
224
}
225
}
225
SYSCTL_PROC(_kern_ipc, OID_AUTO, soacceptqueue, CTLTYPE_UINT | CTLFLAG_RW,
226
SYSCTL_PROC(_kern_ipc, OID_AUTO, soacceptqueue,
227
    CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
226
    0, sizeof(int), sysctl_somaxconn, "I",
228
    0, sizeof(int), sysctl_somaxconn, "I",
227
    "Maximum listen socket pending connection accept queue size");
229
    "Maximum listen socket pending connection accept queue size");
228
SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn,
230
SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn,
229
    CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_SKIP,
231
    CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_SKIP,
230
    0, sizeof(int), sysctl_somaxconn, "I",
232
    0, sizeof(int), sysctl_somaxconn, "I",
231
    "Maximum listen socket pending connection accept queue size (compat)");
233
    "Maximum listen socket pending connection accept queue size (compat)");
232
234
233
static int numopensockets;
235
static VNET_DEFINE(int, numopensockets);
234
SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD,
236
#define	V_numopensockets		VNET(numopensockets)
235
    &numopensockets, 0, "Number of open sockets");
236
237
238
SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets,
239
    CTLFLAG_VNET | CTLFLAG_RD,
240
    &VNET_NAME(numopensockets), 0, "Number of open sockets");
241
237
/*
242
/*
238
 * accept_mtx locks down per-socket fields relating to accept queues.  See
243
 * accept_mtx locks down per-socket fields relating to accept queues.  See
239
 * socketvar.h for an annotation of the protected fields of struct socket.
244
 * socketvar.h for an annotation of the protected fields of struct socket.
Lines 242-248 Link Here
242
MTX_SYSINIT(accept_mtx, &accept_mtx, "accept", MTX_DEF);
247
MTX_SYSINIT(accept_mtx, &accept_mtx, "accept", MTX_DEF);
243
248
244
/*
249
/*
245
 * so_global_mtx protects so_gencnt, numopensockets, and the per-socket
250
 * so_global_mtx protects so_gencnt, V_numopensockets, and the per-socket
246
 * so_gencnt field.
251
 * so_gencnt field.
247
 */
252
 */
248
static struct mtx so_global_mtx;
253
static struct mtx so_global_mtx;
Lines 414-420 Link Here
414
	}
419
	}
415
	mtx_lock(&so_global_mtx);
420
	mtx_lock(&so_global_mtx);
416
	so->so_gencnt = ++so_gencnt;
421
	so->so_gencnt = ++so_gencnt;
417
	++numopensockets;
422
	++V_numopensockets;
418
#ifdef VIMAGE
423
#ifdef VIMAGE
419
	vnet->vnet_sockcnt++;
424
	vnet->vnet_sockcnt++;
420
#endif
425
#endif
Lines 437-443 Link Here
437
442
438
	mtx_lock(&so_global_mtx);
443
	mtx_lock(&so_global_mtx);
439
	so->so_gencnt = ++so_gencnt;
444
	so->so_gencnt = ++so_gencnt;
440
	--numopensockets;	/* Could be below, but faster here. */
445
	--V_numopensockets;	/* Could be below, but faster here. */
441
#ifdef VIMAGE
446
#ifdef VIMAGE
442
	VNET_ASSERT(so->so_vnet != NULL, ("%s:%d so_vnet is NULL, so=%p",
447
	VNET_ASSERT(so->so_vnet != NULL, ("%s:%d so_vnet is NULL, so=%p",
443
	    __func__, __LINE__, so));
448
	    __func__, __LINE__, so));
Lines 744-751 Link Here
744
749
745
	SOCK_LOCK_ASSERT(so);
750
	SOCK_LOCK_ASSERT(so);
746
751
747
	if (backlog < 0 || backlog > somaxconn)
752
	if (backlog < 0 || backlog > V_somaxconn)
748
		backlog = somaxconn;
753
		backlog = V_somaxconn;
749
	so->so_qlimit = backlog;
754
	so->so_qlimit = backlog;
750
	so->so_options |= SO_ACCEPTCONN;
755
	so->so_options |= SO_ACCEPTCONN;
751
}
756
}

Return to bug 219655