[CRIU] [PATCH v7 7/8] build: add a feature test for linux/net_namespace.h

Tycho Andersen tycho.andersen at canonical.com
Tue Oct 18 21:54:07 PDT 2016


This header was only introduced in 2015, so we need to build without it.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 Makefile.config           |  2 +-
 criu/net.c                |  8 +++++++-
 scripts/feature-tests.mak | 11 +++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Makefile.config b/Makefile.config
index cce32fa..2259ad6 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -28,7 +28,7 @@ export DEFINES += $(FEATURE_DEFINES)
 export CFLAGS += $(FEATURE_DEFINES)
 
 FEATURES_LIST	:= TCP_REPAIR STRLCPY STRLCAT PTRACE_PEEKSIGINFO \
-	SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW
+	SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW NET_NAMESPACE_H
 
 # $1 - config name
 define gen-feature-test
diff --git a/criu/net.c b/criu/net.c
index 1e688af..25a02a2 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -1,7 +1,6 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <linux/netlink.h>
-#include <linux/net_namespace.h>
 #include <linux/rtnetlink.h>
 #include <linux/netfilter/nfnetlink.h>
 #include <linux/netfilter/nfnetlink_conntrack.h>
@@ -36,6 +35,13 @@
 #include "protobuf.h"
 #include "images/netdev.pb-c.h"
 
+#ifdef CONFIG_HAS_NET_NAMESPACE_H
+#include <linux/net_namespace.h>
+#else
+#define NETNSA_NSID	1
+#define NETNSA_FD	3
+#endif
+
 #ifndef IFLA_LINK_NETNSID
 #define IFLA_LINK_NETNSID	37
 #endif
diff --git a/scripts/feature-tests.mak b/scripts/feature-tests.mak
index ad50eb4..8812c47 100644
--- a/scripts/feature-tests.mak
+++ b/scripts/feature-tests.mak
@@ -100,3 +100,14 @@ int main(int argc, char **argv)
 }
 
 endef
+
+define FEATURE_TEST_NET_NAMESPACE_H
+
+#include <linux/net_namespace.h>
+
+int main(int argc, char **argv)
+{
+        return 0;
+}
+
+endef
-- 
2.7.4



More information about the CRIU mailing list