Commit afd9024c authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: add nf_static_key_{inc,dec}

Add helper functions increment and decrement the hook static keys.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 073b04e7
...@@ -311,6 +311,20 @@ nf_hook_entry_head(struct net *net, int pf, unsigned int hooknum, ...@@ -311,6 +311,20 @@ nf_hook_entry_head(struct net *net, int pf, unsigned int hooknum,
return NULL; return NULL;
} }
static void nf_static_key_inc(const struct nf_hook_ops *reg, int pf)
{
#ifdef CONFIG_JUMP_LABEL
static_key_slow_inc(&nf_hooks_needed[pf][reg->hooknum]);
#endif
}
static void nf_static_key_dec(const struct nf_hook_ops *reg, int pf)
{
#ifdef CONFIG_JUMP_LABEL
static_key_slow_dec(&nf_hooks_needed[pf][reg->hooknum]);
#endif
}
static int __nf_register_net_hook(struct net *net, int pf, static int __nf_register_net_hook(struct net *net, int pf,
const struct nf_hook_ops *reg) const struct nf_hook_ops *reg)
{ {
...@@ -348,9 +362,8 @@ static int __nf_register_net_hook(struct net *net, int pf, ...@@ -348,9 +362,8 @@ static int __nf_register_net_hook(struct net *net, int pf,
if (pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS) if (pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS)
net_inc_ingress_queue(); net_inc_ingress_queue();
#endif #endif
#ifdef CONFIG_JUMP_LABEL nf_static_key_inc(reg, pf);
static_key_slow_inc(&nf_hooks_needed[pf][reg->hooknum]);
#endif
BUG_ON(p == new_hooks); BUG_ON(p == new_hooks);
nf_hook_entries_free(p); nf_hook_entries_free(p);
return 0; return 0;
...@@ -406,9 +419,7 @@ static void __nf_unregister_net_hook(struct net *net, int pf, ...@@ -406,9 +419,7 @@ static void __nf_unregister_net_hook(struct net *net, int pf,
if (pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS) if (pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS)
net_dec_ingress_queue(); net_dec_ingress_queue();
#endif #endif
#ifdef CONFIG_JUMP_LABEL nf_static_key_dec(reg, pf);
static_key_slow_dec(&nf_hooks_needed[pf][reg->hooknum]);
#endif
} else { } else {
WARN_ONCE(1, "hook not found, pf %d num %d", pf, reg->hooknum); WARN_ONCE(1, "hook not found, pf %d num %d", pf, reg->hooknum);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment