mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
kerndat: check whether ipv6 is supported or not (v2)
v2: use a cached value to dump ipv6 interface addesses call get_ipv6() from kerndat_init_rst too Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
c0bc79d92e
commit
1648db970c
@ -24,6 +24,7 @@ struct kerndat_s {
|
|||||||
bool has_memfd;
|
bool has_memfd;
|
||||||
bool has_fdinfo_lock;
|
bool has_fdinfo_lock;
|
||||||
unsigned long task_size;
|
unsigned long task_size;
|
||||||
|
bool ipv6;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct kerndat_s kdat;
|
extern struct kerndat_s kdat;
|
||||||
|
19
kerndat.c
19
kerndat.c
@ -333,6 +333,21 @@ out:
|
|||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_ipv6()
|
||||||
|
{
|
||||||
|
if (access("/proc/sys/net/ipv6", F_OK) < 0) {
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
pr_debug("ipv6 is disabled\n");
|
||||||
|
kdat.ipv6 = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pr_perror("Unable to access /proc/sys/net/ipv6");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
kdat.ipv6 = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int kerndat_init(void)
|
int kerndat_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -348,6 +363,8 @@ int kerndat_init(void)
|
|||||||
ret = kerndat_fdinfo_has_lock();
|
ret = kerndat_fdinfo_has_lock();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = get_task_size();
|
ret = get_task_size();
|
||||||
|
if (!ret)
|
||||||
|
ret = get_ipv6();
|
||||||
|
|
||||||
kerndat_lsm();
|
kerndat_lsm();
|
||||||
|
|
||||||
@ -371,6 +388,8 @@ int kerndat_init_rst(void)
|
|||||||
ret = kerndat_has_memfd_create();
|
ret = kerndat_has_memfd_create();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = get_task_size();
|
ret = get_task_size();
|
||||||
|
if (!ret)
|
||||||
|
ret = get_ipv6();
|
||||||
|
|
||||||
kerndat_lsm();
|
kerndat_lsm();
|
||||||
|
|
||||||
|
6
net.c
6
net.c
@ -25,6 +25,8 @@
|
|||||||
#include "pstree.h"
|
#include "pstree.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "sysctl.h"
|
#include "sysctl.h"
|
||||||
|
#include "kerndat.h"
|
||||||
|
|
||||||
#include "protobuf.h"
|
#include "protobuf.h"
|
||||||
#include "protobuf/netdev.pb-c.h"
|
#include "protobuf/netdev.pb-c.h"
|
||||||
|
|
||||||
@ -641,10 +643,8 @@ static inline int dump_route(struct cr_imgset *fds)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* If ipv6 is disabled, "ip -6 route dump" dumps all routes */
|
/* If ipv6 is disabled, "ip -6 route dump" dumps all routes */
|
||||||
if (access("/proc/sys/net/ipv6/", F_OK)) {
|
if (!kdat.ipv6)
|
||||||
pr_debug("ipv6 is disabled\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
img = img_from_set(fds, CR_FD_ROUTE6);
|
img = img_from_set(fds, CR_FD_ROUTE6);
|
||||||
if (run_ip_tool("-6", "route", "save", -1, img_raw_fd(img), 0))
|
if (run_ip_tool("-6", "route", "save", -1, img_raw_fd(img), 0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user