Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp555272rdb; Sat, 30 Sep 2023 16:17:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqlEz3jyvuou2Y8Q2LXcG06nLt+5lTArYK/aFvG40WL/2eICnv1qNMOKQrie8AwwQn/y2V X-Received: by 2002:a05:6a00:2490:b0:690:c79c:cc9c with SMTP id c16-20020a056a00249000b00690c79ccc9cmr9646384pfv.14.1696115825245; Sat, 30 Sep 2023 16:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696115825; cv=none; d=google.com; s=arc-20160816; b=LlEvxF66dfEkGbiy2qVaoUpQYcteyHE8Ilqws+ItJBUs1JLzwNEFOTqq6jpeQWKPMY U1fl9KlPNB6aspCjas5kcxmx0IORNTPQL7aa3lhv1OjTcXMnu25MMrWLmuiN/zeEuyEN qarS7bKw9IjHU+afELc3LK6SlwIORJUqFHXdHRcVmzyd7F/UzaOuc8cijQR5NVqVEibN d31z/Q+17mNp1G52NjAc6fSgGDLQSFNvJLywClRXllqP1e4JSsxwzwD10BXfLUQkoY+5 BnUBu6Z5tMvQz5C+q5lnfQOogVPCSlCtzRlsS9SFgzTMR4VTjuSoEgCeIoCozX6z6JWC LOiQ== 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=s97vVZ6AdQilCZkxxPA5FVFX3AoinEVoU+I3gTxfJbg=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=Ci0EOWLCWwHDs/VXY/K8xT+PNS3z1VtVDUdYx6gy1NggGXYBrCJizfUQ5W4hzJtQjf 8OwpQRfeTX7DHQy1YU3X+pq3ZcqCoUVkiIMtnAukzSL8JAo0BK2VEDSNTOOWy1Dw0R1H d9dxiCUeWWHaxR6rLuJT6zzHcb6/UFoAlC0SJVpvHlCQ3dB7ZvS9mb8mTUpTcS74y9Mz ekIFpCRBKuvRQZ1JERujbM5YN+KaGH38TmpOMyNXo5tiIKGYgGOVlwGJEtzG4CnkQNV8 V1L9CpQ9ZycVwVJsyiZ4w5DDNzUY7wTfMpcb0FbMqfzpEnxvp1u6b6K3nQpfTHLDx2hu WBbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="uvHX8JX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id s16-20020a056a00195000b0068e4c3f3ac2si25140818pfk.245.2023.09.30.16.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 16:17:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="uvHX8JX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 63D7D80254ED; Sat, 30 Sep 2023 14:10:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233990AbjI3VKf (ORCPT + 99 others); Sat, 30 Sep 2023 17:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjI3VKe (ORCPT ); Sat, 30 Sep 2023 17:10:34 -0400 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A5C2DA; Sat, 30 Sep 2023 14:10:31 -0700 (PDT) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 8555B100009; Sun, 1 Oct 2023 00:10:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 8555B100009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1696108228; bh=s97vVZ6AdQilCZkxxPA5FVFX3AoinEVoU+I3gTxfJbg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=uvHX8JX/v4heOGOFP3ahtkecx63S5sS4g1b3h1pboJXNbLUMYI7B/wjze/lzSHQhi y4BdXwg/izjqoyjY7TX3j/3GGxDsK4yS7xuJtBB5oTYlFxdT66Tq1fI8FEzAc+B6xo b2OGFpPwmI7Vl8ZNhVbR7CpX7/CDKSFdue0nLIa2BaSYR8Jsmg5q2pe7P6FnLzfUGa kVUBigVCXy0ifvyq/BK/LQD4f5q8F/qYawSJvWS2MQMl9XLuIQp765GPKi7dj/Fl2S 7EPxBLNMWE3//Qpe8zxb4iQjKo6dWKSdxWGyxKNE0QhNivXXZSIqsLKUC7oqcJ+thM OjmOPli7AWEDQ== 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; Sun, 1 Oct 2023 00:10:28 +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; Sun, 1 Oct 2023 00:10:27 +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 v2 03/12] vsock: check for MSG_ZEROCOPY support on send Date: Sun, 1 Oct 2023 00:02:59 +0300 Message-ID: <20230930210308.2394919-4-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230930210308.2394919-1-avkrasnov@salutedevices.com> References: <20230930210308.2394919-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: 180254 [Sep 30 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: 535 535 da804c0ea8918f802fc60e7a20ba49783d957ba2, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;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;salutedevices.com:7.1.1, 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/30 19:49:00 #22015058 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Sat, 30 Sep 2023 14:10:50 -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 0365382beab6..f1da06aa6b00 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