Skip to content

Commit 61b590b

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ingress: don't use nf_hook_list_active
nf_hook_list_active() always returns true once at least one device has NF_INGRESS hook enabled. Thus, don't use this function. Instead, inverse the test and use the static key to elide list_empty test if no NF_INGRESS hooks are active. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 212cd08 commit 61b590b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

include/linux/netfilter_ingress.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
#include <linux/netdevice.h>
66

77
#ifdef CONFIG_NETFILTER_INGRESS
8-
static inline int nf_hook_ingress_active(struct sk_buff *skb)
8+
static inline bool nf_hook_ingress_active(const struct sk_buff *skb)
99
{
10-
return nf_hook_list_active(&skb->dev->nf_hooks_ingress,
11-
NFPROTO_NETDEV, NF_NETDEV_INGRESS);
10+
#ifdef HAVE_JUMP_LABEL
11+
if (!static_key_false(&nf_hooks_needed[NFPROTO_NETDEV][NF_NETDEV_INGRESS]))
12+
return false;
13+
#endif
14+
return !list_empty(&skb->dev->nf_hooks_ingress);
1215
}
1316

1417
static inline int nf_hook_ingress(struct sk_buff *skb)

0 commit comments

Comments
 (0)