From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: [NETFILTER 04/22]: nf_conntrack: remove ugly hack in l4proto registration
Date: Wed, 14 Mar 2007 09:50:18 +0100 (MET) [thread overview]
Message-ID: <20070314085003.15282.53190.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20070314084946.15282.58609.sendpatchset@localhost.localdomain>
[NETFILTER]: nf_conntrack: remove ugly hack in l4proto registration
Remove ugly special-casing of nf_conntrack_l4proto_generic, all it
wants is its sysctl tables registered, so do that explicitly in an
init function and move the remaining protocol initialization and
cleanup code to nf_conntrack_proto.c as well.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 54043273620aa19f6b4334a56e04d90385b96d85
tree b1d212025330251bf39a38414de7488a2bf9bf30
parent 69b5f8d51819903743c648e829d247f0d156b889
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:24:09 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:27:11 +0100
include/net/netfilter/nf_conntrack_core.h | 3 +++
net/netfilter/nf_conntrack_core.c | 18 ++-------------
net/netfilter/nf_conntrack_proto.c | 34 ++++++++++++++++++++++-------
3 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index 85634e1..9fb9066 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -27,6 +27,9 @@ extern unsigned int nf_conntrack_in(int
extern int nf_conntrack_init(void);
extern void nf_conntrack_cleanup(void);
+extern int nf_conntrack_proto_init(void);
+extern void nf_conntrack_proto_fini(void);
+
struct nf_conntrack_l3proto;
extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf);
/* Like above, but you already have conntrack read lock. */
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 7694c51..9858bcb 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1152,14 +1152,7 @@ void nf_conntrack_cleanup(void)
free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc,
nf_conntrack_htable_size);
- nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_generic);
-
- /* free l3proto protocol tables */
- for (i = 0; i < PF_MAX; i++)
- if (nf_ct_protos[i]) {
- kfree(nf_ct_protos[i]);
- nf_ct_protos[i] = NULL;
- }
+ nf_conntrack_proto_fini();
}
static struct list_head *alloc_hashtable(int size, int *vmalloced)
@@ -1237,7 +1230,6 @@ module_param_call(hashsize, set_hashsize
int __init nf_conntrack_init(void)
{
- unsigned int i;
int ret;
/* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB
@@ -1279,16 +1271,10 @@ int __init nf_conntrack_init(void)
goto err_free_conntrack_slab;
}
- ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_generic);
+ ret = nf_conntrack_proto_init();
if (ret < 0)
goto out_free_expect_slab;
- /* Don't NEED lock here, but good form anyway. */
- write_lock_bh(&nf_conntrack_lock);
- for (i = 0; i < AF_MAX; i++)
- nf_ct_l3protos[i] = &nf_conntrack_l3proto_generic;
- write_unlock_bh(&nf_conntrack_lock);
-
/* For use by REJECT target */
rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach);
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index e2c4a58..0ca2f0b 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -294,9 +294,6 @@ int nf_conntrack_l4proto_register(struct
goto out;
}
- if (l4proto == &nf_conntrack_l4proto_generic)
- return nf_ct_l4proto_register_sysctl(l4proto);
-
mutex_lock(&nf_ct_proto_mutex);
retry:
if (nf_ct_protos[l4proto->l3proto]) {
@@ -353,11 +350,6 @@ void nf_conntrack_l4proto_unregister(str
{
BUG_ON(l4proto->l3proto >= PF_MAX);
- if (l4proto == &nf_conntrack_l4proto_generic) {
- nf_ct_l4proto_unregister_sysctl(l4proto);
- return;
- }
-
mutex_lock(&nf_ct_proto_mutex);
BUG_ON(nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto);
rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
@@ -371,3 +363,29 @@ void nf_conntrack_l4proto_unregister(str
nf_ct_iterate_cleanup(kill_l4proto, l4proto);
}
EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister);
+
+int nf_conntrack_proto_init(void)
+{
+ unsigned int i;
+ int err;
+
+ err = nf_ct_l4proto_register_sysctl(&nf_conntrack_l4proto_generic);
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < AF_MAX; i++)
+ rcu_assign_pointer(nf_ct_l3protos[i],
+ &nf_conntrack_l3proto_generic);
+ return 0;
+}
+
+void nf_conntrack_proto_fini(void)
+{
+ unsigned int i;
+
+ nf_ct_l4proto_unregister_sysctl(&nf_conntrack_l4proto_generic);
+
+ /* free l3proto protocol tables */
+ for (i = 0; i < PF_MAX; i++)
+ kfree(nf_ct_protos[i]);
+}
next prev parent reply other threads:[~2007-03-14 8:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 01/22]: x_tables: remove duplicate of xt_prefix Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 03/22]: nf_conntrack: switch protocol registration/unregistration to mutex Patrick McHardy
2007-03-14 8:50 ` Patrick McHardy [this message]
2007-03-14 8:50 ` [NETFILTER 05/22]: nf_conntrack: simplify protocol locking Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 06/22]: nf_conntrack: simplify l4 protocol array allocation Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 07/22]: nfnetlink: use mutex instead of semaphore Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 08/22]: nfnetlink: use netlink_run_queue() Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 09/22]: nf_conntrack: uninline notifier registration functions Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 10/22]: nfnetlink: remove early debugging messages from nfnetlink Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 11/22]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 12/22]: nfnetlink: remove unrequired check in nfnetlink_get_subsys Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 13/22]: nfnetlink: remove unused includes in nfnetlink.c Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 14/22]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol Patrick McHardy
2007-03-14 8:50 ` [JHASH 15/22]: Use const in jhash2 Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 16/22]: nf_conntrack: use jhash2 in __hash_conntrack Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 17/22]: conntrack: add __nf_copy() to copy members in skb Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 18/22]: conntrack: add nf_copy() to safely " Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 19/22]: tcp_conntrack: accept RST|PSH as valid Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 20/22]: tcp_conntrack: factorize out the PUSH flag Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 21/22]: ctnetlink: add support for internal tcp connection tracking flags handling Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 22/22]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute Patrick McHardy
2007-03-14 23:05 ` [NETFILTER 00/22]: Netfilter update for 2.6.22 David Miller
2007-03-14 23:14 ` Patrick McHardy
2007-03-14 23:52 ` David 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=20070314085003.15282.53190.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--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.