Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2896627rdb; Fri, 22 Sep 2023 11:15:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuemoHiDr9RaYJuaOq6oZRPoA4VuJ2Qn+dYVhpBs+Ltj68U3C3ttdkWuHYZth5R1Cq+3DQ X-Received: by 2002:a05:6a21:7897:b0:14e:6c19:60f6 with SMTP id bf23-20020a056a21789700b0014e6c1960f6mr386953pzc.50.1695406548095; Fri, 22 Sep 2023 11:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695406548; cv=none; d=google.com; s=arc-20160816; b=zKAxUfv+PchDYMY0Ey8DKcIB16J9CXKS5Bci2fMQ5a8jx8iILhAHSQvRYqMlEKak6q 2HeTPfHi1b/OqfL4jw0lwpVuKZoRiPeZGemu7aT1YnJDVqaiiPsiaOcVl42ISU7Un6Hv Kx7kHPln30dcHIPsgRrSiIYZE8cUCBLoxM3IBRMzGKr9LXXOotHlZ7eRa6zHhW5DUIap BfmbSpvpRQbi0fWvNhsmarNAgfia97xbEw19j3frZ74mnj7XOnlcX87MWLY3wrYBBPNL wjiv1EPkFfalLm2J6Gqz9qveIAkh1Ga50phTb5+X0FpLU6VEt14ARZVSmAQhxYG9df1k Xj/g== 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=cwfDioEUR/UyI04QbxX4XAX40+tJ7YbibO6KDL5GKJg=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=F/vNPxs8/MdOleaN3YZxmAR++93XxfO6XfdmBjOcj3TDo/uXOgesxW++aMUHc9WaDE jKpFmugTy0BMiuCXvuVd/sLt/UfkmP/ySjD+t3bPaage+j/M3rJEs5Cm4bmXgYtsernW Hq5OPrk6jwkfrI+id29DIvMlB72fy20IcMipNVGULaAKK9rZK7LU8eemQAZSHsKpIvnd 53eNzdfjatTyTtylN2K2gS6ndi1nqaobbsU4sDeud8vAeCu/EIXZ85GqmH5k/ZMC9sIs 0OHKE35h3WUEitAvqNKZqmFDtXQPjLdt1Gm1ys4csc+Be/Od/qGPckDVLJxgN2DR5T9n A1Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=kG1kHE5Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bs70-20020a632849000000b00578af607626si4146089pgb.668.2023.09.22.11.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=kG1kHE5Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D254581F88DB; Thu, 21 Sep 2023 22:32:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbjIVFcC (ORCPT + 99 others); Fri, 22 Sep 2023 01:32:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjIVFbx (ORCPT ); Fri, 22 Sep 2023 01:31:53 -0400 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B178194; Thu, 21 Sep 2023 22:31:45 -0700 (PDT) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 6494A100008; Fri, 22 Sep 2023 08:31:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 6494A100008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1695360703; bh=cwfDioEUR/UyI04QbxX4XAX40+tJ7YbibO6KDL5GKJg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=kG1kHE5QVLPlEXGK0k8WjAcArcWZPBVUWepLhNQyY/xWuf4t+Me9PHwwa7FYNYQkC PI5J27tUFCukt7lLDhFUsD7OGCwbcrw19tXKpq20JaiD2qc/1TvuWQgYKOy5XexnDH YSi4nelqKGX/gJBudo8kQ3GuLYiRcMDZ52BlpgCV0s7ZGv9woCQb3cFBS/M3MNIeef gRaHz2CejrtXil43SJOiGef4B31i74OHVbh6JbfHrCD+YffO1vlF26n+T3hMKUmjFZ y3UwYkDMH9S2R6jUUuspYZQ62QJ9Kn8yRyRcjHlSSolbE2b33O8Da1gQHP1AHtrN3z thw5euRntwZzQ== 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; Fri, 22 Sep 2023 08:31:43 +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; Fri, 22 Sep 2023 08:31:42 +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: , , , , , , Subject: [PATCH net-next v1 03/12] vsock: check for MSG_ZEROCOPY support on send Date: Fri, 22 Sep 2023 08:24:19 +0300 Message-ID: <20230922052428.4005676-4-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230922052428.4005676-1-avkrasnov@salutedevices.com> References: <20230922052428.4005676-1-avkrasnov@salutedevices.com> 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: 180033 [Sep 21 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: avkrasnov@salutedevices.com 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: 534 534 808c2ea49f7195c68d40844e073217da4fa0d1e3, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;salutedevices.com:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1;100.64.160.123:7.1.2, FromAlignment: s, 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/09/22 02:22:00 #21944311 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 22:32:13 -0700 (PDT) This feature totally depends on transport, so if transport doesn't support it, return error. Signed-off-by: Arseniy Krasnov Reviewed-by: Stefano Garzarella --- 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 b01cf9ac2437..e302c0e804d0 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 ****/ @@ -241,4 +244,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 4fd11bf34bc7..134494a78c14 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