check: Add tun support

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2013-08-23 19:18:47 +04:00
parent ed5f82c7e6
commit c2b7800740
3 changed files with 26 additions and 0 deletions

View file

@ -26,6 +26,7 @@
#include "tty.h"
#include "ptrace.h"
#include "kerndat.h"
#include "tun.h"
static int check_tty(void)
{
@ -559,6 +560,7 @@ int cr_check(void)
ret |= check_ptrace_peeksiginfo();
ret |= check_mem_dirty_track();
ret |= check_posix_timers();
ret |= check_tun();
if (!ret)
pr_msg("Looks good.\n");

View file

@ -10,4 +10,5 @@ extern const struct fdtype_ops tunfile_dump_ops;
int dump_tun_link(NetDeviceEntry *nde, struct cr_fdset *fds);
int restore_one_tun(NetDeviceEntry *nde, int nlsk);
extern struct collect_image_info tunfile_cinfo;
int check_tun(void);
#endif

23
tun.c
View file

@ -44,6 +44,29 @@
#define TUN_DEV_GEN_PATH "/dev/net/tun"
int check_tun(void)
{
int fd, idx = 13, ret;
if (opts.check_ms_kernel) {
pr_warn("Skipping tun support check\n");
return 0;
}
fd = open(TUN_DEV_GEN_PATH, O_RDWR);
if (fd < 0) {
pr_perror("Can't check tun support");
return 0;
}
ret = ioctl(fd, TUNSETIFINDEX, &idx);
if (ret < 0)
pr_perror("No proper support for tun dump/restore");
close(fd);
return ret;
}
static LIST_HEAD(tun_links);
struct tun_link {