[CRIU] [PATCH v2 5/5] zdtm: Add tun_ns test

Kirill Tkhai ktkhai at virtuozzo.com
Fri Mar 2 15:46:53 MSK 2018


From: Andrew Vagin <avagin at virtuozzo.com>

tun test in nested net ns wrapper.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
ktkhai: Makefile hunks
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 test/zdtm/static/Makefile |    2 ++
 test/zdtm/static/tun.c    |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index fd333ee0b..c8f95155e 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -157,6 +157,7 @@ TST_NOFILE	:=				\
 		grow_map02			\
 		grow_map03			\
 		tun				\
+		tun_ns				\
 		stopped				\
 		stopped01			\
 		stopped02			\
@@ -483,6 +484,7 @@ socket_listen4v6:	CFLAGS += -D ZDTM_IPV4V6
 socket-tcp6-closed:	CFLAGS += -D ZDTM_IPV6
 socket-tcp6-closed:	CFLAGS += -D ZDTM_IPV4V6
 socket-tcp-closed-last-ack:	CFLAGS += -D ZDTM_TCP_LAST_ACK
+tun_ns:			CFLAGS += -DTUN_NS
 mnt_ext_manual:		CFLAGS += -D ZDTM_EXTMAP_MANUAL
 sigpending:		LDLIBS += -lrt
 vdso01:			LDLIBS += -lrt
diff --git a/test/zdtm/static/tun.c b/test/zdtm/static/tun.c
index c53b8fa88..98519e5d2 100644
--- a/test/zdtm/static/tun.c
+++ b/test/zdtm/static/tun.c
@@ -5,6 +5,7 @@
 #include <sys/socket.h>
 #include <linux/if.h>
 #include <linux/if_tun.h>
+#include <sched.h>
 
 #include "zdtmtst.h"
 
@@ -118,7 +119,10 @@ int main(int argc, char **argv)
 	char addr[ETH_ALEN], a2[ETH_ALEN];
 
 	test_init(argc, argv);
-
+#ifdef TUN_NS
+	unshare(CLONE_NEWNET);
+	system("ip link set up dev lo");
+#endif
 	/* fd[0] -- opened file */
 	fds[0] = __open_tun();
 	if (fds[0] < 0) {



More information about the CRIU mailing list