Message ID | 20230801150304.1980987-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2754089vqg; Tue, 1 Aug 2023 08:40:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlG86o8JCAL9ogf2n2hSg6ynzw7pVYaJtetfrVhqiczvoH1gwQjTvMDOWlVMIb2aCUHDuaCZ X-Received: by 2002:a17:902:82c3:b0:1bb:b86e:8d60 with SMTP id u3-20020a17090282c300b001bbb86e8d60mr12267846plz.46.1690904408136; Tue, 01 Aug 2023 08:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690904408; cv=none; d=google.com; s=arc-20160816; b=WStIPa1hNbNeKHtCuTirOcp2lGALQUk2PXCLG4gqg+cSXdzgOYS+tZEXf5mbOX2Jcg 07QMN6kgULzSvxWcqzmWkxGkLuZguFv/o/mu+wEqgsweW827UR/AAhC1Dpc5StmkIERF FOdK60lcHnwLRkbU12ZZogf1IaH+jO70nwrf7xRPMYTAM+BvoeRmmQ32/2WUTtL0qJkE Jm3+yfgxfrHQK8ShrqkuoD4cTPWMfTOTG5UF5zWBJAt6Jv8bjhGLhUzRzpbyUONdU24g cE/ur+gLNGhO2YzJZr0ztZf52yv88dGvPoX1T2onAK2TNs0/KO54qQZw7x/UVe4IWV4I MkFA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/hioL1u9DXU4Vq6ojeR99zGaLgie88FE03MCHI1yfRc=; fh=Hd4zUvCYfgm5NKjk2Z5ANX1MYCHTiP5VU/sMXaWieA8=; b=CrBsZuSWxHCxHrTsACz6UXsEhbrJsA1wfH5SGHNimBEussl50J2VQ+euoXQU09/ZNE fplE2KJ+ePEvFnZAmixomJZp70/f0/pqNggyu96FelCU0ogVWoHI3q1eyhkjZsaLMOgf D72sPqRh7QnbndQih0xSaO3h7vA3to65HpkVc+lwiaBrFeHO0E1NpBlXjMj8kynAUz/c RQuxbYSepV3XFSDMJmHUUi7c+D/wDZ9mS1gN049/BWcPuBDoqj3EBpt1JwOSPH9hp7Cr vvs8lnxxzNfufRxAd+ssxZaNWbkBtp8bHEibOWHsf1TqhRBEAHXpC24TZuzeWOcuoyFp 1YYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GbnjVZfs; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a170903228b00b001b8904eadb8si9381720plh.460.2023.08.01.08.39.53; Tue, 01 Aug 2023 08:40:08 -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=@kernel.org header.s=k20201202 header.b=GbnjVZfs; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234484AbjHAPDP (ORCPT <rfc822;maxi.paulin@gmail.com> + 99 others); Tue, 1 Aug 2023 11:03:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbjHAPDN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Aug 2023 11:03:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22A86E1; Tue, 1 Aug 2023 08:03:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7885E615E2; Tue, 1 Aug 2023 15:03:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA8CAC433C8; Tue, 1 Aug 2023 15:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690902190; bh=GiTJrXK18Hf7JC/NN63VbVrZqz6m5Mt87YaCCE2Kras=; h=From:To:Cc:Subject:Date:From; b=GbnjVZfsyD+ZTwfKhOPI7Eiy+YHOeoIx68o/1/CElqyruzLDcXSZpSbT6qKOChI7f 3P6aIc51SqA4j5oceeXwpAvX541FvpbFm6NqVARzDYQLAWbk50hT44l4s789wz2JFI FrfbFrj6mTS3bx4PNO8GHUkVovysLIKl9fVRCO02XzEskDrld0BNi4ZFBoZgonfm9N TFzS8kuReBYN0Dj+FJbIMpHLW2eFRwgKOUDnvVNjExhzX2Rm4s6M7pFFHQlvgqe9uX 4YqdgcQ3oTmjpa4A8PNY3UE52yObqfmh/CE4WjIekv69BsvZhQzaR8+wp82Hbsxji/ n5ApBF52jzYJw== From: Arnd Bergmann <arnd@kernel.org> To: Pablo Neira Ayuso <pablo@netfilter.org>, Jozsef Kadlecsik <kadlec@netfilter.org>, Florian Westphal <fw@strlen.de> Cc: Arnd Bergmann <arnd@arndb.de>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Xu <dxu@dxuuu.xyz>, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH] netfilter: bpf_link: avoid unused-function warning Date: Tue, 1 Aug 2023 17:02:41 +0200 Message-Id: <20230801150304.1980987-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773041780984011037 X-GMAIL-MSGID: 1773041780984011037 |
Series |
netfilter: bpf_link: avoid unused-function warning
|
|
Commit Message
Arnd Bergmann
Aug. 1, 2023, 3:02 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> The newly added function is unused in some random configurations: net/netfilter/nf_bpf_link.c:32:1: error: 'get_proto_defrag_hook' defined but not used [-Werror=unused-function] 32 | get_proto_defrag_hook(struct bpf_nf_link *link, | ^~~~~~~~~~~~~~~~~~~~~ Change the preprocessor conditionals to if() checks that the compiler can understand to avoid the warning. Fixes: 91721c2d02d3a ("netfilter: bpf: Support BPF_F_NETFILTER_IP_DEFRAG in netfilter link") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- net/netfilter/nf_bpf_link.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Comments
Hi Arnd, On Tue, Aug 01, 2023 at 05:02:41PM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The newly added function is unused in some random configurations: > > net/netfilter/nf_bpf_link.c:32:1: error: 'get_proto_defrag_hook' defined but not used [-Werror=unused-function] > 32 | get_proto_defrag_hook(struct bpf_nf_link *link, > | ^~~~~~~~~~~~~~~~~~~~~ > This was fixed in 81584c23f249 ("netfilter: bpf: Only define get_proto_defrag_hook() if necessary"). Thanks, Daniel
On Tue, Aug 1, 2023, at 17:20, Daniel Xu wrote: > Hi Arnd, > > On Tue, Aug 01, 2023 at 05:02:41PM +0200, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> The newly added function is unused in some random configurations: >> >> net/netfilter/nf_bpf_link.c:32:1: error: 'get_proto_defrag_hook' defined but not used [-Werror=unused-function] >> 32 | get_proto_defrag_hook(struct bpf_nf_link *link, >> | ^~~~~~~~~~~~~~~~~~~~~ >> > > This was fixed in 81584c23f249 ("netfilter: bpf: Only define > get_proto_defrag_hook() if necessary"). Ok, I guess this will be in tomorrow's linux-next then, right? Arnd
On Tue, Aug 01, 2023 at 07:27:33PM +0200, Arnd Bergmann wrote: > On Tue, Aug 1, 2023, at 17:20, Daniel Xu wrote: > > Hi Arnd, > > > > On Tue, Aug 01, 2023 at 05:02:41PM +0200, Arnd Bergmann wrote: > >> From: Arnd Bergmann <arnd@arndb.de> > >> > >> The newly added function is unused in some random configurations: > >> > >> net/netfilter/nf_bpf_link.c:32:1: error: 'get_proto_defrag_hook' defined but not used [-Werror=unused-function] > >> 32 | get_proto_defrag_hook(struct bpf_nf_link *link, > >> | ^~~~~~~~~~~~~~~~~~~~~ > >> > > > > This was fixed in 81584c23f249 ("netfilter: bpf: Only define > > get_proto_defrag_hook() if necessary"). > > Ok, I guess this will be in tomorrow's linux-next then, right? > > Arnd I'm not too familiar with the linux-next process, but chatgpt is telling me it should be. Thanks, Daniel
diff --git a/net/netfilter/nf_bpf_link.c b/net/netfilter/nf_bpf_link.c index 8fe594bbc7e24..6028fd4c1ab4c 100644 --- a/net/netfilter/nf_bpf_link.c +++ b/net/netfilter/nf_bpf_link.c @@ -74,24 +74,26 @@ static int bpf_nf_enable_defrag(struct bpf_nf_link *link) const struct nf_defrag_hook __maybe_unused *hook; switch (link->hook_ops.pf) { -#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) case NFPROTO_IPV4: + if (!IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)) + return -EAFNOSUPPORT; + hook = get_proto_defrag_hook(link, nf_defrag_v4_hook, "nf_defrag_ipv4"); if (IS_ERR(hook)) return PTR_ERR(hook); link->defrag_hook = hook; return 0; -#endif -#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) case NFPROTO_IPV6: + if (!IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)) + return -EAFNOSUPPORT; + hook = get_proto_defrag_hook(link, nf_defrag_v6_hook, "nf_defrag_ipv6"); if (IS_ERR(hook)) return PTR_ERR(hook); link->defrag_hook = hook; return 0; -#endif default: return -EAFNOSUPPORT; }