Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5915600rwb; Tue, 1 Aug 2023 09:34:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2C4PXmOddHV9dLui+941WaTCXx6+q71Nd1aaNUpjbtsVYKgsvAF65o6jffMOI5srGT1NZ X-Received: by 2002:a05:6402:2054:b0:522:af5c:ad20 with SMTP id bc20-20020a056402205400b00522af5cad20mr3206045edb.1.1690907651389; Tue, 01 Aug 2023 09:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690907651; cv=none; d=google.com; s=arc-20160816; b=RW2+v7OJsjiTq+LpH3F2vxGHdSmwcWzemjmVsDK6HD3rFkn84Rnut8sLQa1jAgqj+L tSAgEJjMMfv2Xf/GGtUl5zwSKD58x4FrF7jkyACnRztmAofCElYQv2glzRbtB9wsOBMd UMMT1QxyP1QfW0Y9tozwjLSoAqt9g7+bJFCoNBSjfeJHFDO2k6EmV4zJgGPkZovrzp3r Q1JAlsIDPvaY+Iv3oL+ocalx5PFMCc5nGbXCMvBYCkB1KFk5Gjk2k4/VfNYPxVtkv84I s5pp8MAbw3iTzKsHyEsphVD4WQYb106NqD5sreak9slzQhpzQsAAG3tpEg5fOWg7OxYB pddw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a056402075100b00521d2fbcfa2si9233932edy.311.2023.08.01.09.32.53; Tue, 01 Aug 2023 09:34:11 -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 S234462AbjHAPDO (ORCPT + 99 others); Tue, 1 Aug 2023 11:03:14 -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 ); 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 To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal Cc: Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Xu , 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann 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 --- net/netfilter/nf_bpf_link.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; } -- 2.39.2