2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

net: Put IFLA_LINKINFO attr on newlink if required

Veth will fill the linkinfo part for peer.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2012-08-10 17:32:56 +04:00
parent 9d18a851c2
commit 3fee68f56b

19
net.c
View File

@@ -146,7 +146,8 @@ struct newlink_req {
char buf[1024]; char buf[1024];
}; };
static int restore_one_link(NetDeviceEntry *nde, int nlsk) static int restore_one_link(NetDeviceEntry *nde, int nlsk,
int (*link_info)(NetDeviceEntry *, struct newlink_req *))
{ {
struct newlink_req req; struct newlink_req req;
@@ -163,6 +164,20 @@ static int restore_one_link(NetDeviceEntry *nde, int nlsk)
addattr_l(&req.h, sizeof(req), IFLA_IFNAME, nde->name, strlen(nde->name)); addattr_l(&req.h, sizeof(req), IFLA_IFNAME, nde->name, strlen(nde->name));
addattr_l(&req.h, sizeof(req), IFLA_MTU, &nde->mtu, sizeof(nde->mtu)); addattr_l(&req.h, sizeof(req), IFLA_MTU, &nde->mtu, sizeof(nde->mtu));
if (link_info) {
struct rtattr *linkinfo;
int ret;
linkinfo = NLMSG_TAIL(&req.h);
addattr_l(&req.h, sizeof(req), IFLA_LINKINFO, NULL, 0);
ret = link_info(nde, &req);
if (ret < 0)
return ret;
linkinfo->rta_len = (void *)NLMSG_TAIL(&req.h) - (void *)linkinfo;
}
pr_info("Restoring netdev idx %d\n", nde->ifindex); pr_info("Restoring netdev idx %d\n", nde->ifindex);
return do_rtnl_req(nlsk, &req, req.h.nlmsg_len, restore_link_cb, NULL); return do_rtnl_req(nlsk, &req, req.h.nlmsg_len, restore_link_cb, NULL);
} }
@@ -173,7 +188,7 @@ static int restore_link(NetDeviceEntry *nde, int nlsk)
switch (nde->type) { switch (nde->type) {
case ND_TYPE__LOOPBACK: case ND_TYPE__LOOPBACK:
return restore_one_link(nde, nlsk); return restore_one_link(nde, nlsk, NULL);
case ND_TYPE__VETH: case ND_TYPE__VETH:
break; break;
} }