Return-Path: Received: from mail-cys01nam02on0131.outbound.protection.outlook.com ([104.47.37.131]:49376 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966419AbeCSQJO (ORCPT ); Mon, 19 Mar 2018 12:09:14 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Roman Kapl , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 077/167] net: move somaxconn init from sysctl code Date: Mon, 19 Mar 2018 16:06:58 +0000 Message-ID: <20180319160513.16384-77-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Roman Kapl [ Upstream commit 7c3f1875c66fbc19762760097cabc91849ea0bbb ] 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 ef547f2ac16 (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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/net_namespace.c | 19 +++++++++++++++++++ net/core/sysctl_net_core.c | 2 -- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index b5c351d2830b..ccd20669ac00 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -310,6 +310,25 @@ static __net_init int setup_net(struct net *net, struc= t user_namespace *user_ns) goto out; } =20 +static int __net_init net_defaults_init_net(struct net *net) +{ + net->core.sysctl_somaxconn =3D SOMAXCONN; + return 0; +} + +static struct pernet_operations net_defaults_ops =3D { + .init =3D net_defaults_init_net, +}; + +static __init int net_defaults_init(void) +{ + if (register_pernet_subsys(&net_defaults_ops)) + panic("Cannot initialize net default settings"); + + return 0; +} + +core_initcall(net_defaults_init); =20 #ifdef CONFIG_NET_NS static struct kmem_cache *net_cachep; diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 6578a0a2f708..32898247d8bf 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -429,8 +429,6 @@ static __net_init int sysctl_core_net_init(struct net *= net) { struct ctl_table *tbl; =20 - net->core.sysctl_somaxconn =3D SOMAXCONN; - tbl =3D netns_core_table; if (!net_eq(net, &init_net)) { tbl =3D kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL); --=20 2.14.1