Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp359959rdg; Tue, 10 Oct 2023 12:23:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGadir3sWTnhE0kk7jZ0+HTwg9ejQuIwQFDPTmXxGNChhi2vrQeQ0G6MkCNhd81KkKE5jSU X-Received: by 2002:a05:6a00:2295:b0:692:7527:c2d0 with SMTP id f21-20020a056a00229500b006927527c2d0mr20037378pfe.32.1696965812847; Tue, 10 Oct 2023 12:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696965812; cv=none; d=google.com; s=arc-20160816; b=reAkvmqHEfm9NlyteVsq6L+3dm8+EUcHNPpqmAXpojg+TNAtfW95ws5CQhQbpT8ERd szRHSKdH9HtR2mqsR7uxnlvYHcdiEbYvH4Thyrd2ogNfqseVGr3H/KxZGzea8wtgB0nZ xuGgRFgrZ6QO4u1XY6CrWTDqeCWsU8vQddVWM0buAMigmKN5YxaCiKu5aBTb98CgnCU2 sq0tnXGhKcO+YOb6nBOaZyIvP1yBlNx7GuRCC2XHS9Qbf0QXQLmsSs8keH99qsX/NC0F +0MAQcCohq7nzeBUaXoiRIqWIYi/nJETn0QlbOW86NJaxmpMcZPLes2olVq8Ye6usg+b b3Ew== 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=m0oYxd4cah7pWlx+kMA8j6QhCNk+63OO5Ug1sTZNRKDt0F79HNhtsnBxl7WiIuwWvB Mdw0TbtFRDCzNvsA6u3xbpnYaLj3Ez26jOKXSV0CEdV3LBD/owxlCJGbApZoqdaTA088 YVHMFoN44gWoIi+cLRixkWI7PPRKnECo9DoFcFgvwzGGlg5g/KOJMsXss5ayCAm2HCK4 hBaM+bGOTASsYunCWvci0i9+FVeAD42UxzpCcnwXOB8gT8Je/JUzBoS4doMk/9JPPHPl qQRlMF++Dtl9YEtU4T4VCCh6tE8lw+uz0p3kK/kXTViABOJigaPaz1D1PvZP7yEljHDj EFxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=OWoaVqOV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id c129-20020a633587000000b005775161c510si7768987pga.504.2023.10.10.12.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 12:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=OWoaVqOV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 0357080290FB; Tue, 10 Oct 2023 12:23:32 -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 S1344080AbjJJTXY (ORCPT + 99 others); Tue, 10 Oct 2023 15:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234388AbjJJTXA (ORCPT ); Tue, 10 Oct 2023 15:23:00 -0400 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C82E111; Tue, 10 Oct 2023 12:22:48 -0700 (PDT) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id CC114120005; Tue, 10 Oct 2023 22:22:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru CC114120005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1696965765; bh=Nw26GZvG7g7SVTOaWO4jdUv74J+L0oFfYXWJ4rCMb3E=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=OWoaVqOV7O13s4JLJkqXPop+ClecZBwfjeFRWJ4yPTOvPx1afsCE5vr/hYMYV5inA 7CjcNLVfGY6GcvIkDW9hgw/lx++qMSaeieFORWPSjxe+uwoXQqNtlWIH09CC2reLZN DhK1xPglWvWprSpZ1sX0eLz+9CVLScchPE+1FmrT2P5HK3fXlDItfofRTPsu8Uw+Yt TYL6KmVzsPf/EclYJeggHfG3EMub1n0N7aAeOXMJFNo5V3zVcdD6WTJgrQmxSrU3JD 79AiyM2rlGUKinsNpBbm2b429pcjn8NKcp9pHJgZqJwTa+RPmaYJh7ySVSIAOO+V50 xaEa+j31ufWow== 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; Tue, 10 Oct 2023 22:22:45 +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; Tue, 10 Oct 2023 22:22:45 +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 v4 03/12] vsock: check for MSG_ZEROCOPY support on send Date: Tue, 10 Oct 2023 22:15:15 +0300 Message-ID: <20231010191524.1694217-4-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20231010191524.1694217-1-avkrasnov@salutedevices.com> References: <20231010191524.1694217-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-m02.sberdevices.ru (172.16.192.103) 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: 180515 [Oct 10 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: 536 536 1ae19c7800f69da91432b5e67ed4a00b9ade0d03, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;p-i-exch-sc-m01.sberdevices.ru:5.0.1,7.1.1;127.0.0.199: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/10/10 16:15:00 #22148151 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,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 10 Oct 2023 12:23:32 -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