Commit 5fbfc7d2 authored by Arseniy Krasnov's avatar Arseniy Krasnov Committed by David S. Miller

vsock: check for MSG_ZEROCOPY support on send

This feature totally depends on transport, so if transport doesn't
support it, return error.
Signed-off-by: default avatarArseniy Krasnov <avkrasnov@salutedevices.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 49dbe25a
...@@ -177,6 +177,9 @@ struct vsock_transport { ...@@ -177,6 +177,9 @@ struct vsock_transport {
/* Read a single skb */ /* Read a single skb */
int (*read_skb)(struct vsock_sock *, skb_read_actor_t); int (*read_skb)(struct vsock_sock *, skb_read_actor_t);
/* Zero-copy. */
bool (*msgzerocopy_allow)(void);
}; };
/**** CORE ****/ /**** CORE ****/
...@@ -241,4 +244,8 @@ static inline void __init vsock_bpf_build_proto(void) ...@@ -241,4 +244,8 @@ static inline void __init vsock_bpf_build_proto(void)
{} {}
#endif #endif
static inline bool vsock_msgzerocopy_allow(const struct vsock_transport *t)
{
return t->msgzerocopy_allow && t->msgzerocopy_allow();
}
#endif /* __AF_VSOCK_H__ */ #endif /* __AF_VSOCK_H__ */
...@@ -1824,6 +1824,12 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, ...@@ -1824,6 +1824,12 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg,
goto out; goto out;
} }
if (msg->msg_flags & MSG_ZEROCOPY &&
!vsock_msgzerocopy_allow(transport)) {
err = -EOPNOTSUPP;
goto out;
}
/* Wait for room in the produce queue to enqueue our user's data. */ /* Wait for room in the produce queue to enqueue our user's data. */
timeout = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); timeout = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment