public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH iproute2] netns: make /var/run/netns bind-mount recursive
@ 2017-08-01 15:46 Casey Callendrello
  2017-08-03 23:04 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Casey Callendrello @ 2017-08-01 15:46 UTC (permalink / raw)
  To: netdev, stephen

When ip netns {add|delete} is first run, it bind-mounts /var/run/netns
on top of itself, then marks it as shared. However, if there are already
bind-mounts in the directory from other tools, these would not be
propagated. Fix this by recursively bind-mounting.

Signed-off-by: Casey Callendrello <casey.callendrello@coreos•com>
---
 ip/ipnetns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 198e9de8..9ee1fe6a 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -636,7 +636,7 @@ static int netns_add(int argc, char **argv)
 		}
 
 		/* Upgrade NETNS_RUN_DIR to a mount point */
-		if (mount(NETNS_RUN_DIR, NETNS_RUN_DIR, "none", MS_BIND, NULL)) {
+		if (mount(NETNS_RUN_DIR, NETNS_RUN_DIR, "none", MS_BIND | MS_REC, NULL)) {
 			fprintf(stderr, "mount --bind %s %s failed: %s\n",
 				NETNS_RUN_DIR, NETNS_RUN_DIR, strerror(errno));
 			return -1;
-- 
2.13.3

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

* Re: [PATCH iproute2] netns: make /var/run/netns bind-mount recursive
  2017-08-01 15:46 [PATCH iproute2] netns: make /var/run/netns bind-mount recursive Casey Callendrello
@ 2017-08-03 23:04 ` Stephen Hemminger
  2017-08-04 13:41   ` Eric W. Biederman
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2017-08-03 23:04 UTC (permalink / raw)
  To: Casey Callendrello; +Cc: netdev, Eric W. Biederman

On Tue,  1 Aug 2017 17:46:09 +0200
Casey Callendrello <casey.callendrello@coreos•com> wrote:

> When ip netns {add|delete} is first run, it bind-mounts /var/run/netns
> on top of itself, then marks it as shared. However, if there are already
> bind-mounts in the directory from other tools, these would not be
> propagated. Fix this by recursively bind-mounting.
> 
> Signed-off-by: Casey Callendrello <casey.callendrello@coreos•com>
> ---
>  ip/ipnetns.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Looks good, but I want a review by Eric to make sure this doesn't break other things.

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

* Re: [PATCH iproute2] netns: make /var/run/netns bind-mount recursive
  2017-08-03 23:04 ` Stephen Hemminger
@ 2017-08-04 13:41   ` Eric W. Biederman
  0 siblings, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2017-08-04 13:41 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Casey Callendrello, netdev

Stephen Hemminger <stephen@networkplumber•org> writes:

> On Tue,  1 Aug 2017 17:46:09 +0200
> Casey Callendrello <casey.callendrello@coreos•com> wrote:
>
>> When ip netns {add|delete} is first run, it bind-mounts /var/run/netns
>> on top of itself, then marks it as shared. However, if there are already
>> bind-mounts in the directory from other tools, these would not be
>> propagated. Fix this by recursively bind-mounting.
>> 
>> Signed-off-by: Casey Callendrello <casey.callendrello@coreos•com>
>> ---
>>  ip/ipnetns.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>
> Looks good, but I want a review by Eric to make sure this doesn't
> break other things.

Acked-by: "Eric W. Biederman" <ebiederm@xmission•com>

I don't see any possible problems with this.  This will just keep all of
the mounts showing up.

It would be really nice if we could at some point detect that a parent
directory is shared (which happens with a common init system) and skip
the steps of the bind mount and making them shared as they are
redundant.  However while that might also solve this issue that is
something for another day.

Eric

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

end of thread, other threads:[~2017-08-04 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 15:46 [PATCH iproute2] netns: make /var/run/netns bind-mount recursive Casey Callendrello
2017-08-03 23:04 ` Stephen Hemminger
2017-08-04 13:41   ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox