@@ -311,6 +311,20 @@ nf_hook_entry_head(struct net *net, int pf, unsigned int hooknum,
311311 return NULL ;
312312}
313313
314+ static void nf_static_key_inc (const struct nf_hook_ops * reg , int pf )
315+ {
316+ #ifdef CONFIG_JUMP_LABEL
317+ static_key_slow_inc (& nf_hooks_needed [pf ][reg -> hooknum ]);
318+ #endif
319+ }
320+
321+ static void nf_static_key_dec (const struct nf_hook_ops * reg , int pf )
322+ {
323+ #ifdef CONFIG_JUMP_LABEL
324+ static_key_slow_dec (& nf_hooks_needed [pf ][reg -> hooknum ]);
325+ #endif
326+ }
327+
314328static int __nf_register_net_hook (struct net * net , int pf ,
315329 const struct nf_hook_ops * reg )
316330{
@@ -348,9 +362,8 @@ static int __nf_register_net_hook(struct net *net, int pf,
348362 if (pf == NFPROTO_NETDEV && reg -> hooknum == NF_NETDEV_INGRESS )
349363 net_inc_ingress_queue ();
350364#endif
351- #ifdef CONFIG_JUMP_LABEL
352- static_key_slow_inc (& nf_hooks_needed [pf ][reg -> hooknum ]);
353- #endif
365+ nf_static_key_inc (reg , pf );
366+
354367 BUG_ON (p == new_hooks );
355368 nf_hook_entries_free (p );
356369 return 0 ;
@@ -406,9 +419,7 @@ static void __nf_unregister_net_hook(struct net *net, int pf,
406419 if (pf == NFPROTO_NETDEV && reg -> hooknum == NF_NETDEV_INGRESS )
407420 net_dec_ingress_queue ();
408421#endif
409- #ifdef CONFIG_JUMP_LABEL
410- static_key_slow_dec (& nf_hooks_needed [pf ][reg -> hooknum ]);
411- #endif
422+ nf_static_key_dec (reg , pf );
412423 } else {
413424 WARN_ONCE (1 , "hook not found, pf %d num %d" , pf , reg -> hooknum );
414425 }
0 commit comments