Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4665341iob; Sun, 8 May 2022 21:10:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBvtU6ec7qCnHPLKPKndO9pisZffL32KRLzt60ybqX4SyLXuJjEN4bpASbUMqet6phmBO6 X-Received: by 2002:a17:902:cec9:b0:15e:cbf4:c246 with SMTP id d9-20020a170902cec900b0015ecbf4c246mr14979129plg.1.1652069414386; Sun, 08 May 2022 21:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652069414; cv=none; d=google.com; s=arc-20160816; b=etEOLvFHNs7yHSBuZkd6p9EemFhKvwpsLICl19Ne0TpIE8uK25nVN9Yg936Or8Ke8H eVADXOTDDKmUJtbEgNnbPpP5x5bPjTNwpfJxLeI1QtdpQRtwQIjfOB0nZeznLzJqpyfW wXfhWXbL9udOPHov+7XvVZEmGTjvKvPyKJt7j6NLbEcmU3LFyaBu4MUW7fDzhQOdaU7E bAx3nzoZ3AHVZgchFbyezt3LDxCaO5cTwnN+hXcMvUSD6sJbl4A+FklP8u2U0SYptTwC OQve5WAOn4KIAYXZ5yxDX9/aKWFgUnoAhjwFIL2Jc5TTAOYg3WocR2PA8xz/XJWoC1JS y+Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=hz8cN3gu7AH5J5jQIlr6+13kmwxut9ycO89aQGaXRjo=; b=W8wQJ+Rx/pFK2eJHQY0NuuljKvikZtI6WbvCI/IdqmHjgC8K53r+x6lsNKEqYfV2tb nAW7+EjHA0yGu0JeU8WYbsk0wUOT5CrC27DTzF+ZiZ0iVYs6biyLmF0OErumPZg8HCb6 loAEmLgvYpwFkeS3ekX/9OldPghKRFLAa/+Ao5OQUwPIAJQ6jdiMvBfCWz0eSJgORqvh +kbBWfL+Xg+1WhRyWLe2FF9CdIzel9FLo9W6NwOwrWIGIoeiMPrAq/QsRaIiOUNNRgnQ Pu/zDu8V6W6XxV2naNG1wunjaQd1XF3ej2Jezj7Cg/yBsOBMR/ZnYxgh4JKPh93/JptL GlKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="gGm/eOSL"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m3-20020a654c83000000b003c66b6ca640si8531293pgt.311.2022.05.08.21.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:10:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="gGm/eOSL"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68167954A0; Sun, 8 May 2022 21:08:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380642AbiEEObS (ORCPT + 99 others); Thu, 5 May 2022 10:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiEEObR (ORCPT ); Thu, 5 May 2022 10:31:17 -0400 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.129.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 06941AE46 for ; Thu, 5 May 2022 07:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651760857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hz8cN3gu7AH5J5jQIlr6+13kmwxut9ycO89aQGaXRjo=; b=gGm/eOSLp7Gr5275ZDi6X+l0di8QO+vvX9DFTdCCoTMe8dqlt0SpB6BCoyaBNmc4JZLU2G YgYm0EiLUSHLx4m63XqWTuKN0rx6O//xuWZxIcCI2ENjvMEiy0Ny6wYv/DvKUQd96KEuxU 0rtDIICTfh7cdY0BCobNsgqbb08vilQ= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-111-Y_1Qq3JJMj6nqwpw2ohXEA-1; Thu, 05 May 2022 10:27:36 -0400 X-MC-Unique: Y_1Qq3JJMj6nqwpw2ohXEA-1 Received: by mail-ed1-f70.google.com with SMTP id s24-20020a05640217d800b00425e19e7deaso2414321edy.3 for ; Thu, 05 May 2022 07:27:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=hz8cN3gu7AH5J5jQIlr6+13kmwxut9ycO89aQGaXRjo=; b=Z7G05LmAXd9mP8AKtVLOJQ9/mlE3pg9UrIZOyWvred+aPbTAQHoT9XbdHofNBkvmqS pngHHgH9aybHGSr/AlB5ykWrVSV8pCtQ+/LIZL4jrerrNu3DiRWwDp1N/fXGzrnUCCJg eb8Tj5YQ2UNRypyMp+5gLwPOZhE7CSRd+L/FECczP1qYxtw9nlFPrUpUw7+pl7xzXRnM o7hnSiwHj+6pnDEEmhzD4/s/MBBRDc0gfZDre0zpxtdvG7qAezHecat1i42bPtZSxUGl M/3G4S2CGb5r57ESiaAyfMtu9Y+46kTtZmlPiPNyqFU4bx/ocQ1F7vm6j+kBTLOKk3dA k48Q== X-Gm-Message-State: AOAM53284q+qHik7JQgvYY93U0dO1tzA9atEKFH3Y8c885PU/pyLTi40 Kl0jqN3S+6k+CTHws+qF08yzwX+wDVEBo42dxtAY3SXUDbdsOzAlEG44L7z0nQm+SwsOPHjRRXA 6T2cemT9J1JHpTnm1VA24i89B X-Received: by 2002:a17:907:6294:b0:6e1:ea4:74a3 with SMTP id nd20-20020a170907629400b006e10ea474a3mr26223923ejc.168.1651760854354; Thu, 05 May 2022 07:27:34 -0700 (PDT) X-Received: by 2002:a17:907:6294:b0:6e1:ea4:74a3 with SMTP id nd20-20020a170907629400b006e10ea474a3mr26223834ejc.168.1651760853491; Thu, 05 May 2022 07:27:33 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id k20-20020a170906971400b006f3ef214dc9sm805808ejx.47.2022.05.05.07.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 07:27:32 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id B4CF734D4E7; Thu, 5 May 2022 16:27:31 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: shaozhengchao , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bpf@vger.kernel.org" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" Cc: "ast@kernel.org" , "daniel@iogearbox.net" , "hawk@kernel.org" , "john.fastabend@gmail.com" , "andrii@kernel.org" , "kafai@fb.com" , "songliubraving@fb.com" , "yhs@fb.com" , "kpsingh@kernel.org" , "bigeasy@linutronix.de" , "imagedong@tencent.com" , "petrm@nvidia.com" , "memxor@gmail.com" , "arnd@arndb.de" , "weiyongjun (A)" , yuehaibing Subject: Re: =?utf-8?B?562U5aSNOg==?= [PATCH bpf-next] bpf/xdp: Can't detach BPF XDP prog if not exist In-Reply-To: <594b5198d54c4c729728c20d167d9c2d@huawei.com> References: <20220504035207.98221-1-shaozhengchao@huawei.com> <875ymlwnmy.fsf@toke.dk> <594b5198d54c4c729728c20d167d9c2d@huawei.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Thu, 05 May 2022 16:27:31 +0200 Message-ID: <87tua43vho.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 shaozhengchao writes: > Thank you for your reply. I wiil change sample application firstly. > But if kernel does nothing and return 0, maybe user will think setup > is OK, actually It failed. Is this acceptable? Your patch was about detach; what has that got to do with "setup is OK"? As for detaching, it's possible to write the application in a way that it will always get a consistent result. There are basically two cases when using netlink to detach an XDP program (bpf_link has its own semantics, so setting that aside here): 1. The application just wants to turn off XDP entirely on the interface (e.g., 'ip link set dev XXX xdp off'). In this case you just send a RTM_SETLINK message with an IFLA_XDP_FD of -1, and if you don't get an error you can be sure that there is now no XDP program attached. Whether this was because there was already no program attached, or because you just detached it doesn't really matter in this case, since you're doing an unspecific detach anyway. 2. You attached a program earlier, and now you want to detach that (and only that) program. Or, equivalently, you queried the link and want to detach the program you know is attached there. In this case you send an RTM_SETLINK message with an IFLA_XDP_FD of -1 and an IFLA_XDP_EXPECTED_FD referring to the existing program. In this case you will get an error if that specific program is not in fact attached, whether because it was detached or swapped out in the meantime. I don't see how case 1. is improved by returning ENOENT if there is no program attached; if you care about detaching a specific program you'd use case 2. anyway, and if you just want to check if a program is attached, you'd do an RTM_GETLINK. -Toke