use sysctl to adjust SOMAXCONN
Subsystems (3)
PATCH 1/1 use sysctl to adjust SOMAXCONN
This patch allows the effective SOMAXCONN value to be adjusted by sysctl, as net.core.listen_max. The user-space value remains fixed at the current value of 128, so this should not affect the behavior of applications by default. A value larger than 128 is sometimes useful for benchmarking purposes, when lots of new TCP connections are established at once.
-- kolya
net/socket.c renamed from net/socket.c.orig +3 -2
@@ -1055,14 +1055,15 @@* ready for listening. */ +int sysctl_listen_max =SOMAXCONN ;asmlinkage long sys_listen (int fd,int backlog) {struct socket *sock;int err;if ((sock =sockfd_lookup (fd, &err)) !=NULL ) { -if ((unsigned ) backlog >SOMAXCONN ) - backlog =SOMAXCONN ; +if ((unsigned ) backlog > sysctl_listen_max) + backlog = sysctl_listen_max; err=sock->ops->listen (sock, backlog);sockfd_put (sock); }
net/core/sysctl_net_core.c renamed from net/core/sysctl_net_core.c.orig +4 -0
@@ -29,6 +29,7 @@extern int sysctl_core_destroy_delay;extern int sysctl_optmem_max;extern int sysctl_hot_list_len; +extern int sysctl_listen_max;#ifdef CONFIG_NET_DIVERT extern char sysctl_divert_version[];
@@ -88,6 +89,9 @@ (void *)sysctl_divert_version, 32, 0444, NULL, &proc_dostring}, #endif /* CONFIG_NET_DIVERT */ + {NET_CORE_LISTEN_MAX, "listen_max", + &sysctl_listen_max, sizeof(int), 0644, NULL, + &proc_dointvec}, #endif /* CONFIG_NET */ { 0 } };
include/linux/sysctl.h renamed from include/linux/sysctl.h.orig +2 -1
@@ -203,7 +203,8 @@NET_CORE_NO_CONG =14 ,NET_CORE_LO_CONG =15 ,NET_CORE_MOD_CONG =16 , - NET_CORE_DEV_WEIGHT=17 +NET_CORE_DEV_WEIGHT =17 , + NET_CORE_LISTEN_MAX=18 };/* /proc/sys/net/ethernet */