[CRIU] [PATCH 2/4] kerndat: check whether ipv6 is supported or not

Andrey Vagin avagin at openvz.org
Tue Nov 17 12:19:37 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 include/kerndat.h |  1 +
 kerndat.c         | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

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..6b9e8bf 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -333,6 +333,20 @@ out:
 	return exit_code;
 }
 
+static int get_ipv6()
+{
+	if (access("/proc/sys/net/ipv6", F_OK) < 0) {
+		if (errno == ENOENT) {
+			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 +362,8 @@ int kerndat_init(void)
 		ret = kerndat_fdinfo_has_lock();
 	if (!ret)
 		ret = get_task_size();
+	if (!ret)
+		ret = get_ipv6();
 
 	kerndat_lsm();
 
-- 
2.4.3



More information about the CRIU mailing list