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

Submitted by Tycho Andersen on Oct. 19, 2016, 4:54 a.m.

Details

Message ID 1476852848-31714-8-git-send-email-tycho.andersen@canonical.com
State Accepted
Series "Series without cover letter"
Commit 85967eaf1d7b1b07efb4aa95405d58d6ca8b680e
Headers show

Commit Message

Tycho Andersen Oct. 19, 2016, 4:54 a.m.
This header was only introduced in 2015, so we need to build without it.

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

Patch hide | download patch | download mbox

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