From: Konstantin Khlebnikov <hidden> Date: 2016-02-21 17:44:28
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 <redacted>
Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
---
net/ipv4/devinet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -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)gotoerr_alloc_all;
From: Konstantin Khlebnikov <hidden> Date: 2016-02-21 17:39:25
On 21.02.2016 12:25, Vasily Averin wrote:
Konstantin,
I've investigated question with sysctls initialization inside namespaces some time ago.
IIRC I've found people expect that sysctl values should be inherited from parent namespace.
It allows node admin to adjust unsafe pre-compiled settings, and prepare adequate defaults
before creation of namespaces.
Only few sysctls are handled in this manner and they are copied from host,
not parent. This works somehow for flat containers, as soon as you go deeper
this turns into madness. Default settings must be controlled by software who
creates namespaces. For now it must reset all yet-not-known sysctls into sane defaults.
BTW two ipv6 sysctl are special: net.ipv6.conf.default.disable_ipv6 and
net.ipv6.conf.default.autoconf their defaults are controlled by module
parameters and inherited by all namespaces. And this makes sense.
However, there is corner case:
module with sysctl can be loaded after creation of namespaces.
In this case namespaces will get pre-compiled sysctl defaults,
and are not be able to adjust them even if they want to do it.
Thank you,
Vasily Averin
On 21.02.2016 10:11, Konstantin Khlebnikov wrote:
quoted
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 <redacted>
Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
---
net/ipv4/devinet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -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)gotoerr_alloc_all;
Konstantin,
I've investigated question with sysctls initialization inside namespaces some time ago.
IIRC I've found people expect that sysctl values should be inherited from parent namespace.
It allows node admin to adjust unsafe pre-compiled settings, and prepare adequate defaults
before creation of namespaces.
However, there is corner case:
module with sysctl can be loaded after creation of namespaces.
In this case namespaces will get pre-compiled sysctl defaults,
and are not be able to adjust them even if they want to do it.
Thank you,
Vasily Averin
On 21.02.2016 10:11, Konstantin Khlebnikov wrote:
quoted hunk
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 <redacted>
Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
---
net/ipv4/devinet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -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)gotoerr_alloc_all;
From: David Miller <davem@davemloft.net> Date: 2016-02-23 23:21:46
From: Konstantin Khlebnikov <redacted>
Date: Sun, 21 Feb 2016 10:11:02 +0300
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 <redacted>
Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
The horse has long left the stable on this. We cannot change this now
without breaking things.
Imagine someone who intentionally sets up init_net with a certain set
of settings and expects them to propagate into every created namespace.
We'll break things for them and given the behavior existed for so long
what the administrator is doing is very reasonable.
I'm not applying this sorry, we are stuck with the current behavior
whether we like it or not.
From: Konstantin Khlebnikov <hidden> Date: 2016-02-24 05:17:09
On Wed, Feb 24, 2016 at 2:21 AM, David Miller [off-list ref] wrote:
From: Konstantin Khlebnikov <redacted>
Date: Sun, 21 Feb 2016 10:11:02 +0300
quoted
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 <redacted>
Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
The horse has long left the stable on this. We cannot change this now
without breaking things.
Imagine someone who intentionally sets up init_net with a certain set
of settings and expects them to propagate into every created namespace.
We'll break things for them and given the behavior existed for so long
what the administrator is doing is very reasonable.
I'm not applying this sorry, we are stuck with the current behavior
whether we like it or not.
Major kernel upgrades always break something in weird setups.
This shouldn't block bug fixing.
This kludge works only for several ipv4 sysctls. If software or man ever
have tried to setup ipv6 or tune tcp and want some non-default setup then
it/he already knows that sysctls must be configured inside.