Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1072803rdb; Sat, 7 Oct 2023 10:29:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/L6iOfNle4UrtKjSNvJxsjHQxvGiL+5ka2ajfGl8h5zEuBvQviGZ7DyUDU3IlcgQOM1j9 X-Received: by 2002:a05:6e02:156c:b0:351:19a4:8e67 with SMTP id k12-20020a056e02156c00b0035119a48e67mr14053895ilu.28.1696699753815; Sat, 07 Oct 2023 10:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696699753; cv=none; d=google.com; s=arc-20160816; b=UDSgcjLW2yowYHTFICp2Cq8msrhX83jckT9cIuIJsPiJ3cO+k7ojICgMHRSvQI64k+ LkTP+51c88Mt+6Qdm7v/pvDUCEzU8hkDJtOH5grWtypnta1WDny8xoLV9AjeL0dslCOJ Sgx10dxKWUTTw4ZLw20BV4LSYnnnaCuu5R3o2By1BwE/ciBeYckMcAvC0cTBD+g3hpCl durJaNtGh5qHtXvCEbhaccEHSMZsnzMo0nU3Or9eFNp8KQcZnnI+eqigL1YWVFwk1zq5 lXm/Y5SuOq4Fw2r0LCQpi4qfmnpsJ8EN2XpYL4Vb5tmodXxx6UKRwFt0fqva3eUngzK1 DiUQ== 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=Nw26GZvG7g7SVTOaWO4jdUv74J+L0oFfYXWJ4rCMb3E=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=NxdUyjmDn9hFhAwsxesynRfiMpd8W3rDWfN8RT3DZueCNKDE2nBYNtHSoyv9dgCQVu 1Ny0qtcNiSfca0eWquVmNIxTBiSNLgPyxfA1R3s8Ctgb5uvZUYMR6TNaL8z9d94tF7Nf jzcNLrtoub6F+QZbbU5YmgfygjsrACmbg3k408ocunkwbxiS7L7BPngNjSeCk8ILp0Rb Zv8s4zk8sfgtk0cW6D73sRrsh59AzLzyE7BbxJwh7gPmRL7myPAayx7nbx+kJCLYAib1 QtoB901MndM+xhsCbaKwSwjk/CuyIWSaOxkrgoZCKi0jS1uRizcFylW/syL9fqW0df5F G6og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=pPl7tRnn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l10-20020a63570a000000b00584a9290bd3si6068813pgb.522.2023.10.07.10.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 10:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=pPl7tRnn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 5031D80C038C; Sat, 7 Oct 2023 10:29:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344169AbjJGR27 (ORCPT + 99 others); Sat, 7 Oct 2023 13:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344079AbjJGR2v (ORCPT ); Sat, 7 Oct 2023 13:28:51 -0400 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 261999F; Sat, 7 Oct 2023 10:28:49 -0700 (PDT) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 1238F12000A; Sat, 7 Oct 2023 20:28:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 1238F12000A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1696699727; bh=Nw26GZvG7g7SVTOaWO4jdUv74J+L0oFfYXWJ4rCMb3E=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=pPl7tRnnHaF4zHdrOpNOWHl6IYJFI1xtqC7V6Tx3As1PNnoMiwfEg+LVxno7NQiVS cDW9ZK1T1F12TUihV9nVtIq/mdhEUvw0h92Itb8vurITkcxK819+x3hiskGCF+ckR3 6UgUjmF+b+3R2aaiRQ4dWtcmJlEVdvae92YH9H5aIIW2YNP7b40nj5KYRSFKui3gT1 wqTTbRayO73RZCtitC6hjN9IhnkrSGVjVTmqw9+etwYlA4ACGYbcR/M0Rkwm8/PQgs 7kjlVZOoFaa139bjL9WmELznyj7R6Z2xeCNyfLNP5u993eM8irI3iXHFSLgvwPaVia zTrbxau3Jbb4Q== 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, 7 Oct 2023 20:28:46 +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, 7 Oct 2023 20:28:46 +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 v3 03/12] vsock: check for MSG_ZEROCOPY support on send Date: Sat, 7 Oct 2023 20:21:30 +0300 Message-ID: <20231007172139.1338644-4-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20231007172139.1338644-1-avkrasnov@salutedevices.com> References: <20231007172139.1338644-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: 180453 [Oct 07 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 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}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:5.0.1,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/10/07 16:48:00 #22085983 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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 07 Oct 2023 10:29:12 -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 38486efd3d05..71108b1f0dfc 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