[CRIU] [PATCH] zdtm: check restoring of sockets in the TCP_CLOSE state

Andrey Vagin avagin at openvz.org
Fri Sep 25 04:02:46 PDT 2015


From: Andrew Vagin <avagin at openvz.org>

(00.004456) Error (sk-inet.c:188): Name resolved on unconnected socket
(00.004466) Error (cr-dump.c:1255): Dump files (pid: 7944) failed with -1
(00.004680) Error (cr-dump.c:1617): Dumping FAILED.

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/Makefile            |  1 +
 test/zdtm/live/static/socket-closed-tcp.c | 58 +++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 test/zdtm/live/static/socket-closed-tcp.c

diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index c3a9929..6352f80 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -64,6 +64,7 @@ TST_NOFILE	=				\
 		socket-tcpbuf			\
 		socket-tcpbuf-local		\
 		socket-tcpbuf6			\
+		socket-closed-tcp		\
 		sock_opts00			\
 		sock_opts01			\
 		sk-unix-unconn			\
diff --git a/test/zdtm/live/static/socket-closed-tcp.c b/test/zdtm/live/static/socket-closed-tcp.c
new file mode 100644
index 0000000..32ca56f
--- /dev/null
+++ b/test/zdtm/live/static/socket-closed-tcp.c
@@ -0,0 +1,58 @@
+#include "zdtmtst.h"
+
+#ifdef ZDTM_IPV6
+#define ZDTM_FAMILY AF_INET6
+#else
+#define ZDTM_FAMILY AF_INET
+#endif
+
+const char *test_doc = "Check, that a TCP socket in the TCP_CLOSE state can be restored\n";
+const char *test_author = "Andrey Vagin <avagin at openvz.org";
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <netinet/tcp.h>
+
+static int port = 8880;
+
+int main(int argc, char **argv)
+{
+	int fd, fd_s, clt;
+
+	test_init(argc, argv);
+
+	if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) {
+		err("initializing server failed");
+		return 1;
+	}
+
+	clt = tcp_init_client(ZDTM_FAMILY, "localhost", port);
+	if (clt < 0)
+		return 1;
+
+	/*
+	 * parent is server of TCP connection
+	 */
+	fd = tcp_accept_server(fd_s);
+	if (fd < 0) {
+		err("can't accept client connection %m");
+		return 1;
+	}
+	close(fd_s);
+
+	shutdown(fd, SHUT_WR);
+	shutdown(clt, SHUT_WR);
+	close(fd);
+
+	test_daemon();
+	test_waitsig();
+
+
+	pass();
+	return 0;
+}
-- 
2.4.3



More information about the CRIU mailing list