From patchwork Sat Jun 3 20:49:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 102915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1841342vqr; Sat, 3 Jun 2023 13:57:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48XllRIJNsqYQu3EbOjN0yHPKSyzIL0aPHAbin1SDuNNDbMqRAVW91tNC/7+lcC/H+BcDO X-Received: by 2002:a05:6359:d08:b0:127:f952:6b9f with SMTP id gp8-20020a0563590d0800b00127f9526b9fmr4029362rwb.10.1685825865510; Sat, 03 Jun 2023 13:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685825865; cv=none; d=google.com; s=arc-20160816; b=PfGpR8Vbb157bK6YXyb2Qp8v4u1d2YOdR3GGeP75rltH4/aqtdj0KErQll4ny+4QOA q1uEIJctFMFQ/lL7ElhBZnyI4nqCTPMVqMPCT8LJCRxBvp/owNuz21hH+qbbbMfqYCQb ezwwwUT4inLg1j8aP2bZ1offrIJSBgwV0MTStY/DIa3v/+kY0e6X6SMJ9q2emY0DuMtL PpPouoeXzLpiG9rGs7DysCRqGUYUqCMdZZGxDScYh0JSOggCSIR1Ba0pRVdK1eYbwI1V U3JzZmaspHvEb6+GqvFkAkHq+Z/NqCBJRP5eyTI7uuSc49j/eXa0ovL2E0ANTYTlesMV 7eiA== 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=pGRKmptf8rnCAWvTVqyyVPDerQAXOfU4f4nc05VCIBKgLck/tF255/eTJJxFFCwoE1 NyQBuub7ig+TYgxkvjCEwlkYCgMIMLO318lPHhrkg8X/bivk8GrPJLBwHSTJvwMsrQzw cwEr3kfZHAe+AeO+gju7nmb6Et13EVAaE3NA994mQuFiOUQM7AP+cbBDzv+E+8Q2tVk9 W8U3YDCwUGT2XCvSQasKwudqOKDuO6ewz82VDqPFLSmPRCH30lVBwN7mM/wBeLU8G0CH 69KrV2CG5hLo8Q0a5WTMLZPS3fv/Igwi1YSEF6laNMxbcX/G2ugGu1iThm6qNoKZlEN5 fRFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=Jg52u5GE; 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 x18-20020a17090aca1200b002536c5eb7cfsi4983933pjt.58.2023.06.03.13.57.33; Sat, 03 Jun 2023 13:57:45 -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=Jg52u5GE; 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 S233642AbjFCUzl (ORCPT + 99 others); Sat, 3 Jun 2023 16:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232898AbjFCUzG (ORCPT ); Sat, 3 Jun 2023 16:55:06 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 736911B5; Sat, 3 Jun 2023 13:54:57 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 745FE5FD3D; Sat, 3 Jun 2023 23:54:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685825689; bh=Lcii1bQY+QJwpWB+RMSKu82Ek54JP6VHZpwuHhErzzg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Jg52u5GEQEg5YduLkopjTNW3BjaxbL328jtMgCcJGiSHEe1c5falJz5UAYOmb8btl 7f+eJRuv3Sl6eX4w42HLrim/lrm6Jmi0hABMEJK1ZpKpIVg/qPJCqgcdAmvq725dJ5 7lNxZpdDEl9jm+a2IhMiHWQjyjDQeFfoRpRS/lzABhlrc4QyEEjLuYQ5jxIfWlN2vv YrxGR+OA1+/8rmM2/Zd9ESP90sE4ScNs4TcpAkZzXGHwTA5TI6EeX5B9PWsp0w9Etf 1huTfS4oouFZtvh/6LZeIZP/GfZIc+FGrSPJ3X6ACxZKCNqpFeX6KhEzv9q8K/ie1v nSE+Wie9B5LZg== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sat, 3 Jun 2023 23:54: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 v4 13/17] net/sock: enable setting SO_ZEROCOPY for PF_VSOCK Date: Sat, 3 Jun 2023 23:49:35 +0300 Message-ID: <20230603204939.1598818-14-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> References: <20230603204939.1598818-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/06/03 16:55:00 #21417531 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,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767716542790421854?= X-GMAIL-MSGID: =?utf-8?q?1767716542790421854?= 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;