diff --git a/cr-check.c b/cr-check.c index 519131837..92484cfd6 100644 --- a/cr-check.c +++ b/cr-check.c @@ -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"); diff --git a/include/tun.h b/include/tun.h index 6c998c677..7897495b2 100644 --- a/include/tun.h +++ b/include/tun.h @@ -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 diff --git a/tun.c b/tun.c index 96ba75159..08ebcf10d 100644 --- a/tun.c +++ b/tun.c @@ -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 {