[2/2] zdtm: Check that 'tcp-close' option closes sockets

Submitted by Pavel Begunkov (Silence) on June 2, 2017, 6:32 a.m.

Details

Message ID 20170602063227.979-1-asml.silence@gmail.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Pavel Begunkov (Silence) June 2, 2017, 6:32 a.m.
There are 2 test cases:
1. Connected socket should be restored in the closed state
2. Listening socket state should not change after restore

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
---
 test/zdtm/static/Makefile               |  2 +
 test/zdtm/static/socket-tcp-close0.c    | 72 +++++++++++++++++++++++++++++++++
 test/zdtm/static/socket-tcp-close0.desc |  1 +
 test/zdtm/static/socket-tcp-close1.c    | 50 +++++++++++++++++++++++
 test/zdtm/static/socket-tcp-close1.desc |  1 +
 5 files changed, 126 insertions(+)
 create mode 100644 test/zdtm/static/socket-tcp-close0.c
 create mode 100644 test/zdtm/static/socket-tcp-close0.desc
 create mode 100644 test/zdtm/static/socket-tcp-close1.c
 create mode 120000 test/zdtm/static/socket-tcp-close1.desc

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 1ea9393c..d5eeadc8 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -82,6 +82,8 @@  TST_NOFILE	:=				\
 		socket-tcp-closed		\
 		socket-tcp-closed-last-ack	\
 		socket-tcp6-closed		\
+		socket-tcp-close0 		\
+		socket-tcp-close1 		\
 		socket-tcp-unconn		\
 		socket-tcp6-unconn		\
 		socket-tcp-syn-sent		\
diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c
new file mode 100644
index 00000000..2bc0f64f
--- /dev/null
+++ b/test/zdtm/static/socket-tcp-close0.c
@@ -0,0 +1,72 @@ 
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/tcp.h>
+#include <netinet/in.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check that tcp-close option closes connected tcp socket";
+const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
+
+static int port = 8880;
+
+static int check_socket_closed(int sk)
+{
+	int err, buffer = 0;
+	struct tcp_info info;
+	socklen_t len = sizeof(info);
+
+	err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
+	if (err != 0) {
+		pr_perror("Can't get socket state\n");
+		return -1;
+	} else if (info.tcpi_state != TCP_CLOSE) {
+		pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state);
+		return -1;
+	}
+
+	err = recv(sk, &buffer, sizeof(buffer), 0);
+	if (!err || errno != ENOTCONN) {
+		pr_perror("Invalid recv response\n");
+		return -1;
+	}
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	int fd, fd_s, clt;
+
+	test_init(argc, argv);
+
+	fd_s = tcp_init_server(AF_INET, &port);
+	if (fd_s < 0) {
+		pr_err("Server initializations failed\n");
+		return 1;
+	}
+	clt = tcp_init_client(AF_INET, "localhost", port);
+	if (clt < 0)
+		return 1;
+
+	fd = tcp_accept_server(fd_s);
+	if (fd < 0) {
+		pr_err("Can't accept client connection\n");
+		return 1;
+	}
+	close(fd_s);
+
+	test_daemon();
+	test_waitsig();
+
+	if (check_socket_closed(fd)) {
+		fail("Server socket isn't closed\n");
+		return 1;
+	}
+	if (check_socket_closed(clt)) {
+		fail("Client socket isn't closed\n");
+		return 1;
+	}
+	pass();
+	return 0;
+}
diff --git a/test/zdtm/static/socket-tcp-close0.desc b/test/zdtm/static/socket-tcp-close0.desc
new file mode 100644
index 00000000..e85de0e6
--- /dev/null
+++ b/test/zdtm/static/socket-tcp-close0.desc
@@ -0,0 +1 @@ 
+{'dopts': '--tcp-established', 'ropts': '--tcp-close'}
diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c
new file mode 100644
index 00000000..54511a34
--- /dev/null
+++ b/test/zdtm/static/socket-tcp-close1.c
@@ -0,0 +1,50 @@ 
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/tcp.h>
+#include <netinet/in.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check that tcp-close option doesn't close listening tcp socket";
+const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
+
+static int port = 8880;
+
+static int check_socket_state(int sk, int state)
+{
+	int err;
+	struct tcp_info info;
+	socklen_t len = sizeof(info);
+
+	err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
+	if (err != 0) {
+		pr_perror("Can't get socket state\n");
+		return -1;
+	}
+	return info.tcpi_state == state ? 0 : -1;
+}
+
+int main(int argc, char **argv)
+{
+	int fd_s;
+
+	test_init(argc, argv);
+
+	fd_s = tcp_init_server(AF_INET, &port);
+	if (fd_s < 0) {
+		pr_err("Server initializations failed\n");
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	if (check_socket_state(fd_s, TCP_LISTEN)) {
+		fail("Listen socket state is changed\n");
+		close(fd_s);
+		return 1;
+	}
+	close(fd_s);
+	pass();
+	return 0;
+}
diff --git a/test/zdtm/static/socket-tcp-close1.desc b/test/zdtm/static/socket-tcp-close1.desc
new file mode 120000
index 00000000..836b8fa5
--- /dev/null
+++ b/test/zdtm/static/socket-tcp-close1.desc
@@ -0,0 +1 @@ 
+socket-tcp-close0.desc
\ No newline at end of file

Comments

Andrey Vagin June 20, 2017, 6:41 p.m.
Pavel, pls take a look at this and fix ASAP. Thanks!


https://ci.openvz.org/job/CRIU/job/CRIU-dump-only/job/criu-dev/2557/consoleFull

[root@fc24 criu]# python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst
==================== Run zdtm/static/socket-tcp-close0 in h ====================
Start test
./socket-tcp-close0 --pidfile=socket-tcp-close0.pid --outfile=socket-tcp-close0.out
Run criu dump
Send the 15 signal to  24
Wait for zdtm/static/socket-tcp-close0(24) to die for 0.100000
########### Test zdtm/static/socket-tcp-close0 FAIL at result check ############
Test output: ================================
18:08:38.015:    24: ERR: socket-tcp-close0.c:25: Invalid socket state (1)
18:08:38.016:    24: FAIL: socket-tcp-close0.c:63: Server socket isn't closed
 (errno = 11 (Resource temporarily unavailable))

 <<< ================================

On Fri, Jun 02, 2017 at 09:32:27AM +0300, Pavel Begunkov wrote:
> There are 2 test cases:
> 1. Connected socket should be restored in the closed state
> 2. Listening socket state should not change after restore
> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
> ---
>  test/zdtm/static/Makefile               |  2 +
>  test/zdtm/static/socket-tcp-close0.c    | 72 +++++++++++++++++++++++++++++++++
>  test/zdtm/static/socket-tcp-close0.desc |  1 +
>  test/zdtm/static/socket-tcp-close1.c    | 50 +++++++++++++++++++++++
>  test/zdtm/static/socket-tcp-close1.desc |  1 +
>  5 files changed, 126 insertions(+)
>  create mode 100644 test/zdtm/static/socket-tcp-close0.c
>  create mode 100644 test/zdtm/static/socket-tcp-close0.desc
>  create mode 100644 test/zdtm/static/socket-tcp-close1.c
>  create mode 120000 test/zdtm/static/socket-tcp-close1.desc
> 
> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
> index 1ea9393c..d5eeadc8 100644
> --- a/test/zdtm/static/Makefile
> +++ b/test/zdtm/static/Makefile
> @@ -82,6 +82,8 @@ TST_NOFILE	:=				\
>  		socket-tcp-closed		\
>  		socket-tcp-closed-last-ack	\
>  		socket-tcp6-closed		\
> +		socket-tcp-close0 		\
> +		socket-tcp-close1 		\
>  		socket-tcp-unconn		\
>  		socket-tcp6-unconn		\
>  		socket-tcp-syn-sent		\
> diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c
> new file mode 100644
> index 00000000..2bc0f64f
> --- /dev/null
> +++ b/test/zdtm/static/socket-tcp-close0.c
> @@ -0,0 +1,72 @@
> +#include <errno.h>
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <netinet/tcp.h>
> +#include <netinet/in.h>
> +
> +#include "zdtmtst.h"
> +
> +const char *test_doc = "Check that tcp-close option closes connected tcp socket";
> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
> +
> +static int port = 8880;
> +
> +static int check_socket_closed(int sk)
> +{
> +	int err, buffer = 0;
> +	struct tcp_info info;
> +	socklen_t len = sizeof(info);
> +
> +	err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
> +	if (err != 0) {
> +		pr_perror("Can't get socket state\n");
> +		return -1;
> +	} else if (info.tcpi_state != TCP_CLOSE) {
> +		pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state);
> +		return -1;
> +	}
> +
> +	err = recv(sk, &buffer, sizeof(buffer), 0);
> +	if (!err || errno != ENOTCONN) {
> +		pr_perror("Invalid recv response\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	int fd, fd_s, clt;
> +
> +	test_init(argc, argv);
> +
> +	fd_s = tcp_init_server(AF_INET, &port);
> +	if (fd_s < 0) {
> +		pr_err("Server initializations failed\n");
> +		return 1;
> +	}
> +	clt = tcp_init_client(AF_INET, "localhost", port);
> +	if (clt < 0)
> +		return 1;
> +
> +	fd = tcp_accept_server(fd_s);
> +	if (fd < 0) {
> +		pr_err("Can't accept client connection\n");
> +		return 1;
> +	}
> +	close(fd_s);
> +
> +	test_daemon();
> +	test_waitsig();
> +
> +	if (check_socket_closed(fd)) {
> +		fail("Server socket isn't closed\n");
> +		return 1;
> +	}
> +	if (check_socket_closed(clt)) {
> +		fail("Client socket isn't closed\n");
> +		return 1;
> +	}
> +	pass();
> +	return 0;
> +}
> diff --git a/test/zdtm/static/socket-tcp-close0.desc b/test/zdtm/static/socket-tcp-close0.desc
> new file mode 100644
> index 00000000..e85de0e6
> --- /dev/null
> +++ b/test/zdtm/static/socket-tcp-close0.desc
> @@ -0,0 +1 @@
> +{'dopts': '--tcp-established', 'ropts': '--tcp-close'}
> diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c
> new file mode 100644
> index 00000000..54511a34
> --- /dev/null
> +++ b/test/zdtm/static/socket-tcp-close1.c
> @@ -0,0 +1,50 @@
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <netinet/tcp.h>
> +#include <netinet/in.h>
> +
> +#include "zdtmtst.h"
> +
> +const char *test_doc = "Check that tcp-close option doesn't close listening tcp socket";
> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
> +
> +static int port = 8880;
> +
> +static int check_socket_state(int sk, int state)
> +{
> +	int err;
> +	struct tcp_info info;
> +	socklen_t len = sizeof(info);
> +
> +	err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
> +	if (err != 0) {
> +		pr_perror("Can't get socket state\n");
> +		return -1;
> +	}
> +	return info.tcpi_state == state ? 0 : -1;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	int fd_s;
> +
> +	test_init(argc, argv);
> +
> +	fd_s = tcp_init_server(AF_INET, &port);
> +	if (fd_s < 0) {
> +		pr_err("Server initializations failed\n");
> +		return 1;
> +	}
> +
> +	test_daemon();
> +	test_waitsig();
> +
> +	if (check_socket_state(fd_s, TCP_LISTEN)) {
> +		fail("Listen socket state is changed\n");
> +		close(fd_s);
> +		return 1;
> +	}
> +	close(fd_s);
> +	pass();
> +	return 0;
> +}
> diff --git a/test/zdtm/static/socket-tcp-close1.desc b/test/zdtm/static/socket-tcp-close1.desc
> new file mode 120000
> index 00000000..836b8fa5
> --- /dev/null
> +++ b/test/zdtm/static/socket-tcp-close1.desc
> @@ -0,0 +1 @@
> +socket-tcp-close0.desc
> \ No newline at end of file
> -- 
> 2.11.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
Pavel Begunkov (Silence) June 20, 2017, 7:14 p.m.
On Tue, Jun 20, 2017 at 9:41 PM, Andrei Vagin <avagin@virtuozzo.com> wrote:
> Pavel, pls take a look at this and fix ASAP. Thanks!

I'll look. Thanks for the notice.

--
Pavel

>
>
> https://ci.openvz.org/job/CRIU/job/CRIU-dump-only/job/criu-dev/2557/consoleFull
>
> [root@fc24 criu]# python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst
> ==================== Run zdtm/static/socket-tcp-close0 in h ====================
> Start test
> ./socket-tcp-close0 --pidfile=socket-tcp-close0.pid --outfile=socket-tcp-close0.out
> Run criu dump
> Send the 15 signal to  24
> Wait for zdtm/static/socket-tcp-close0(24) to die for 0.100000
> ########### Test zdtm/static/socket-tcp-close0 FAIL at result check ############
> Test output: ================================
> 18:08:38.015:    24: ERR: socket-tcp-close0.c:25: Invalid socket state (1)
> 18:08:38.016:    24: FAIL: socket-tcp-close0.c:63: Server socket isn't closed
>  (errno = 11 (Resource temporarily unavailable))
>
>  <<< ================================
>
> On Fri, Jun 02, 2017 at 09:32:27AM +0300, Pavel Begunkov wrote:
>> There are 2 test cases:
>> 1. Connected socket should be restored in the closed state
>> 2. Listening socket state should not change after restore
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>> Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
>> ---
>>  test/zdtm/static/Makefile               |  2 +
>>  test/zdtm/static/socket-tcp-close0.c    | 72 +++++++++++++++++++++++++++++++++
>>  test/zdtm/static/socket-tcp-close0.desc |  1 +
>>  test/zdtm/static/socket-tcp-close1.c    | 50 +++++++++++++++++++++++
>>  test/zdtm/static/socket-tcp-close1.desc |  1 +
>>  5 files changed, 126 insertions(+)
>>  create mode 100644 test/zdtm/static/socket-tcp-close0.c
>>  create mode 100644 test/zdtm/static/socket-tcp-close0.desc
>>  create mode 100644 test/zdtm/static/socket-tcp-close1.c
>>  create mode 120000 test/zdtm/static/socket-tcp-close1.desc
>>
>> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
>> index 1ea9393c..d5eeadc8 100644
>> --- a/test/zdtm/static/Makefile
>> +++ b/test/zdtm/static/Makefile
>> @@ -82,6 +82,8 @@ TST_NOFILE  :=                              \
>>               socket-tcp-closed               \
>>               socket-tcp-closed-last-ack      \
>>               socket-tcp6-closed              \
>> +             socket-tcp-close0               \
>> +             socket-tcp-close1               \
>>               socket-tcp-unconn               \
>>               socket-tcp6-unconn              \
>>               socket-tcp-syn-sent             \
>> diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c
>> new file mode 100644
>> index 00000000..2bc0f64f
>> --- /dev/null
>> +++ b/test/zdtm/static/socket-tcp-close0.c
>> @@ -0,0 +1,72 @@
>> +#include <errno.h>
>> +#include <sys/types.h>
>> +#include <sys/socket.h>
>> +#include <netinet/tcp.h>
>> +#include <netinet/in.h>
>> +
>> +#include "zdtmtst.h"
>> +
>> +const char *test_doc = "Check that tcp-close option closes connected tcp socket";
>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
>> +
>> +static int port = 8880;
>> +
>> +static int check_socket_closed(int sk)
>> +{
>> +     int err, buffer = 0;
>> +     struct tcp_info info;
>> +     socklen_t len = sizeof(info);
>> +
>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
>> +     if (err != 0) {
>> +             pr_perror("Can't get socket state\n");
>> +             return -1;
>> +     } else if (info.tcpi_state != TCP_CLOSE) {
>> +             pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state);
>> +             return -1;
>> +     }
>> +
>> +     err = recv(sk, &buffer, sizeof(buffer), 0);
>> +     if (!err || errno != ENOTCONN) {
>> +             pr_perror("Invalid recv response\n");
>> +             return -1;
>> +     }
>> +     return 0;
>> +}
>> +
>> +int main(int argc, char **argv)
>> +{
>> +     int fd, fd_s, clt;
>> +
>> +     test_init(argc, argv);
>> +
>> +     fd_s = tcp_init_server(AF_INET, &port);
>> +     if (fd_s < 0) {
>> +             pr_err("Server initializations failed\n");
>> +             return 1;
>> +     }
>> +     clt = tcp_init_client(AF_INET, "localhost", port);
>> +     if (clt < 0)
>> +             return 1;
>> +
>> +     fd = tcp_accept_server(fd_s);
>> +     if (fd < 0) {
>> +             pr_err("Can't accept client connection\n");
>> +             return 1;
>> +     }
>> +     close(fd_s);
>> +
>> +     test_daemon();
>> +     test_waitsig();
>> +
>> +     if (check_socket_closed(fd)) {
>> +             fail("Server socket isn't closed\n");
>> +             return 1;
>> +     }
>> +     if (check_socket_closed(clt)) {
>> +             fail("Client socket isn't closed\n");
>> +             return 1;
>> +     }
>> +     pass();
>> +     return 0;
>> +}
>> diff --git a/test/zdtm/static/socket-tcp-close0.desc b/test/zdtm/static/socket-tcp-close0.desc
>> new file mode 100644
>> index 00000000..e85de0e6
>> --- /dev/null
>> +++ b/test/zdtm/static/socket-tcp-close0.desc
>> @@ -0,0 +1 @@
>> +{'dopts': '--tcp-established', 'ropts': '--tcp-close'}
>> diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c
>> new file mode 100644
>> index 00000000..54511a34
>> --- /dev/null
>> +++ b/test/zdtm/static/socket-tcp-close1.c
>> @@ -0,0 +1,50 @@
>> +#include <sys/types.h>
>> +#include <sys/socket.h>
>> +#include <netinet/tcp.h>
>> +#include <netinet/in.h>
>> +
>> +#include "zdtmtst.h"
>> +
>> +const char *test_doc = "Check that tcp-close option doesn't close listening tcp socket";
>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
>> +
>> +static int port = 8880;
>> +
>> +static int check_socket_state(int sk, int state)
>> +{
>> +     int err;
>> +     struct tcp_info info;
>> +     socklen_t len = sizeof(info);
>> +
>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
>> +     if (err != 0) {
>> +             pr_perror("Can't get socket state\n");
>> +             return -1;
>> +     }
>> +     return info.tcpi_state == state ? 0 : -1;
>> +}
>> +
>> +int main(int argc, char **argv)
>> +{
>> +     int fd_s;
>> +
>> +     test_init(argc, argv);
>> +
>> +     fd_s = tcp_init_server(AF_INET, &port);
>> +     if (fd_s < 0) {
>> +             pr_err("Server initializations failed\n");
>> +             return 1;
>> +     }
>> +
>> +     test_daemon();
>> +     test_waitsig();
>> +
>> +     if (check_socket_state(fd_s, TCP_LISTEN)) {
>> +             fail("Listen socket state is changed\n");
>> +             close(fd_s);
>> +             return 1;
>> +     }
>> +     close(fd_s);
>> +     pass();
>> +     return 0;
>> +}
>> diff --git a/test/zdtm/static/socket-tcp-close1.desc b/test/zdtm/static/socket-tcp-close1.desc
>> new file mode 120000
>> index 00000000..836b8fa5
>> --- /dev/null
>> +++ b/test/zdtm/static/socket-tcp-close1.desc
>> @@ -0,0 +1 @@
>> +socket-tcp-close0.desc
>> \ No newline at end of file
>> --
>> 2.11.1
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
Pavel Begunkov (Silence) June 25, 2017, 11:27 p.m.
I was checking failed tests related to 'tcp-close' and couldn't find
any problems. Furthermore, I can't reproduce the error locally. Thus I
wonder if I can get access to the test server where it failed or at
least dump & log files of the run. It would be very helpful. For
example, for this one
https://ci.openvz.org/job/CRIU/job/CRIU-crit/job/criu-dev/2474/

On Tue, Jun 20, 2017 at 10:14 PM, Pavel Begunkov <asml.silence@gmail.com> wrote:
> On Tue, Jun 20, 2017 at 9:41 PM, Andrei Vagin <avagin@virtuozzo.com> wrote:
>> Pavel, pls take a look at this and fix ASAP. Thanks!
>
> I'll look. Thanks for the notice.
>
> --
> Pavel
>
>>
>>
>> https://ci.openvz.org/job/CRIU/job/CRIU-dump-only/job/criu-dev/2557/consoleFull
>>
>> [root@fc24 criu]# python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst
>> ==================== Run zdtm/static/socket-tcp-close0 in h ====================
>> Start test
>> ./socket-tcp-close0 --pidfile=socket-tcp-close0.pid --outfile=socket-tcp-close0.out
>> Run criu dump
>> Send the 15 signal to  24
>> Wait for zdtm/static/socket-tcp-close0(24) to die for 0.100000
>> ########### Test zdtm/static/socket-tcp-close0 FAIL at result check ############
>> Test output: ================================
>> 18:08:38.015:    24: ERR: socket-tcp-close0.c:25: Invalid socket state (1)
>> 18:08:38.016:    24: FAIL: socket-tcp-close0.c:63: Server socket isn't closed
>>  (errno = 11 (Resource temporarily unavailable))
>>
>>  <<< ================================
>>
>> On Fri, Jun 02, 2017 at 09:32:27AM +0300, Pavel Begunkov wrote:
>>> There are 2 test cases:
>>> 1. Connected socket should be restored in the closed state
>>> 2. Listening socket state should not change after restore
>>>
>>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>>> Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
>>> ---
>>>  test/zdtm/static/Makefile               |  2 +
>>>  test/zdtm/static/socket-tcp-close0.c    | 72 +++++++++++++++++++++++++++++++++
>>>  test/zdtm/static/socket-tcp-close0.desc |  1 +
>>>  test/zdtm/static/socket-tcp-close1.c    | 50 +++++++++++++++++++++++
>>>  test/zdtm/static/socket-tcp-close1.desc |  1 +
>>>  5 files changed, 126 insertions(+)
>>>  create mode 100644 test/zdtm/static/socket-tcp-close0.c
>>>  create mode 100644 test/zdtm/static/socket-tcp-close0.desc
>>>  create mode 100644 test/zdtm/static/socket-tcp-close1.c
>>>  create mode 120000 test/zdtm/static/socket-tcp-close1.desc
>>>
>>> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
>>> index 1ea9393c..d5eeadc8 100644
>>> --- a/test/zdtm/static/Makefile
>>> +++ b/test/zdtm/static/Makefile
>>> @@ -82,6 +82,8 @@ TST_NOFILE  :=                              \
>>>               socket-tcp-closed               \
>>>               socket-tcp-closed-last-ack      \
>>>               socket-tcp6-closed              \
>>> +             socket-tcp-close0               \
>>> +             socket-tcp-close1               \
>>>               socket-tcp-unconn               \
>>>               socket-tcp6-unconn              \
>>>               socket-tcp-syn-sent             \
>>> diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c
>>> new file mode 100644
>>> index 00000000..2bc0f64f
>>> --- /dev/null
>>> +++ b/test/zdtm/static/socket-tcp-close0.c
>>> @@ -0,0 +1,72 @@
>>> +#include <errno.h>
>>> +#include <sys/types.h>
>>> +#include <sys/socket.h>
>>> +#include <netinet/tcp.h>
>>> +#include <netinet/in.h>
>>> +
>>> +#include "zdtmtst.h"
>>> +
>>> +const char *test_doc = "Check that tcp-close option closes connected tcp socket";
>>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
>>> +
>>> +static int port = 8880;
>>> +
>>> +static int check_socket_closed(int sk)
>>> +{
>>> +     int err, buffer = 0;
>>> +     struct tcp_info info;
>>> +     socklen_t len = sizeof(info);
>>> +
>>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
>>> +     if (err != 0) {
>>> +             pr_perror("Can't get socket state\n");
>>> +             return -1;
>>> +     } else if (info.tcpi_state != TCP_CLOSE) {
>>> +             pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state);
>>> +             return -1;
>>> +     }
>>> +
>>> +     err = recv(sk, &buffer, sizeof(buffer), 0);
>>> +     if (!err || errno != ENOTCONN) {
>>> +             pr_perror("Invalid recv response\n");
>>> +             return -1;
>>> +     }
>>> +     return 0;
>>> +}
>>> +
>>> +int main(int argc, char **argv)
>>> +{
>>> +     int fd, fd_s, clt;
>>> +
>>> +     test_init(argc, argv);
>>> +
>>> +     fd_s = tcp_init_server(AF_INET, &port);
>>> +     if (fd_s < 0) {
>>> +             pr_err("Server initializations failed\n");
>>> +             return 1;
>>> +     }
>>> +     clt = tcp_init_client(AF_INET, "localhost", port);
>>> +     if (clt < 0)
>>> +             return 1;
>>> +
>>> +     fd = tcp_accept_server(fd_s);
>>> +     if (fd < 0) {
>>> +             pr_err("Can't accept client connection\n");
>>> +             return 1;
>>> +     }
>>> +     close(fd_s);
>>> +
>>> +     test_daemon();
>>> +     test_waitsig();
>>> +
>>> +     if (check_socket_closed(fd)) {
>>> +             fail("Server socket isn't closed\n");
>>> +             return 1;
>>> +     }
>>> +     if (check_socket_closed(clt)) {
>>> +             fail("Client socket isn't closed\n");
>>> +             return 1;
>>> +     }
>>> +     pass();
>>> +     return 0;
>>> +}
>>> diff --git a/test/zdtm/static/socket-tcp-close0.desc b/test/zdtm/static/socket-tcp-close0.desc
>>> new file mode 100644
>>> index 00000000..e85de0e6
>>> --- /dev/null
>>> +++ b/test/zdtm/static/socket-tcp-close0.desc
>>> @@ -0,0 +1 @@
>>> +{'dopts': '--tcp-established', 'ropts': '--tcp-close'}
>>> diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c
>>> new file mode 100644
>>> index 00000000..54511a34
>>> --- /dev/null
>>> +++ b/test/zdtm/static/socket-tcp-close1.c
>>> @@ -0,0 +1,50 @@
>>> +#include <sys/types.h>
>>> +#include <sys/socket.h>
>>> +#include <netinet/tcp.h>
>>> +#include <netinet/in.h>
>>> +
>>> +#include "zdtmtst.h"
>>> +
>>> +const char *test_doc = "Check that tcp-close option doesn't close listening tcp socket";
>>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
>>> +
>>> +static int port = 8880;
>>> +
>>> +static int check_socket_state(int sk, int state)
>>> +{
>>> +     int err;
>>> +     struct tcp_info info;
>>> +     socklen_t len = sizeof(info);
>>> +
>>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
>>> +     if (err != 0) {
>>> +             pr_perror("Can't get socket state\n");
>>> +             return -1;
>>> +     }
>>> +     return info.tcpi_state == state ? 0 : -1;
>>> +}
>>> +
>>> +int main(int argc, char **argv)
>>> +{
>>> +     int fd_s;
>>> +
>>> +     test_init(argc, argv);
>>> +
>>> +     fd_s = tcp_init_server(AF_INET, &port);
>>> +     if (fd_s < 0) {
>>> +             pr_err("Server initializations failed\n");
>>> +             return 1;
>>> +     }
>>> +
>>> +     test_daemon();
>>> +     test_waitsig();
>>> +
>>> +     if (check_socket_state(fd_s, TCP_LISTEN)) {
>>> +             fail("Listen socket state is changed\n");
>>> +             close(fd_s);
>>> +             return 1;
>>> +     }
>>> +     close(fd_s);
>>> +     pass();
>>> +     return 0;
>>> +}
>>> diff --git a/test/zdtm/static/socket-tcp-close1.desc b/test/zdtm/static/socket-tcp-close1.desc
>>> new file mode 120000
>>> index 00000000..836b8fa5
>>> --- /dev/null
>>> +++ b/test/zdtm/static/socket-tcp-close1.desc
>>> @@ -0,0 +1 @@
>>> +socket-tcp-close0.desc
>>> \ No newline at end of file
>>> --
>>> 2.11.1
>>>
>>> _______________________________________________
>>> CRIU mailing list
>>> CRIU@openvz.org
>>> https://lists.openvz.org/mailman/listinfo/criu
Andrey Vagin June 26, 2017, 9:33 p.m.
Pavel,

Pls, run the next command to reproduce the issue:

python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst

Pay attantion to the --norst option:
# ./test/zdtm.py run -h
....
--norst Don't restore tasks, leave them running after dump

On Mon, Jun 26, 2017 at 02:27:33AM +0300, Pavel Begunkov wrote:
> I was checking failed tests related to 'tcp-close' and couldn't find
> any problems. Furthermore, I can't reproduce the error locally. Thus I
> wonder if I can get access to the test server where it failed or at
> least dump & log files of the run. It would be very helpful. For
> example, for this one
> https://ci.openvz.org/job/CRIU/job/CRIU-crit/job/criu-dev/2474/
> 
> On Tue, Jun 20, 2017 at 10:14 PM, Pavel Begunkov <asml.silence@gmail.com> wrote:
> > On Tue, Jun 20, 2017 at 9:41 PM, Andrei Vagin <avagin@virtuozzo.com> wrote:
> >> Pavel, pls take a look at this and fix ASAP. Thanks!
> >
> > I'll look. Thanks for the notice.
> >
> > --
> > Pavel
> >
> >>
> >>
> >> https://ci.openvz.org/job/CRIU/job/CRIU-dump-only/job/criu-dev/2557/consoleFull
> >>
> >> [root@fc24 criu]# python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst
> >> ==================== Run zdtm/static/socket-tcp-close0 in h ====================
> >> Start test
> >> ./socket-tcp-close0 --pidfile=socket-tcp-close0.pid --outfile=socket-tcp-close0.out
> >> Run criu dump
> >> Send the 15 signal to  24
> >> Wait for zdtm/static/socket-tcp-close0(24) to die for 0.100000
> >> ########### Test zdtm/static/socket-tcp-close0 FAIL at result check ############
> >> Test output: ================================
> >> 18:08:38.015:    24: ERR: socket-tcp-close0.c:25: Invalid socket state (1)
> >> 18:08:38.016:    24: FAIL: socket-tcp-close0.c:63: Server socket isn't closed
> >>  (errno = 11 (Resource temporarily unavailable))
> >>
> >>  <<< ================================
> >>
> >> On Fri, Jun 02, 2017 at 09:32:27AM +0300, Pavel Begunkov wrote:
> >>> There are 2 test cases:
> >>> 1. Connected socket should be restored in the closed state
> >>> 2. Listening socket state should not change after restore
> >>>
> >>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> >>> Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
> >>> ---
> >>>  test/zdtm/static/Makefile               |  2 +
> >>>  test/zdtm/static/socket-tcp-close0.c    | 72 +++++++++++++++++++++++++++++++++
> >>>  test/zdtm/static/socket-tcp-close0.desc |  1 +
> >>>  test/zdtm/static/socket-tcp-close1.c    | 50 +++++++++++++++++++++++
> >>>  test/zdtm/static/socket-tcp-close1.desc |  1 +
> >>>  5 files changed, 126 insertions(+)
> >>>  create mode 100644 test/zdtm/static/socket-tcp-close0.c
> >>>  create mode 100644 test/zdtm/static/socket-tcp-close0.desc
> >>>  create mode 100644 test/zdtm/static/socket-tcp-close1.c
> >>>  create mode 120000 test/zdtm/static/socket-tcp-close1.desc
> >>>
> >>> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
> >>> index 1ea9393c..d5eeadc8 100644
> >>> --- a/test/zdtm/static/Makefile
> >>> +++ b/test/zdtm/static/Makefile
> >>> @@ -82,6 +82,8 @@ TST_NOFILE  :=                              \
> >>>               socket-tcp-closed               \
> >>>               socket-tcp-closed-last-ack      \
> >>>               socket-tcp6-closed              \
> >>> +             socket-tcp-close0               \
> >>> +             socket-tcp-close1               \
> >>>               socket-tcp-unconn               \
> >>>               socket-tcp6-unconn              \
> >>>               socket-tcp-syn-sent             \
> >>> diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c
> >>> new file mode 100644
> >>> index 00000000..2bc0f64f
> >>> --- /dev/null
> >>> +++ b/test/zdtm/static/socket-tcp-close0.c
> >>> @@ -0,0 +1,72 @@
> >>> +#include <errno.h>
> >>> +#include <sys/types.h>
> >>> +#include <sys/socket.h>
> >>> +#include <netinet/tcp.h>
> >>> +#include <netinet/in.h>
> >>> +
> >>> +#include "zdtmtst.h"
> >>> +
> >>> +const char *test_doc = "Check that tcp-close option closes connected tcp socket";
> >>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
> >>> +
> >>> +static int port = 8880;
> >>> +
> >>> +static int check_socket_closed(int sk)
> >>> +{
> >>> +     int err, buffer = 0;
> >>> +     struct tcp_info info;
> >>> +     socklen_t len = sizeof(info);
> >>> +
> >>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
> >>> +     if (err != 0) {
> >>> +             pr_perror("Can't get socket state\n");
> >>> +             return -1;
> >>> +     } else if (info.tcpi_state != TCP_CLOSE) {
> >>> +             pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state);
> >>> +             return -1;
> >>> +     }
> >>> +
> >>> +     err = recv(sk, &buffer, sizeof(buffer), 0);
> >>> +     if (!err || errno != ENOTCONN) {
> >>> +             pr_perror("Invalid recv response\n");
> >>> +             return -1;
> >>> +     }
> >>> +     return 0;
> >>> +}
> >>> +
> >>> +int main(int argc, char **argv)
> >>> +{
> >>> +     int fd, fd_s, clt;
> >>> +
> >>> +     test_init(argc, argv);
> >>> +
> >>> +     fd_s = tcp_init_server(AF_INET, &port);
> >>> +     if (fd_s < 0) {
> >>> +             pr_err("Server initializations failed\n");
> >>> +             return 1;
> >>> +     }
> >>> +     clt = tcp_init_client(AF_INET, "localhost", port);
> >>> +     if (clt < 0)
> >>> +             return 1;
> >>> +
> >>> +     fd = tcp_accept_server(fd_s);
> >>> +     if (fd < 0) {
> >>> +             pr_err("Can't accept client connection\n");
> >>> +             return 1;
> >>> +     }
> >>> +     close(fd_s);
> >>> +
> >>> +     test_daemon();
> >>> +     test_waitsig();
> >>> +
> >>> +     if (check_socket_closed(fd)) {
> >>> +             fail("Server socket isn't closed\n");
> >>> +             return 1;
> >>> +     }
> >>> +     if (check_socket_closed(clt)) {
> >>> +             fail("Client socket isn't closed\n");
> >>> +             return 1;
> >>> +     }
> >>> +     pass();
> >>> +     return 0;
> >>> +}
> >>> diff --git a/test/zdtm/static/socket-tcp-close0.desc b/test/zdtm/static/socket-tcp-close0.desc
> >>> new file mode 100644
> >>> index 00000000..e85de0e6
> >>> --- /dev/null
> >>> +++ b/test/zdtm/static/socket-tcp-close0.desc
> >>> @@ -0,0 +1 @@
> >>> +{'dopts': '--tcp-established', 'ropts': '--tcp-close'}
> >>> diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c
> >>> new file mode 100644
> >>> index 00000000..54511a34
> >>> --- /dev/null
> >>> +++ b/test/zdtm/static/socket-tcp-close1.c
> >>> @@ -0,0 +1,50 @@
> >>> +#include <sys/types.h>
> >>> +#include <sys/socket.h>
> >>> +#include <netinet/tcp.h>
> >>> +#include <netinet/in.h>
> >>> +
> >>> +#include "zdtmtst.h"
> >>> +
> >>> +const char *test_doc = "Check that tcp-close option doesn't close listening tcp socket";
> >>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
> >>> +
> >>> +static int port = 8880;
> >>> +
> >>> +static int check_socket_state(int sk, int state)
> >>> +{
> >>> +     int err;
> >>> +     struct tcp_info info;
> >>> +     socklen_t len = sizeof(info);
> >>> +
> >>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
> >>> +     if (err != 0) {
> >>> +             pr_perror("Can't get socket state\n");
> >>> +             return -1;
> >>> +     }
> >>> +     return info.tcpi_state == state ? 0 : -1;
> >>> +}
> >>> +
> >>> +int main(int argc, char **argv)
> >>> +{
> >>> +     int fd_s;
> >>> +
> >>> +     test_init(argc, argv);
> >>> +
> >>> +     fd_s = tcp_init_server(AF_INET, &port);
> >>> +     if (fd_s < 0) {
> >>> +             pr_err("Server initializations failed\n");
> >>> +             return 1;
> >>> +     }
> >>> +
> >>> +     test_daemon();
> >>> +     test_waitsig();
> >>> +
> >>> +     if (check_socket_state(fd_s, TCP_LISTEN)) {
> >>> +             fail("Listen socket state is changed\n");
> >>> +             close(fd_s);
> >>> +             return 1;
> >>> +     }
> >>> +     close(fd_s);
> >>> +     pass();
> >>> +     return 0;
> >>> +}
> >>> diff --git a/test/zdtm/static/socket-tcp-close1.desc b/test/zdtm/static/socket-tcp-close1.desc
> >>> new file mode 120000
> >>> index 00000000..836b8fa5
> >>> --- /dev/null
> >>> +++ b/test/zdtm/static/socket-tcp-close1.desc
> >>> @@ -0,0 +1 @@
> >>> +socket-tcp-close0.desc
> >>> \ No newline at end of file
> >>> --
> >>> 2.11.1
> >>>
> >>> _______________________________________________
> >>> CRIU mailing list
> >>> CRIU@openvz.org
> >>> https://lists.openvz.org/mailman/listinfo/criu
Pavel Begunkov (Silence) June 28, 2017, 12:46 a.m.
Andei,

This clarifies the problem, thanks a lot.
P.S. patch was sent to ml.

On Tue, Jun 27, 2017 at 12:33 AM, Andrei Vagin <avagin@virtuozzo.com> wrote:
> Pavel,
>
> Pls, run the next command to reproduce the issue:
>
> python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst
>
> Pay attantion to the --norst option:
> # ./test/zdtm.py run -h
> ....
> --norst Don't restore tasks, leave them running after dump
>
> On Mon, Jun 26, 2017 at 02:27:33AM +0300, Pavel Begunkov wrote:
>> I was checking failed tests related to 'tcp-close' and couldn't find
>> any problems. Furthermore, I can't reproduce the error locally. Thus I
>> wonder if I can get access to the test server where it failed or at
>> least dump & log files of the run. It would be very helpful. For
>> example, for this one
>> https://ci.openvz.org/job/CRIU/job/CRIU-crit/job/criu-dev/2474/
>>
>> On Tue, Jun 20, 2017 at 10:14 PM, Pavel Begunkov <asml.silence@gmail.com> wrote:
>> > On Tue, Jun 20, 2017 at 9:41 PM, Andrei Vagin <avagin@virtuozzo.com> wrote:
>> >> Pavel, pls take a look at this and fix ASAP. Thanks!
>> >
>> > I'll look. Thanks for the notice.
>> >
>> > --
>> > Pavel
>> >
>> >>
>> >>
>> >> https://ci.openvz.org/job/CRIU/job/CRIU-dump-only/job/criu-dev/2557/consoleFull
>> >>
>> >> [root@fc24 criu]# python test/zdtm.py run -t zdtm/static/socket-tcp-close0 --norst
>> >> ==================== Run zdtm/static/socket-tcp-close0 in h ====================
>> >> Start test
>> >> ./socket-tcp-close0 --pidfile=socket-tcp-close0.pid --outfile=socket-tcp-close0.out
>> >> Run criu dump
>> >> Send the 15 signal to  24
>> >> Wait for zdtm/static/socket-tcp-close0(24) to die for 0.100000
>> >> ########### Test zdtm/static/socket-tcp-close0 FAIL at result check ############
>> >> Test output: ================================
>> >> 18:08:38.015:    24: ERR: socket-tcp-close0.c:25: Invalid socket state (1)
>> >> 18:08:38.016:    24: FAIL: socket-tcp-close0.c:63: Server socket isn't closed
>> >>  (errno = 11 (Resource temporarily unavailable))
>> >>
>> >>  <<< ================================
>> >>
>> >> On Fri, Jun 02, 2017 at 09:32:27AM +0300, Pavel Begunkov wrote:
>> >>> There are 2 test cases:
>> >>> 1. Connected socket should be restored in the closed state
>> >>> 2. Listening socket state should not change after restore
>> >>>
>> >>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>> >>> Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
>> >>> ---
>> >>>  test/zdtm/static/Makefile               |  2 +
>> >>>  test/zdtm/static/socket-tcp-close0.c    | 72 +++++++++++++++++++++++++++++++++
>> >>>  test/zdtm/static/socket-tcp-close0.desc |  1 +
>> >>>  test/zdtm/static/socket-tcp-close1.c    | 50 +++++++++++++++++++++++
>> >>>  test/zdtm/static/socket-tcp-close1.desc |  1 +
>> >>>  5 files changed, 126 insertions(+)
>> >>>  create mode 100644 test/zdtm/static/socket-tcp-close0.c
>> >>>  create mode 100644 test/zdtm/static/socket-tcp-close0.desc
>> >>>  create mode 100644 test/zdtm/static/socket-tcp-close1.c
>> >>>  create mode 120000 test/zdtm/static/socket-tcp-close1.desc
>> >>>
>> >>> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
>> >>> index 1ea9393c..d5eeadc8 100644
>> >>> --- a/test/zdtm/static/Makefile
>> >>> +++ b/test/zdtm/static/Makefile
>> >>> @@ -82,6 +82,8 @@ TST_NOFILE  :=                              \
>> >>>               socket-tcp-closed               \
>> >>>               socket-tcp-closed-last-ack      \
>> >>>               socket-tcp6-closed              \
>> >>> +             socket-tcp-close0               \
>> >>> +             socket-tcp-close1               \
>> >>>               socket-tcp-unconn               \
>> >>>               socket-tcp6-unconn              \
>> >>>               socket-tcp-syn-sent             \
>> >>> diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c
>> >>> new file mode 100644
>> >>> index 00000000..2bc0f64f
>> >>> --- /dev/null
>> >>> +++ b/test/zdtm/static/socket-tcp-close0.c
>> >>> @@ -0,0 +1,72 @@
>> >>> +#include <errno.h>
>> >>> +#include <sys/types.h>
>> >>> +#include <sys/socket.h>
>> >>> +#include <netinet/tcp.h>
>> >>> +#include <netinet/in.h>
>> >>> +
>> >>> +#include "zdtmtst.h"
>> >>> +
>> >>> +const char *test_doc = "Check that tcp-close option closes connected tcp socket";
>> >>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
>> >>> +
>> >>> +static int port = 8880;
>> >>> +
>> >>> +static int check_socket_closed(int sk)
>> >>> +{
>> >>> +     int err, buffer = 0;
>> >>> +     struct tcp_info info;
>> >>> +     socklen_t len = sizeof(info);
>> >>> +
>> >>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
>> >>> +     if (err != 0) {
>> >>> +             pr_perror("Can't get socket state\n");
>> >>> +             return -1;
>> >>> +     } else if (info.tcpi_state != TCP_CLOSE) {
>> >>> +             pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state);
>> >>> +             return -1;
>> >>> +     }
>> >>> +
>> >>> +     err = recv(sk, &buffer, sizeof(buffer), 0);
>> >>> +     if (!err || errno != ENOTCONN) {
>> >>> +             pr_perror("Invalid recv response\n");
>> >>> +             return -1;
>> >>> +     }
>> >>> +     return 0;
>> >>> +}
>> >>> +
>> >>> +int main(int argc, char **argv)
>> >>> +{
>> >>> +     int fd, fd_s, clt;
>> >>> +
>> >>> +     test_init(argc, argv);
>> >>> +
>> >>> +     fd_s = tcp_init_server(AF_INET, &port);
>> >>> +     if (fd_s < 0) {
>> >>> +             pr_err("Server initializations failed\n");
>> >>> +             return 1;
>> >>> +     }
>> >>> +     clt = tcp_init_client(AF_INET, "localhost", port);
>> >>> +     if (clt < 0)
>> >>> +             return 1;
>> >>> +
>> >>> +     fd = tcp_accept_server(fd_s);
>> >>> +     if (fd < 0) {
>> >>> +             pr_err("Can't accept client connection\n");
>> >>> +             return 1;
>> >>> +     }
>> >>> +     close(fd_s);
>> >>> +
>> >>> +     test_daemon();
>> >>> +     test_waitsig();
>> >>> +
>> >>> +     if (check_socket_closed(fd)) {
>> >>> +             fail("Server socket isn't closed\n");
>> >>> +             return 1;
>> >>> +     }
>> >>> +     if (check_socket_closed(clt)) {
>> >>> +             fail("Client socket isn't closed\n");
>> >>> +             return 1;
>> >>> +     }
>> >>> +     pass();
>> >>> +     return 0;
>> >>> +}
>> >>> diff --git a/test/zdtm/static/socket-tcp-close0.desc b/test/zdtm/static/socket-tcp-close0.desc
>> >>> new file mode 100644
>> >>> index 00000000..e85de0e6
>> >>> --- /dev/null
>> >>> +++ b/test/zdtm/static/socket-tcp-close0.desc
>> >>> @@ -0,0 +1 @@
>> >>> +{'dopts': '--tcp-established', 'ropts': '--tcp-close'}
>> >>> diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c
>> >>> new file mode 100644
>> >>> index 00000000..54511a34
>> >>> --- /dev/null
>> >>> +++ b/test/zdtm/static/socket-tcp-close1.c
>> >>> @@ -0,0 +1,50 @@
>> >>> +#include <sys/types.h>
>> >>> +#include <sys/socket.h>
>> >>> +#include <netinet/tcp.h>
>> >>> +#include <netinet/in.h>
>> >>> +
>> >>> +#include "zdtmtst.h"
>> >>> +
>> >>> +const char *test_doc = "Check that tcp-close option doesn't close listening tcp socket";
>> >>> +const char *test_author = "Pavel Begunkov <asml.silence@gmail.com>";
>> >>> +
>> >>> +static int port = 8880;
>> >>> +
>> >>> +static int check_socket_state(int sk, int state)
>> >>> +{
>> >>> +     int err;
>> >>> +     struct tcp_info info;
>> >>> +     socklen_t len = sizeof(info);
>> >>> +
>> >>> +     err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
>> >>> +     if (err != 0) {
>> >>> +             pr_perror("Can't get socket state\n");
>> >>> +             return -1;
>> >>> +     }
>> >>> +     return info.tcpi_state == state ? 0 : -1;
>> >>> +}
>> >>> +
>> >>> +int main(int argc, char **argv)
>> >>> +{
>> >>> +     int fd_s;
>> >>> +
>> >>> +     test_init(argc, argv);
>> >>> +
>> >>> +     fd_s = tcp_init_server(AF_INET, &port);
>> >>> +     if (fd_s < 0) {
>> >>> +             pr_err("Server initializations failed\n");
>> >>> +             return 1;
>> >>> +     }
>> >>> +
>> >>> +     test_daemon();
>> >>> +     test_waitsig();
>> >>> +
>> >>> +     if (check_socket_state(fd_s, TCP_LISTEN)) {
>> >>> +             fail("Listen socket state is changed\n");
>> >>> +             close(fd_s);
>> >>> +             return 1;
>> >>> +     }
>> >>> +     close(fd_s);
>> >>> +     pass();
>> >>> +     return 0;
>> >>> +}
>> >>> diff --git a/test/zdtm/static/socket-tcp-close1.desc b/test/zdtm/static/socket-tcp-close1.desc
>> >>> new file mode 120000
>> >>> index 00000000..836b8fa5
>> >>> --- /dev/null
>> >>> +++ b/test/zdtm/static/socket-tcp-close1.desc
>> >>> @@ -0,0 +1 @@
>> >>> +socket-tcp-close0.desc
>> >>> \ No newline at end of file
>> >>> --
>> >>> 2.11.1
>> >>>
>> >>> _______________________________________________
>> >>> CRIU mailing list
>> >>> CRIU@openvz.org
>> >>> https://lists.openvz.org/mailman/listinfo/criu