[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250617045347.1233128-2-niuxuewei.nxw@antgroup.com>
Date: Tue, 17 Jun 2025 12:53:44 +0800
From: Xuewei Niu <niuxuewei97@...il.com>
To: sgarzare@...hat.com,
mst@...hat.com,
pabeni@...hat.com,
jasowang@...hat.com,
xuanzhuo@...ux.alibaba.com,
davem@...emloft.net,
netdev@...r.kernel.org,
stefanha@...hat.com,
leonardi@...hat.com
Cc: virtualization@...ts.linux.dev,
kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
fupan.lfp@...group.com,
Xuewei Niu <niuxuewei.nxw@...group.com>
Subject: [PATCH net-next v3 1/3] vsock: Add support for SIOCINQ ioctl
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@...group.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
Powered by blists - more mailing lists