lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue,  1 Aug 2023 17:02:41 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: Pablo Neira Ayuso <pablo@...filter.org>,
	Jozsef Kadlecsik <kadlec@...filter.org>,
	Florian Westphal <fw@...len.de>
Cc: Arnd Bergmann <arnd@...db.de>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	Alexei Starovoitov <ast@...nel.org>,
	Daniel Xu <dxu@...uu.xyz>,
	netfilter-devel@...r.kernel.org,
	coreteam@...filter.org,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	bpf@...r.kernel.org
Subject: [PATCH] netfilter: bpf_link: avoid unused-function warning

From: Arnd Bergmann <arnd@...db.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@...db.de>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ