From: Zhu Yanjun <zyjzyj2000@gmail.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
zyjzyj2000@gmail.com, Yue.Tao@windriver.com,
alexandre.dietsch@windriver.com, davem@davemloft.net,
honkiko@gmail.com, cwang@twopensource.com
Cc: Zhu Yanjun <Yanjun.Zhu@windriver.com>
Subject: [PATCH 1/1] ipv4: net namespace does not inherit network configurations
Date: Thu, 21 Aug 2014 10:32:01 +0800 [thread overview]
Message-ID: <1408588321-13537-2-git-send-email-Yanjun.Zhu@windriver.com> (raw)
In-Reply-To: <1408588321-13537-1-git-send-email-Yanjun.Zhu@windriver.com>
Ipv4 net namespace requires a similar logic change as commit c900a800
[ipv6: fix bad free of addrconf_init_net] introduces for newer kernels.
Since a net namespace is independent to another. That is, there
is no any relationship between the net namespaces. So a new net
namespace should not inherit network configurations from another
net namespace including the host.
CC: Hong Zhiguo <honkiko@gmail.com>
CC: David S. Miller <davem@davemloft.net>
Suggested-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Zhu Yanjun <Yanjun.Zhu@windriver.com>
---
net/ipv4/devinet.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e944937..a16aa39 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2220,28 +2220,23 @@ static __net_init int devinet_init_net(struct net *net)
#endif
err = -ENOMEM;
- all = &ipv4_devconf;
- dflt = &ipv4_devconf_dflt;
- if (!net_eq(net, &init_net)) {
- all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL);
- if (all == NULL)
- goto err_alloc_all;
-
- dflt = kmemdup(dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
- if (dflt == NULL)
- goto err_alloc_dflt;
+ all = kmemdup(&ipv4_devconf, sizeof(ipv4_devconf), GFP_KERNEL);
+ if (all == NULL)
+ goto err_alloc_all;
+ dflt = kmemdup(&ipv4_devconf_dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
+ if (dflt == NULL)
+ goto err_alloc_dflt;
#ifdef CONFIG_SYSCTL
- tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
- if (tbl == NULL)
- goto err_alloc_ctl;
+ tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
+ if (tbl == NULL)
+ goto err_alloc_ctl;
- tbl[0].data = &all->data[IPV4_DEVCONF_FORWARDING - 1];
- tbl[0].extra1 = all;
- tbl[0].extra2 = net;
+ tbl[0].data = &all->data[IPV4_DEVCONF_FORWARDING - 1];
+ tbl[0].extra1 = all;
+ tbl[0].extra2 = net;
#endif
- }
#ifdef CONFIG_SYSCTL
err = __devinet_sysctl_register(net, "all", all);
--
1.9.1
next prev parent reply other threads:[~2014-08-21 2:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 2:32 [PATCH V2 0/1] ipv4: net namespace does not inherit network configurations Zhu Yanjun
2014-08-21 2:32 ` Zhu Yanjun [this message]
2014-08-21 3:18 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408588321-13537-2-git-send-email-Yanjun.Zhu@windriver.com \
--to=zyjzyj2000@gmail.com \
--cc=Yanjun.Zhu@windriver.com \
--cc=Yue.Tao@windriver.com \
--cc=alexandre.dietsch@windriver.com \
--cc=cwang@twopensource.com \
--cc=davem@davemloft.net \
--cc=honkiko@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).