lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240517144607.2595798-4-niuxuewei.nxw@antgroup.com>
Date: Fri, 17 May 2024 22:46:05 +0800
From: Xuewei Niu <niuxuewei97@...il.com>
To: stefanha@...hat.com,
	sgarzare@...hat.com
Cc: mst@...hat.com,
	davem@...emloft.net,
	kvm@...r.kernel.org,
	virtualization@...ts.linux.dev,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Xuewei Niu <niuxuewei.nxw@...group.com>
Subject: [RFC PATCH 3/5] vsock/virtio: can_msgzerocopy adapts to multi-devices

Adds a new argument, named "cid", to let them know which `virtio_vsock` to
be selected.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@...group.com>
---
 include/linux/virtio_vsock.h            | 2 +-
 net/vmw_vsock/virtio_transport.c        | 5 ++---
 net/vmw_vsock/virtio_transport_common.c | 6 +++---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
index c82089dee0c8..21bfd5e0c2e7 100644
--- a/include/linux/virtio_vsock.h
+++ b/include/linux/virtio_vsock.h
@@ -168,7 +168,7 @@ struct virtio_transport {
 	 * extra checks and can perform zerocopy transmission by
 	 * default.
 	 */
-	bool (*can_msgzerocopy)(int bufs_num);
+	bool (*can_msgzerocopy)(u32 cid, int bufs_num);
 };
 
 ssize_t
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 93d25aeafb83..998b22e5ce36 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -521,14 +521,13 @@ static void virtio_vsock_rx_done(struct virtqueue *vq)
 	queue_work(virtio_vsock_workqueue, &vsock->rx_work);
 }
 
-static bool virtio_transport_can_msgzerocopy(int bufs_num)
+static bool virtio_transport_can_msgzerocopy(u32 cid, int bufs_num)
 {
 	struct virtio_vsock *vsock;
 	bool res = false;
 
 	rcu_read_lock();
-
-	vsock = rcu_dereference(the_virtio_vsock);
+	vsock = virtio_transport_get_virtio_vsock(cid);
 	if (vsock) {
 		struct virtqueue *vq = vsock->vqs[VSOCK_VQ_TX];
 
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index bed75a41419e..e7315d7b9af1 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -39,7 +39,7 @@ virtio_transport_get_ops(struct vsock_sock *vsk)
 
 static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops,
 				       struct virtio_vsock_pkt_info *info,
-				       size_t pkt_len)
+				       size_t pkt_len, unsigned int cid)
 {
 	struct iov_iter *iov_iter;
 
@@ -62,7 +62,7 @@ static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops,
 		int pages_to_send = iov_iter_npages(iov_iter, MAX_SKB_FRAGS);
 
 		/* +1 is for packet header. */
-		return t_ops->can_msgzerocopy(pages_to_send + 1);
+		return t_ops->can_msgzerocopy(cid, pages_to_send + 1);
 	}
 
 	return true;
@@ -375,7 +375,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
 			info->msg->msg_flags &= ~MSG_ZEROCOPY;
 
 		if (info->msg->msg_flags & MSG_ZEROCOPY)
-			can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len);
+			can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len, src_cid);
 
 		if (can_zcopy)
 			max_skb_len = min_t(u32, VIRTIO_VSOCK_MAX_PKT_BUF_SIZE,
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ