From: yzhu1 <Yanjun.Zhu@windriver.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>
Subject: Re: [PATCH 1/1] net namespace: dynamically configure new net namespace inherit net config
Date: Thu, 8 Oct 2015 14:44:18 +0800 [thread overview]
Message-ID: <561610C2.5000309@windriver.com> (raw)
In-Reply-To: <1435311439-26916-1-git-send-email-Yanjun.Zhu@windriver.com>
Hi, Miller
Would you like to check this patch?
Thanks a lot.
Zhu Yanjun
On 06/26/2015 05:37 PM, Zhu Yanjun wrote:
> The new net namespace can inherit from the original net config, or
> the current net config. As such, a config is needed to decide where
> the new namespace inherit from.
>
> Signed-off-by: Zhu Yanjun <Yanjun.Zhu@windriver.com>
> ---
> init/Kconfig | 9 +++++++++
> net/ipv4/devinet.c | 13 +++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index dc24dec..fab8c41 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1212,6 +1212,15 @@ config NET_NS
> Allow user space to create what appear to be multiple instances
> of the network stack.
>
> +config NET_NS_INHERIT_ORIGINAL
> + bool "New network namespace inherits from original net config"
> + depends on NET_NS
> + default n
> + help
> + Allow new network namespace inherit from original net config.
> + If no, the new network namespace inherits from the current net
> + config including the modified net config.
> +
> endif # NAMESPACES
>
> config SCHED_AUTOGROUP
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 419d23c..cf635e4 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -2271,6 +2271,7 @@ static __net_init int devinet_init_net(struct net *net)
> #endif
>
> err = -ENOMEM;
> +#ifndef CONFIG_NET_NS_INHERIT_ORIGINAL
> all = &ipv4_devconf;
> dflt = &ipv4_devconf_dflt;
>
> @@ -2282,6 +2283,15 @@ static __net_init int devinet_init_net(struct net *net)
> dflt = kmemdup(dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
> if (!dflt)
> goto err_alloc_dflt;
> +#else
> + all = kmemdup(&ipv4_devconf, sizeof(ipv4_devconf), GFP_KERNEL);
> + if (!all)
> + goto err_alloc_all;
> +
> + dflt = kmemdup(&ipv4_devconf_dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
> + if (!dflt)
> + goto err_alloc_dflt;
> +#endif
>
> #ifdef CONFIG_SYSCTL
> tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
> @@ -2292,7 +2302,10 @@ static __net_init int devinet_init_net(struct net *net)
> tbl[0].extra1 = all;
> tbl[0].extra2 = net;
> #endif
> +
> +#ifndef CONFIG_NET_NS_INHERIT_ORIGINAL
> }
> +#endif
>
> #ifdef CONFIG_SYSCTL
> err = __devinet_sysctl_register(net, "all", all);
next prev parent reply other threads:[~2015-10-08 6:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 9:37 [PATCH 1/1] net namespace: dynamically configure new net namespace inherit net config Zhu Yanjun
2015-06-26 9:50 ` yzhu1
2015-06-26 14:34 ` Paul Gortmaker
2015-07-02 2:04 ` yzhu1
2015-10-08 6:44 ` yzhu1 [this message]
2015-10-09 3:13 ` Paul Gortmaker
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=561610C2.5000309@windriver.com \
--to=yanjun.zhu@windriver.com \
--cc=davem@davemloft.net \
--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).