Skip to content

Commit f7c7226

Browse files
justxueweikuba-moo
authored andcommitted
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@antgroup.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Luigi Leonardi <leonardi@redhat.com> Link: https://patch.msgid.link/20250708-siocinq-v6-2-3775f9a9e359@antgroup.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f0c5827 commit f7c7226

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,28 @@ static int vsock_do_ioctl(struct socket *sock, unsigned int cmd,
13891389
vsk = vsock_sk(sk);
13901390

13911391
switch (cmd) {
1392+
case SIOCINQ: {
1393+
ssize_t n_bytes;
1394+
1395+
if (!vsk->transport) {
1396+
ret = -EOPNOTSUPP;
1397+
break;
1398+
}
1399+
1400+
if (sock_type_connectible(sk->sk_type) &&
1401+
sk->sk_state == TCP_LISTEN) {
1402+
ret = -EINVAL;
1403+
break;
1404+
}
1405+
1406+
n_bytes = vsock_stream_has_data(vsk);
1407+
if (n_bytes < 0) {
1408+
ret = n_bytes;
1409+
break;
1410+
}
1411+
ret = put_user(n_bytes, arg);
1412+
break;
1413+
}
13921414
case SIOCOUTQ: {
13931415
ssize_t n_bytes;
13941416

0 commit comments

Comments
 (0)