Re: [RFC PATCH v1 03/12] vsock: check for MSG_ZEROCOPY support

From: Stefano Garzarella
Date: Thu Feb 16 2023 - 09:03:29 EST


On Mon, Feb 06, 2023 at 06:55:46AM +0000, Arseniy Krasnov wrote:
This feature totally depends on transport, so if transport doesn't
support it, return error.

Signed-off-by: Arseniy Krasnov <AVKrasnov@xxxxxxxxxxxxxx>
---
include/net/af_vsock.h | 2 ++
net/vmw_vsock/af_vsock.c | 7 +++++++
2 files changed, 9 insertions(+)

diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 568a87c5e0d0..96d829004c81 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -173,6 +173,8 @@ struct vsock_transport {

/* Addressing. */
u32 (*get_local_cid)(void);
+

LGTM, just add comment here for a new section following what we did for
other callaback, e.g.:

/* Zero-copy. */
+ bool (*msgzerocopy_allow)(void);
};

/**** CORE ****/
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index f752b30b71d6..fb0fcb390113 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1788,6 +1788,13 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg,
goto out;
}

+ if (msg->msg_flags & MSG_ZEROCOPY &&
+ (!transport->msgzerocopy_allow ||
+ !transport->msgzerocopy_allow())) {
+ err = -EOPNOTSUPP;
+ goto out;
+ }
+
/* Wait for room in the produce queue to enqueue our user's data. */
timeout = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);

--
2.25.1