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 <mszer...@redhat.com> Signed-off-by: Phil Sutter <p...@nwl.cc> --- ip/ipnetns.c | 5 +++++ 1 file changed, 5 insertions(+) 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; } -- 2.8.2