@@ -636,7 +636,7 @@ static int netns_add(int argc, char **argv)
* file in all namespaces allowing the network namespace to be freed
* sooner.
*/
- while (mount("", NETNS_RUN_DIR, "none", MS_SHARED | MS_REC, NULL)) {
+ while (mount("", NETNS_RUN_DIR, "none", MS_SHARED, NULL)) {
/* Fail unless we need to make the mount point */
if (errno != EINVAL || made_netns_run_dir_mount) {
fprintf(stderr, "mount --make-shared %s failed: %s\n",
@@ -678,6 +678,11 @@ static int netns_add(int argc, char **argv)
netns_path, strerror(errno));
goto out_delete;
}
+ if (mount("", netns_path, "none", MS_PRIVATE, NULL)) {
+ fprintf(stderr, "mount --make-private %s failed: %s\n",
+ netns_path, strerror(errno));
+ return -1;
+ }
return 0;
out_delete:
netns_delete(argc, argv);
On systems with a shared /proc mount point, the netns mounts inherit that propagation group and therefore cause unnecessary overhead upon netns deletion. In order to achieve this, the MS_REC flag when making NETNS_RUN_DIR shared has to be removed as well or otherwise it will make existing netns mount points shared again. Suggested-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Phil Sutter <phil@nwl.cc> --- ip/ipnetns.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)