From patchwork Sun Feb 21 07:11:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 585845 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B0DAC1409B7 for ; Mon, 22 Feb 2016 04:44:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yandex-team.ru header.i=@yandex-team.ru header.b=zJLo+7gW; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751811AbcBURo1 (ORCPT ); Sun, 21 Feb 2016 12:44:27 -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 Received: from smtpcorp4.mail.yandex.net (smtpcorp4.mail.yandex.net [95.108.252.2]) by forward-corp1f.mail.yandex.net (Yandex) with ESMTP id 266E4242020E; Sun, 21 Feb 2016 10:11:06 +0300 (MSK) Received: from smtpcorp4.mail.yandex.net (localhost [127.0.0.1]) by smtpcorp4.mail.yandex.net (Yandex) with ESMTP id B8D6E2C0310; Sun, 21 Feb 2016 10:11:05 +0300 (MSK) Received: from 130.193.34.175-iva.dhcp.yndx.net (130.193.34.175-iva.dhcp.yndx.net [130.193.34.175]) by smtpcorp4.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 51wfU8Rsfz-B5BOkJs4; Sun, 21 Feb 2016 10:11:05 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1456038665; bh=TUVCVK5g6wrcDf5M5amQNpzdqQfDuOz8mpLaT5E9kBs=; h=Subject:From:To:Cc:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding; b=zJLo+7gW3jOcr/ty5rEqa8SG3jK6pnyS6C9VeTELHMZBc0ygMgwc5WY74oEYCyNkN koxbUESaYSzzzQ9xiWAV7tMoUm+pg886hkdzNdvJkl+yuayxGYjANEeLVzwuAZrSQy ERhqmDHNuL0rRXTJ1tCbP6ZBIgrJQCjfb7/agrqI= 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 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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") Acked-by: "Eric W. Biederman" --- 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;