netns: make /var/run/netns bind-mount recursive
Subsystems (2)
PATCH 1/1 netns: make /var/run/netns bind-mount recursive
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.
--- ip/ipnetns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipnetns.c +1 -1
@@ -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 ;
Signature · 1 line
2.13.3
Quoted 10 lines · On Tue, 1 Aug 2017 17:46:09 +0200 Casey Callendrello…
When ip netns {add|delete} is first run, it bind-mounts
/var/run/netnson 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 <[email protected]>--- 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.
Eric W. Biederman
Acked-byQuoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Tue, 1 Aug 2017 17:46:09 +0200 Casey Callendrello…
When ip netns {add|delete} is first run, it bind-mounts
/var/run/netnson 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.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Casey Callendrello <[email protected]>--- 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.
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