Commit 972d1cb1 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller
Browse files

[NETFILTER]: Add helper functions for mass hook registration/unregistration


Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 137dc023
...@@ -110,6 +110,8 @@ struct nf_info ...@@ -110,6 +110,8 @@ struct nf_info
/* Function to register/unregister hook points. */ /* Function to register/unregister hook points. */
int nf_register_hook(struct nf_hook_ops *reg); int nf_register_hook(struct nf_hook_ops *reg);
void nf_unregister_hook(struct nf_hook_ops *reg); void nf_unregister_hook(struct nf_hook_ops *reg);
int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n);
void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
/* Functions to register get/setsockopt ranges (non-inclusive). You /* Functions to register get/setsockopt ranges (non-inclusive). You
need to check permissions yourself! */ need to check permissions yourself! */
......
...@@ -63,6 +63,34 @@ void nf_unregister_hook(struct nf_hook_ops *reg) ...@@ -63,6 +63,34 @@ void nf_unregister_hook(struct nf_hook_ops *reg)
} }
EXPORT_SYMBOL(nf_unregister_hook); EXPORT_SYMBOL(nf_unregister_hook);
int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n)
{
unsigned int i;
int err = 0;
for (i = 0; i < n; i++) {
err = nf_register_hook(&reg[i]);
if (err)
goto err;
}
return err;
err:
if (i > 0)
nf_unregister_hooks(reg, i);
return err;
}
EXPORT_SYMBOL(nf_register_hooks);
void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n)
{
unsigned int i;
for (i = 0; i < n; i++)
nf_unregister_hook(&reg[i]);
}
EXPORT_SYMBOL(nf_unregister_hooks);
unsigned int nf_iterate(struct list_head *head, unsigned int nf_iterate(struct list_head *head,
struct sk_buff **skb, struct sk_buff **skb,
int hook, int hook,
......
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