[CRIU] [PATCH 2/2] test: check that corked udp sockets are not dumped

Andrei Vagin avagin at openvz.org
Mon Dec 4 22:41:11 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

The kernel doesn't have an interface to get a sent queue for udp
sockets, so currently we can't dump them and criu dump has to fail in
such cases.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/Makefile               |  1 +
 test/zdtm/static/socket_udp-corked.c    | 76 +++++++++++++++++++++++++++++++++
 test/zdtm/static/socket_udp-corked.desc |  1 +
 3 files changed, 78 insertions(+)
 create mode 100644 test/zdtm/static/socket_udp-corked.c
 create mode 100644 test/zdtm/static/socket_udp-corked.desc

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 289edd721..135afd22f 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -28,6 +28,7 @@ TST_NOFILE	:=				\
 		socket_listen6			\
 		socket_listen4v6		\
 		socket_udp			\
+		socket_udp-corked		\
 		socket6_udp			\
 		socket_udp_shutdown		\
 		sk-freebind			\
diff --git a/test/zdtm/static/socket_udp-corked.c b/test/zdtm/static/socket_udp-corked.c
new file mode 100644
index 000000000..30cfac5ec
--- /dev/null
+++ b/test/zdtm/static/socket_udp-corked.c
@@ -0,0 +1,76 @@
+#include "zdtmtst.h"
+
+const char *test_doc = "static test for UDP socket\n";
+const char *test_author = "Pavel Emelyanov <xemul at parallels.com<>\n";
+
+/* Description:
+ * Create two tcp socket, server send asynchronous request on
+ * read data and clietn write data after migration
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>  /* for sockaddr_in and inet_ntoa() */
+#include <sys/wait.h>
+#include <netinet/udp.h>
+
+static int port = 8880;
+
+#define MSG1 "msg1"
+
+int main(int argc, char **argv)
+{
+	int ret, sk1;
+	socklen_t len = sizeof(struct sockaddr_in);
+	struct sockaddr_in addr1;
+	int opt;
+
+	test_init(argc, argv);
+
+	sk1 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+	if (sk1 < 0) {
+		pr_perror("Can't create socket");
+		return 1;
+	}
+
+	memset(&addr1, 0, sizeof(addr1));
+	addr1.sin_family = AF_INET;
+	addr1.sin_addr.s_addr = inet_addr("127.0.0.1");
+	addr1.sin_port = htons(port);
+
+	ret = bind(sk1, (struct sockaddr *)&addr1, len);
+	if (ret < 0) {
+		pr_perror("Can't bind socket");
+		return 1;
+	}
+	ret = connect(sk1, (struct sockaddr *)&addr1, len);
+	if (ret < 0) {
+		pr_perror("Can't connect");
+		return 1;
+	}
+
+	opt = 1;
+	if (setsockopt(sk1, SOL_UDP, UDP_CORK, &opt, sizeof(opt))) {
+		pr_perror("Unable to set UDP_CORK");
+		return 1;
+	}
+
+	if (write(sk1, MSG1, sizeof(MSG1)) != sizeof(MSG1)) {
+		pr_perror("write");
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+
+	pass();
+	return 0;
+}
diff --git a/test/zdtm/static/socket_udp-corked.desc b/test/zdtm/static/socket_udp-corked.desc
new file mode 100644
index 000000000..ded89879a
--- /dev/null
+++ b/test/zdtm/static/socket_udp-corked.desc
@@ -0,0 +1 @@
+{'flags': 'crfail'}
-- 
2.13.6



More information about the CRIU mailing list