From patchwork Mon Feb 6 06:55:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 13129374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47208C61DA4 for ; Mon, 6 Feb 2023 06:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjBFG4s (ORCPT ); Mon, 6 Feb 2023 01:56:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjBFG4r (ORCPT ); Mon, 6 Feb 2023 01:56:47 -0500 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB7F01BAFE; Sun, 5 Feb 2023 22:56:17 -0800 (PST) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 0A8535FD0A; Mon, 6 Feb 2023 09:55:47 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1675666547; bh=jKp9H6Gl8+dpKJMrNsPP4bgIPg00ur5gUBmdQBd30+A=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=myKw0kJTJWPZcUUzr+ic9NSsNN78CsbnOLPu9EvN6QY+EwKU30KYqP3PP3UQnydSy 2AtycgAaILRUybm61fyYNyv22cgvUKRD0Pgj+4LVIv4QllAEu8YnC/QxAiw6Q7AOne K7MR6Ha/2gzXYIizt54FPfllLYLM1mtXEo4a6w0Fv5d+2QmzcOYA1AkRtOfwvCVdvl Tia/7spzmxrC4p9vYDQ71nha5tRl84aPNaVpQGxNOfzLfl3IZQ/UPvl5YWMSWsWl/K ITraHe4ZRnWomtJCGXATOP9LcBTEUMIbUWQEyXeDOGUzzkX7RC+j4hHaIhHjflUdbp LlhPhj0eaufxw== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 6 Feb 2023 09:55:47 +0300 (MSK) From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arseniy Krasnov , "Krasnov Arseniy" CC: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , kernel Subject: [RFC PATCH v1 03/12] vsock: check for MSG_ZEROCOPY support Thread-Topic: [RFC PATCH v1 03/12] vsock: check for MSG_ZEROCOPY support Thread-Index: AQHZOfgJ1YmcF1NMGkqzPZVVHI90wA== Date: Mon, 6 Feb 2023 06:55:46 +0000 Message-ID: In-Reply-To: <0e7c6fc4-b4a6-a27b-36e9-359597bba2b5@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <6875DB21EF0B2A4184A9CDEF0D4F4475@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/02/06 01:18:00 #20834045 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This feature totally depends on transport, so if transport doesn't support it, return error. Signed-off-by: Arseniy Krasnov --- 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); + + 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);