[CRIU] [PATCH v3 5/7] dump netns ipv4 conf all/default
Pavel Tikhomirov
ptikhomirov at parallels.com
Wed Oct 1 03:42:40 PDT 2014
Signed-off-by: Pavel Tikhomirov <ptikhomirov at parallels.com>
---
net.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/net.c b/net.c
index 05616cf..9d5fce8 100644
--- a/net.c
+++ b/net.c
@@ -536,6 +536,38 @@ 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);
+ if (!netns.def_conf)
+ return -1;
+ netns.all_conf = xmalloc(sizeof(int) * NET_DEV_CONF_SIZE);
+ if (!netns.all_conf) {
+ xfree(netns.def_conf);
+ return -1;
+ }
+
+ 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;
@@ -625,6 +657,8 @@ int dump_net_ns(int pid, int ns_id)
if (!ret)
ret = mount_ns_sysfs();
if (!ret)
+ ret = dump_netns_conf(fds);
+ if (!ret)
ret = dump_links(fds);
if (!ret)
ret = dump_ifaddr(fds);
--
1.9.3
More information about the CRIU
mailing list