[CRIU] [PATCH 13/13] criu: rename current_ns_mask to root_ns_mask

Andrey Vagin avagin at openvz.org
Tue Mar 11 08:18:29 PDT 2014


Now we supports sub-mntns, so root_ns_mask sounds more correct than
current_ns_mask.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-dump.c            | 10 +++++-----
 cr-restore.c         |  6 +++---
 include/namespaces.h |  2 +-
 mount.c              |  2 +-
 namespaces.c         | 10 +++++-----
 net.c                |  4 ++--
 pstree.c             |  8 ++++----
 sk-tcp.c             |  8 ++++----
 sockets.c            |  2 +-
 tun.c                |  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 7b23808..dd76de4 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -367,7 +367,7 @@ static int dump_filemap(pid_t pid, struct vma_area *vma_area,
 
 static int check_sysvipc_map_dump(pid_t pid, VmaEntry *vma)
 {
-	if (current_ns_mask & CLONE_NEWIPC)
+	if (root_ns_mask & CLONE_NEWIPC)
 		return 0;
 
 	pr_err("Task %d with SysVIPC shmem map @%"PRIx64" doesn't live in IPC ns\n",
@@ -1260,7 +1260,7 @@ static int dump_zombies(void)
 {
 	struct pstree_item *item;
 	int ret = -1;
-	int pidns = current_ns_mask & CLONE_NEWPID;
+	int pidns = root_ns_mask & CLONE_NEWPID;
 
 	if (pidns && set_proc_fd(get_service_fd(CR_PROC_FD_OFF)))
 		return -1;
@@ -1448,7 +1448,7 @@ static int dump_one_task(struct pstree_item *item)
 		goto err;
 	}
 
-	if (current_ns_mask & CLONE_NEWPID && root_item == item) {
+	if (root_ns_mask & CLONE_NEWPID && root_item == item) {
 		int pfd;
 
 		pfd = parasite_get_proc_fd_seized(parasite_ctl);
@@ -1780,8 +1780,8 @@ int cr_dump_tasks(pid_t pid)
 	if (dump_pstree(root_item))
 		goto err;
 
-	if (current_ns_mask)
-		if (dump_namespaces(root_item, current_ns_mask) < 0)
+	if (root_ns_mask)
+		if (dump_namespaces(root_item, root_ns_mask) < 0)
 			goto err;
 
 	ret = cr_dump_shmem();
diff --git a/cr-restore.c b/cr-restore.c
index 880f531..f8a179d 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1486,14 +1486,14 @@ static int restore_root_task(struct pstree_item *init)
 	 */
 
 	if (init->pid.virt == INIT_PID) {
-		if (!(current_ns_mask & CLONE_NEWPID)) {
+		if (!(root_ns_mask & CLONE_NEWPID)) {
 			pr_err("This process tree can only be restored "
 				"in a new pid namespace.\n"
 				"criu should be re-executed with the "
 				"\"--namespace pid\" option.\n");
 			return -1;
 		}
-	} else	if (current_ns_mask & CLONE_NEWPID) {
+	} else	if (root_ns_mask & CLONE_NEWPID) {
 		pr_err("Can't restore pid namespace without the process init\n");
 		return -1;
 	}
@@ -1583,7 +1583,7 @@ out_kill:
 	 * The processes can be killed only when all of them have been created,
 	 * otherwise an external proccesses can be killed.
 	 */
-	if (current_ns_mask & CLONE_NEWPID) {
+	if (root_ns_mask & CLONE_NEWPID) {
 		/* Kill init */
 		if (root_item->pid.real > 0)
 			kill(root_item->pid.real, SIGKILL);
diff --git a/include/namespaces.h b/include/namespaces.h
index 3faf223..d307fcc 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -30,7 +30,7 @@ extern bool check_ns_proc(struct fd_link *link);
 
 extern struct ns_desc pid_ns_desc;
 extern struct ns_desc user_ns_desc;
-extern unsigned long current_ns_mask;
+extern unsigned long root_ns_mask;
 
 extern const struct fdtype_ops nsfile_dump_ops;
 extern struct collect_image_info nsfile_cinfo;
diff --git a/mount.c b/mount.c
index d4db092..c07ee69 100644
--- a/mount.c
+++ b/mount.c
@@ -1641,7 +1641,7 @@ int mntns_collect_root(pid_t pid)
 	int ret;
 	char path[PATH_MAX + 1];
 
-	if (!(current_ns_mask & CLONE_NEWNS)) {
+	if (!(root_ns_mask & CLONE_NEWNS)) {
 		/*
 		 * If criu and tasks we dump live in the same mount
 		 * namespace, we can just open the root directory.
diff --git a/namespaces.c b/namespaces.c
index b8036a3..e092605 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -115,7 +115,7 @@ int restore_ns(int rst, struct ns_desc *nd)
 
 struct ns_id *ns_ids = NULL;
 static unsigned int ns_next_id = 1;
-unsigned long current_ns_mask = 0;
+unsigned long root_ns_mask = 0;
 
 int add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd)
 {
@@ -179,9 +179,9 @@ static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd
 
 	if (pid != getpid()) {
 		if (pid == root_item->pid.real) {
-			BUG_ON(current_ns_mask & nd->cflag);
+			BUG_ON(root_ns_mask & nd->cflag);
 			pr_info("Will take %s namespace in the image\n", nd->str);
-			current_ns_mask |= nd->cflag;
+			root_ns_mask |= nd->cflag;
 		} else if (nd->cflag != CLONE_NEWNS) {
 			pr_err("Can't dump nested %s namespace for %d\n",
 					nd->str, pid);
@@ -402,14 +402,14 @@ static int gen_ns_ids(int pid)
  */
 int gen_predump_ns_mask(void)
 {
-	BUG_ON(current_ns_mask);
+	BUG_ON(root_ns_mask);
 
 	if (gen_ns_ids(getpid()))
 		return -1;
 	if (gen_ns_ids(root_item->pid.real))
 		return -1;
 
-	pr_info("NS mask generated: %lx\n", current_ns_mask);
+	pr_info("NS mask generated: %lx\n", root_ns_mask);
 	return 0;
 }
 
diff --git a/net.c b/net.c
index ac66374..ed327e4 100644
--- a/net.c
+++ b/net.c
@@ -588,7 +588,7 @@ int network_lock(void)
 	pr_info("Lock network\n");
 
 	/* Each connection will be locked on dump */
-	if  (!(current_ns_mask & CLONE_NEWNET))
+	if  (!(root_ns_mask & CLONE_NEWNET))
 		return 0;
 
 	return run_scripts("network-lock");
@@ -601,7 +601,7 @@ void network_unlock(void)
 	cpt_unlock_tcp_connections();
 	rst_unlock_tcp_connections();
 
-	if (current_ns_mask & CLONE_NEWNET)
+	if (root_ns_mask & CLONE_NEWNET)
 		run_scripts("network-unlock");
 }
 
diff --git a/pstree.c b/pstree.c
index aac29c7..4b6a665 100644
--- a/pstree.c
+++ b/pstree.c
@@ -637,7 +637,7 @@ set_mask:
 
 		if (item == root_item) {
 			pr_info("Will restore in %lx namespaces\n", cflags);
-			current_ns_mask = cflags & CLONE_ALLNS;
+			root_ns_mask = cflags & CLONE_ALLNS;
 			continue;
 		}
 
@@ -645,7 +645,7 @@ set_mask:
 		 * Nested mount namespaces are supported only
 		 * nobody shares external mntns.
 		 */
-		if (cflags & current_ns_mask & CLONE_NEWNS)
+		if (cflags & root_ns_mask & CLONE_NEWNS)
 			cflags &= ~CLONE_NEWNS;
 
 		/*
@@ -654,14 +654,14 @@ set_mask:
 		 * this namespace is either inherited from the
 		 * criu or is created for the init task (only)
 		 */
-		if (cflags & CLONE_ALLNS == 0)
+		if ((cflags & CLONE_ALLNS) == 0)
 			continue;
 
 		pr_err("Can't restore sub-task in NS\n");
 		return -1;
 	}
 
-	pr_debug("NS mask to use %lx\n", current_ns_mask);
+	pr_debug("NS mask to use %lx\n", root_ns_mask);
 	return 0;
 }
 
diff --git a/sk-tcp.c b/sk-tcp.c
index baf3221..29d8618 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -127,7 +127,7 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
 		goto err1;
 	}
 
-	if (!(current_ns_mask & CLONE_NEWNET)) {
+	if (!(root_ns_mask & CLONE_NEWNET)) {
 		ret = nf_lock_connection(sk);
 		if (ret < 0)
 			goto err2;
@@ -146,7 +146,7 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
 	return 0;
 
 err3:
-	if (!(current_ns_mask & CLONE_NEWNET))
+	if (!(root_ns_mask & CLONE_NEWNET))
 		nf_unlock_connection(sk);
 err2:
 	close(sk->rfd);
@@ -160,7 +160,7 @@ static void tcp_unlock_one(struct inet_sk_desc *sk)
 
 	list_del(&sk->rlist);
 
-	if (!(current_ns_mask & CLONE_NEWNET)) {
+	if (!(root_ns_mask & CLONE_NEWNET)) {
 		ret = nf_unlock_connection(sk);
 		if (ret < 0)
 			pr_perror("Failed to unlock TCP connection");
@@ -685,7 +685,7 @@ void rst_unlock_tcp_connections(void)
 	struct inet_sk_info *ii;
 
 	/* Network will be unlocked by network-unlock scripts */
-	if (current_ns_mask & CLONE_NEWNET)
+	if (root_ns_mask & CLONE_NEWNET)
 		return;
 
 	list_for_each_entry(ii, &rst_tcp_repair_sockets, rlist)
diff --git a/sockets.c b/sockets.c
index 36b2378..f72ef8b 100644
--- a/sockets.c
+++ b/sockets.c
@@ -522,7 +522,7 @@ int collect_sockets(int pid)
 	int nl;
 	struct sock_diag_req req;
 
-	if (current_ns_mask & CLONE_NEWNET) {
+	if (root_ns_mask & CLONE_NEWNET) {
 		pr_info("Switching to %d's net for collecting sockets\n", pid);
 
 		if (switch_ns(pid, &net_ns_desc, &rst))
diff --git a/tun.c b/tun.c
index d453015..de4458a 100644
--- a/tun.c
+++ b/tun.c
@@ -270,7 +270,7 @@ static int dump_tunfile(int lfd, u32 id, const struct fd_parms *p)
 	TunfileEntry tfe = TUNFILE_ENTRY__INIT;
 	struct ifreq ifr;
 
-	if (!(current_ns_mask & CLONE_NEWNET)) {
+	if (!(root_ns_mask & CLONE_NEWNET)) {
 		pr_err("Net namespace is required to dump tun link\n");
 		return -1;
 	}
-- 
1.8.5.3



More information about the CRIU mailing list