Skip to content

Commit ddcfa71

Browse files
committed
netfilter: add nf_ingress_hook() helper function
Add helper function to check if this is an ingress hook. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent afd9024 commit ddcfa71

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

net/netfilter/core.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ nf_hook_entry_head(struct net *net, int pf, unsigned int hooknum,
311311
return NULL;
312312
}
313313

314+
static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
315+
{
316+
return pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS;
317+
}
318+
314319
static void nf_static_key_inc(const struct nf_hook_ops *reg, int pf)
315320
{
316321
#ifdef CONFIG_JUMP_LABEL
@@ -359,7 +364,7 @@ static int __nf_register_net_hook(struct net *net, int pf,
359364

360365
hooks_validate(new_hooks);
361366
#ifdef CONFIG_NETFILTER_INGRESS
362-
if (pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS)
367+
if (nf_ingress_hook(reg, pf))
363368
net_inc_ingress_queue();
364369
#endif
365370
nf_static_key_inc(reg, pf);
@@ -416,7 +421,7 @@ static void __nf_unregister_net_hook(struct net *net, int pf,
416421

417422
if (nf_remove_net_hook(p, reg)) {
418423
#ifdef CONFIG_NETFILTER_INGRESS
419-
if (pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS)
424+
if (nf_ingress_hook(reg, pf))
420425
net_dec_ingress_queue();
421426
#endif
422427
nf_static_key_dec(reg, pf);

0 commit comments

Comments
 (0)