mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
netns: create a netlink route socket out of dump_links()
It will be used to dump netns id-s too. Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
0cd9ad0bd5
commit
f7d15e436f
31
criu/net.c
31
criu/net.c
@ -1007,9 +1007,8 @@ out:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_links(struct ns_id *ns, struct cr_imgset *fds)
|
static int dump_links(int rtsk, struct ns_id *ns, struct cr_imgset *fds)
|
||||||
{
|
{
|
||||||
int sk, ret;
|
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr nlh;
|
struct nlmsghdr nlh;
|
||||||
struct rtgenmsg g;
|
struct rtgenmsg g;
|
||||||
@ -1017,12 +1016,6 @@ static int dump_links(struct ns_id *ns, struct cr_imgset *fds)
|
|||||||
|
|
||||||
pr_info("Dumping netns links\n");
|
pr_info("Dumping netns links\n");
|
||||||
|
|
||||||
ret = sk = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
|
||||||
if (sk < 0) {
|
|
||||||
pr_perror("Can't open rtnl sock for net dump");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
req.nlh.nlmsg_len = sizeof(req);
|
req.nlh.nlmsg_len = sizeof(req);
|
||||||
req.nlh.nlmsg_type = RTM_GETLINK;
|
req.nlh.nlmsg_type = RTM_GETLINK;
|
||||||
@ -1031,10 +1024,7 @@ static int dump_links(struct ns_id *ns, struct cr_imgset *fds)
|
|||||||
req.nlh.nlmsg_seq = CR_NLMSG_SEQ;
|
req.nlh.nlmsg_seq = CR_NLMSG_SEQ;
|
||||||
req.g.rtgen_family = AF_PACKET;
|
req.g.rtgen_family = AF_PACKET;
|
||||||
|
|
||||||
ret = do_rtnl_req(sk, &req, sizeof(req), dump_one_link, NULL, ns, fds);
|
return do_rtnl_req(rtsk, &req, sizeof(req), dump_one_link, NULL, ns, fds);
|
||||||
close(sk);
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int restore_link_cb(struct nlmsghdr *hdr, struct ns_id *ns, void *arg)
|
static int restore_link_cb(struct nlmsghdr *hdr, struct ns_id *ns, void *arg)
|
||||||
@ -1882,10 +1872,19 @@ int dump_net_ns(struct ns_id *ns)
|
|||||||
|
|
||||||
ret = mount_ns_sysfs();
|
ret = mount_ns_sysfs();
|
||||||
if (!(opts.empty_ns & CLONE_NEWNET)) {
|
if (!(opts.empty_ns & CLONE_NEWNET)) {
|
||||||
|
int sk;
|
||||||
|
|
||||||
|
sk = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
|
if (sk < 0) {
|
||||||
|
pr_perror("Can't open rtnl sock for net dump");
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = dump_netns_conf(ns, fds);
|
ret = dump_links(sk, ns, fds);
|
||||||
if (!ret)
|
|
||||||
ret = dump_links(ns, fds);
|
close(sk);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = dump_ifaddr(fds);
|
ret = dump_ifaddr(fds);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
@ -1894,6 +1893,8 @@ int dump_net_ns(struct ns_id *ns)
|
|||||||
ret = dump_rule(fds);
|
ret = dump_rule(fds);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = dump_iptables(fds);
|
ret = dump_iptables(fds);
|
||||||
|
if (!ret)
|
||||||
|
ret = dump_netns_conf(ns, fds);
|
||||||
}
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = dump_nf_ct(fds, CR_FD_NETNF_CT);
|
ret = dump_nf_ct(fds, CR_FD_NETNF_CT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user