[CRIU] [PATCH 11/28] ns: Add top_net_ns global variable

Kirill Tkhai ktkhai at virtuozzo.com
Mon Jun 5 20:25:05 MSK 2017


It will be need for fast obtaining root_item's net_ns,
and to fixup old dumps.

lookup_ns_by_id() can't fail otherwise it'd failed
in MARK_ROOT_NS().

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/include/namespaces.h |    1 +
 criu/namespaces.c         |    2 ++
 2 files changed, 3 insertions(+)

diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 631d6228a..4e06ebc0f 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -163,6 +163,7 @@ struct ns_id {
 extern struct ns_id *ns_ids;
 extern struct ns_id *top_pid_ns;
 extern struct ns_id *root_user_ns;
+extern struct ns_id *top_net_ns;
 
 #define NS_DESC_ENTRY(_cflag, _str, _alt_str)		\
 	{						\
diff --git a/criu/namespaces.c b/criu/namespaces.c
index d73b2d9f9..ea8e3e391 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -895,6 +895,7 @@ static int set_ns_hookups(struct ns_id *ns)
 
 struct ns_id *top_pid_ns = NULL;
 struct ns_id *root_user_ns = NULL;
+struct ns_id *top_net_ns = NULL;
 /* Mapping NS_ROOT to NS_CRIU */
 UsernsEntry *userns_entry;
 
@@ -2158,6 +2159,7 @@ int set_ns_roots(void)
 	if (MARK_ROOT_NS(ids, net) || MARK_ROOT_NS(ids, ipc) || MARK_ROOT_NS(ids, uts) ||
 	    MARK_ROOT_NS(ids, mnt) || MARK_ROOT_NS(ids, cgroup))
 		return -1;
+	top_net_ns = lookup_ns_by_id(ids->net_ns_id, &net_ns_desc);
 	return 0;
 }
 



More information about the CRIU mailing list