[CRIU] [PATCH 4/4] ns: Keep all clone flags fixups together

Kirill Tkhai ktkhai at virtuozzo.com
Fri Feb 24 03:31:52 PST 2017


It improves readability, when they all are in the only place
and they all are seen.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c |   15 +--------------
 criu/pstree.c     |   12 ++++++++++++
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 586a8770b..91119a80c 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1047,20 +1047,7 @@ static inline int fork_with_pid(struct pstree_item *item)
 	if (ca.clone_flags & CLONE_FILES)
 		close_pid_proc();
 
-	/*
-	 * Some kernel modules, such as netwrok packet generator
-	 * run kernel thread upon net-namespace creattion taking
-	 * the @pid we've been requeting via LAST_PID_PATH interface
-	 * so that we can't restore a take with pid needed.
-	 *
-	 * Here is an idea -- unhare net namespace in callee instead.
-	 */
-	/*
-	 * The cgroup namespace is also unshared explicitly in the
-	 * move_in_cgroup(), so drop this flag here as well.
-	 */
-	ret = clone_noasan(restore_task_with_children,
-			(ca.clone_flags & ~(CLONE_NEWNET | CLONE_NEWCGROUP)) | SIGCHLD, &ca);
+	ret = clone_noasan(restore_task_with_children, ca.clone_flags | SIGCHLD, &ca);
 	if (ret < 0) {
 		pr_perror("Can't fork for %d", pid);
 		goto err_unlock;
diff --git a/criu/pstree.c b/criu/pstree.c
index 8cb0bff93..dd40fbcee 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -882,6 +882,18 @@ static int prepare_pstree_kobj_ids(void)
 			 * with tasks hierarhy in any way.
 			 */
 			rsti(item)->clone_flags &= ~(CLONE_NEWNS | CLONE_NEWUSER);
+		/*
+		 * Net namespaces also do not correlated with task hierarhy,
+		 * so we create them manually in prepare_net_namespaces().
+		 * The second reason is that some kernel modules, such as network
+		 * packet generator, run kernel thread upon net-namespace creattion
+		 * taking the pid we've been requeting via LAST_PID_PATH interface
+		 * in fork_with_pid(), so that we can't restore a take with pid needed.
+		 *
+		 * The cgroup namespace is also unshared explicitly in the
+		 * move_in_cgroup(), so drop this flag here as well.
+		 */
+		rsti(item)->clone_flags &= ~(CLONE_NEWNET | CLONE_NEWCGROUP);
 
 		cflags &= CLONE_ALLNS;
 



More information about the CRIU mailing list