Commit d2012883 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

criu: rename current_ns_mask to root_ns_mask (v2)

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

v2: typo fix
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4067f4bb
......@@ -357,7 +357,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",
......@@ -1258,7 +1258,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;
......@@ -1446,7 +1446,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);
......@@ -1771,8 +1771,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();
......
......@@ -1490,14 +1490,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;
}
......@@ -1588,7 +1588,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);
......
......@@ -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;
......
......@@ -1725,7 +1725,7 @@ int mntns_collect_root(pid_t pid)
close_service_fd(ROOT_FD_OFF);
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.
......
......@@ -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 rst_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_SUBNS) {
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;
}
......
......@@ -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");
}
......
......@@ -667,8 +667,8 @@ set_mask:
if (item == root_item) {
pr_info("Will restore in %lx namespaces\n", cflags);
current_ns_mask = cflags;
} else if (cflags & ~(current_ns_mask & CLONE_SUBNS)) {
root_ns_mask = cflags;
} else if (cflags & ~(root_ns_mask & CLONE_SUBNS)) {
/*
* Namespaces from CLONE_SUBNS can be nested, but in
* this case nobody can't share external namespaces of
......@@ -684,7 +684,7 @@ set_mask:
}
}
pr_debug("NS mask to use %lx\n", current_ns_mask);
pr_debug("NS mask to use %lx\n", root_ns_mask);
return 0;
}
......
......@@ -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)
......
......@@ -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))
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment