Skip to content

Commit b705dcc

Browse files
Tycho Andersenxemul
Tycho Andersen
authored andcommitted
net: pass the struct nlattrs to dump() functions
We'll use this later in the series to get specific information that macvlan links need. v2: pass the IFLA_LINKINFO instead of the whole attribute buffer, since that's al all we expect the info functions to need, and all we allow them to populate on restore travis-ci: success for series starting with [v10,01/11] net: pass the struct nlattrs to dump() functions Signed-off-by: Tycho Andersen <[email protected]> Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent 05ac45b commit b705dcc

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

criu/include/net.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef __CR_NET_H__
22
#define __CR_NET_H__
33

4+
#include <linux/netlink.h>
5+
46
#include "common/list.h"
57

68
struct cr_imgset;
@@ -23,7 +25,7 @@ extern void network_unlock(void);
2325
extern struct ns_desc net_ns_desc;
2426

2527
#include "images/netdev.pb-c.h"
26-
extern int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds);
28+
extern int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **info);
2729
extern int read_ns_sys_file(char *path, char *buf, int len);
2830
extern int restore_link_parms(NetDeviceEntry *nde, int nlsk);
2931

criu/include/tun.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
#define TUN_MINOR 200
66
#endif
77

8+
#include <linux/netlink.h>
9+
810
#include "images/netdev.pb-c.h"
911

1012
extern const struct fdtype_ops tunfile_dump_ops;
11-
extern int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds);
13+
extern int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **info);
1214
extern int restore_one_tun(NetDeviceEntry *nde, int nlsk);
1315
extern struct collect_image_info tunfile_cinfo;
1416
extern int check_tun_cr(int no_tun_err);

criu/net.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,14 @@ static int ipv4_conf_op_old(char *tgt, int *conf, int n, int op, int *def_conf)
338338
return 0;
339339
}
340340

341-
int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds)
341+
int write_netdev_img(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **info)
342342
{
343343
return pb_write_one(img_from_set(fds, CR_FD_NETDEV), nde, PB_NETDEV);
344344
}
345345

346346
static int dump_one_netdev(int type, struct ifinfomsg *ifi,
347347
struct nlattr **tb, struct cr_imgset *fds,
348-
int (*dump)(NetDeviceEntry *, struct cr_imgset *))
348+
int (*dump)(NetDeviceEntry *, struct cr_imgset *, struct nlattr **info))
349349
{
350350
int ret = -1;
351351
int i;
@@ -355,6 +355,7 @@ static int dump_one_netdev(int type, struct ifinfomsg *ifi,
355355
SysctlEntry *confs6 = NULL;
356356
int size6 = ARRAY_SIZE(devconfs6);
357357
char stable_secret[MAX_STR_CONF_LEN + 1] = {};
358+
struct nlattr *info[IFLA_INFO_MAX], **arg = NULL;
358359

359360
if (!tb[IFLA_IFNAME]) {
360361
pr_err("No name for link %d\n", ifi->ifi_index);
@@ -422,7 +423,16 @@ static int dump_one_netdev(int type, struct ifinfomsg *ifi,
422423
if (!dump)
423424
dump = write_netdev_img;
424425

425-
ret = dump(&netdev, fds);
426+
if (tb[IFLA_LINKINFO]) {
427+
ret = nla_parse_nested(info, IFLA_INFO_MAX, tb[IFLA_LINKINFO], NULL);
428+
if (ret < 0) {
429+
pr_err("failed to parse nested linkinfo\n");
430+
return -1;
431+
}
432+
arg = info;
433+
}
434+
435+
ret = dump(&netdev, fds, arg);
426436
err_free:
427437
xfree(netdev.conf4);
428438
xfree(confs4);
@@ -464,7 +474,7 @@ static int dump_unknown_device(struct ifinfomsg *ifi, char *kind,
464474
return -1;
465475
}
466476

467-
static int dump_bridge(NetDeviceEntry *nde, struct cr_imgset *imgset)
477+
static int dump_bridge(NetDeviceEntry *nde, struct cr_imgset *imgset, struct nlattr **info)
468478
{
469479
char spath[IFNAMSIZ + 16]; /* len("class/net//brif") + 1 for null */
470480
int ret, fd;
@@ -496,7 +506,7 @@ static int dump_bridge(NetDeviceEntry *nde, struct cr_imgset *imgset)
496506
return -1;
497507
}
498508

499-
return write_netdev_img(nde, imgset);
509+
return write_netdev_img(nde, imgset, info);
500510
}
501511

502512
static int dump_one_ethernet(struct ifinfomsg *ifi, char *kind,

criu/tun.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ struct collect_image_info tunfile_cinfo = {
399399
.collect = collect_one_tunfile,
400400
};
401401

402-
int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
402+
int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds, struct nlattr **info)
403403
{
404404
TunLinkEntry tle = TUN_LINK_ENTRY__INIT;
405405
char spath[64];
@@ -430,7 +430,7 @@ int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
430430
tle.sndbuf = tl->dmp.sndbuf;
431431

432432
nde->tun = &tle;
433-
return write_netdev_img(nde, fds);
433+
return write_netdev_img(nde, fds, info);
434434
}
435435

436436
int restore_one_tun(NetDeviceEntry *nde, int nlsk)

0 commit comments

Comments
 (0)