diff options
author | Patrick McHardy <kaber@trash.net> | 2007-07-08 01:32:53 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-11 01:17:58 -0400 |
commit | e9c1b084e17ca225b6be731b819308ee0f9e04b8 (patch) | |
tree | f2cb1ee43873b5c6bc6eb54a9b450f0409afcf05 /net/netfilter | |
parent | cf6994c2b9812a9f02b99e89df411ffc5db9c779 (diff) |
[NETFILTER]: nf_conntrack: move expectaton related init code to nf_conntrack_expect.c
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 20 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_expect.c | 48 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_standalone.c | 11 |
3 files changed, 57 insertions, 22 deletions
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 793f12ff168b..ed44a09ae739 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -961,12 +961,12 @@ void nf_conntrack_cleanup(void) | |||
961 | rcu_assign_pointer(nf_ct_destroy, NULL); | 961 | rcu_assign_pointer(nf_ct_destroy, NULL); |
962 | 962 | ||
963 | kmem_cache_destroy(nf_conntrack_cachep); | 963 | kmem_cache_destroy(nf_conntrack_cachep); |
964 | kmem_cache_destroy(nf_ct_expect_cachep); | ||
965 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc, | 964 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc, |
966 | nf_conntrack_htable_size); | 965 | nf_conntrack_htable_size); |
967 | 966 | ||
968 | nf_conntrack_proto_fini(); | 967 | nf_conntrack_proto_fini(); |
969 | nf_conntrack_helper_fini(); | 968 | nf_conntrack_helper_fini(); |
969 | nf_conntrack_expect_fini(); | ||
970 | } | 970 | } |
971 | 971 | ||
972 | struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced) | 972 | struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced) |
@@ -1088,21 +1088,17 @@ int __init nf_conntrack_init(void) | |||
1088 | goto err_free_hash; | 1088 | goto err_free_hash; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | nf_ct_expect_cachep = kmem_cache_create("nf_conntrack_expect", | 1091 | ret = nf_conntrack_proto_init(); |
1092 | sizeof(struct nf_conntrack_expect), | 1092 | if (ret < 0) |
1093 | 0, 0, NULL, NULL); | ||
1094 | if (!nf_ct_expect_cachep) { | ||
1095 | printk(KERN_ERR "Unable to create nf_expect slab cache\n"); | ||
1096 | goto err_free_conntrack_slab; | 1093 | goto err_free_conntrack_slab; |
1097 | } | ||
1098 | 1094 | ||
1099 | ret = nf_conntrack_proto_init(); | 1095 | ret = nf_conntrack_expect_init(); |
1100 | if (ret < 0) | 1096 | if (ret < 0) |
1101 | goto out_free_expect_slab; | 1097 | goto out_fini_proto; |
1102 | 1098 | ||
1103 | ret = nf_conntrack_helper_init(); | 1099 | ret = nf_conntrack_helper_init(); |
1104 | if (ret < 0) | 1100 | if (ret < 0) |
1105 | goto out_fini_proto; | 1101 | goto out_fini_expect; |
1106 | 1102 | ||
1107 | /* For use by REJECT target */ | 1103 | /* For use by REJECT target */ |
1108 | rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach); | 1104 | rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach); |
@@ -1116,10 +1112,10 @@ int __init nf_conntrack_init(void) | |||
1116 | 1112 | ||
1117 | return ret; | 1113 | return ret; |
1118 | 1114 | ||
1115 | out_fini_expect: | ||
1116 | nf_conntrack_expect_fini(); | ||
1119 | out_fini_proto: | 1117 | out_fini_proto: |
1120 | nf_conntrack_proto_fini(); | 1118 | nf_conntrack_proto_fini(); |
1121 | out_free_expect_slab: | ||
1122 | kmem_cache_destroy(nf_ct_expect_cachep); | ||
1123 | err_free_conntrack_slab: | 1119 | err_free_conntrack_slab: |
1124 | kmem_cache_destroy(nf_conntrack_cachep); | 1120 | kmem_cache_destroy(nf_conntrack_cachep); |
1125 | err_free_hash: | 1121 | err_free_hash: |
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index 5c8cb0f243a2..ad197bccc7ca 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c | |||
@@ -29,7 +29,7 @@ | |||
29 | LIST_HEAD(nf_ct_expect_list); | 29 | LIST_HEAD(nf_ct_expect_list); |
30 | EXPORT_SYMBOL_GPL(nf_ct_expect_list); | 30 | EXPORT_SYMBOL_GPL(nf_ct_expect_list); |
31 | 31 | ||
32 | struct kmem_cache *nf_ct_expect_cachep __read_mostly; | 32 | static struct kmem_cache *nf_ct_expect_cachep __read_mostly; |
33 | static unsigned int nf_ct_expect_next_id; | 33 | static unsigned int nf_ct_expect_next_id; |
34 | 34 | ||
35 | /* nf_conntrack_expect helper functions */ | 35 | /* nf_conntrack_expect helper functions */ |
@@ -413,3 +413,49 @@ const struct file_operations exp_file_ops = { | |||
413 | .release = seq_release | 413 | .release = seq_release |
414 | }; | 414 | }; |
415 | #endif /* CONFIG_PROC_FS */ | 415 | #endif /* CONFIG_PROC_FS */ |
416 | |||
417 | static int __init exp_proc_init(void) | ||
418 | { | ||
419 | #ifdef CONFIG_PROC_FS | ||
420 | struct proc_dir_entry *proc; | ||
421 | |||
422 | proc = proc_net_fops_create("nf_conntrack_expect", 0440, &exp_file_ops); | ||
423 | if (!proc) | ||
424 | return -ENOMEM; | ||
425 | #endif /* CONFIG_PROC_FS */ | ||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static void exp_proc_remove(void) | ||
430 | { | ||
431 | #ifdef CONFIG_PROC_FS | ||
432 | proc_net_remove("nf_conntrack_expect"); | ||
433 | #endif /* CONFIG_PROC_FS */ | ||
434 | } | ||
435 | |||
436 | int __init nf_conntrack_expect_init(void) | ||
437 | { | ||
438 | int err; | ||
439 | |||
440 | nf_ct_expect_cachep = kmem_cache_create("nf_conntrack_expect", | ||
441 | sizeof(struct nf_conntrack_expect), | ||
442 | 0, 0, NULL, NULL); | ||
443 | if (!nf_ct_expect_cachep) | ||
444 | return -ENOMEM; | ||
445 | |||
446 | err = exp_proc_init(); | ||
447 | if (err < 0) | ||
448 | goto err1; | ||
449 | |||
450 | return 0; | ||
451 | |||
452 | err1: | ||
453 | kmem_cache_destroy(nf_ct_expect_cachep); | ||
454 | return err; | ||
455 | } | ||
456 | |||
457 | void nf_conntrack_expect_fini(void) | ||
458 | { | ||
459 | exp_proc_remove(); | ||
460 | kmem_cache_destroy(nf_ct_expect_cachep); | ||
461 | } | ||
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index fe536b20408b..098e7993932a 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
@@ -411,7 +411,7 @@ EXPORT_SYMBOL_GPL(nf_ct_log_invalid); | |||
411 | static int __init nf_conntrack_standalone_init(void) | 411 | static int __init nf_conntrack_standalone_init(void) |
412 | { | 412 | { |
413 | #ifdef CONFIG_PROC_FS | 413 | #ifdef CONFIG_PROC_FS |
414 | struct proc_dir_entry *proc, *proc_exp, *proc_stat; | 414 | struct proc_dir_entry *proc, *proc_stat; |
415 | #endif | 415 | #endif |
416 | int ret = 0; | 416 | int ret = 0; |
417 | 417 | ||
@@ -423,13 +423,9 @@ static int __init nf_conntrack_standalone_init(void) | |||
423 | proc = proc_net_fops_create("nf_conntrack", 0440, &ct_file_ops); | 423 | proc = proc_net_fops_create("nf_conntrack", 0440, &ct_file_ops); |
424 | if (!proc) goto cleanup_init; | 424 | if (!proc) goto cleanup_init; |
425 | 425 | ||
426 | proc_exp = proc_net_fops_create("nf_conntrack_expect", 0440, | ||
427 | &exp_file_ops); | ||
428 | if (!proc_exp) goto cleanup_proc; | ||
429 | |||
430 | proc_stat = create_proc_entry("nf_conntrack", S_IRUGO, proc_net_stat); | 426 | proc_stat = create_proc_entry("nf_conntrack", S_IRUGO, proc_net_stat); |
431 | if (!proc_stat) | 427 | if (!proc_stat) |
432 | goto cleanup_proc_exp; | 428 | goto cleanup_proc; |
433 | 429 | ||
434 | proc_stat->proc_fops = &ct_cpu_seq_fops; | 430 | proc_stat->proc_fops = &ct_cpu_seq_fops; |
435 | proc_stat->owner = THIS_MODULE; | 431 | proc_stat->owner = THIS_MODULE; |
@@ -449,8 +445,6 @@ static int __init nf_conntrack_standalone_init(void) | |||
449 | #endif | 445 | #endif |
450 | #ifdef CONFIG_PROC_FS | 446 | #ifdef CONFIG_PROC_FS |
451 | remove_proc_entry("nf_conntrack", proc_net_stat); | 447 | remove_proc_entry("nf_conntrack", proc_net_stat); |
452 | cleanup_proc_exp: | ||
453 | proc_net_remove("nf_conntrack_expect"); | ||
454 | cleanup_proc: | 448 | cleanup_proc: |
455 | proc_net_remove("nf_conntrack"); | 449 | proc_net_remove("nf_conntrack"); |
456 | cleanup_init: | 450 | cleanup_init: |
@@ -466,7 +460,6 @@ static void __exit nf_conntrack_standalone_fini(void) | |||
466 | #endif | 460 | #endif |
467 | #ifdef CONFIG_PROC_FS | 461 | #ifdef CONFIG_PROC_FS |
468 | remove_proc_entry("nf_conntrack", proc_net_stat); | 462 | remove_proc_entry("nf_conntrack", proc_net_stat); |
469 | proc_net_remove("nf_conntrack_expect"); | ||
470 | proc_net_remove("nf_conntrack"); | 463 | proc_net_remove("nf_conntrack"); |
471 | #endif /* CNFIG_PROC_FS */ | 464 | #endif /* CNFIG_PROC_FS */ |
472 | nf_conntrack_cleanup(); | 465 | nf_conntrack_cleanup(); |