Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp23370821rwd; Sat, 1 Jul 2023 00:14:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHzu6N00ToVI7fAJyk4YYAseVDOFlcIK9lzmLbGg79D4iXKr42r4giupI6+GJRvc7cUjJSB X-Received: by 2002:a05:6a20:9390:b0:12d:91a0:2408 with SMTP id x16-20020a056a20939000b0012d91a02408mr4577158pzh.19.1688195647467; Sat, 01 Jul 2023 00:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688195647; cv=none; d=google.com; s=arc-20160816; b=b6v7WsepjdWDAp2Eq8uxLTGB96GKvfwuKtv6CCG/Cwv7wMUGP9JZ7/Wx/+Kl4Gcx80 FeNDRAOtsRnFGa5XqLafKd/8oVwPp6SB3oIVHJl2qJmJ+VJnfgPwrrbe7CIG9Ie5mJCE 4g32VUCXUFxTouB2dw2l0Kkb16kaEsZaoPZZcWKwUQklMJ2rNTeB7NAudXzSF7JMFiUb 8K64xf9FjypI/7ZqZKUEGjTJsgSewGp/kaAzjeKocjUs/LBe0Z3CIv23fRsdkg6boLlw 32+PYWjp0IlQqlcJ6RvfyuIVUsK+/x4LCNrHbVAvqEdXtLatKoAYjs9cSd7MlwkuGBvU hCpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=dXr+GIu8Zm+IAJzZ6mwmY2cDmvd5mo+b/fOvW2U8kdk=; fh=PzWIi6JmlJNekYqVy23433fKO6OE4+V62ucRx731HUI=; b=X/RtCAqIRJkXyVG/T5r3CsuGWXq+vvmLefeWVLipR609avfIxBVpUoVoQemC17K0c9 M59cSWxJeeO94uy2N6Ql++DZ3Ylg1N79XCs/U3ZixWSQVk1E0/WFl9oHfs5eqFgvqV08 bILmQoH4tNedOJzEQrZL6gOGc8KwR2pxIP0J409EhZPy5nvKWb2af6nVdJVkfrQWDfR4 Wd4zJdu+QoT0VuVwMEyfs5gcxQTRyMaU2thzYhIqO+4Ybx4jdyuqU9F7AeGydD/hLI9N 5CrhFZXJJ8qP0MjXfb4l4By4vVyRkWFKMFU+Zv/3qxBAdfxPR+RqYlp1PPX7lSjXd5sG svGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=WolKDo7b; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr5-20020a056a000f0500b006738dfbaf42si12085449pfb.374.2023.07.01.00.13.54; Sat, 01 Jul 2023 00:14:07 -0700 (PDT) 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=WolKDo7b; 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 S229968AbjGAGxf (ORCPT + 99 others); Sat, 1 Jul 2023 02:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjGAGw0 (ORCPT ); Sat, 1 Jul 2023 02:52:26 -0400 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 276574691; Fri, 30 Jun 2023 23:46:05 -0700 (PDT) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 83C4312000F; Sat, 1 Jul 2023 09:45:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 83C4312000F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1688193911; bh=dXr+GIu8Zm+IAJzZ6mwmY2cDmvd5mo+b/fOvW2U8kdk=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=WolKDo7buF+N6Aw5KwT0NDvX841UpCcSLrR8bO+y2EcCFeD/fMRjxOPI+E38eUWLi GM/PV5DBcoUWUkBJJOExBB21yi6DBJjKjqRu/k1ihVeutj6FhgJgVEcacjSFPznOqX e6UxqW2iO4nR+9jQeGBPkOhR5U8VYxzArskDmhHts7zVhlAO6JFjxI2zRzrosTSpsY NzPGn8d9O6LwGgT7YCmvj4EVFwzY2mZRLpI41AiPIA14b9kBzKBr9hZXGqBfSBOe85 NCAhI1507AUYEDnxF9Nt3LbxTgq7oNiI+rItF28MrZ2A9Wl/Uk5C3TOGtqk0e8U+m4 dcsQDBBqQgB0Q== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Sat, 1 Jul 2023 09:45:10 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sat, 1 Jul 2023 09:44:48 +0300 From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , , Arseniy Krasnov Subject: [RFC PATCH v5 08/17] vsock: check for MSG_ZEROCOPY support on send Date: Sat, 1 Jul 2023 09:39:38 +0300 Message-ID: <20230701063947.3422088-9-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230701063947.3422088-1-AVKrasnov@sberdevices.ru> References: <20230701063947.3422088-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 178380 [Jun 30 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: AVKrasnov@sberdevices.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 517 517 b0056c19d8e10afbb16cb7aad7258dedb0179a79, {Tracking_from_domain_doesnt_match_to}, sberdevices.ru:7.1.1,5.0.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;100.64.160.123:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, {Tracking_white_helo}, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/07/01 04:02:00 #21597763 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_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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 | 7 +++++++ net/vmw_vsock/af_vsock.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h index 0e7504a42925..ec09edc5f3a0 100644 --- a/include/net/af_vsock.h +++ b/include/net/af_vsock.h @@ -177,6 +177,9 @@ struct vsock_transport { /* Read a single skb */ int (*read_skb)(struct vsock_sock *, skb_read_actor_t); + + /* Zero-copy. */ + bool (*msgzerocopy_allow)(void); }; /**** CORE ****/ @@ -243,4 +246,8 @@ static inline void __init vsock_bpf_build_proto(void) {} #endif +static inline bool vsock_msgzerocopy_allow(const struct vsock_transport *t) +{ + return t->msgzerocopy_allow && t->msgzerocopy_allow(); +} #endif /* __AF_VSOCK_H__ */ diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 07803d9fbf6d..033006e1b5ad 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1824,6 +1824,12 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, 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); -- 2.25.1