From nobody Tue Oct 7 20:06:59 2025 Received: from out28-73.mail.aliyun.com (out28-73.mail.aliyun.com [115.124.28.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B54811E48A; Tue, 8 Jul 2025 06:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751956610; cv=none; b=poRUIEIIakfq46pBUxeEcbmJ85N//lwkTZE0Upu1/ZagBUO7PgfU85cv/7n2UJPdTlXTJDqcPf2VRXuXlCXV3qkjfFrSOtlM9Gp/kDJfF8hajBD74xhVamCm32Qqshb3Y4Og8DijKEGc8BaNMKz4Ab2TTGACDlQAQEBhCfsCZmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751956610; c=relaxed/simple; bh=lrNsByWI4+JZUOhPSorgBp0TBt5xNkaU5kzScC5uvPo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sfTXSjFFjwTR84i2KMzEP3MBxPudinvo27hZxafo9LBTNI2g5cxppgBwO0/Byd01JwwFbnPcR+RlGfkP7O8xSUfQPwka6tb0z+mVbUxFJEWZ9SDK7woy6EVmBVGyLqjdN3+DeKZjD6R4zZHtUAddB2cJ0joWKbt+js1o0Z9k8JI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=H+8QSoGf; arc=none smtp.client-ip=115.124.28.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="H+8QSoGf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1751956605; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; bh=enAMJL6mb/z9WNfWVziA8KCdR5RF2FfP9GwDXl38f/E=; b=H+8QSoGfmlSGIIxJeJ7pYnYimR+DcyuUI9Fd2F39PUDxk8fu1TO5DxD0Thn/Fv/HX97NCpIZm08Ebytje96Bg/dyKu6L7qU1YcnxODl4Cu617wk1gUnFZ0F/gOQ8n6IGyUt1jkcCW7uhfq33uijmm3JABNV/XP/a78Wj1BBIueU= Received: from 127.0.0.1(mailfrom:niuxuewei.nxw@antgroup.com fp:SMTPD_---.dhGPAe-_1751956603 cluster:ay29) by smtp.aliyun-inc.com; Tue, 08 Jul 2025 14:36:44 +0800 From: Xuewei Niu Date: Tue, 08 Jul 2025 14:36:12 +0800 Subject: [PATCH net-next v6 2/4] vsock: Add support for SIOCINQ ioctl Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250708-siocinq-v6-2-3775f9a9e359@antgroup.com> References: <20250708-siocinq-v6-0-3775f9a9e359@antgroup.com> In-Reply-To: <20250708-siocinq-v6-0-3775f9a9e359@antgroup.com> To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xuewei Niu , niuxuewei97@gmail.com X-Mailer: b4 0.14.2 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 Reviewed-by: Luigi Leonardi Reviewed-by: Stefano Garzarella --- 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 2e7a3034e965db30b6ee295370d866e6d8b1c341..bae6b89bb5fb7dd7a3a378f9209= 7561a98a0c814 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, unsig= ned int cmd, vsk =3D vsock_sk(sk); =20 switch (cmd) { + case SIOCINQ: { + ssize_t n_bytes; + + if (!vsk->transport) { + ret =3D -EOPNOTSUPP; + break; + } + + if (sock_type_connectible(sk->sk_type) && + sk->sk_state =3D=3D TCP_LISTEN) { + ret =3D -EINVAL; + break; + } + + n_bytes =3D vsock_stream_has_data(vsk); + if (n_bytes < 0) { + ret =3D n_bytes; + break; + } + ret =3D put_user(n_bytes, arg); + break; + } case SIOCOUTQ: { ssize_t n_bytes; =20 --=20 2.34.1