[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <26d57ed5-f2f5-5e1d-b557-67a41c1c573c@sberdevices.ru>
Date: Sat, 17 Dec 2022 19:47:50 +0000
From: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
To: Stefano Garzarella <sgarzare@...hat.com>,
Stefan Hajnoczi <stefanha@...hat.com>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
kernel <kernel@...rdevices.ru>,
Krasnov Arseniy <oxffffaa@...il.com>,
Arseniy Krasnov <AVKrasnov@...rdevices.ru>
Subject: [RFC PATCH v1 2/2] vsock_test: mutual hungup reproducer
This is not for merge, just demo.
Signed-off-by: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
---
tools/testing/vsock/vsock_test.c | 78 ++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index bb6d691cb30d..320ecf4db74b 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -699,7 +699,85 @@ static void test_stream_poll_rcvlowat_client(const struct test_opts *opts)
close(fd);
}
+static void test_stall_client(const struct test_opts *opts)
+{
+ int fd;
+ unsigned long lowat_val = 128*1024;
+ size_t data_size = 64 * 1024;
+ void *data;
+
+
+ fd = vsock_stream_connect(opts->peer_cid, 1234);
+ assert(fd != -1);
+
+ assert(!setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT,
+ &lowat_val, sizeof(lowat_val)));
+
+ data = malloc(data_size);
+ assert(data);
+
+ /* Wait for tx to send data. */
+ sleep(3);
+
+ while (1) {
+ struct pollfd fds = {0};
+
+ fds.fd = fd;
+ fds.events = POLLIN | POLLRDNORM | POLLERR | POLLRDHUP | POLLHUP;
+
+ /* Try to wait for 1 sec. */
+ printf("[RX] ENTER POLL\n");
+ assert(poll(&fds, 1, -1) >= 0);
+ printf("[RX] LEAVE POLL\n");
+
+ if (fds.revents & (POLLIN | POLLRDNORM)) {
+ read(fd, data, data_size);
+ }
+
+ if (fds.revents & POLLERR) {
+ printf("[RX] POLL ERR\n");
+ break;
+ }
+
+ if (fds.revents & (POLLRDHUP | POLLHUP)) {
+ printf("[RX] POLL DONE\n");
+ break;
+ }
+ }
+
+ close(fd);
+ exit(0);
+}
+
+static void test_stall_server(const struct test_opts *opts)
+{
+ size_t data_size = (256 * 1024) + 1;
+ void *data;
+ int fd;
+
+ fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
+ assert(fd != -1);
+
+ data = malloc(data_size);
+ assert(data);
+
+ printf("[TX] ENTER WRITE\n");
+ assert(write(fd, data, data_size) == data_size);
+
+ /* Never get here without kernel patch. */
+ printf("[TX] LEAVE WRITE\n");
+
+ close(fd);
+ exit(0);
+}
+
+
static struct test_case test_cases[] = {
+ {
+ .name = "Test stall",
+ .run_client = test_stall_client,
+ .run_server = test_stall_server,
+ },
{
.name = "SOCK_STREAM connection reset",
.run_client = test_stream_connection_reset,
--
2.25.1
Powered by blists - more mailing lists