From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khlebnikov Subject: [PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults Date: Sun, 21 Feb 2016 10:11:02 +0300 Message-ID: <20160221071102.9686.63148.stgit@buzz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "David S. Miller" Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Vasily Averin , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Eric W. Biederman" List-Id: containers.vger.kernel.org Currently initial net.ipv4.conf.all.* and net.ipv4.conf.default.* are copied from init network namespace because static structures are used for init_net. This makes no sense because new netns might be created from any netns. This patch makes private copy also for init netns if network namespaces are enabled. Other sysctls in net.ipv4 and net.ipv6 already initialized with default values at namespace creation. Signed-off-by: Konstantin Khlebnikov Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net") --- net/ipv4/devinet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index cebd9d31e65a..9d73d4bbdba3 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -2290,7 +2290,7 @@ static __net_init int devinet_init_net(struct net *net) all = &ipv4_devconf; dflt = &ipv4_devconf_dflt; - if (!net_eq(net, &init_net)) { + if (IS_ENABLED(CONFIG_NET_NS)) { all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL); if (!all) goto err_alloc_all; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbcBURo2 (ORCPT ); Sun, 21 Feb 2016 12:44:28 -0500 Received: from forward-corp1f.mail.yandex.net ([95.108.130.40]:48929 "EHLO forward-corp1f.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbcBURoZ (ORCPT ); Sun, 21 Feb 2016 12:44:25 -0500 Authentication-Results: smtpcorp4.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults From: Konstantin Khlebnikov To: netdev@vger.kernel.org, "David S. Miller" Cc: containers@lists.linux-foundation.org, Vasily Averin , linux-kernel@vger.kernel.org, "Eric W. Biederman" Date: Sun, 21 Feb 2016 10:11:02 +0300 Message-ID: <20160221071102.9686.63148.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently initial net.ipv4.conf.all.* and net.ipv4.conf.default.* are copied from init network namespace because static structures are used for init_net. This makes no sense because new netns might be created from any netns. This patch makes private copy also for init netns if network namespaces are enabled. Other sysctls in net.ipv4 and net.ipv6 already initialized with default values at namespace creation. Signed-off-by: Konstantin Khlebnikov Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net") --- net/ipv4/devinet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index cebd9d31e65a..9d73d4bbdba3 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -2290,7 +2290,7 @@ static __net_init int devinet_init_net(struct net *net) all = &ipv4_devconf; dflt = &ipv4_devconf_dflt; - if (!net_eq(net, &init_net)) { + if (IS_ENABLED(CONFIG_NET_NS)) { all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL); if (!all) goto err_alloc_all;