This feature totally depends on transport, so if transport doesn't
support it, return error.
Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
 
        /* Read a single skb */
        int (*read_skb)(struct vsock_sock *, skb_read_actor_t);
+
+       /* Zero-copy. */
+       bool (*msgzerocopy_allow)(void);
 };
 
 /**** CORE ****/
 {}
 #endif
 
+static inline bool vsock_msgzerocopy_allow(const struct vsock_transport *t)
+{
+       return t->msgzerocopy_allow && t->msgzerocopy_allow();
+}
 #endif /* __AF_VSOCK_H__ */
 
                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. */
        timeout = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);