Commit fe7d8a92 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

tun: Check tun has ioctl() cmd SIOCGSKNS

Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
parent 8f9553a0
......@@ -1209,6 +1209,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 (kerndat_nsid() < 0)
......@@ -1246,6 +1253,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 },
......
......@@ -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;
......
......@@ -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__ */
......@@ -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"
......@@ -933,6 +934,11 @@ out_unmap:
return ret;
}
static int kerndat_tun_netns(void)
{
return check_tun_netns_cr(&kdat.tun_ns);
}
int kerndat_init(void)
{
int ret;
......@@ -969,6 +975,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)
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment