Skip to content

Commit 78aa52d

Browse files
Roman Kaplgregkh
authored andcommitted
net: move somaxconn init from sysctl code
[ Upstream commit 7c3f187 ] The default value for somaxconn is set in sysctl_core_net_init(), but this function is not called when kernel is configured without CONFIG_SYSCTL. This results in the kernel not being able to accept TCP connections, because the backlog has zero size. Usually, the user ends up with: "TCP: request_sock_TCP: Possible SYN flooding on port 7. Dropping request. Check SNMP counters." If SYN cookies are not enabled the connection is rejected. Before ef547f2 (tcp: remove max_qlen_log), the effects were less severe, because the backlog was always at least eight slots long. Signed-off-by: Roman Kapl <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 87d96d1 commit 78aa52d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

net/core/net_namespace.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,25 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns)
310310
goto out;
311311
}
312312

313+
static int __net_init net_defaults_init_net(struct net *net)
314+
{
315+
net->core.sysctl_somaxconn = SOMAXCONN;
316+
return 0;
317+
}
318+
319+
static struct pernet_operations net_defaults_ops = {
320+
.init = net_defaults_init_net,
321+
};
322+
323+
static __init int net_defaults_init(void)
324+
{
325+
if (register_pernet_subsys(&net_defaults_ops))
326+
panic("Cannot initialize net default settings");
327+
328+
return 0;
329+
}
330+
331+
core_initcall(net_defaults_init);
313332

314333
#ifdef CONFIG_NET_NS
315334
static struct kmem_cache *net_cachep;

net/core/sysctl_net_core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ static __net_init int sysctl_core_net_init(struct net *net)
429429
{
430430
struct ctl_table *tbl;
431431

432-
net->core.sysctl_somaxconn = SOMAXCONN;
433-
434432
tbl = netns_core_table;
435433
if (!net_eq(net, &init_net)) {
436434
tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);

0 commit comments

Comments
 (0)