[CRIU] [PATCH 2/4] kerndat: check whether ipv6 is supported or not (v2)
Andrey Vagin
avagin at openvz.org
Wed Nov 18 03:03:15 PST 2015
From: Andrew Vagin <avagin at virtuozzo.com>
v2: use a cached value to dump ipv6 interface addesses
call get_ipv6() from kerndat_init_rst too
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
include/kerndat.h | 1 +
kerndat.c | 19 +++++++++++++++++++
net.c | 6 +++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/include/kerndat.h b/include/kerndat.h
index b9ae749..e76b0d2 100644
--- a/include/kerndat.h
+++ b/include/kerndat.h
@@ -24,6 +24,7 @@ struct kerndat_s {
bool has_memfd;
bool has_fdinfo_lock;
unsigned long task_size;
+ bool ipv6;
};
extern struct kerndat_s kdat;
diff --git a/kerndat.c b/kerndat.c
index dab56ba..5b9df83 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -333,6 +333,21 @@ out:
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 ret;
@@ -348,6 +363,8 @@ int kerndat_init(void)
ret = kerndat_fdinfo_has_lock();
if (!ret)
ret = get_task_size();
+ if (!ret)
+ ret = get_ipv6();
kerndat_lsm();
@@ -371,6 +388,8 @@ int kerndat_init_rst(void)
ret = kerndat_has_memfd_create();
if (!ret)
ret = get_task_size();
+ if (!ret)
+ ret = get_ipv6();
kerndat_lsm();
diff --git a/net.c b/net.c
index cca5ef8..7c42178 100644
--- a/net.c
+++ b/net.c
@@ -25,6 +25,8 @@
#include "pstree.h"
#include "string.h"
#include "sysctl.h"
+#include "kerndat.h"
+
#include "protobuf.h"
#include "protobuf/netdev.pb-c.h"
@@ -641,10 +643,8 @@ static inline int dump_route(struct cr_imgset *fds)
return -1;
/* If ipv6 is disabled, "ip -6 route dump" dumps all routes */
- if (access("/proc/sys/net/ipv6/", F_OK)) {
- pr_debug("ipv6 is disabled\n");
+ if (!kdat.ipv6)
return 0;
- }
img = img_from_set(fds, CR_FD_ROUTE6);
if (run_ip_tool("-6", "route", "save", -1, img_raw_fd(img), 0))
--
2.4.3
More information about the CRIU
mailing list