[CRIU] [PATCH v4 5/8] dump netns ipv4 conf all/default
Pavel Emelyanov
xemul at parallels.com
Wed Oct 8 08:28:43 PDT 2014
On 10/08/2014 05:21 PM, Pavel Tikhomirov wrote:
> 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 f56f095..c385363 100644
> --- a/net.c
> +++ b/net.c
> @@ -535,6 +535,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("default", netns.def_conf, CTL_READ);
> + if (ret < 0)
> + goto err_free;
> + ret = ipv4_conf_op("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);
Please, pull the repo. There's no more such routine as fdset_fd.
> +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;
> @@ -624,6 +656,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);
>
More information about the CRIU
mailing list