Re: [linux-yocto] [PATCH] ipv4: net namespace does not inherit network configurations

2018-10-25 Thread Bruce Ashfield

On 10/24/18 2:27 AM, zhe...@windriver.com wrote:

From: He Zhe 

patch from https://lkml.org/lkml/2014/7/29/119


Did this never make the mainline kernel ?

We either need an upstream git commit hash, or an explanation of
why it didn't make mainline. I haven't read the link you provided,
but I shouldn't have to click on anything in a commit message :D

Bruce



Ipv4 net namespace requires a similar logic change as commit a79ca223e029
[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 
CC: David S. Miller 
Signed-off-by: Zhu Yanjun 
Signed-off-by: yzhu1 
Signed-off-by: He Zhe 
---
This is for linux-yocto-dev, linux-yocto master and 4.18 branches.

  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 ea4bd8a..f69b2dd 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2412,28 +2412,23 @@ static __net_init int devinet_init_net(struct net *net)
  #endif
  
  	err = -ENOMEM;

-   all = _devconf;
-   dflt = _devconf_dflt;
+   all = kmemdup(_devconf, sizeof(ipv4_devconf), GFP_KERNEL);
+   if (all == NULL)
+   goto err_alloc_all;
  
-	if (!net_eq(net, _net)) {

-   all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL);
-   if (!all)
-   goto err_alloc_all;
-
-   dflt = kmemdup(dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
-   if (!dflt)
-   goto err_alloc_dflt;
+   dflt = kmemdup(_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)
-   goto err_alloc_ctl;
+   tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
+   if (tbl == NULL)
+   goto err_alloc_ctl;
  
-		tbl[0].data = >data[IPV4_DEVCONF_FORWARDING - 1];

-   tbl[0].extra1 = all;
-   tbl[0].extra2 = net;
+   tbl[0].data = >data[IPV4_DEVCONF_FORWARDING - 1];
+   tbl[0].extra1 = all;
+   tbl[0].extra2 = net;
  #endif
-   }
  
  #ifdef CONFIG_SYSCTL

err = __devinet_sysctl_register(net, "all", NETCONFA_IFINDEX_ALL, all);



--
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH] ipv4: net namespace does not inherit network configurations

2018-10-24 Thread zhe.he
From: He Zhe 

patch from https://lkml.org/lkml/2014/7/29/119

Ipv4 net namespace requires a similar logic change as commit a79ca223e029
[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 
CC: David S. Miller 
Signed-off-by: Zhu Yanjun 
Signed-off-by: yzhu1 
Signed-off-by: He Zhe 
---
This is for linux-yocto-dev, linux-yocto master and 4.18 branches.

 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 ea4bd8a..f69b2dd 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2412,28 +2412,23 @@ static __net_init int devinet_init_net(struct net *net)
 #endif
 
err = -ENOMEM;
-   all = _devconf;
-   dflt = _devconf_dflt;
+   all = kmemdup(_devconf, sizeof(ipv4_devconf), GFP_KERNEL);
+   if (all == NULL)
+   goto err_alloc_all;
 
-   if (!net_eq(net, _net)) {
-   all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL);
-   if (!all)
-   goto err_alloc_all;
-
-   dflt = kmemdup(dflt, sizeof(ipv4_devconf_dflt), GFP_KERNEL);
-   if (!dflt)
-   goto err_alloc_dflt;
+   dflt = kmemdup(_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)
-   goto err_alloc_ctl;
+   tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
+   if (tbl == NULL)
+   goto err_alloc_ctl;
 
-   tbl[0].data = >data[IPV4_DEVCONF_FORWARDING - 1];
-   tbl[0].extra1 = all;
-   tbl[0].extra2 = net;
+   tbl[0].data = >data[IPV4_DEVCONF_FORWARDING - 1];
+   tbl[0].extra1 = all;
+   tbl[0].extra2 = net;
 #endif
-   }
 
 #ifdef CONFIG_SYSCTL
err = __devinet_sysctl_register(net, "all", NETCONFA_IFINDEX_ALL, all);
-- 
2.7.4

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto