From patchwork Mon May 22 07:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 97161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1274694vqo; Mon, 22 May 2023 00:51:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mNETswdRtNTq41/ySaBlDQf3kqYldX+hVaib43rMFpzEqCUFVulbQ3xcts5bVbm0n5ZAY X-Received: by 2002:a17:90b:3108:b0:247:ab52:d5d8 with SMTP id gc8-20020a17090b310800b00247ab52d5d8mr9265386pjb.26.1684741861842; Mon, 22 May 2023 00:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741861; cv=none; d=google.com; s=arc-20160816; b=hif8M2c+4JS3ocuVavFVIQzpp7cPL/6+FAJa+ft9JPWYWmcv1jG4zHHC05Zk/oKr3g UIBcCWESs4lgMztEEAku0e2AuhjK8fqYIFwn0fDymM1jFyBS4PleSjPV0rxK/f9s6nHl 1rpqMoZvzExeOruDb0Ql1em+c0Q1x3FgPqg8DfhsvhrlsZWrHqH7dN1J8KCT57s/RTwl w7I2fJS8kosADuFxCCzclknponNLdfxrjkuGpLKzJOgqmA3r/ftn4AXkzwZZOwNuEjoj 5fhDlChcf7U5XuGKsnDYbO106aOlNUCYQWOCLSqRQKeHIlNKbVye+MGg6+8fxGG17u6l IoGw== 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=Lcii1bQY+QJwpWB+RMSKu82Ek54JP6VHZpwuHhErzzg=; b=Tmx+acdUmWFR89zVjR9GGl5IWYWhTORGdrZMuI5kTfSOkm9qRXOORW6w/hmRO260UW 3E9oW73rNXQhCbmJ0JWnm5j/DmcxB/lN9S6hEsDxzOqHt2iRip18hPFkhOm8FXA1Qi0r nVhXHRJGKf4UnWdhgs+o6+SAy4NF+zOtPbNn8L+Vt/9IJG85Al+JIWavMumwwnuMnQ2H Ng8HUMy3eqJz1GDbhj0FpHkLWPhxrwWFM1v/WZpri/ODw5ON6ZwWreGOVC8qMuof/W4l Hf1gsRvCXSI5/ogf8KzUw+ehhV/C3d+e8YoIZbzWuSoiePplqzl+YfGg2XHgPYvZPQZR XN6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=i4G+Rrrt; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a17090aa89500b0023409b3983fsi4347113pjq.99.2023.05.22.00.50.46; Mon, 22 May 2023 00:51:01 -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=i4G+Rrrt; 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 S230460AbjEVHqG (ORCPT + 99 others); Mon, 22 May 2023 03:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232564AbjEVHo6 (ORCPT ); Mon, 22 May 2023 03:44:58 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 060F2B0; Mon, 22 May 2023 00:44:58 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id AD5295FD57; Mon, 22 May 2023 10:44:55 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1684741495; bh=Lcii1bQY+QJwpWB+RMSKu82Ek54JP6VHZpwuHhErzzg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=i4G+Rrrt8FjyGOQCUGkcbP/uLAllSTwiqRcxvCBd+AEUplaO/lK78vVC+rYo2n2dg 6CrJTQTnWmiBC2R5qp9XHHLBF+66RXNEtTJ+WpChSoU8ZgqL16OD0QCWv6ZKlxIePt moh9Dglj70wLhzMyeUKIhY1loWO0U2fhzJBFjkP4JhMl3rPqMuXJJS37WPyYlE1EzK P+RcV8M9PyZaFgqhMPwV2PQFBOI6tThFm819ly79cLBn3kQ6SsVUcoUqMihPtCR1V3 2v6/YdVS+bStijZuOPRP3+7zzCtyMNO1WtUH/5LdZdn9BZIYJnooy1wtYip/wJRbr1 dRbf559Dj2Qbw== 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:55 +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 13/17] net/sock: enable setting SO_ZEROCOPY for PF_VSOCK Date: Mon, 22 May 2023 10:39:46 +0300 Message-ID: <20230522073950.3574171-14-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766579882087085527?= X-GMAIL-MSGID: =?utf-8?q?1766579882087085527?= PF_VSOCK supports MSG_ZEROCOPY transmission, so SO_ZEROCOPY could be enabled. PF_VSOCK implementation is a little bit special comparing to PF_INET - MSG_ZEROCOPY support depends on transport layer of PF_VSOCK, but here we can't "ask" its transport, so setting of this option is always allowed, but if some transport doesn't support zerocopy tx, send callback of PF_VSOCK will return -EOPNOTSUPP. Signed-off-by: Arseniy Krasnov --- net/core/sock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/sock.c index 5440e67bcfe3..d558e541e6d7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1452,9 +1452,11 @@ int sk_setsockopt(struct sock *sk, int level, int optname, (sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) ret = -EOPNOTSUPP; - } else if (sk->sk_family != PF_RDS) { + } else if (sk->sk_family != PF_RDS && + sk->sk_family != PF_VSOCK) { ret = -EOPNOTSUPP; } + if (!ret) { if (val < 0 || val > 1) ret = -EINVAL;