mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 22:35:33 +00:00
kerndat: check if setsockopt IPV6_FREEBIND is supported
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
14e8836564
commit
f1c8d386b4
@@ -1375,6 +1375,14 @@ static int check_openat2(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_ipv6_freebind(void)
|
||||
{
|
||||
if (!kdat.has_ipv6_freebind)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int (*chk_feature)(void);
|
||||
|
||||
/*
|
||||
@@ -1494,6 +1502,7 @@ int cr_check(void)
|
||||
ret |= check_move_mount_set_group();
|
||||
ret |= check_openat2();
|
||||
ret |= check_ptrace_get_rseq_conf();
|
||||
ret |= check_ipv6_freebind();
|
||||
|
||||
if (kdat.lsm == LSMTYPE__APPARMOR)
|
||||
ret |= check_apparmor_stacking();
|
||||
@@ -1614,6 +1623,7 @@ static struct feature_list feature_list[] = {
|
||||
{ "move_mount_set_group", check_move_mount_set_group },
|
||||
{ "openat2", check_openat2 },
|
||||
{ "get_rseq_conf", check_ptrace_get_rseq_conf },
|
||||
{ "ipv6_freebind", check_ipv6_freebind },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
@@ -84,6 +84,7 @@ struct kerndat_s {
|
||||
bool has_rseq;
|
||||
bool has_ptrace_get_rseq_conf;
|
||||
struct __ptrace_rseq_configuration libc_rseq_conf;
|
||||
bool has_ipv6_freebind;
|
||||
};
|
||||
|
||||
extern struct kerndat_s kdat;
|
||||
|
@@ -1541,6 +1541,34 @@ static int kerndat_has_nftables_concat(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef IPV6_FREEBIND
|
||||
#define IPV6_FREEBIND 78
|
||||
#endif
|
||||
|
||||
static int kerndat_has_ipv6_freebind(void)
|
||||
{
|
||||
int sk, val;
|
||||
|
||||
sk = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sk == -1) {
|
||||
pr_perror("Unable to create a ipv6 dgram socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
val = 1;
|
||||
if (setsockopt(sk, SOL_IPV6, IPV6_FREEBIND, &val, sizeof(int)) == -1) {
|
||||
if (errno == ENOPROTOOPT) {
|
||||
kdat.has_ipv6_freebind = false;
|
||||
return 0;
|
||||
}
|
||||
pr_perror("Unable to setsockopt ipv6_freebind");
|
||||
return -1;
|
||||
}
|
||||
|
||||
kdat.has_ipv6_freebind = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some features depend on resource that can be dynamically changed
|
||||
* at the OS runtime. There are cases that we cannot determine the
|
||||
@@ -1780,6 +1808,10 @@ int kerndat_init(void)
|
||||
pr_err("kerndat_has_ptrace_get_rseq_conf failed when initializing kerndat.\n");
|
||||
ret = -1;
|
||||
}
|
||||
if (!ret && (kerndat_has_ipv6_freebind() < 0)) {
|
||||
pr_err("kerndat_has_ipv6_freebind failed when initializing kerndat.\n");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
kerndat_lsm();
|
||||
kerndat_mmap_min_addr();
|
||||
|
Reference in New Issue
Block a user