All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Jones Desougi <jones@ingate.com>
Cc: netfilter-devel@lists.netfilter.org, davem@davemloft.net
Subject: Re: [NETFILTER 01/12]: Add helper functions for mass hook registration/unregistration
Date: Thu, 06 Apr 2006 18:10:02 +0200	[thread overview]
Message-ID: <44353D5A.2040301@trash.net> (raw)
In-Reply-To: <200604061542.k36FgRVL032443@usagi.ingate.se>

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

Jones Desougi wrote:
>>+err:
>>+	if (i > 0)
>>+		nf_unregister_hooks(reg, i - i);
> 
>                                          ^^^^^
> 
>>+	return err;
>>+}
> 
> 
> That should make it a nice noop. :-)
> Change the line to:
> +		nf_unregister_hooks(reg, i);

One typo and one thinko, good catch. I wonder why it didn't crash
in my tests, I did try unloading and reloading.

Corrected patch attached.

[-- Attachment #2: 01.diff --]
[-- Type: text/plain, Size: 2008 bytes --]

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

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 3bf0d209e539917efcc5286b8f1cab2856ebdd49
tree 4c5840cf32ee69cc6138534d24c4d43a23fad557
parent 32a976a8703b098e898a9a13f9ddcabbf654e7d8
author Patrick McHardy <kaber@trash.net> Thu, 06 Apr 2006 11:32:05 +0200
committer Patrick McHardy <kaber@trash.net> Thu, 06 Apr 2006 11:32:05 +0200

 include/linux/netfilter.h |    2 ++
 net/netfilter/core.c      |   28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 412e52c..5aa9316 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -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! */
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 1ceb1a6..5c7143e 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -63,6 +63,34 @@ void nf_unregister_hook(struct nf_hook_o
 }
 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,

  reply	other threads:[~2006-04-06 16:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-06 10:04 [NETFILTER 00/12]: Netfilter Update Patrick McHardy
2006-04-06 10:04 ` [NETFILTER 01/12]: Add helper functions for mass hook registration/unregistration Patrick McHardy
2006-04-06 15:42   ` Jones Desougi
2006-04-06 16:10     ` Patrick McHardy [this message]
2006-04-06 21:11       ` David S. Miller
2006-04-06 10:04 ` [NETFILTER 02/12]: Clean up hook registration Patrick McHardy
2006-04-06 21:12   ` David S. Miller
2006-04-06 10:04 ` [NETFILTER 03/12]: Fix section mismatch warnings Patrick McHardy
2006-04-06 21:13   ` David S. Miller
2006-04-06 22:42     ` Patrick McHardy
2006-04-06 10:04 ` [NETFILTER 04/12]: H.323 helper: move some function prototypes to ip_conntrack_h323.h Patrick McHardy
2006-04-06 21:13   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 05/12]: H.323 helper: change EXPORT_SYMBOL to EXPORT_SYMBOL_GPL Patrick McHardy
2006-04-06 21:14   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 06/12]: H.323 helper: make get_h245_addr() static Patrick McHardy
2006-04-06 21:15   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 07/12]: H.323 helper: add parameter 'default_rrq_ttl' Patrick McHardy
2006-04-06 21:15   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 08/12]: H.323 helper: update Changelog Patrick McHardy
2006-04-06 21:17   ` David S. Miller
2006-04-06 22:36     ` Patrick McHardy
2006-04-06 10:05 ` [NETFILTER 09/12]: Fix IP_NF_CONNTRACK_NETLINK dependency Patrick McHardy
2006-04-06 21:17   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 10/12]: Introduce infrastructure for address family specific operations Patrick McHardy
2006-04-06 21:18   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 11/12]: Add address family specific checksum helpers Patrick McHardy
2006-04-06 21:18   ` David S. Miller
2006-04-06 10:05 ` [NETFILTER 12/12]: Convert conntrack/ipt_REJECT to new checksumming functions Patrick McHardy
2006-04-06 21:19   ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44353D5A.2040301@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=jones@ingate.com \
    --cc=netfilter-devel@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.