2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

tun: Check tun has ioctl() cmd SIOCGSKNS

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2018-03-02 15:46:28 +03:00
committed by Andrei Vagin
parent 67e164bd32
commit b85f402672
5 changed files with 39 additions and 0 deletions

View File

@@ -1242,6 +1242,13 @@ static int check_tun(void)
return check_tun_cr(-1);
}
static int check_tun_netns(void)
{
bool has = false;
check_tun_netns_cr(&has);
return has ? 0 : -1;
}
static int check_nsid(void)
{
if (!kdat.has_nsid) {
@@ -1273,6 +1280,7 @@ static struct feature_list feature_list[] = {
{ "aio_remap", check_aio_remap },
{ "timerfd", check_timerfd },
{ "tun", check_tun },
{ "tun_ns", check_tun_netns },
{ "userns", check_userns },
{ "fdinfo_lock", check_fdinfo_lock },
{ "seccomp_suspend", check_ptrace_suspend_seccomp },

View File

@@ -48,6 +48,7 @@ struct kerndat_s {
enum loginuid_func luid;
bool compat_cr;
bool sk_ns;
bool tun_ns;
enum pagemap_func pmap;
unsigned int has_xtlocks;
unsigned long mmap_min_addr;

View File

@@ -15,5 +15,6 @@ struct net_link;
extern int restore_one_tun(struct net_link *link, int nlsk);
extern struct collect_image_info tunfile_cinfo;
extern int check_tun_cr(int no_tun_err);
extern int check_tun_netns_cr(bool *result);
#endif /* __CR_TUN_H__ */

View File

@@ -29,6 +29,7 @@
#include "sk-inet.h"
#include "sockets.h"
#include "net.h"
#include "tun.h"
#include <compel/plugins/std/syscall-codes.h>
#include <compel/compel.h>
#include "netfilter.h"
@@ -1014,6 +1015,12 @@ close:
bclose(&f);
return ret;
}
static int kerndat_tun_netns(void)
{
return check_tun_netns_cr(&kdat.tun_ns);
}
int kerndat_init(void)
{
int ret;
@@ -1050,6 +1057,8 @@ int kerndat_init(void)
ret = kerndat_compat_restore();
if (!ret)
ret = kerndat_socket_netns();
if (!ret)
ret = kerndat_tun_netns();
if (!ret)
ret = kerndat_nsid();
if (!ret)

View File

@@ -19,6 +19,7 @@
#include "net.h"
#include "namespaces.h"
#include "xmalloc.h"
#include "kerndat.h"
#include "images/tun.pb-c.h"
@@ -70,6 +71,25 @@ int check_tun_cr(int no_tun_err)
return ret;
}
int check_tun_netns_cr(bool *result)
{
bool val;
int tun;
tun = open(TUN_DEV_GEN_PATH, O_RDONLY);
if (tun < 0) {
pr_perror("Unable to create tun");
return -1;
}
check_has_netns_ioc(tun, &val, "tun");
close(tun);
if (result)
*result = val;
return 0;
}
static LIST_HEAD(tun_links);
struct tun_link {