]> err.no Git - linux-2.6/commitdiff
[NETFILTER]: Add helper functions for mass hook registration/unregistration
authorPatrick McHardy <kaber@trash.net>
Thu, 6 Apr 2006 21:09:12 +0000 (14:09 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 10 Apr 2006 05:25:32 +0000 (22:25 -0700)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netfilter.h
net/netfilter/core.c

index 412e52ca9720c7d942948b904554cf6052a8ac16..5aa9316079234f77b897d34ae7d5e3febb7dfd36 100644 (file)
@@ -110,6 +110,8 @@ struct nf_info
 /* Function to register/unregister hook points. */
 int nf_register_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
    need to check permissions yourself! */
index 1ceb1a6c254b81083ec7f50408b70ebbad017454..645d6210557104d721ba75f3bfc7131520abc892 100644 (file)
@@ -63,6 +63,34 @@ void nf_unregister_hook(struct nf_hook_ops *reg)
 }
 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,
                        struct sk_buff **skb,
                        int hook,