diff options
-rw-r--r-- | include/linux/socket.h | 1 | ||||
-rw-r--r-- | include/net/net_namespace.h | 1 | ||||
-rw-r--r-- | net/core/sysctl_net_core.c | 4 | ||||
-rw-r--r-- | net/socket.c | 8 |
4 files changed, 8 insertions, 6 deletions
diff --git a/include/linux/socket.h b/include/linux/socket.h index eb5bdd59a644..bd2b30a74e76 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
@@ -24,7 +24,6 @@ struct __kernel_sockaddr_storage { | |||
24 | #include <linux/types.h> /* pid_t */ | 24 | #include <linux/types.h> /* pid_t */ |
25 | #include <linux/compiler.h> /* __user */ | 25 | #include <linux/compiler.h> /* __user */ |
26 | 26 | ||
27 | extern int sysctl_somaxconn; | ||
28 | #ifdef CONFIG_PROC_FS | 27 | #ifdef CONFIG_PROC_FS |
29 | struct seq_file; | 28 | struct seq_file; |
30 | extern void socket_seq_show(struct seq_file *seq); | 29 | extern void socket_seq_show(struct seq_file *seq); |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index d5936115d972..b62e31fca474 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -39,6 +39,7 @@ struct net { | |||
39 | 39 | ||
40 | /* core sysctls */ | 40 | /* core sysctls */ |
41 | struct ctl_table_header *sysctl_core_hdr; | 41 | struct ctl_table_header *sysctl_core_hdr; |
42 | int sysctl_somaxconn; | ||
42 | 43 | ||
43 | /* List of all packet sockets. */ | 44 | /* List of all packet sockets. */ |
44 | rwlock_t packet_sklist_lock; | 45 | rwlock_t packet_sklist_lock; |
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index dc4cf7dda9d1..130338f83ae5 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c | |||
@@ -127,7 +127,7 @@ static struct ctl_table net_core_table[] = { | |||
127 | { | 127 | { |
128 | .ctl_name = NET_CORE_SOMAXCONN, | 128 | .ctl_name = NET_CORE_SOMAXCONN, |
129 | .procname = "somaxconn", | 129 | .procname = "somaxconn", |
130 | .data = &sysctl_somaxconn, | 130 | .data = &init_net.sysctl_somaxconn, |
131 | .maxlen = sizeof(int), | 131 | .maxlen = sizeof(int), |
132 | .mode = 0644, | 132 | .mode = 0644, |
133 | .proc_handler = &proc_dointvec | 133 | .proc_handler = &proc_dointvec |
@@ -161,6 +161,8 @@ static __net_init int sysctl_core_net_init(struct net *net) | |||
161 | { | 161 | { |
162 | struct ctl_table *tbl, *tmp; | 162 | struct ctl_table *tbl, *tmp; |
163 | 163 | ||
164 | net->sysctl_somaxconn = SOMAXCONN; | ||
165 | |||
164 | tbl = net_core_table; | 166 | tbl = net_core_table; |
165 | if (net != &init_net) { | 167 | if (net != &init_net) { |
166 | tbl = kmemdup(tbl, sizeof(net_core_table), GFP_KERNEL); | 168 | tbl = kmemdup(tbl, sizeof(net_core_table), GFP_KERNEL); |
diff --git a/net/socket.c b/net/socket.c index 9ebca5c695d6..7651de008502 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1365,17 +1365,17 @@ asmlinkage long sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen) | |||
1365 | * ready for listening. | 1365 | * ready for listening. |
1366 | */ | 1366 | */ |
1367 | 1367 | ||
1368 | int sysctl_somaxconn __read_mostly = SOMAXCONN; | ||
1369 | |||
1370 | asmlinkage long sys_listen(int fd, int backlog) | 1368 | asmlinkage long sys_listen(int fd, int backlog) |
1371 | { | 1369 | { |
1372 | struct socket *sock; | 1370 | struct socket *sock; |
1373 | int err, fput_needed; | 1371 | int err, fput_needed; |
1372 | int somaxconn; | ||
1374 | 1373 | ||
1375 | sock = sockfd_lookup_light(fd, &err, &fput_needed); | 1374 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
1376 | if (sock) { | 1375 | if (sock) { |
1377 | if ((unsigned)backlog > sysctl_somaxconn) | 1376 | somaxconn = sock->sk->sk_net->sysctl_somaxconn; |
1378 | backlog = sysctl_somaxconn; | 1377 | if ((unsigned)backlog > somaxconn) |
1378 | backlog = somaxconn; | ||
1379 | 1379 | ||
1380 | err = security_socket_listen(sock, backlog); | 1380 | err = security_socket_listen(sock, backlog); |
1381 | if (!err) | 1381 | if (!err) |