[CRIU] [PATCH 02/10] ns: Introduce collect_net_namespaces

Pavel Emelyanov xemul at parallels.com
Mon Sep 29 11:03:55 PDT 2014


And move sockets collection there.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-dump.c     | 4 ----
 include/net.h | 2 ++
 namespaces.c  | 4 ++++
 net.c         | 8 +++++++-
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 03f107d..8bbbdd2 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -41,7 +41,6 @@
 #include "syscall.h"
 #include "ptrace.h"
 #include "util.h"
-#include "sockets.h"
 #include "namespaces.h"
 #include "image.h"
 #include "proc_parse.h"
@@ -1799,9 +1798,6 @@ int cr_dump_tasks(pid_t pid)
 	if (collect_namespaces() < 0)
 		goto err;
 
-	if (collect_sockets(pid))
-		goto err;
-
 	glob_imgset = cr_glob_imgset_open(O_DUMP);
 	if (!glob_imgset)
 		goto err;
diff --git a/include/net.h b/include/net.h
index be9d81e..2e86af7 100644
--- a/include/net.h
+++ b/include/net.h
@@ -14,6 +14,8 @@ struct veth_pair {
 	char *outside;
 };
 
+extern int collect_net_namespaces(void);
+
 extern int network_lock(void);
 extern void network_unlock(void);
 
diff --git a/namespaces.c b/namespaces.c
index b900a3a..316ab4b 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -528,6 +528,10 @@ int collect_namespaces(void)
 	if (ret < 0)
 		return ret;
 
+	ret = collect_net_namespaces();
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
diff --git a/net.c b/net.c
index fdfd40b..060b3f5 100644
--- a/net.c
+++ b/net.c
@@ -19,7 +19,8 @@
 #include "util-pie.h"
 #include "plugin.h"
 #include "action-scripts.h"
-
+#include "sockets.h"
+#include "pstree.h"
 #include "protobuf.h"
 #include "protobuf/netdev.pb-c.h"
 
@@ -627,4 +628,9 @@ int veth_pair_add(char *in, char *out)
 	return 0;
 }
 
+int collect_net_namespaces(void)
+{
+	return collect_sockets(root_item->pid.real);
+}
+
 struct ns_desc net_ns_desc = NS_DESC_ENTRY(CLONE_NEWNET, "net");
-- 
1.8.4.2




More information about the CRIU mailing list