mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 01:31:34 +00:00
net: Sanitize dump_links() function code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
9a6bc0fdab
commit
02650b0711
1 changed files with 4 additions and 9 deletions
13
net.c
13
net.c
|
|
@ -180,7 +180,7 @@ static int dump_one_link(struct nlmsghdr *hdr, void *arg)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int do_dump_links(int (*cb)(struct nlmsghdr *h, void *), void *arg)
|
||||
static int dump_links(struct cr_fdset *fds)
|
||||
{
|
||||
int sk, ret;
|
||||
struct {
|
||||
|
|
@ -188,6 +188,8 @@ static int do_dump_links(int (*cb)(struct nlmsghdr *h, void *), void *arg)
|
|||
struct rtgenmsg g;
|
||||
} req;
|
||||
|
||||
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");
|
||||
|
|
@ -202,19 +204,12 @@ static int do_dump_links(int (*cb)(struct nlmsghdr *h, void *), void *arg)
|
|||
req.nlh.nlmsg_seq = CR_NLMSG_SEQ;
|
||||
req.g.rtgen_family = AF_PACKET;
|
||||
|
||||
ret = do_rtnl_req(sk, &req, sizeof(req), cb, arg);
|
||||
ret = do_rtnl_req(sk, &req, sizeof(req), dump_one_link, fds);
|
||||
close(sk);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dump_links(struct cr_fdset *fds)
|
||||
{
|
||||
pr_info("Dumping netns links\n");
|
||||
|
||||
return do_dump_links(dump_one_link, fds);
|
||||
}
|
||||
|
||||
static int restore_link_cb(struct nlmsghdr *hdr, void *arg)
|
||||
{
|
||||
pr_info("Got response on SETLINK =)\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue