Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3175197rdh; Thu, 28 Sep 2023 05:07:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+s5+V8EuSrEXvi12okcYCHaS4DXwNKrrn2Gu02QSEspP+UdbAYFUwjz5hqSZBFTccwSMg X-Received: by 2002:a05:6808:1520:b0:3ae:4cb2:fb43 with SMTP id u32-20020a056808152000b003ae4cb2fb43mr1244787oiw.21.1695902849319; Thu, 28 Sep 2023 05:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695902849; cv=none; d=google.com; s=arc-20160816; b=qvtiWoh0X6SVjZRbkPFZ0xVClGd5IXswM953QLMlGgpM6UsNwoHschM80c9oO/G/Tr 2PpY06l57oOvSqqxi8pBn4hxm+Pywi5I4SXKwo4SoZaJ7F3D1sVDmtzPd4bhCLvRQKC/ +bLUSL91MgfN6+UHlnIYo5Ilx+QXsAkXOPIODOXYlLTwvWBKSvRj9+2bF7WpM7xwrT1J z7Jb8iPcMI+eNC0VMKhJLx6rQrVRNVIHY/7JmOJvgGV4gWxxNSSznURRUY/D9bm2qc4g uo9E4+KAV5IxBw1iKZLJBk1lS0RgGnhn8XjeXiFBAQpz1Jn5YhkzTv9lNbDcBRIVLlhg qwYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=5ZfgeRRpxxzCC+gNpf+86BJgqXyg6OKxaxt423MyxVE=; fh=UzrhCmO8t1Tr3M5Pd0fRmywRAbM/SVsPwX26RUA+C4Y=; b=zfhl2o21/yOvOWPG4tTRriOUMKkb9yE5dwRpAN+WRyIsL2wgygjRcKkNswzz74g82G THrowNritlE3egxKBI/Tiy+xSVaPyuH50sVjWzkqqU1YLZ3NIUF4kthu0aMXsLz0sEzY fn71eyCY/fPE5foZYTTxgWKT3ogZ9M22J2+Gv6G342NV2rsKK4bnfXdYybBv/p0yrEyP p13BD9tG4LQBTXPt52DG+jpFPBNM3LuVXkpUWMtyvwqgL5SQm9Y/cM/54EviDXA/FCpI jxkd5SpmYdLoJ+4bxNaOQwV43Igwck/Ko2QodobXz82zkFB4ZvaSK/vX+tuiFQMAaiOJ DrPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b13-20020a63d80d000000b0056a36f9eb0esi6997482pgh.15.2023.09.28.05.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 05:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 43BFB8092EEB; Thu, 28 Sep 2023 04:56:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbjI1LyK (ORCPT + 99 others); Thu, 28 Sep 2023 07:54:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231982AbjI1LyJ (ORCPT ); Thu, 28 Sep 2023 07:54:09 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0AF5F5; Thu, 28 Sep 2023 04:54:07 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qlpah-0004NV-5c; Thu, 28 Sep 2023 13:53:59 +0200 Date: Thu, 28 Sep 2023 13:53:59 +0200 From: Florian Westphal To: David Wang <00107082@163.com> Cc: Daniel Xu , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH] uapi/netfilter: Change netfilter hook verdict code definition from macro to enum Message-ID: <20230928115359.GB27208@breakpoint.cc> References: <20230904130201.14632-1-00107082@163.com> <19d2362f.5c85.18a6647817b.Coremail.00107082@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19d2362f.5c85.18a6647817b.Coremail.00107082@163.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 28 Sep 2023 04:56:23 -0700 (PDT) David Wang <00107082@163.com> wrote: Hello, > At 2023-09-06 00:38:02, "Daniel Xu" wrote: > >Hi David, > > > >On Mon, Sep 04, 2023 at 09:02:02PM +0800, David Wang wrote: > > >> #include > >> > >> /* Responses from hook functions. */ > >> -#define NF_DROP 0 > >> -#define NF_ACCEPT 1 > >> -#define NF_STOLEN 2 > >> -#define NF_QUEUE 3 > >> -#define NF_REPEAT 4 > >> -#define NF_STOP 5 /* Deprecated, for userspace nf_queue compatibility. */ > >> -#define NF_MAX_VERDICT NF_STOP > >> +enum { > >> + NF_DROP = 0, > >> + NF_ACCEPT = 1, > >> + NF_STOLEN = 2, > >> + NF_QUEUE = 3, > >> + NF_REPEAT = 4, > >> + NF_STOP = 5, /* Deprecated, for userspace nf_queue compatibility. */ > >> + NF_MAX_VERDICT = NF_STOP, > >> +}; > > > >Switching from macro to enum works for almost all use cases, but not > >all. If someone if #ifdefing the symbols (which is plausible) this > >change would break them. > > > >I think I've seen some other networking code define both enums and > >macros. But it was a little ugly. Not sure if that is acceptable here or > >not. > > > >[...] > > > >Thanks, > >Daniel > > > Thanks for the review~ > I do not have a strong reasoning to deny the possibility of breaking unexpected usage of this macros, > > but I also agree that it is ugly to use both enum and macro at the same time. > > Kind of don't know how to proceed from here now... I was about to apply this as-is, but Pablo Neira would prefer to keep the defines as well. So, as a compromise, I would suggest to just *add* /* verdicts available to BPF are exported via vmlinux.h */ enum { NF_DROP = 0, NF_ACCEPT = 1, }; #define NF_DROP 0 ... This way BTF won't have the other verdicts, but ATM those cannot be used in BPF programs anyway. Would you mind making a new version of the patch? Otherwise I can mangle it locally here as needed.