mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-04 00:05:26 +00:00
net: Move ifla parsing higher the call-stack
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
25
net.c
25
net.c
@@ -18,19 +18,11 @@ void show_netdevices(int fd, struct cr_options *opt)
|
|||||||
pb_show_plain(fd, PB_NETDEV);
|
pb_show_plain(fd, PB_NETDEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_one_netdev(int type, struct nlmsghdr *h, struct ifinfomsg *ifi, struct cr_fdset *fds)
|
static int dump_one_netdev(int type, struct ifinfomsg *ifi,
|
||||||
|
struct rtattr **tb, struct cr_fdset *fds)
|
||||||
{
|
{
|
||||||
int len = h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
|
|
||||||
struct rtattr * tb[IFLA_MAX+1];
|
|
||||||
NetDeviceEntry netdev = NET_DEVICE_ENTRY__INIT;
|
NetDeviceEntry netdev = NET_DEVICE_ENTRY__INIT;
|
||||||
|
|
||||||
if (len < 0) {
|
|
||||||
pr_err("No iflas for link %d\n", ifi->ifi_index);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
|
|
||||||
|
|
||||||
if (!tb[IFLA_IFNAME]) {
|
if (!tb[IFLA_IFNAME]) {
|
||||||
pr_err("No name for link %d\n", ifi->ifi_index);
|
pr_err("No name for link %d\n", ifi->ifi_index);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -49,14 +41,23 @@ static int dump_one_link(struct nlmsghdr *hdr, void *arg)
|
|||||||
{
|
{
|
||||||
struct cr_fdset *fds = arg;
|
struct cr_fdset *fds = arg;
|
||||||
struct ifinfomsg *ifi;
|
struct ifinfomsg *ifi;
|
||||||
int ret = 0;
|
int ret = 0, len = hdr->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
|
||||||
|
struct rtattr * tb[IFLA_MAX+1];
|
||||||
|
|
||||||
ifi = NLMSG_DATA(hdr);
|
ifi = NLMSG_DATA(hdr);
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
pr_err("No iflas for link %d\n", ifi->ifi_index);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
|
||||||
|
|
||||||
pr_info("\tLD: Got link %d, type %d\n", ifi->ifi_index, ifi->ifi_type);
|
pr_info("\tLD: Got link %d, type %d\n", ifi->ifi_index, ifi->ifi_type);
|
||||||
|
|
||||||
switch (ifi->ifi_type) {
|
switch (ifi->ifi_type) {
|
||||||
case ARPHRD_LOOPBACK:
|
case ARPHRD_LOOPBACK:
|
||||||
ret = dump_one_netdev(ND_TYPE__LOOPBACK, hdr, ifi, fds);
|
ret = dump_one_netdev(ND_TYPE__LOOPBACK, ifi, tb, fds);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_err("Unsupported link type %d\n", ifi->ifi_type);
|
pr_err("Unsupported link type %d\n", ifi->ifi_type);
|
||||||
|
Reference in New Issue
Block a user