diff mbox

[iproute,PATCHv2,1/2] ipnetns: Move NETNS_RUN_DIR into it's own propagation group

Message ID 1467730280-17493-2-git-send-email-phil@nwl.cc
State Rejected, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Phil Sutter July 5, 2016, 2:51 p.m. UTC
On systems where the parent mount point is shared, NETNS_RUN_DIR
inherits the parent's propagation group. This leads to netns mount
points being propagated to the parent and thus showing up twice in the
output of 'mount'.

By making the newly mounted NETNS_RUN_DIR private first, then shared
again, it will move to it's own propagation group which will still allow
for netns mounts to propagate between mount namespaces but gets rid of
the double netns entry at the same time.

Suggested-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 ip/ipnetns.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index b3ee23c23aaa2..1cefe73c68bfc 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -650,6 +650,11 @@  static int netns_add(int argc, char **argv)
 				NETNS_RUN_DIR, NETNS_RUN_DIR, strerror(errno));
 			return -1;
 		}
+		if (mount("", NETNS_RUN_DIR, "none", MS_PRIVATE, NULL)) {
+			fprintf(stderr, "mount --make-private %s failed: %s\n",
+				NETNS_RUN_DIR, strerror(errno));
+			return -1;
+		}
 		made_netns_run_dir_mount = 1;
 	}