Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1338875 > unrolled thread
| Started by | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> |
|---|---|
| First post | 2016-02-21 18:50 +0100 |
| Last post | 2016-02-21 23:20 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2016-02-21 18:50 +0100
Re: [PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults Vasily Averin <vvs@virtuozzo.com> - 2016-02-21 18:50 +0100
Re: [PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults ebiederm@xmission.com (Eric W. Biederman) - 2016-02-21 23:20 +0100
| From | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> |
|---|---|
| Date | 2016-02-21 18:50 +0100 |
| Subject | [PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults |
| Message-ID | <r4G9d-XY-29@gated-at.bofh.it> |
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 <khlebnikov@yandex-team.ru>
Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
---
net/ipv4/devinet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index cebd9d31e65a..9d73d4bbdba3 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -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)
goto err_alloc_all;
[toc] | [next] | [standalone]
| From | Vasily Averin <vvs@virtuozzo.com> |
|---|---|
| Date | 2016-02-21 18:50 +0100 |
| Message-ID | <r4G9d-XY-31@gated-at.bofh.it> |
| In reply to | #1338875 |
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:
> 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 <khlebnikov@yandex-team.ru>
> Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
> ---
> net/ipv4/devinet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index cebd9d31e65a..9d73d4bbdba3 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -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)
> goto err_alloc_all;
>
>
[toc] | [prev] | [next] | [standalone]
| From | ebiederm@xmission.com (Eric W. Biederman) |
|---|---|
| Date | 2016-02-21 23:20 +0100 |
| Subject | Re: [PATCH] ipv4: in new netns initialize sysctls in net.ipv4.conf.* with defaults |
| Message-ID | <r4Kwa-4gx-3@gated-at.bofh.it> |
| In reply to | #1338875 |
Konstantin Khlebnikov <khlebnikov@yandex-team.ru> writes:
> 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.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Assuming that this does not cause a regression I am all for this,
as it makes the kernels behavior predictable.
When creating a network namespace we have two predictable choices.
Copy from the current network namespace, or initialize all sysctl values
with the kernel's defaults. Copying values looks like a way to
introduce subtle hard to debug breakage into existing setups. So all
else being equal my preference is that we initialize values in new
nework namespaces to their initial defaults.
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> Fixes: 752d14dc6aa9 ("[IPV4]: Move the devinet pointers on the struct net")
> ---
> net/ipv4/devinet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index cebd9d31e65a..9d73d4bbdba3 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -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)
> goto err_alloc_all;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web