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: 53029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2087941wrn; Sun, 5 Feb 2023 22:58:19 -0800 (PST) X-Google-Smtp-Source: AK7set9S7mMDc+nvu30KEtc2e92dy2Z+jnuHGzjd32HR78SZzM3K6sDz+K69+HUhnCp2Kmhwc5yo X-Received: by 2002:a17:90a:3e82:b0:230:caa5:521d with SMTP id k2-20020a17090a3e8200b00230caa5521dmr1127557pjc.17.1675666698764; Sun, 05 Feb 2023 22:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675666698; cv=none; d=google.com; s=arc-20160816; b=lG5iln+yRKbu8zGOPNsa9NF7ZdOd1EcFFCU8wHeszMCbuG9BD3xd6PhK+LXMaK3Oh6 pn/vB7yC45+NWUjqwQhvKd1ZEtZE2Epu56KJedfMgqQW4ZqZSDrQ1MM2oR5PAn8m5bd0 obrn0VV2hi1ArBwMqU3Dy/jLfmQcF+Fiw/2pQYctIzgxlfnfzzBMyWZKeZYS1YTqlsgR Xn6A+BKW7VhexdWurHCSett1zzK7QyczO9ybhSIXSED4PkjdifOrn6pLT6L/hkfPf8WJ Gro1/zsBC10D2aQAqVDvDSbalMNJDAgN23mL6RicZgipChvb+rV1apJkU7KxaBQ4CtkQ aIAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=jKp9H6Gl8+dpKJMrNsPP4bgIPg00ur5gUBmdQBd30+A=; b=lW0tOLl+XHflkaedZWmXUkd1l+pKZa2kVWwpa3IzEB38hil+zzOG0GVqy1xBZMkHzB cgKbyTDkOioOGsxwCMuMGMZq0GZBtn+jaQlghCUxAJQqdKZ5vEupvp3eHTGcVKAv9RUS QgJjrTd/1KfKDX21UgBVgSLSOVCYFyJNLqQ3MTYcHiS4CmbAY7YHpRHrpZHifekTtFcQ Bw2jv7bfMX6RTqJg+XsL3X84tE2Od4BdNmA2ymw0L8C/TOczifm10/A2QTpGLv9GGYZR 3rT18kor3dTQhws4GwH0cGfuIuq4W8+FSIVVLlAotX/VN4OQb+k2HmwcJTrZkPxVzPvc jteA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=myKw0kJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch19-20020a17090af41300b002298836bbecsi3620056pjb.171.2023.02.05.22.58.06; Sun, 05 Feb 2023 22:58:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=myKw0kJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbjBFG4t (ORCPT + 99 others); Mon, 6 Feb 2023 01:56:49 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757063883876944655?= X-GMAIL-MSGID: =?utf-8?q?1757063883876944655?= 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(+) -- 2.25.1 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);