[CRIU] [PATCH 1/2] zdtm: check SO_REUSEADDR is restored

Andrey Vagin avagin at openvz.org
Mon Jan 14 05:49:02 EST 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/socket-tcp.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/test/zdtm/live/static/socket-tcp.c b/test/zdtm/live/static/socket-tcp.c
index b37f012..ca5939e 100644
--- a/test/zdtm/live/static/socket-tcp.c
+++ b/test/zdtm/live/static/socket-tcp.c
@@ -58,6 +58,8 @@ int main(int argc, char **argv)
 	pid_t extpid;
 	uint32_t crc;
 	int pfd[2];
+	int val;
+	socklen_t optlen;
 
 	if (pipe(pfd)) {
 		err("pipe() failed");
@@ -136,6 +138,12 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+	val = 1;
+	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))) {
+		err("setsockopt");
+		return 1;
+	}
+
 	test_daemon();
 #ifdef STREAM
 	while (test_go()) {
@@ -169,6 +177,16 @@ int main(int argc, char **argv)
 	if (datachk(buf, BUF_SIZE, &crc))
 		return 2;
 #endif
+	optlen = sizeof(val);
+	if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, &optlen)) {
+		err("getsockopt");
+		return 1;
+	}
+	if (val != 1) {
+		fail("SO_REUSEADDR are not set for %d\n", fd);
+		return 1;
+	}
+
 	pass();
 	return 0;
 }
-- 
1.7.11.7



More information about the CRIU mailing list