netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support
@ 2025-06-30  7:57 Xuewei Niu
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl Xuewei Niu
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Xuewei Niu @ 2025-06-30  7:57 UTC (permalink / raw)
  To: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui
  Cc: virtualization, kvm, linux-kernel, fupan.lfp, Xuewei Niu

Introduce SIOCINQ ioctl support for vsock, indicating the length of unread
bytes.

Similar with SIOCOUTQ ioctl, the information is transport-dependent.

The first patch adds SIOCINQ ioctl support in AF_VSOCK.

Thanks to @dexuan, the second patch is to fix the issue where hyper-v
`hvs_stream_has_data()` doesn't return the readable bytes.

The third patch wraps the ioctl into `ioctl_int()`, which implements a
retry mechanism to prevent immediate failure.

The last one adds two test cases to check the functionality. The changes
have been tested, and the results are as expected.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>

--

v1->v2:
https://lore.kernel.org/lkml/20250519070649.3063874-1-niuxuewei.nxw@antgroup.com/
- Use net-next tree.
- Reuse `rx_bytes` to count unread bytes.
- Wrap ioctl syscall with an int pointer argument to implement a retry
  mechanism.

v2->v3:
https://lore.kernel.org/netdev/20250613031152.1076725-1-niuxuewei.nxw@antgroup.com/
- Update commit messages following the guidelines
- Remove `unread_bytes` callback and reuse `vsock_stream_has_data()`
- Move the tests to the end of array
- Split the refactoring patch
- Include <sys/ioctl.h> in the util.c

v3->v4:
https://lore.kernel.org/netdev/20250617045347.1233128-1-niuxuewei.nxw@antgroup.com/
- Hyper-v `hvs_stream_has_data()` returns the readable bytes
- Skip testing the null value for `actual` (int pointer)
- Rename `ioctl_int()` to `vsock_ioctl_int()`
- Fix a typo and a format issue in comments
- Remove the `RECEIVED` barrier.
- The return type of `vsock_ioctl_int()` has been changed to bool

Xuewei Niu (4):
  vsock: Add support for SIOCINQ ioctl
  hv_sock: Return the readable bytes in hvs_stream_has_data()
  test/vsock: Add retry mechanism to ioctl wrapper
  test/vsock: Add ioctl SIOCINQ tests

 net/vmw_vsock/af_vsock.c         | 22 +++++++++
 net/vmw_vsock/hyperv_transport.c | 16 +++++--
 tools/testing/vsock/util.c       | 32 +++++++++----
 tools/testing/vsock/util.h       |  1 +
 tools/testing/vsock/vsock_test.c | 80 ++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+), 12 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl
  2025-06-30  7:57 [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Xuewei Niu
@ 2025-06-30  7:57 ` Xuewei Niu
  2025-07-02  9:56   ` Stefano Garzarella
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data() Xuewei Niu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Xuewei Niu @ 2025-06-30  7:57 UTC (permalink / raw)
  To: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui
  Cc: virtualization, kvm, linux-kernel, fupan.lfp, Xuewei Niu

Add support for SIOCINQ ioctl, indicating the length of bytes unread in the
socket. The value is obtained from `vsock_stream_has_data()`.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
---
 net/vmw_vsock/af_vsock.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 2e7a3034e965..bae6b89bb5fb 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1389,6 +1389,28 @@ static int vsock_do_ioctl(struct socket *sock, unsigned int cmd,
 	vsk = vsock_sk(sk);
 
 	switch (cmd) {
+	case SIOCINQ: {
+		ssize_t n_bytes;
+
+		if (!vsk->transport) {
+			ret = -EOPNOTSUPP;
+			break;
+		}
+
+		if (sock_type_connectible(sk->sk_type) &&
+		    sk->sk_state == TCP_LISTEN) {
+			ret = -EINVAL;
+			break;
+		}
+
+		n_bytes = vsock_stream_has_data(vsk);
+		if (n_bytes < 0) {
+			ret = n_bytes;
+			break;
+		}
+		ret = put_user(n_bytes, arg);
+		break;
+	}
 	case SIOCOUTQ: {
 		ssize_t n_bytes;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data()
  2025-06-30  7:57 [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Xuewei Niu
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl Xuewei Niu
@ 2025-06-30  7:57 ` Xuewei Niu
  2025-07-02  9:58   ` Stefano Garzarella
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper Xuewei Niu
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Xuewei Niu @ 2025-06-30  7:57 UTC (permalink / raw)
  To: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui
  Cc: virtualization, kvm, linux-kernel, fupan.lfp, Xuewei Niu

When hv_sock was originally added, __vsock_stream_recvmsg() and
vsock_stream_has_data() actually only needed to know whether there
is any readable data or not, so hvs_stream_has_data() was written to
return 1 or 0 for simplicity.

However, now hvs_stream_has_data() should return the readable bytes
because vsock_data_ready() -> vsock_stream_has_data() needs to know the
actual bytes rather than a boolean value of 1 or 0.

The SIOCINQ ioctl support also needs hvs_stream_has_data() to return
the readable bytes.

Let hvs_stream_has_data() return the readable bytes of the payload in
the next host-to-guest VMBus hv_sock packet.

Note: there may be multpile incoming hv_sock packets pending in the
VMBus channel's ringbuffer, but so far there is not a VMBus API that
allows us to know all the readable bytes in total without reading and
caching the payload of the multiple packets, so let's just return the
readable bytes of the next single packet. In the future, we'll either
add a VMBus API that allows us to know the total readable bytes without
touching the data in the ringbuffer, or the hv_sock driver needs to
understand the VMBus packet format and parse the packets directly.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
---
 net/vmw_vsock/hyperv_transport.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index 31342ab502b4..64f1290a9ae7 100644
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -694,15 +694,25 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
 static s64 hvs_stream_has_data(struct vsock_sock *vsk)
 {
 	struct hvsock *hvs = vsk->trans;
+	bool need_refill = !hvs->recv_desc;
 	s64 ret;
 
 	if (hvs->recv_data_len > 0)
-		return 1;
+		return hvs->recv_data_len;
 
 	switch (hvs_channel_readable_payload(hvs->chan)) {
 	case 1:
-		ret = 1;
-		break;
+		if (!need_refill)
+			return -EIO;
+
+		hvs->recv_desc = hv_pkt_iter_first(hvs->chan);
+		if (!hvs->recv_desc)
+			return -ENOBUFS;
+
+		ret = hvs_update_recv_data(hvs);
+		if (ret)
+			return ret;
+		return hvs->recv_data_len;
 	case 0:
 		vsk->peer_shutdown |= SEND_SHUTDOWN;
 		ret = 0;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper
  2025-06-30  7:57 [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Xuewei Niu
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl Xuewei Niu
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data() Xuewei Niu
@ 2025-06-30  7:57 ` Xuewei Niu
  2025-07-02 10:20   ` Stefano Garzarella
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests Xuewei Niu
  2025-07-02  1:09 ` [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Jakub Kicinski
  4 siblings, 1 reply; 17+ messages in thread
From: Xuewei Niu @ 2025-06-30  7:57 UTC (permalink / raw)
  To: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui
  Cc: virtualization, kvm, linux-kernel, fupan.lfp, Xuewei Niu

Wrap the ioctl in `ioctl_int()`, which takes a pointer to the actual
int value and an expected int value. The function will not return until
either the ioctl returns the expected value or a timeout occurs, thus
avoiding immediate failure.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
---
 tools/testing/vsock/util.c | 32 +++++++++++++++++++++++---------
 tools/testing/vsock/util.h |  1 +
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
index 0c7e9cbcbc85..481c395227e4 100644
--- a/tools/testing/vsock/util.c
+++ b/tools/testing/vsock/util.c
@@ -16,6 +16,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include <sys/epoll.h>
+#include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <linux/sockios.h>
 
@@ -97,28 +98,41 @@ void vsock_wait_remote_close(int fd)
 	close(epollfd);
 }
 
-/* Wait until transport reports no data left to be sent.
- * Return false if transport does not implement the unsent_bytes() callback.
+/* Wait until ioctl gives an expected int value.
+ * Return false if the op is not supported.
  */
-bool vsock_wait_sent(int fd)
+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected)
 {
-	int ret, sock_bytes_unsent;
+	int ret;
+	char name[32];
+
+	snprintf(name, sizeof(name), "ioctl(%lu)", op);
 
 	timeout_begin(TIMEOUT);
 	do {
-		ret = ioctl(fd, SIOCOUTQ, &sock_bytes_unsent);
+		ret = ioctl(fd, op, actual);
 		if (ret < 0) {
 			if (errno == EOPNOTSUPP)
 				break;
 
-			perror("ioctl(SIOCOUTQ)");
+			perror(name);
 			exit(EXIT_FAILURE);
 		}
-		timeout_check("SIOCOUTQ");
-	} while (sock_bytes_unsent != 0);
+		timeout_check(name);
+	} while (*actual != expected);
 	timeout_end();
 
-	return !ret;
+	return ret >= 0;
+}
+
+/* Wait until transport reports no data left to be sent.
+ * Return false if transport does not implement the unsent_bytes() callback.
+ */
+bool vsock_wait_sent(int fd)
+{
+	int sock_bytes_unsent;
+
+	return vsock_ioctl_int(fd, SIOCOUTQ, &sock_bytes_unsent, 0);
 }
 
 /* Create socket <type>, bind to <cid, port> and return the file descriptor. */
diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
index 5e2db67072d5..d59581f68d61 100644
--- a/tools/testing/vsock/util.h
+++ b/tools/testing/vsock/util.h
@@ -54,6 +54,7 @@ int vsock_stream_listen(unsigned int cid, unsigned int port);
 int vsock_seqpacket_accept(unsigned int cid, unsigned int port,
 			   struct sockaddr_vm *clientaddrp);
 void vsock_wait_remote_close(int fd);
+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected);
 bool vsock_wait_sent(int fd);
 void send_buf(int fd, const void *buf, size_t len, int flags,
 	      ssize_t expected_ret);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests
  2025-06-30  7:57 [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Xuewei Niu
                   ` (2 preceding siblings ...)
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper Xuewei Niu
@ 2025-06-30  7:57 ` Xuewei Niu
  2025-07-02 10:27   ` Stefano Garzarella
  2025-07-02  1:09 ` [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Jakub Kicinski
  4 siblings, 1 reply; 17+ messages in thread
From: Xuewei Niu @ 2025-06-30  7:57 UTC (permalink / raw)
  To: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui
  Cc: virtualization, kvm, linux-kernel, fupan.lfp, Xuewei Niu

Add SIOCINQ ioctl tests for both SOCK_STREAM and SOCK_SEQPACKET.

The client waits for the server to send data, and checks if the SIOCINQ
ioctl value matches the data size. After consuming the data, the client
checks if the SIOCINQ value is 0.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
---
 tools/testing/vsock/vsock_test.c | 80 ++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index f669baaa0dca..1f525a7e0098 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -1305,6 +1305,56 @@ static void test_unsent_bytes_client(const struct test_opts *opts, int type)
 	close(fd);
 }
 
+static void test_unread_bytes_server(const struct test_opts *opts, int type)
+{
+	unsigned char buf[MSG_BUF_IOCTL_LEN];
+	int client_fd;
+
+	client_fd = vsock_accept(VMADDR_CID_ANY, opts->peer_port, NULL, type);
+	if (client_fd < 0) {
+		perror("accept");
+		exit(EXIT_FAILURE);
+	}
+
+	for (int i = 0; i < sizeof(buf); i++)
+		buf[i] = rand() & 0xFF;
+
+	send_buf(client_fd, buf, sizeof(buf), 0, sizeof(buf));
+	control_writeln("SENT");
+
+	close(client_fd);
+}
+
+static void test_unread_bytes_client(const struct test_opts *opts, int type)
+{
+	unsigned char buf[MSG_BUF_IOCTL_LEN];
+	int fd;
+	int sock_bytes_unread;
+
+	fd = vsock_connect(opts->peer_cid, opts->peer_port, type);
+	if (fd < 0) {
+		perror("connect");
+		exit(EXIT_FAILURE);
+	}
+
+	control_expectln("SENT");
+	/* The data has arrived but has not been read. The expected is
+	 * MSG_BUF_IOCTL_LEN.
+	 */
+	if (!vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread,
+			     MSG_BUF_IOCTL_LEN)) {
+		fprintf(stderr, "Test skipped, TIOCINQ not supported.\n");
+		goto out;
+	}
+
+	recv_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
+	/* All data has been consumed, so the expected is 0. */
+	vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread, 0);
+
+out:
+	close(fd);
+}
+
 static void test_stream_unsent_bytes_client(const struct test_opts *opts)
 {
 	test_unsent_bytes_client(opts, SOCK_STREAM);
@@ -1325,6 +1375,26 @@ static void test_seqpacket_unsent_bytes_server(const struct test_opts *opts)
 	test_unsent_bytes_server(opts, SOCK_SEQPACKET);
 }
 
+static void test_stream_unread_bytes_client(const struct test_opts *opts)
+{
+	test_unread_bytes_client(opts, SOCK_STREAM);
+}
+
+static void test_stream_unread_bytes_server(const struct test_opts *opts)
+{
+	test_unread_bytes_server(opts, SOCK_STREAM);
+}
+
+static void test_seqpacket_unread_bytes_client(const struct test_opts *opts)
+{
+	test_unread_bytes_client(opts, SOCK_SEQPACKET);
+}
+
+static void test_seqpacket_unread_bytes_server(const struct test_opts *opts)
+{
+	test_unread_bytes_server(opts, SOCK_SEQPACKET);
+}
+
 #define RCVLOWAT_CREDIT_UPD_BUF_SIZE	(1024 * 128)
 /* This define is the same as in 'include/linux/virtio_vsock.h':
  * it is used to decide when to send credit update message during
@@ -2051,6 +2121,16 @@ static struct test_case test_cases[] = {
 		.run_client = test_stream_nolinger_client,
 		.run_server = test_stream_nolinger_server,
 	},
+	{
+		.name = "SOCK_STREAM ioctl(SIOCINQ) functionality",
+		.run_client = test_stream_unread_bytes_client,
+		.run_server = test_stream_unread_bytes_server,
+	},
+	{
+		.name = "SOCK_SEQPACKET ioctl(SIOCINQ) functionality",
+		.run_client = test_seqpacket_unread_bytes_client,
+		.run_server = test_seqpacket_unread_bytes_server,
+	},
 	{},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support
  2025-06-30  7:57 [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Xuewei Niu
                   ` (3 preceding siblings ...)
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests Xuewei Niu
@ 2025-07-02  1:09 ` Jakub Kicinski
  2025-07-02  2:15   ` Xuewei Niu
  4 siblings, 1 reply; 17+ messages in thread
From: Jakub Kicinski @ 2025-07-02  1:09 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui, virtualization, kvm, linux-kernel,
	fupan.lfp, Xuewei Niu

On Mon, 30 Jun 2025 15:57:23 +0800 Xuewei Niu wrote:
> Introduce SIOCINQ ioctl support for vsock, indicating the length of unread
> bytes.
> 
> Similar with SIOCOUTQ ioctl, the information is transport-dependent.

This series does not apply cleanly on current net-next.
Please rebase & repost.
Please note that we request that repost do not happen more often than
24 hours apart:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support
  2025-07-02  1:09 ` [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Jakub Kicinski
@ 2025-07-02  2:15   ` Xuewei Niu
  0 siblings, 0 replies; 17+ messages in thread
From: Xuewei Niu @ 2025-07-02  2:15 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: sgarzare, mst, pabeni, jasowang, xuanzhuo, davem, netdev,
	stefanha, leonardi, decui, virtualization, kvm, linux-kernel,
	fupan.lfp, Xuewei Niu


> On Jul 2, 2025, at 09:09, Jakub Kicinski <kuba@kernel.org> wrote:
> 
> On Mon, 30 Jun 2025 15:57:23 +0800 Xuewei Niu wrote:
>> Introduce SIOCINQ ioctl support for vsock, indicating the length of unread
>> bytes.
>> 
>> Similar with SIOCOUTQ ioctl, the information is transport-dependent.
> 
> This series does not apply cleanly on current net-next.
> Please rebase & repost.
> Please note that we request that repost do not happen more often than
> 24 hours apart:
> https://www.kernel.org/doc/html/next/process/maintainer-netdev.html

I'll rebase, and send out v5 in a few days, in order to have more comments.

Thanks,
Xuewei

> -- 
> pw-bot: cr


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl Xuewei Niu
@ 2025-07-02  9:56   ` Stefano Garzarella
  0 siblings, 0 replies; 17+ messages in thread
From: Stefano Garzarella @ 2025-07-02  9:56 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: mst, pabeni, jasowang, xuanzhuo, davem, netdev, stefanha,
	leonardi, decui, virtualization, kvm, linux-kernel, fupan.lfp,
	Xuewei Niu

On Mon, Jun 30, 2025 at 03:57:24PM +0800, Xuewei Niu wrote:
>Add support for SIOCINQ ioctl, indicating the length of bytes unread in the
>socket. The value is obtained from `vsock_stream_has_data()`.
>
>Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>---
> net/vmw_vsock/af_vsock.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
>diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>index 2e7a3034e965..bae6b89bb5fb 100644
>--- a/net/vmw_vsock/af_vsock.c
>+++ b/net/vmw_vsock/af_vsock.c
>@@ -1389,6 +1389,28 @@ static int vsock_do_ioctl(struct socket *sock, unsigned int cmd,
> 	vsk = vsock_sk(sk);
>
> 	switch (cmd) {
>+	case SIOCINQ: {
>+		ssize_t n_bytes;
>+
>+		if (!vsk->transport) {
>+			ret = -EOPNOTSUPP;
>+			break;
>+		}
>+
>+		if (sock_type_connectible(sk->sk_type) &&
>+		    sk->sk_state == TCP_LISTEN) {
>+			ret = -EINVAL;
>+			break;
>+		}
>+
>+		n_bytes = vsock_stream_has_data(vsk);

This patch should go after we fixed vsock_stream_has_data() for hyper-v.

The rest LGTM!

Thanks,
Stefano

>+		if (n_bytes < 0) {
>+			ret = n_bytes;
>+			break;
>+		}
>+		ret = put_user(n_bytes, arg);
>+		break;
>+	}
> 	case SIOCOUTQ: {
> 		ssize_t n_bytes;
>
>-- 
>2.34.1
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data()
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data() Xuewei Niu
@ 2025-07-02  9:58   ` Stefano Garzarella
  2025-07-02 10:05     ` Xuewei Niu
  0 siblings, 1 reply; 17+ messages in thread
From: Stefano Garzarella @ 2025-07-02  9:58 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: mst, pabeni, jasowang, xuanzhuo, davem, netdev, stefanha,
	leonardi, decui, virtualization, kvm, linux-kernel, fupan.lfp,
	Xuewei Niu

On Mon, Jun 30, 2025 at 03:57:25PM +0800, Xuewei Niu wrote:

IMO here you should not reset the author to you, but you should keep
Dexuan as authour of this patch.

>When hv_sock was originally added, __vsock_stream_recvmsg() and
>vsock_stream_has_data() actually only needed to know whether there
>is any readable data or not, so hvs_stream_has_data() was written to
>return 1 or 0 for simplicity.
>
>However, now hvs_stream_has_data() should return the readable bytes
>because vsock_data_ready() -> vsock_stream_has_data() needs to know the
>actual bytes rather than a boolean value of 1 or 0.
>
>The SIOCINQ ioctl support also needs hvs_stream_has_data() to return
>the readable bytes.
>
>Let hvs_stream_has_data() return the readable bytes of the payload in
>the next host-to-guest VMBus hv_sock packet.
>
>Note: there may be multpile incoming hv_sock packets pending in the
>VMBus channel's ringbuffer, but so far there is not a VMBus API that
>allows us to know all the readable bytes in total without reading and
>caching the payload of the multiple packets, so let's just return the
>readable bytes of the next single packet. In the future, we'll either
>add a VMBus API that allows us to know the total readable bytes without
>touching the data in the ringbuffer, or the hv_sock driver needs to
>understand the VMBus packet format and parse the packets directly.
>
>Signed-off-by: Dexuan Cui <decui@microsoft.com>
>Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>---
> net/vmw_vsock/hyperv_transport.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
>diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
>index 31342ab502b4..64f1290a9ae7 100644
>--- a/net/vmw_vsock/hyperv_transport.c
>+++ b/net/vmw_vsock/hyperv_transport.c
>@@ -694,15 +694,25 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
> static s64 hvs_stream_has_data(struct vsock_sock *vsk)
> {
> 	struct hvsock *hvs = vsk->trans;
>+	bool need_refill = !hvs->recv_desc;

For v5 remember to fix this as Paolo suggested. Dexuan proposed a fix on 
his thread.

Stefano

> 	s64 ret;
>
> 	if (hvs->recv_data_len > 0)
>-		return 1;
>+		return hvs->recv_data_len;
>
> 	switch (hvs_channel_readable_payload(hvs->chan)) {
> 	case 1:
>-		ret = 1;
>-		break;
>+		if (!need_refill)
>+			return -EIO;
>+
>+		hvs->recv_desc = hv_pkt_iter_first(hvs->chan);
>+		if (!hvs->recv_desc)
>+			return -ENOBUFS;
>+
>+		ret = hvs_update_recv_data(hvs);
>+		if (ret)
>+			return ret;
>+		return hvs->recv_data_len;
> 	case 0:
> 		vsk->peer_shutdown |= SEND_SHUTDOWN;
> 		ret = 0;
>-- 
>2.34.1
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data()
  2025-07-02  9:58   ` Stefano Garzarella
@ 2025-07-02 10:05     ` Xuewei Niu
  0 siblings, 0 replies; 17+ messages in thread
From: Xuewei Niu @ 2025-07-02 10:05 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: mst, pabeni, jasowang, xuanzhuo, davem, netdev, stefanha,
	leonardi, decui, virtualization, kvm, linux-kernel, fupan.lfp,
	Xuewei Niu


> On Jul 2, 2025, at 17:58, Stefano Garzarella <sgarzare@redhat.com> wrote:
> 
> On Mon, Jun 30, 2025 at 03:57:25PM +0800, Xuewei Niu wrote:
> 
> IMO here you should not reset the author to you, but you should keep
> Dexuan as authour of this patch.

Well, I did that. However, `./scripts/checkpatch.pl` is unhappy wihtout my SOB.
Perhaps I should ignore it, and will do in the next :)  

> 
>> When hv_sock was originally added, __vsock_stream_recvmsg() and
>> vsock_stream_has_data() actually only needed to know whether there
>> is any readable data or not, so hvs_stream_has_data() was written to
>> return 1 or 0 for simplicity.
>> 
>> However, now hvs_stream_has_data() should return the readable bytes
>> because vsock_data_ready() -> vsock_stream_has_data() needs to know the
>> actual bytes rather than a boolean value of 1 or 0.
>> 
>> The SIOCINQ ioctl support also needs hvs_stream_has_data() to return
>> the readable bytes.
>> 
>> Let hvs_stream_has_data() return the readable bytes of the payload in
>> the next host-to-guest VMBus hv_sock packet.
>> 
>> Note: there may be multpile incoming hv_sock packets pending in the
>> VMBus channel's ringbuffer, but so far there is not a VMBus API that
>> allows us to know all the readable bytes in total without reading and
>> caching the payload of the multiple packets, so let's just return the
>> readable bytes of the next single packet. In the future, we'll either
>> add a VMBus API that allows us to know the total readable bytes without
>> touching the data in the ringbuffer, or the hv_sock driver needs to
>> understand the VMBus packet format and parse the packets directly.
>> 
>> Signed-off-by: Dexuan Cui <decui@microsoft.com>
>> Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>> ---
>> net/vmw_vsock/hyperv_transport.c | 16 +++++++++++++---
>> 1 file changed, 13 insertions(+), 3 deletions(-)
>> 
>> diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
>> index 31342ab502b4..64f1290a9ae7 100644
>> --- a/net/vmw_vsock/hyperv_transport.c
>> +++ b/net/vmw_vsock/hyperv_transport.c
>> @@ -694,15 +694,25 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
>> static s64 hvs_stream_has_data(struct vsock_sock *vsk)
>> {
>> 	struct hvsock *hvs = vsk->trans;
>> +	bool need_refill = !hvs->recv_desc;
> 
> For v5 remember to fix this as Paolo suggested. Dexuan proposed a fix on his thread.

Will do. And big thanks to Dexuan for the great work.

Thanks,
Xuewei

> Stefano
> 
>> 	s64 ret;
>> 
>> 	if (hvs->recv_data_len > 0)
>> -		return 1;
>> +		return hvs->recv_data_len;
>> 
>> 	switch (hvs_channel_readable_payload(hvs->chan)) {
>> 	case 1:
>> -		ret = 1;
>> -		break;
>> +		if (!need_refill)
>> +			return -EIO;
>> +
>> +		hvs->recv_desc = hv_pkt_iter_first(hvs->chan);
>> +		if (!hvs->recv_desc)
>> +			return -ENOBUFS;
>> +
>> +		ret = hvs_update_recv_data(hvs);
>> +		if (ret)
>> +			return ret;
>> +		return hvs->recv_data_len;
>> 	case 0:
>> 		vsk->peer_shutdown |= SEND_SHUTDOWN;
>> 		ret = 0;
>> -- 
>> 2.34.1
>> 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper Xuewei Niu
@ 2025-07-02 10:20   ` Stefano Garzarella
  2025-07-03  3:05     ` Xuewei Niu
  0 siblings, 1 reply; 17+ messages in thread
From: Stefano Garzarella @ 2025-07-02 10:20 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: mst, pabeni, jasowang, xuanzhuo, davem, netdev, stefanha,
	leonardi, decui, virtualization, kvm, linux-kernel, fupan.lfp,
	Xuewei Niu

On Mon, Jun 30, 2025 at 03:57:26PM +0800, Xuewei Niu wrote:
>Wrap the ioctl in `ioctl_int()`, which takes a pointer to the actual
>int value and an expected int value. The function will not return until
>either the ioctl returns the expected value or a timeout occurs, thus
>avoiding immediate failure.
>
>Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>---
> tools/testing/vsock/util.c | 32 +++++++++++++++++++++++---------
> tools/testing/vsock/util.h |  1 +
> 2 files changed, 24 insertions(+), 9 deletions(-)
>
>diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
>index 0c7e9cbcbc85..481c395227e4 100644
>--- a/tools/testing/vsock/util.c
>+++ b/tools/testing/vsock/util.c
>@@ -16,6 +16,7 @@
> #include <unistd.h>
> #include <assert.h>
> #include <sys/epoll.h>
>+#include <sys/ioctl.h>
> #include <sys/mman.h>
> #include <linux/sockios.h>
>
>@@ -97,28 +98,41 @@ void vsock_wait_remote_close(int fd)
> 	close(epollfd);
> }
>
>-/* Wait until transport reports no data left to be sent.
>- * Return false if transport does not implement the unsent_bytes() 
>callback.
>+/* Wait until ioctl gives an expected int value.
>+ * Return false if the op is not supported.
>  */
>-bool vsock_wait_sent(int fd)
>+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected)

Why we need the `actual` parameter?

> {
>-	int ret, sock_bytes_unsent;
>+	int ret;
>+	char name[32];
>+
>+	snprintf(name, sizeof(name), "ioctl(%lu)", op);
>
> 	timeout_begin(TIMEOUT);
> 	do {
>-		ret = ioctl(fd, SIOCOUTQ, &sock_bytes_unsent);
>+		ret = ioctl(fd, op, actual);
> 		if (ret < 0) {
> 			if (errno == EOPNOTSUPP)
> 				break;
>
>-			perror("ioctl(SIOCOUTQ)");
>+			perror(name);
> 			exit(EXIT_FAILURE);
> 		}
>-		timeout_check("SIOCOUTQ");
>-	} while (sock_bytes_unsent != 0);
>+		timeout_check(name);
>+	} while (*actual != expected);
> 	timeout_end();
>
>-	return !ret;
>+	return ret >= 0;
>+}
>+
>+/* Wait until transport reports no data left to be sent.
>+ * Return false if transport does not implement the unsent_bytes() callback.
>+ */
>+bool vsock_wait_sent(int fd)
>+{
>+	int sock_bytes_unsent;
>+
>+	return vsock_ioctl_int(fd, SIOCOUTQ, &sock_bytes_unsent, 0);
> }
>
> /* Create socket <type>, bind to <cid, port> and return the file descriptor. */
>diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
>index 5e2db67072d5..d59581f68d61 100644
>--- a/tools/testing/vsock/util.h
>+++ b/tools/testing/vsock/util.h
>@@ -54,6 +54,7 @@ int vsock_stream_listen(unsigned int cid, unsigned int port);
> int vsock_seqpacket_accept(unsigned int cid, unsigned int port,
> 			   struct sockaddr_vm *clientaddrp);
> void vsock_wait_remote_close(int fd);
>+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected);
> bool vsock_wait_sent(int fd);
> void send_buf(int fd, const void *buf, size_t len, int flags,
> 	      ssize_t expected_ret);
>-- 
>2.34.1
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests
  2025-06-30  7:57 ` [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests Xuewei Niu
@ 2025-07-02 10:27   ` Stefano Garzarella
  2025-07-03  2:51     ` Xuewei Niu
  0 siblings, 1 reply; 17+ messages in thread
From: Stefano Garzarella @ 2025-07-02 10:27 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: mst, pabeni, jasowang, xuanzhuo, davem, netdev, stefanha,
	leonardi, decui, virtualization, kvm, linux-kernel, fupan.lfp,
	Xuewei Niu

On Mon, Jun 30, 2025 at 03:57:27PM +0800, Xuewei Niu wrote:
>Add SIOCINQ ioctl tests for both SOCK_STREAM and SOCK_SEQPACKET.
>
>The client waits for the server to send data, and checks if the SIOCINQ
>ioctl value matches the data size. After consuming the data, the client
>checks if the SIOCINQ value is 0.
>
>Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>---
> tools/testing/vsock/vsock_test.c | 80 ++++++++++++++++++++++++++++++++
> 1 file changed, 80 insertions(+)
>
>diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
>index f669baaa0dca..1f525a7e0098 100644
>--- a/tools/testing/vsock/vsock_test.c
>+++ b/tools/testing/vsock/vsock_test.c
>@@ -1305,6 +1305,56 @@ static void test_unsent_bytes_client(const struct test_opts *opts, int type)
> 	close(fd);
> }
>
>+static void test_unread_bytes_server(const struct test_opts *opts, int type)
>+{
>+	unsigned char buf[MSG_BUF_IOCTL_LEN];
>+	int client_fd;
>+
>+	client_fd = vsock_accept(VMADDR_CID_ANY, opts->peer_port, NULL, type);
>+	if (client_fd < 0) {
>+		perror("accept");
>+		exit(EXIT_FAILURE);
>+	}
>+
>+	for (int i = 0; i < sizeof(buf); i++)
>+		buf[i] = rand() & 0xFF;
>+
>+	send_buf(client_fd, buf, sizeof(buf), 0, sizeof(buf));
>+	control_writeln("SENT");
>+
>+	close(client_fd);
>+}
>+
>+static void test_unread_bytes_client(const struct test_opts *opts, int type)
>+{
>+	unsigned char buf[MSG_BUF_IOCTL_LEN];
>+	int fd;
>+	int sock_bytes_unread;
>+
>+	fd = vsock_connect(opts->peer_cid, opts->peer_port, type);
>+	if (fd < 0) {
>+		perror("connect");
>+		exit(EXIT_FAILURE);
>+	}
>+
>+	control_expectln("SENT");
>+	/* The data has arrived but has not been read. The expected is
>+	 * MSG_BUF_IOCTL_LEN.
>+	 */
>+	if (!vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread,

I know that TIOCINQ is the same of SIOCINQ, but IMO is confusing, why 
not using SIOCINQ ?

The rest LGTM.

Thanks,
Stefano

>+			     MSG_BUF_IOCTL_LEN)) {
>+		fprintf(stderr, "Test skipped, TIOCINQ not supported.\n");
>+		goto out;
>+	}
>+
>+	recv_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
>+	/* All data has been consumed, so the expected is 0. */
>+	vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread, 0);
>+
>+out:
>+	close(fd);
>+}
>+
> static void test_stream_unsent_bytes_client(const struct test_opts *opts)
> {
> 	test_unsent_bytes_client(opts, SOCK_STREAM);
>@@ -1325,6 +1375,26 @@ static void test_seqpacket_unsent_bytes_server(const struct test_opts *opts)
> 	test_unsent_bytes_server(opts, SOCK_SEQPACKET);
> }
>
>+static void test_stream_unread_bytes_client(const struct test_opts *opts)
>+{
>+	test_unread_bytes_client(opts, SOCK_STREAM);
>+}
>+
>+static void test_stream_unread_bytes_server(const struct test_opts *opts)
>+{
>+	test_unread_bytes_server(opts, SOCK_STREAM);
>+}
>+
>+static void test_seqpacket_unread_bytes_client(const struct test_opts *opts)
>+{
>+	test_unread_bytes_client(opts, SOCK_SEQPACKET);
>+}
>+
>+static void test_seqpacket_unread_bytes_server(const struct test_opts *opts)
>+{
>+	test_unread_bytes_server(opts, SOCK_SEQPACKET);
>+}
>+
> #define RCVLOWAT_CREDIT_UPD_BUF_SIZE	(1024 * 128)
> /* This define is the same as in 'include/linux/virtio_vsock.h':
>  * it is used to decide when to send credit update message during
>@@ -2051,6 +2121,16 @@ static struct test_case test_cases[] = {
> 		.run_client = test_stream_nolinger_client,
> 		.run_server = test_stream_nolinger_server,
> 	},
>+	{
>+		.name = "SOCK_STREAM ioctl(SIOCINQ) functionality",
>+		.run_client = test_stream_unread_bytes_client,
>+		.run_server = test_stream_unread_bytes_server,
>+	},
>+	{
>+		.name = "SOCK_SEQPACKET ioctl(SIOCINQ) functionality",
>+		.run_client = test_seqpacket_unread_bytes_client,
>+		.run_server = test_seqpacket_unread_bytes_server,
>+	},
> 	{},
> };
>
>-- 
>2.34.1
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests
  2025-07-02 10:27   ` Stefano Garzarella
@ 2025-07-03  2:51     ` Xuewei Niu
  2025-07-03  7:37       ` Stefano Garzarella
  0 siblings, 1 reply; 17+ messages in thread
From: Xuewei Niu @ 2025-07-03  2:51 UTC (permalink / raw)
  To: sgarzare
  Cc: davem, decui, fupan.lfp, jasowang, kvm, leonardi, linux-kernel,
	mst, netdev, niuxuewei.nxw, niuxuewei97, pabeni, stefanha,
	virtualization, xuanzhuo

Resend: forgot to reply all...

> On Mon, Jun 30, 2025 at 03:57:27PM +0800, Xuewei Niu wrote:
> >Add SIOCINQ ioctl tests for both SOCK_STREAM and SOCK_SEQPACKET.
> >
> >The client waits for the server to send data, and checks if the SIOCINQ
> >ioctl value matches the data size. After consuming the data, the client
> >checks if the SIOCINQ value is 0.
> >
> >Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
> >---
> > tools/testing/vsock/vsock_test.c | 80 ++++++++++++++++++++++++++++++++
> > 1 file changed, 80 insertions(+)
> >
> >diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
> >index f669baaa0dca..1f525a7e0098 100644
> >--- a/tools/testing/vsock/vsock_test.c
> >+++ b/tools/testing/vsock/vsock_test.c
> >@@ -1305,6 +1305,56 @@ static void test_unsent_bytes_client(const struct test_opts *opts, int type)
> > 	close(fd);
> > }
> >
> >+static void test_unread_bytes_server(const struct test_opts *opts, int type)
> >+{
> >+	unsigned char buf[MSG_BUF_IOCTL_LEN];
> >+	int client_fd;
> >+
> >+	client_fd = vsock_accept(VMADDR_CID_ANY, opts->peer_port, NULL, type);
> >+	if (client_fd < 0) {
> >+		perror("accept");
> >+		exit(EXIT_FAILURE);
> >+	}
> >+
> >+	for (int i = 0; i < sizeof(buf); i++)
> >+		buf[i] = rand() & 0xFF;
> >+
> >+	send_buf(client_fd, buf, sizeof(buf), 0, sizeof(buf));
> >+	control_writeln("SENT");
> >+
> >+	close(client_fd);
> >+}
> >+
> >+static void test_unread_bytes_client(const struct test_opts *opts, int type)
> >+{
> >+	unsigned char buf[MSG_BUF_IOCTL_LEN];
> >+	int fd;
> >+	int sock_bytes_unread;
> >+
> >+	fd = vsock_connect(opts->peer_cid, opts->peer_port, type);
> >+	if (fd < 0) {
> >+		perror("connect");
> >+		exit(EXIT_FAILURE);
> >+	}
> >+
> >+	control_expectln("SENT");
> >+	/* The data has arrived but has not been read. The expected is
> >+	 * MSG_BUF_IOCTL_LEN.
> >+	 */
> >+	if (!vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread,
> 
> I know that TIOCINQ is the same of SIOCINQ, but IMO is confusing, why 
> not using SIOCINQ ?

I tried to use `SIOCINQ` but got:

```
vsock_test.c: In function 'test_unread_bytes_client':
vsock_test.c:1344:34: error: 'SIOCINQ' undeclared (first use in this function); did you mean 'TIOCINQ'?
 1344 |         if (!vsock_ioctl_int(fd, SIOCINQ, &sock_bytes_unread,
      |                                  ^~~~~~~
      |                                  TIOCINQ
vsock_test.c:1344:34: note: each undeclared identifier is reported only once for each function it appears in
```

I just followed the compiler suggestion, and replaced it with `TIOCINQ`.
Following your comments, I found that `SIOCINQ` is defined in `linux/sockios.h`, as documented in [1].
The documentation suggests that we can use `FIONREAD` alternatively.
In order to avoid confusion, I'd like to choose `SIOCINQ`.

1: https://man7.org/linux/man-pages/man7/unix.7.html

Thanks,
Xuewei
 
> The rest LGTM.
> 
> Thanks,
> Stefano
> 
> >+			     MSG_BUF_IOCTL_LEN)) {
> >+		fprintf(stderr, "Test skipped, TIOCINQ not supported.\n");
> >+		goto out;
> >+	}
> >+
> >+	recv_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
> >+	/* All data has been consumed, so the expected is 0. */
> >+	vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread, 0);
> >+
> >+out:
> >+	close(fd);
> >+}
> >+
> > static void test_stream_unsent_bytes_client(const struct test_opts *opts)
> > {
> > 	test_unsent_bytes_client(opts, SOCK_STREAM);
> >@@ -1325,6 +1375,26 @@ static void test_seqpacket_unsent_bytes_server(const struct test_opts *opts)
> > 	test_unsent_bytes_server(opts, SOCK_SEQPACKET);
> > }
> >
> >+static void test_stream_unread_bytes_client(const struct test_opts *opts)
> >+{
> >+	test_unread_bytes_client(opts, SOCK_STREAM);
> >+}
> >+
> >+static void test_stream_unread_bytes_server(const struct test_opts *opts)
> >+{
> >+	test_unread_bytes_server(opts, SOCK_STREAM);
> >+}
> >+
> >+static void test_seqpacket_unread_bytes_client(const struct test_opts *opts)
> >+{
> >+	test_unread_bytes_client(opts, SOCK_SEQPACKET);
> >+}
> >+
> >+static void test_seqpacket_unread_bytes_server(const struct test_opts *opts)
> >+{
> >+	test_unread_bytes_server(opts, SOCK_SEQPACKET);
> >+}
> >+
> > #define RCVLOWAT_CREDIT_UPD_BUF_SIZE	(1024 * 128)
> > /* This define is the same as in 'include/linux/virtio_vsock.h':
> >  * it is used to decide when to send credit update message during
> >@@ -2051,6 +2121,16 @@ static struct test_case test_cases[] = {
> > 		.run_client = test_stream_nolinger_client,
> > 		.run_server = test_stream_nolinger_server,
> > 	},
> >+	{
> >+		.name = "SOCK_STREAM ioctl(SIOCINQ) functionality",
> >+		.run_client = test_stream_unread_bytes_client,
> >+		.run_server = test_stream_unread_bytes_server,
> >+	},
> >+	{
> >+		.name = "SOCK_SEQPACKET ioctl(SIOCINQ) functionality",
> >+		.run_client = test_seqpacket_unread_bytes_client,
> >+		.run_server = test_seqpacket_unread_bytes_server,
> >+	},
> > 	{},
> > };
> >
> >-- 
> >2.34.1
> >

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper
  2025-07-02 10:20   ` Stefano Garzarella
@ 2025-07-03  3:05     ` Xuewei Niu
  2025-07-03  7:36       ` Stefano Garzarella
  0 siblings, 1 reply; 17+ messages in thread
From: Xuewei Niu @ 2025-07-03  3:05 UTC (permalink / raw)
  To: sgarzare
  Cc: davem, decui, fupan.lfp, jasowang, kvm, leonardi, linux-kernel,
	mst, netdev, niuxuewei.nxw, niuxuewei97, pabeni, stefanha,
	virtualization, xuanzhuo

Resend: the previous message was rejected due to HTML
Resend: forgot to reply all...

> On Mon, Jun 30, 2025 at 03:57:26PM +0800, Xuewei Niu wrote:
> >Wrap the ioctl in `ioctl_int()`, which takes a pointer to the actual
> >int value and an expected int value. The function will not return until
> >either the ioctl returns the expected value or a timeout occurs, thus
> >avoiding immediate failure.
> >
> >Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
> >---
> > tools/testing/vsock/util.c | 32 +++++++++++++++++++++++---------
> > tools/testing/vsock/util.h |  1 +
> > 2 files changed, 24 insertions(+), 9 deletions(-)
> >
> >diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
> >index 0c7e9cbcbc85..481c395227e4 100644
> >--- a/tools/testing/vsock/util.c
> >+++ b/tools/testing/vsock/util.c
> >@@ -16,6 +16,7 @@
> > #include <unistd.h>
> > #include <assert.h>
> > #include <sys/epoll.h>
> >+#include <sys/ioctl.h>
> > #include <sys/mman.h>
> > #include <linux/sockios.h>
> >
> >@@ -97,28 +98,41 @@ void vsock_wait_remote_close(int fd)
> > 	close(epollfd);
> > }
> >
> >-/* Wait until transport reports no data left to be sent.
> >- * Return false if transport does not implement the unsent_bytes() 
> >callback.
> >+/* Wait until ioctl gives an expected int value.
> >+ * Return false if the op is not supported.
> >  */
> >-bool vsock_wait_sent(int fd)
> >+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected)
> 
> Why we need the `actual` parameter?

We can exit early `if (*actual == expected)`, and the `expected` can be any integer.
I also make it to be a pointer, because the caller might need to have the actual value.

Thanks,
Xuewei
 
> > {
> >-	int ret, sock_bytes_unsent;
> >+	int ret;
> >+	char name[32];
> >+
> >+	snprintf(name, sizeof(name), "ioctl(%lu)", op);
> >
> > 	timeout_begin(TIMEOUT);
> > 	do {
> >-		ret = ioctl(fd, SIOCOUTQ, &sock_bytes_unsent);
> >+		ret = ioctl(fd, op, actual);
> > 		if (ret < 0) {
> > 			if (errno == EOPNOTSUPP)
> > 				break;
> >
> >-			perror("ioctl(SIOCOUTQ)");
> >+			perror(name);
> > 			exit(EXIT_FAILURE);
> > 		}
> >-		timeout_check("SIOCOUTQ");
> >-	} while (sock_bytes_unsent != 0);
> >+		timeout_check(name);
> >+	} while (*actual != expected);
> > 	timeout_end();
> >
> >-	return !ret;
> >+	return ret >= 0;
> >+}
> >+
> >+/* Wait until transport reports no data left to be sent.
> >+ * Return false if transport does not implement the unsent_bytes() callback.
> >+ */
> >+bool vsock_wait_sent(int fd)
> >+{
> >+	int sock_bytes_unsent;
> >+
> >+	return vsock_ioctl_int(fd, SIOCOUTQ, &sock_bytes_unsent, 0);
> > }
> >
> > /* Create socket <type>, bind to <cid, port> and return the file descriptor. */
> >diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
> >index 5e2db67072d5..d59581f68d61 100644
> >--- a/tools/testing/vsock/util.h
> >+++ b/tools/testing/vsock/util.h
> >@@ -54,6 +54,7 @@ int vsock_stream_listen(unsigned int cid, unsigned int port);
> > int vsock_seqpacket_accept(unsigned int cid, unsigned int port,
> > 			   struct sockaddr_vm *clientaddrp);
> > void vsock_wait_remote_close(int fd);
> >+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected);
> > bool vsock_wait_sent(int fd);
> > void send_buf(int fd, const void *buf, size_t len, int flags,
> > 	      ssize_t expected_ret);
> >-- 
> >2.34.1
> >

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper
  2025-07-03  3:05     ` Xuewei Niu
@ 2025-07-03  7:36       ` Stefano Garzarella
  2025-07-03  7:53         ` Xuewei Niu
  0 siblings, 1 reply; 17+ messages in thread
From: Stefano Garzarella @ 2025-07-03  7:36 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: davem, decui, fupan.lfp, jasowang, kvm, leonardi, linux-kernel,
	mst, netdev, niuxuewei.nxw, pabeni, stefanha, virtualization,
	xuanzhuo

On Thu, Jul 03, 2025 at 11:05:14AM +0800, Xuewei Niu wrote:
>Resend: the previous message was rejected due to HTML
>Resend: forgot to reply all...
>
>> On Mon, Jun 30, 2025 at 03:57:26PM +0800, Xuewei Niu wrote:
>> >Wrap the ioctl in `ioctl_int()`, which takes a pointer to the actual
>> >int value and an expected int value. The function will not return until
>> >either the ioctl returns the expected value or a timeout occurs, thus
>> >avoiding immediate failure.
>> >
>> >Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>> >---
>> > tools/testing/vsock/util.c | 32 +++++++++++++++++++++++---------
>> > tools/testing/vsock/util.h |  1 +
>> > 2 files changed, 24 insertions(+), 9 deletions(-)
>> >
>> >diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
>> >index 0c7e9cbcbc85..481c395227e4 100644
>> >--- a/tools/testing/vsock/util.c
>> >+++ b/tools/testing/vsock/util.c
>> >@@ -16,6 +16,7 @@
>> > #include <unistd.h>
>> > #include <assert.h>
>> > #include <sys/epoll.h>
>> >+#include <sys/ioctl.h>
>> > #include <sys/mman.h>
>> > #include <linux/sockios.h>
>> >
>> >@@ -97,28 +98,41 @@ void vsock_wait_remote_close(int fd)
>> > 	close(epollfd);
>> > }
>> >
>> >-/* Wait until transport reports no data left to be sent.
>> >- * Return false if transport does not implement the unsent_bytes()
>> >callback.
>> >+/* Wait until ioctl gives an expected int value.
>> >+ * Return false if the op is not supported.
>> >  */
>> >-bool vsock_wait_sent(int fd)
>> >+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected)
>>
>> Why we need the `actual` parameter?
>
>We can exit early `if (*actual == expected)`, and the `expected` can be any integer.
>I also make it to be a pointer, because the caller might need to have the actual value.

IIUC this function return true if `*actual == expected` or false if 
there was an error, so I don't see the point of aving `actual`, since it 
can only be equal to `expected` if it returns true, or invalid if it 
returs false.

Thanks,
Stefano

>
>Thanks,
>Xuewei
>
>> > {
>> >-	int ret, sock_bytes_unsent;
>> >+	int ret;
>> >+	char name[32];
>> >+
>> >+	snprintf(name, sizeof(name), "ioctl(%lu)", op);
>> >
>> > 	timeout_begin(TIMEOUT);
>> > 	do {
>> >-		ret = ioctl(fd, SIOCOUTQ, &sock_bytes_unsent);
>> >+		ret = ioctl(fd, op, actual);
>> > 		if (ret < 0) {
>> > 			if (errno == EOPNOTSUPP)
>> > 				break;
>> >
>> >-			perror("ioctl(SIOCOUTQ)");
>> >+			perror(name);
>> > 			exit(EXIT_FAILURE);
>> > 		}
>> >-		timeout_check("SIOCOUTQ");
>> >-	} while (sock_bytes_unsent != 0);
>> >+		timeout_check(name);
>> >+	} while (*actual != expected);
>> > 	timeout_end();
>> >
>> >-	return !ret;
>> >+	return ret >= 0;
>> >+}
>> >+
>> >+/* Wait until transport reports no data left to be sent.
>> >+ * Return false if transport does not implement the unsent_bytes() callback.
>> >+ */
>> >+bool vsock_wait_sent(int fd)
>> >+{
>> >+	int sock_bytes_unsent;
>> >+
>> >+	return vsock_ioctl_int(fd, SIOCOUTQ, &sock_bytes_unsent, 0);
>> > }
>> >
>> > /* Create socket <type>, bind to <cid, port> and return the file descriptor. */
>> >diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
>> >index 5e2db67072d5..d59581f68d61 100644
>> >--- a/tools/testing/vsock/util.h
>> >+++ b/tools/testing/vsock/util.h
>> >@@ -54,6 +54,7 @@ int vsock_stream_listen(unsigned int cid, unsigned int port);
>> > int vsock_seqpacket_accept(unsigned int cid, unsigned int port,
>> > 			   struct sockaddr_vm *clientaddrp);
>> > void vsock_wait_remote_close(int fd);
>> >+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected);
>> > bool vsock_wait_sent(int fd);
>> > void send_buf(int fd, const void *buf, size_t len, int flags,
>> > 	      ssize_t expected_ret);
>> >--
>> >2.34.1
>> >
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests
  2025-07-03  2:51     ` Xuewei Niu
@ 2025-07-03  7:37       ` Stefano Garzarella
  0 siblings, 0 replies; 17+ messages in thread
From: Stefano Garzarella @ 2025-07-03  7:37 UTC (permalink / raw)
  To: Xuewei Niu
  Cc: davem, decui, fupan.lfp, jasowang, kvm, leonardi, linux-kernel,
	mst, netdev, niuxuewei.nxw, pabeni, stefanha, virtualization,
	xuanzhuo

On Thu, Jul 03, 2025 at 10:51:56AM +0800, Xuewei Niu wrote:
>Resend: forgot to reply all...
>
>> On Mon, Jun 30, 2025 at 03:57:27PM +0800, Xuewei Niu wrote:
>> >Add SIOCINQ ioctl tests for both SOCK_STREAM and SOCK_SEQPACKET.
>> >
>> >The client waits for the server to send data, and checks if the SIOCINQ
>> >ioctl value matches the data size. After consuming the data, the client
>> >checks if the SIOCINQ value is 0.
>> >
>> >Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
>> >---
>> > tools/testing/vsock/vsock_test.c | 80 ++++++++++++++++++++++++++++++++
>> > 1 file changed, 80 insertions(+)
>> >
>> >diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
>> >index f669baaa0dca..1f525a7e0098 100644
>> >--- a/tools/testing/vsock/vsock_test.c
>> >+++ b/tools/testing/vsock/vsock_test.c
>> >@@ -1305,6 +1305,56 @@ static void test_unsent_bytes_client(const struct test_opts *opts, int type)
>> > 	close(fd);
>> > }
>> >
>> >+static void test_unread_bytes_server(const struct test_opts *opts, int type)
>> >+{
>> >+	unsigned char buf[MSG_BUF_IOCTL_LEN];
>> >+	int client_fd;
>> >+
>> >+	client_fd = vsock_accept(VMADDR_CID_ANY, opts->peer_port, NULL, type);
>> >+	if (client_fd < 0) {
>> >+		perror("accept");
>> >+		exit(EXIT_FAILURE);
>> >+	}
>> >+
>> >+	for (int i = 0; i < sizeof(buf); i++)
>> >+		buf[i] = rand() & 0xFF;
>> >+
>> >+	send_buf(client_fd, buf, sizeof(buf), 0, sizeof(buf));
>> >+	control_writeln("SENT");
>> >+
>> >+	close(client_fd);
>> >+}
>> >+
>> >+static void test_unread_bytes_client(const struct test_opts *opts, int type)
>> >+{
>> >+	unsigned char buf[MSG_BUF_IOCTL_LEN];
>> >+	int fd;
>> >+	int sock_bytes_unread;
>> >+
>> >+	fd = vsock_connect(opts->peer_cid, opts->peer_port, type);
>> >+	if (fd < 0) {
>> >+		perror("connect");
>> >+		exit(EXIT_FAILURE);
>> >+	}
>> >+
>> >+	control_expectln("SENT");
>> >+	/* The data has arrived but has not been read. The expected is
>> >+	 * MSG_BUF_IOCTL_LEN.
>> >+	 */
>> >+	if (!vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread,
>>
>> I know that TIOCINQ is the same of SIOCINQ, but IMO is confusing, why
>> not using SIOCINQ ?
>
>I tried to use `SIOCINQ` but got:
>
>```
>vsock_test.c: In function 'test_unread_bytes_client':
>vsock_test.c:1344:34: error: 'SIOCINQ' undeclared (first use in this function); did you mean 'TIOCINQ'?
> 1344 |         if (!vsock_ioctl_int(fd, SIOCINQ, &sock_bytes_unread,
>      |                                  ^~~~~~~
>      |                                  TIOCINQ
>vsock_test.c:1344:34: note: each undeclared identifier is reported only once for each function it appears in
>```
>
>I just followed the compiler suggestion, and replaced it with `TIOCINQ`.
>Following your comments, I found that `SIOCINQ` is defined in `linux/sockios.h`, as documented in [1].
>The documentation suggests that we can use `FIONREAD` alternatively.
>In order to avoid confusion, I'd like to choose `SIOCINQ`.

Yep, I'd also use SIOCINQ.

Thanks,
Stefano

>
>1: https://man7.org/linux/man-pages/man7/unix.7.html
>
>Thanks,
>Xuewei
>
>> The rest LGTM.
>>
>> Thanks,
>> Stefano
>>
>> >+			     MSG_BUF_IOCTL_LEN)) {
>> >+		fprintf(stderr, "Test skipped, TIOCINQ not supported.\n");
>> >+		goto out;
>> >+	}
>> >+
>> >+	recv_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
>> >+	/* All data has been consumed, so the expected is 0. */
>> >+	vsock_ioctl_int(fd, TIOCINQ, &sock_bytes_unread, 0);
>> >+
>> >+out:
>> >+	close(fd);
>> >+}
>> >+
>> > static void test_stream_unsent_bytes_client(const struct test_opts *opts)
>> > {
>> > 	test_unsent_bytes_client(opts, SOCK_STREAM);
>> >@@ -1325,6 +1375,26 @@ static void test_seqpacket_unsent_bytes_server(const struct test_opts *opts)
>> > 	test_unsent_bytes_server(opts, SOCK_SEQPACKET);
>> > }
>> >
>> >+static void test_stream_unread_bytes_client(const struct test_opts *opts)
>> >+{
>> >+	test_unread_bytes_client(opts, SOCK_STREAM);
>> >+}
>> >+
>> >+static void test_stream_unread_bytes_server(const struct test_opts *opts)
>> >+{
>> >+	test_unread_bytes_server(opts, SOCK_STREAM);
>> >+}
>> >+
>> >+static void test_seqpacket_unread_bytes_client(const struct test_opts *opts)
>> >+{
>> >+	test_unread_bytes_client(opts, SOCK_SEQPACKET);
>> >+}
>> >+
>> >+static void test_seqpacket_unread_bytes_server(const struct test_opts *opts)
>> >+{
>> >+	test_unread_bytes_server(opts, SOCK_SEQPACKET);
>> >+}
>> >+
>> > #define RCVLOWAT_CREDIT_UPD_BUF_SIZE	(1024 * 128)
>> > /* This define is the same as in 'include/linux/virtio_vsock.h':
>> >  * it is used to decide when to send credit update message during
>> >@@ -2051,6 +2121,16 @@ static struct test_case test_cases[] = {
>> > 		.run_client = test_stream_nolinger_client,
>> > 		.run_server = test_stream_nolinger_server,
>> > 	},
>> >+	{
>> >+		.name = "SOCK_STREAM ioctl(SIOCINQ) functionality",
>> >+		.run_client = test_stream_unread_bytes_client,
>> >+		.run_server = test_stream_unread_bytes_server,
>> >+	},
>> >+	{
>> >+		.name = "SOCK_SEQPACKET ioctl(SIOCINQ) functionality",
>> >+		.run_client = test_seqpacket_unread_bytes_client,
>> >+		.run_server = test_seqpacket_unread_bytes_server,
>> >+	},
>> > 	{},
>> > };
>> >
>> >--
>> >2.34.1
>> >
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper
  2025-07-03  7:36       ` Stefano Garzarella
@ 2025-07-03  7:53         ` Xuewei Niu
  0 siblings, 0 replies; 17+ messages in thread
From: Xuewei Niu @ 2025-07-03  7:53 UTC (permalink / raw)
  To: sgarzare
  Cc: davem, decui, fupan.lfp, jasowang, kvm, leonardi, linux-kernel,
	mst, netdev, niuxuewei.nxw, niuxuewei97, pabeni, stefanha,
	virtualization, xuanzhuo

> On Thu, Jul 03, 2025 at 11:05:14AM +0800, Xuewei Niu wrote:
> >Resend: the previous message was rejected due to HTML
> >Resend: forgot to reply all...
> >
> >> On Mon, Jun 30, 2025 at 03:57:26PM +0800, Xuewei Niu wrote:
> >> >Wrap the ioctl in `ioctl_int()`, which takes a pointer to the actual
> >> >int value and an expected int value. The function will not return until
> >> >either the ioctl returns the expected value or a timeout occurs, thus
> >> >avoiding immediate failure.
> >> >
> >> >Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
> >> >---
> >> > tools/testing/vsock/util.c | 32 +++++++++++++++++++++++---------
> >> > tools/testing/vsock/util.h |  1 +
> >> > 2 files changed, 24 insertions(+), 9 deletions(-)
> >> >
> >> >diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
> >> >index 0c7e9cbcbc85..481c395227e4 100644
> >> >--- a/tools/testing/vsock/util.c
> >> >+++ b/tools/testing/vsock/util.c
> >> >@@ -16,6 +16,7 @@
> >> > #include <unistd.h>
> >> > #include <assert.h>
> >> > #include <sys/epoll.h>
> >> >+#include <sys/ioctl.h>
> >> > #include <sys/mman.h>
> >> > #include <linux/sockios.h>
> >> >
> >> >@@ -97,28 +98,41 @@ void vsock_wait_remote_close(int fd)
> >> > 	close(epollfd);
> >> > }
> >> >
> >> >-/* Wait until transport reports no data left to be sent.
> >> >- * Return false if transport does not implement the unsent_bytes()
> >> >callback.
> >> >+/* Wait until ioctl gives an expected int value.
> >> >+ * Return false if the op is not supported.
> >> >  */
> >> >-bool vsock_wait_sent(int fd)
> >> >+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected)
> >>
> >> Why we need the `actual` parameter?
> >
> >We can exit early `if (*actual == expected)`, and the `expected` can be any integer.
> >I also make it to be a pointer, because the caller might need to have the actual value.
> 
> IIUC this function return true if `*actual == expected` or false if 
> there was an error, so I don't see the point of aving `actual`, since it 
> can only be equal to `expected` if it returns true, or invalid if it 
> returs false.

Nice catch! I'll remove it in v5.

Thanks,
Xuewei

> Thanks,
> Stefano
> 
> >
> >Thanks,
> >Xuewei
> >
> >> > {
> >> >-	int ret, sock_bytes_unsent;
> >> >+	int ret;
> >> >+	char name[32];
> >> >+
> >> >+	snprintf(name, sizeof(name), "ioctl(%lu)", op);
> >> >
> >> > 	timeout_begin(TIMEOUT);
> >> > 	do {
> >> >-		ret = ioctl(fd, SIOCOUTQ, &sock_bytes_unsent);
> >> >+		ret = ioctl(fd, op, actual);
> >> > 		if (ret < 0) {
> >> > 			if (errno == EOPNOTSUPP)
> >> > 				break;
> >> >
> >> >-			perror("ioctl(SIOCOUTQ)");
> >> >+			perror(name);
> >> > 			exit(EXIT_FAILURE);
> >> > 		}
> >> >-		timeout_check("SIOCOUTQ");
> >> >-	} while (sock_bytes_unsent != 0);
> >> >+		timeout_check(name);
> >> >+	} while (*actual != expected);
> >> > 	timeout_end();
> >> >
> >> >-	return !ret;
> >> >+	return ret >= 0;
> >> >+}
> >> >+
> >> >+/* Wait until transport reports no data left to be sent.
> >> >+ * Return false if transport does not implement the unsent_bytes() callback.
> >> >+ */
> >> >+bool vsock_wait_sent(int fd)
> >> >+{
> >> >+	int sock_bytes_unsent;
> >> >+
> >> >+	return vsock_ioctl_int(fd, SIOCOUTQ, &sock_bytes_unsent, 0);
> >> > }
> >> >
> >> > /* Create socket <type>, bind to <cid, port> and return the file descriptor. */
> >> >diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
> >> >index 5e2db67072d5..d59581f68d61 100644
> >> >--- a/tools/testing/vsock/util.h
> >> >+++ b/tools/testing/vsock/util.h
> >> >@@ -54,6 +54,7 @@ int vsock_stream_listen(unsigned int cid, unsigned int port);
> >> > int vsock_seqpacket_accept(unsigned int cid, unsigned int port,
> >> > 			   struct sockaddr_vm *clientaddrp);
> >> > void vsock_wait_remote_close(int fd);
> >> >+bool vsock_ioctl_int(int fd, unsigned long op, int *actual, int expected);
> >> > bool vsock_wait_sent(int fd);
> >> > void send_buf(int fd, const void *buf, size_t len, int flags,
> >> > 	      ssize_t expected_ret);
> >> >--
> >> >2.34.1
> >> >
> >

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-07-03  7:53 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30  7:57 [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Xuewei Niu
2025-06-30  7:57 ` [RESEND PATCH net-next v4 1/4] vsock: Add support for SIOCINQ ioctl Xuewei Niu
2025-07-02  9:56   ` Stefano Garzarella
2025-06-30  7:57 ` [RESEND PATCH net-next v4 2/4] hv_sock: Return the readable bytes in hvs_stream_has_data() Xuewei Niu
2025-07-02  9:58   ` Stefano Garzarella
2025-07-02 10:05     ` Xuewei Niu
2025-06-30  7:57 ` [RESEND PATCH net-next v4 3/4] test/vsock: Add retry mechanism to ioctl wrapper Xuewei Niu
2025-07-02 10:20   ` Stefano Garzarella
2025-07-03  3:05     ` Xuewei Niu
2025-07-03  7:36       ` Stefano Garzarella
2025-07-03  7:53         ` Xuewei Niu
2025-06-30  7:57 ` [RESEND PATCH net-next v4 4/4] test/vsock: Add ioctl SIOCINQ tests Xuewei Niu
2025-07-02 10:27   ` Stefano Garzarella
2025-07-03  2:51     ` Xuewei Niu
2025-07-03  7:37       ` Stefano Garzarella
2025-07-02  1:09 ` [RESEND PATCH net-next v4 0/4] vsock: Introduce SIOCINQ ioctl support Jakub Kicinski
2025-07-02  2:15   ` Xuewei Niu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).