[CRIU] [PATCH v2 1/6] net: pass the struct nlattrs to dump() functions

Tycho Andersen tycho.andersen at canonical.com
Thu Oct 13 08:15:40 PDT 2016


We'll use this later in the series to get specific information that macvlan
links need.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 criu/include/net.h |  4 +++-
 criu/include/tun.h |  4 +++-
 criu/net.c         | 10 +++++-----
 criu/tun.c         |  4 ++--
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/criu/include/net.h b/criu/include/net.h
index ede380f..b4a6e99 100644
--- a/criu/include/net.h
+++ b/criu/include/net.h
@@ -1,6 +1,8 @@
 #ifndef __CR_NET_H__
 #define __CR_NET_H__
 
+#include <linux/netlink.h>
+
 #include "list.h"
 
 struct cr_imgset;
@@ -23,7 +25,7 @@ extern void network_unlock(void);
 extern struct ns_desc net_ns_desc;
 
 #include "images/netdev.pb-c.h"
-extern int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds);
+extern int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **data);
 extern int read_ns_sys_file(char *path, char *buf, int len);
 extern int restore_link_parms(NetDeviceEntry *nde, int nlsk);
 
diff --git a/criu/include/tun.h b/criu/include/tun.h
index 1e313d6..c0f22d7 100644
--- a/criu/include/tun.h
+++ b/criu/include/tun.h
@@ -5,10 +5,12 @@
 #define TUN_MINOR	200
 #endif
 
+#include <linux/netlink.h>
+
 #include "images/netdev.pb-c.h"
 
 extern const struct fdtype_ops tunfile_dump_ops;
-extern int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds);
+extern int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **data);
 extern int restore_one_tun(NetDeviceEntry *nde, int nlsk);
 extern struct collect_image_info tunfile_cinfo;
 extern int check_tun_cr(int no_tun_err);
diff --git a/criu/net.c b/criu/net.c
index 32e51ed..698d54c 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -337,14 +337,14 @@ static int ipv4_conf_op_old(char *tgt, int *conf, int n, int op, int *def_conf)
 	return 0;
 }
 
-int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds)
+int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **data)
 {
 	return pb_write_one(img_from_set(fds, CR_FD_NETDEV), nde, PB_NETDEV);
 }
 
 static int dump_one_netdev(int type, struct ifinfomsg *ifi,
 		struct nlattr **tb, struct cr_imgset *fds,
-		int (*dump)(NetDeviceEntry *, struct cr_imgset *))
+		int (*dump)(NetDeviceEntry *, struct cr_imgset *, struct nlattr **data))
 {
 	int ret = -1;
 	int i;
@@ -421,7 +421,7 @@ static int dump_one_netdev(int type, struct ifinfomsg *ifi,
 	if (!dump)
 		dump = write_netdev_img;
 
-	ret = dump(&netdev, fds);
+	ret = dump(&netdev, fds, tb);
 err_free:
 	xfree(netdev.conf4);
 	xfree(confs4);
@@ -463,7 +463,7 @@ static int dump_unknown_device(struct ifinfomsg *ifi, char *kind,
 	return -1;
 }
 
-static int dump_bridge(NetDeviceEntry *nde, struct cr_imgset *imgset)
+static int dump_bridge(NetDeviceEntry *nde, struct cr_imgset *imgset, struct nlattr **data)
 {
 	char spath[IFNAMSIZ + 16]; /* len("class/net//brif") + 1 for null */
 	int ret, fd;
@@ -495,7 +495,7 @@ static int dump_bridge(NetDeviceEntry *nde, struct cr_imgset *imgset)
 		return -1;
 	}
 
-	return write_netdev_img(nde, imgset);
+	return write_netdev_img(nde, imgset, data);
 }
 
 static int dump_one_ethernet(struct ifinfomsg *ifi, char *kind,
diff --git a/criu/tun.c b/criu/tun.c
index b3b8f8f..dcdc2ab 100644
--- a/criu/tun.c
+++ b/criu/tun.c
@@ -397,7 +397,7 @@ struct collect_image_info tunfile_cinfo = {
 	.collect = collect_one_tunfile,
 };
 
-int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
+int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **data)
 {
 	TunLinkEntry tle = TUN_LINK_ENTRY__INIT;
 	char spath[64];
@@ -428,7 +428,7 @@ int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
 	tle.sndbuf = tl->dmp.sndbuf;
 
 	nde->tun = &tle;
-	return write_netdev_img(nde, fds);
+	return write_netdev_img(nde, fds, data);
 }
 
 int restore_one_tun(NetDeviceEntry *nde, int nlsk)
-- 
2.7.4



More information about the CRIU mailing list