diff options
author | Patrick McHardy <kaber@trash.net> | 2007-03-14 19:38:25 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:25:40 -0400 |
commit | ac5357ebac43e191003c2cd0722377dccfa01a84 (patch) | |
tree | a5a09bed344af07a68a95c2c4606a6c7eedc4748 /net | |
parent | b19caa0ca071dce76b0e81e957e7eb7c03d72cf5 (diff) |
[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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 18 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto.c | 34 |
2 files changed, 28 insertions, 24 deletions
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 7694c51f1251..9858bcb29aa0 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -1152,14 +1152,7 @@ void nf_conntrack_cleanup(void) | |||
1152 | free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc, | 1152 | free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc, |
1153 | nf_conntrack_htable_size); | 1153 | nf_conntrack_htable_size); |
1154 | 1154 | ||
1155 | nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_generic); | 1155 | nf_conntrack_proto_fini(); |
1156 | |||
1157 | /* free l3proto protocol tables */ | ||
1158 | for (i = 0; i < PF_MAX; i++) | ||
1159 | if (nf_ct_protos[i]) { | ||
1160 | kfree(nf_ct_protos[i]); | ||
1161 | nf_ct_protos[i] = NULL; | ||
1162 | } | ||
1163 | } | 1156 | } |
1164 | 1157 | ||
1165 | static struct list_head *alloc_hashtable(int size, int *vmalloced) | 1158 | static struct list_head *alloc_hashtable(int size, int *vmalloced) |
@@ -1237,7 +1230,6 @@ module_param_call(hashsize, set_hashsize, param_get_uint, | |||
1237 | 1230 | ||
1238 | int __init nf_conntrack_init(void) | 1231 | int __init nf_conntrack_init(void) |
1239 | { | 1232 | { |
1240 | unsigned int i; | ||
1241 | int ret; | 1233 | int ret; |
1242 | 1234 | ||
1243 | /* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB | 1235 | /* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB |
@@ -1279,16 +1271,10 @@ int __init nf_conntrack_init(void) | |||
1279 | goto err_free_conntrack_slab; | 1271 | goto err_free_conntrack_slab; |
1280 | } | 1272 | } |
1281 | 1273 | ||
1282 | ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_generic); | 1274 | ret = nf_conntrack_proto_init(); |
1283 | if (ret < 0) | 1275 | if (ret < 0) |
1284 | goto out_free_expect_slab; | 1276 | goto out_free_expect_slab; |
1285 | 1277 | ||
1286 | /* Don't NEED lock here, but good form anyway. */ | ||
1287 | write_lock_bh(&nf_conntrack_lock); | ||
1288 | for (i = 0; i < AF_MAX; i++) | ||
1289 | nf_ct_l3protos[i] = &nf_conntrack_l3proto_generic; | ||
1290 | write_unlock_bh(&nf_conntrack_lock); | ||
1291 | |||
1292 | /* For use by REJECT target */ | 1278 | /* For use by REJECT target */ |
1293 | rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach); | 1279 | rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach); |
1294 | 1280 | ||
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index e2c4a58603a8..0ca2f0ba7c76 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 nf_conntrack_l4proto *l4proto) | |||
294 | goto out; | 294 | goto out; |
295 | } | 295 | } |
296 | 296 | ||
297 | if (l4proto == &nf_conntrack_l4proto_generic) | ||
298 | return nf_ct_l4proto_register_sysctl(l4proto); | ||
299 | |||
300 | mutex_lock(&nf_ct_proto_mutex); | 297 | mutex_lock(&nf_ct_proto_mutex); |
301 | retry: | 298 | retry: |
302 | if (nf_ct_protos[l4proto->l3proto]) { | 299 | if (nf_ct_protos[l4proto->l3proto]) { |
@@ -353,11 +350,6 @@ void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *l4proto) | |||
353 | { | 350 | { |
354 | BUG_ON(l4proto->l3proto >= PF_MAX); | 351 | BUG_ON(l4proto->l3proto >= PF_MAX); |
355 | 352 | ||
356 | if (l4proto == &nf_conntrack_l4proto_generic) { | ||
357 | nf_ct_l4proto_unregister_sysctl(l4proto); | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | mutex_lock(&nf_ct_proto_mutex); | 353 | mutex_lock(&nf_ct_proto_mutex); |
362 | BUG_ON(nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto); | 354 | BUG_ON(nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto); |
363 | rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], | 355 | rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], |
@@ -371,3 +363,29 @@ void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *l4proto) | |||
371 | nf_ct_iterate_cleanup(kill_l4proto, l4proto); | 363 | nf_ct_iterate_cleanup(kill_l4proto, l4proto); |
372 | } | 364 | } |
373 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister); | 365 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister); |
366 | |||
367 | int nf_conntrack_proto_init(void) | ||
368 | { | ||
369 | unsigned int i; | ||
370 | int err; | ||
371 | |||
372 | err = nf_ct_l4proto_register_sysctl(&nf_conntrack_l4proto_generic); | ||
373 | if (err < 0) | ||
374 | return err; | ||
375 | |||
376 | for (i = 0; i < AF_MAX; i++) | ||
377 | rcu_assign_pointer(nf_ct_l3protos[i], | ||
378 | &nf_conntrack_l3proto_generic); | ||
379 | return 0; | ||
380 | } | ||
381 | |||
382 | void nf_conntrack_proto_fini(void) | ||
383 | { | ||
384 | unsigned int i; | ||
385 | |||
386 | nf_ct_l4proto_unregister_sysctl(&nf_conntrack_l4proto_generic); | ||
387 | |||
388 | /* free l3proto protocol tables */ | ||
389 | for (i = 0; i < PF_MAX; i++) | ||
390 | kfree(nf_ct_protos[i]); | ||
391 | } | ||