Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3963290pxm; Tue, 1 Mar 2022 08:35:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvDOh72q9vFGX0ielNOYTnxvPHDOQolMK+atZSmgrKYxnEVxFpG6WO1VEP3IP37yBVYA3u X-Received: by 2002:a05:6a00:13aa:b0:4f1:1e5f:1c39 with SMTP id t42-20020a056a0013aa00b004f11e5f1c39mr28186744pfg.24.1646152559166; Tue, 01 Mar 2022 08:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646152559; cv=none; d=google.com; s=arc-20160816; b=rV+tIvWEkwkxRW76+guF+TNy30Pog8U0x1bTBLl6a9/eYLvNkI6g/RZI1HDcRIOlPu oYmrFBVtDZM4m2cP9JFVzqTv8MRfOHWBIx3r1U+2okLziS91MAmQv+xH0bo0oT2gNPTo dobuF9W2sFnI/qzDe6FSU+CTCFjxJ49gpg8AzLLwzUKfzrUqP6MMOepV4yKLQc/JvNGh McExfzTbx0EENtLfwe7E/5rA5srxWeIXbvy3ogajXRyi+dYczgP/bHkjXVbX6SOOugy8 vVmr9H841WHnAMdodRB22A0SUoaMAFt6wBiqCUDB/22cgs44LXxdltalpfsgTS2Tz3wj VygA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=M9/JEVnJvWyMcgf/Ei/JoJH8yPdXLZfORGjH2dloKRc=; b=x5EPiYu36p3wX4bi+AErUcssm/llheBmtRzovMH3ANxKDRvrme7Ag/aK24F2CPBOvb zftrjZlIaRrGrVDf34lJ1JbRr4wkML4ykVJbrckldbxMW/VmBPqCXkZBK6DKwKZe17U0 Qq2hr52NpyGFe1PstrDYaL2alxb+zuLsiyb948KJvhtXn5gMQmiu2o0hsWnd3SBcmSQ2 swPML5SiNTW6e8oVfjf68Xn2FoH4cgbFmR7vmtqgOP1hE57pC7Of6FaAJnkCCEqyjVi7 k8rkbGPtKBlvDxKnhWslfNjLl1qmoTNyvDb7Kv0RaSKvddTay6uUaF+C3PgaeUPYiIrY LkRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NlFrEJ1d; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a634f4c000000b0034eb5da7d67si12918857pgl.549.2022.03.01.08.35.40; Tue, 01 Mar 2022 08:35:59 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=NlFrEJ1d; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235653AbiCAPXH (ORCPT + 99 others); Tue, 1 Mar 2022 10:23:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235573AbiCAPXB (ORCPT ); Tue, 1 Mar 2022 10:23:01 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 337C3A8ED0 for ; Tue, 1 Mar 2022 07:22:20 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id bm39so13197684qkb.0 for ; Tue, 01 Mar 2022 07:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=M9/JEVnJvWyMcgf/Ei/JoJH8yPdXLZfORGjH2dloKRc=; b=NlFrEJ1dEuJ0AcQqwJ+8p+coXsH+g3uANH4LRahRbKynTBadd3VdN0RcXP1ghojOle tE9Kgv2zAd0yYCpKyuQBM9lG2eFfhP+HbxVgiFno05OM9JQHe3bW+IADYKvg1QsCGqnq 4gj8JuYK0VDWuZe8RkvlX4QR0DpiNyS0VRylU+1Clo+MORzKL/COJiwD8s8cXmsPg5dT qPPcUjSJJ2fthuorYka64tXuJeAw5WOx32b51sPBPc6kfsrz+vEVoTsKB5QMpcNqdyxJ R0u3xVoagGg2ymjsEk7GjKgEOScHogR7qJVS6Q1P4QLWQirnJv33b2/im9mAV062Hz5K IYSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=M9/JEVnJvWyMcgf/Ei/JoJH8yPdXLZfORGjH2dloKRc=; b=flDT8iF8LsSrAocVCyAc+Aidh72BVccOma/wUhnGQMEWHRfz8c5o2oZiO8rH7E0B91 q+XErcoxbTrhM6KDrlO605NFSuXLivc9ym1UWjFL1J52CeLWBSrE22XjwvZOvx04YPNg FYs5aoES0moJRqg7wzf+GD1FLHDuLI7SqAAxMJU0631k3SM+WafXE6Y/SeGmbx1Oo2U9 0CMK5SZkvprELz58Yr+H9xC0gANVFi+06GIbYvTpaQdz6d9nLjnJC4x3MsbweNfANSIX bZ/94tbdKw5gcXzrTKinUP5JOUBzTbwUTrNzjr4RYe/wFCn16s2JA7iZu/zTmSuKGXxY xTtA== X-Gm-Message-State: AOAM532nrMB2ZKqhcKaEGlYurT4yHUM8fA0QHOoamhgA2Hm7JrTX+MJc 3p3SRZHvXSd0eRpOWwStwrW1hDyKtcI= X-Received: by 2002:a37:b95:0:b0:5f1:91da:6aa9 with SMTP id 143-20020a370b95000000b005f191da6aa9mr13627341qkl.760.1646148139358; Tue, 01 Mar 2022 07:22:19 -0800 (PST) Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com. [209.85.128.177]) by smtp.gmail.com with ESMTPSA id j10-20020ac85f8a000000b002dde6288fa7sm9551633qta.83.2022.03.01.07.22.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 07:22:18 -0800 (PST) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-2d07ae0b1c0so148407417b3.2 for ; Tue, 01 Mar 2022 07:22:18 -0800 (PST) X-Received: by 2002:a81:6603:0:b0:2d6:d166:8c31 with SMTP id a3-20020a816603000000b002d6d1668c31mr24869128ywc.351.1646148137765; Tue, 01 Mar 2022 07:22:17 -0800 (PST) MIME-Version: 1.0 References: <20220301144453.snstwdjy3kmpi4zf@begin> <20220301150028.romzjw2b4aczl7kf@begin> <20220301152017.jkx7amcbfqkoojin@begin> In-Reply-To: <20220301152017.jkx7amcbfqkoojin@begin> From: Willem de Bruijn Date: Tue, 1 Mar 2022 10:21:41 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] SO_ZEROCOPY should rather return -ENOPROTOOPT To: Samuel Thibault , Willem de Bruijn , willemb@google.com, davem@davemloft.net, kuba@kernel.org, linux-kernel@vger.kernel.org, Network Development Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Tue, Mar 1, 2022 at 10:20 AM Samuel Thibault wrote: > > Willem de Bruijn, le mar. 01 mars 2022 10:14:18 -0500, a ecrit: > > On Tue, Mar 1, 2022 at 10:00 AM Samuel Thibault > > wrote: > > > > > > Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit: > > > > On Tue, Mar 1, 2022 at 9:44 AM Samuel Thibault wrote: > > > > > > > > > > ENOTSUPP is documented as "should never be seen by user programs", and > > > > > is not exposed in , so applications cannot safely check against > > > > > it. We should rather return the well-known -ENOPROTOOPT. > > > > > > > > > > Signed-off-by: Samuel Thibault > > > > > > > > > > diff --git a/net/core/sock.c b/net/core/sock.c > > > > > index 4ff806d71921..6e5b84194d56 100644 > > > > > --- a/net/core/sock.c > > > > > +++ b/net/core/sock.c > > > > > @@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, > > > > > if (!(sk_is_tcp(sk) || > > > > > (sk->sk_type == SOCK_DGRAM && > > > > > sk->sk_protocol == IPPROTO_UDP))) > > > > > - ret = -ENOTSUPP; > > > > > + ret = -ENOPROTOOPT; > > > > > } else if (sk->sk_family != PF_RDS) { > > > > > - ret = -ENOTSUPP; > > > > > + ret = -ENOPROTOOPT; > > > > > } > > > > > if (!ret) { > > > > > if (val < 0 || val > 1) > > > > > > > > That should have been a public error code. Perhaps rather EOPNOTSUPP. > > > > > > > > The problem with a change now is that it will confuse existing > > > > applications that check for -524 (ENOTSUPP). > > > > > > They were not supposed to hardcord -524... > > > > > > Actually, they already had to check against EOPNOTSUPP to support older > > > kernels, so EOPNOTSUPP is not supposed to pose a problem. > > > > Which older kernels returned EOPNOTSUPP on SO_ZEROCOPY? > > Sorry, bad copy/paste, I meant ENOPROTOOPT. Same point though, right? These are not legacy concerns, but specific to applications written to SO_ZEROCOPY. I expect that most will just ignore the exact error code and will work with either.