[CRIU] [PATCH v2 5/8] dump netns ipv4 conf all/default
Pavel Tikhomirov
ptikhomirov at parallels.com
Thu Sep 25 01:00:40 PDT 2014
Signed-off-by: Pavel Tikhomirov <ptikhomirov at parallels.com>
---
net.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/net.c b/net.c
index abf9f50..cab7920 100644
--- a/net.c
+++ b/net.c
@@ -526,6 +526,33 @@ static inline int dump_iptables(struct cr_fdset *fds)
return run_iptables_tool("iptables-save", -1, fdset_fd(fds, CR_FD_IPTABLES));
}
+static int dump_netns_conf(struct cr_fdset *fds)
+{
+ int ret;
+ NetnsEntry netns = NETNS_ENTRY__INIT;
+
+ netns.n_def_conf = NET_DEV_CONF_SIZE;
+ netns.n_all_conf = NET_DEV_CONF_SIZE;
+ netns.def_conf = xmalloc(sizeof(int) * NET_DEV_CONF_SIZE);
+ netns.all_conf = xmalloc(sizeof(int) * NET_DEV_CONF_SIZE);
+
+ ret = ipv4_conf_op("net/ipv4/conf/default", netns.def_conf, CTL_READ);
+ if (ret < 0)
+ goto err_free;
+ ret = ipv4_conf_op("net/ipv4/conf/all", netns.all_conf, CTL_READ);
+ if (ret < 0)
+ goto err_free;
+
+ ret = pb_write_one(fdset_fd(fds, CR_FD_NETNS), &netns, PB_NETNS);
+err_free:
+ xfree(netns.def_conf);
+ xfree(netns.all_conf);
+ if (ret < 0)
+ return -1;
+
+ return 0;
+}
+
static int restore_ip_dump(int type, int pid, char *cmd)
{
int fd, ret;
@@ -622,6 +649,8 @@ int dump_net_ns(int pid, int ns_id)
ret = dump_route(fds);
if (!ret)
ret = dump_iptables(fds);
+ if (!ret)
+ ret = dump_netns_conf(fds);
close(ns_sysfs_fd);
ns_sysfs_fd = -1;
--
1.9.3
More information about the CRIU
mailing list