Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2586856rwd; Mon, 22 May 2023 00:48:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UUpY62mcDekWpFAHXEpDpDNxV9XppkDCrP/g1E4+17AkV6kFhARNuespf8gA2wH6cji9J X-Received: by 2002:a17:902:bc44:b0:1a6:83fa:b370 with SMTP id t4-20020a170902bc4400b001a683fab370mr8308295plz.2.1684741697064; Mon, 22 May 2023 00:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741697; cv=none; d=google.com; s=arc-20160816; b=p98vQGOnEsRff4hK8Phk0jI/a9QN8pX2q3Q8JQZxIL7/XKOLmcbRmSwo1jQP5p+GFo XxpsKNTjDHG82AUo7tZp++9LxQTvYISft1Fb0V/6ZKTbfUruWevK+rcDpBFBUq95Xi7R 278Hp0nCIDszU983E7TL1iuAr3mU6eYAU5ucxok2I79uw8PU91ylDvM2aZbsvK0dvWDB bvmZreRVTC8P6EvssAq5aG33d2IUS9QP9/n7SO+14dcfHG/WiQnjWMA7tq3l9z3PQXH9 CMqNChlHjkheUoTFjATWF7C8EClHgNoPcJ8h71HniTcz72vjrAvaaznZvBBMP79FWkNK 7xFA== 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; bh=rdOhUerakR8PkBSqvNyyaQ4KUq1usiTH07SMuCH4gko=; b=JU6J11xox6ddoo4uZmrhjKD1bIl/ZfdhGGpplWxrFPVFs/r7IeE54VF6Y82fOHGZFJ n6MWR7HzOlMKoFr8kI3xyA5CAJOqIWGC72Flv4WOzWt5ilju0lVzGA+CHoD6kxtCNbjf Ow5F/plMMCpl/VDzWTJlDvWczQUeX17FFjQ3c9c4T2qLM9ialqRFAC471Oc9QlNHZF/N Ky/RjCysJiOEybImY89uphOoJqN/VXtYOVzNAuwqXpJJPhAcsY8hzcPKosRlzVWjoO16 IVLtJaTzncwf71AXkpZGh2DHoAXeeDifYg1Z8KJpmzqCDKseU2J0jN1AxX6sc45u576z SjNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=afhzMxdk; 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 jc20-20020a17090325d400b001a1d76e7214si4226811plb.111.2023.05.22.00.48.05; Mon, 22 May 2023 00:48:17 -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=afhzMxdk; 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 S232671AbjEVHpl (ORCPT + 99 others); Mon, 22 May 2023 03:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232667AbjEVHox (ORCPT ); Mon, 22 May 2023 03:44:53 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7BBAC; Mon, 22 May 2023 00:44:52 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id E31415FD52; Mon, 22 May 2023 10:44:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1684741489; bh=rdOhUerakR8PkBSqvNyyaQ4KUq1usiTH07SMuCH4gko=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=afhzMxdkDtJUmBXzFtC7IxMqv6onxs+XsBptdqzYoOCTGQd2AyLHJl4NtJ27Z/esk jpeIdiSteqcvNwzWT+N6ULi3n/Hw4hH+s58W2XLjQP1YKLOuGZTHxPZlocXVyXW8vs FwCi7xD3YJ77rryf6ny+UYH1fz3SI+6UVJRbwm7Znv2QuqL1NU9yivRbIo8ws8+AWZ dUznSEF0JA4FMb0kt0BOqVU3YbUlqnXtkYRIKWPu4Pfnr98FRpKo4q+ZoMu9Fd79i5 eGJKT46r2bWgsqunoXymFfJY/F55XL495sPs77MYTx4p3xyFGVqost4qW9HSfKQPn/ dXnDXfADInQJg== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 22 May 2023 10:44:49 +0300 (MSK) 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 v3 08/17] vsock: check for MSG_ZEROCOPY support Date: Mon, 22 May 2023 10:39:41 +0300 Message-ID: <20230522073950.3574171-9-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> References: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/05/22 04:49:00 #21364689 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 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 b2da791d920b..dbfe82ee7769 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