All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/1] ipv4: net namespace does not inherit network configurations
@ 2014-08-21  2:32 Zhu Yanjun
  2014-08-21  2:32 ` [PATCH 1/1] " Zhu Yanjun
  2014-08-21  3:18 ` [PATCH V2 0/1] " Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Zhu Yanjun @ 2014-08-21  2:32 UTC (permalink / raw)
  To: linux-kernel, netdev, zyjzyj2000, Yue.Tao, alexandre.dietsch,
	davem, honkiko, cwang
  Cc: Zhu Yanjun

V2: Following the advice from Cong Wang, I submit a patch as normal.

Hi,all

I did a test on kernel3.16 rc6:

root@qemu1:~# echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
root@qemu1:~# echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
root@qemu1:~# ip netns list
root@qemu1:~# ip netns add fib1
root@qemu1:~# ip netns exec fib1 bash
root@qemu1:~# cat /proc/sys/net/ipv6/conf/all/forwarding
0
root@qemu1:~# cat /proc/sys/net/ipv4/conf/all/forwarding
1

The behavior of ipv4 and ipv6 is very inconsistent. I checked
the kernel source code. I found that from this patch
[ipv6: fix bad free of addrconf_init_net], the above difference
appeared.

Since a net namespace is independent to another. That is, there
is no any relationship between the net namespaces. So the behavior
of ipv4 is not correct.

Based on this patch [ipv6: fix bad free of addrconf_init_net], I made
a new patch to fix this problem on ipv4.

Any reply is appreciated. 

Zhu Yanjun (1):
  ipv4: net namespace does not inherit network configurations

 net/ipv4/devinet.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] ipv4: net namespace does not inherit network configurations
  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
  2014-08-21  3:18 ` [PATCH V2 0/1] " Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Zhu Yanjun @ 2014-08-21  2:32 UTC (permalink / raw)
  To: linux-kernel, netdev, zyjzyj2000, Yue.Tao, alexandre.dietsch,
	davem, honkiko, cwang
  Cc: Zhu Yanjun

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2 0/1] ipv4: net namespace does not inherit network configurations
  2014-08-21  2:32 [PATCH V2 0/1] ipv4: net namespace does not inherit network configurations Zhu Yanjun
  2014-08-21  2:32 ` [PATCH 1/1] " Zhu Yanjun
@ 2014-08-21  3:18 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2014-08-21  3:18 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: linux-kernel, netdev, Yue.Tao, alexandre.dietsch, davem, honkiko,
	cwang, Zhu Yanjun

On Thu, 21 Aug 2014 10:32:00 +0800
Zhu Yanjun <zyjzyj2000@gmail.com> wrote:

> V2: Following the advice from Cong Wang, I submit a patch as normal.
> 
> Hi,all
> 
> I did a test on kernel3.16 rc6:
> 
> root@qemu1:~# echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
> root@qemu1:~# echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
> root@qemu1:~# ip netns list
> root@qemu1:~# ip netns add fib1
> root@qemu1:~# ip netns exec fib1 bash
> root@qemu1:~# cat /proc/sys/net/ipv6/conf/all/forwarding
> 0
> root@qemu1:~# cat /proc/sys/net/ipv4/conf/all/forwarding
> 1
> 
> The behavior of ipv4 and ipv6 is very inconsistent. I checked
> the kernel source code. I found that from this patch
> [ipv6: fix bad free of addrconf_init_net], the above difference
> appeared.
> 
> Since a net namespace is independent to another. That is, there
> is no any relationship between the net namespaces. So the behavior
> of ipv4 is not correct.
> 
> Based on this patch [ipv6: fix bad free of addrconf_init_net], I made
> a new patch to fix this problem on ipv4.
> 
> Any reply is appreciated. 
> 
> Zhu Yanjun (1):
>   ipv4: net namespace does not inherit network configurations
> 
>  net/ipv4/devinet.c | 29 ++++++++++++-----------------
>  1 file changed, 12 insertions(+), 17 deletions(-)
> 

This a semantic change to network namespaces and therefore is
likely to break existing applications using network namespaces.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-21  3:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21  2:32 [PATCH V2 0/1] ipv4: net namespace does not inherit network configurations Zhu Yanjun
2014-08-21  2:32 ` [PATCH 1/1] " Zhu Yanjun
2014-08-21  3:18 ` [PATCH V2 0/1] " Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.