diff options
| author | Patrick McHardy <kaber@trash.net> | 2007-07-08 01:30:08 -0400 |
|---|---|---|
| committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-11 01:17:42 -0400 |
| commit | ac565e5fc104fe1842a87f2206fcfb7b6dda903d (patch) | |
| tree | 6d5241eb5b8061cfd2019977dcd619c2797a06ab | |
| parent | 330f7db5e578e1e298ba3a41748e5ea333a64a2b (diff) | |
[NETFILTER]: nf_conntrack: export hash allocation/destruction functions
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/net/netfilter/nf_conntrack.h | 4 | ||||
| -rw-r--r-- | net/netfilter/nf_conntrack_core.c | 23 |
2 files changed, 16 insertions, 11 deletions
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index ef4a403878a3..8f2cbb965f3d 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
| @@ -172,6 +172,10 @@ static inline void nf_ct_put(struct nf_conn *ct) | |||
| 172 | extern int nf_ct_l3proto_try_module_get(unsigned short l3proto); | 172 | extern int nf_ct_l3proto_try_module_get(unsigned short l3proto); |
| 173 | extern void nf_ct_l3proto_module_put(unsigned short l3proto); | 173 | extern void nf_ct_l3proto_module_put(unsigned short l3proto); |
| 174 | 174 | ||
| 175 | extern struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced); | ||
| 176 | extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, | ||
| 177 | int size); | ||
| 178 | |||
| 175 | extern struct nf_conntrack_tuple_hash * | 179 | extern struct nf_conntrack_tuple_hash * |
| 176 | __nf_conntrack_find(const struct nf_conntrack_tuple *tuple, | 180 | __nf_conntrack_find(const struct nf_conntrack_tuple *tuple, |
| 177 | const struct nf_conn *ignored_conntrack); | 181 | const struct nf_conn *ignored_conntrack); |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 8ed761cc0819..f4c3039728dc 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
| @@ -920,8 +920,7 @@ static int kill_all(struct nf_conn *i, void *data) | |||
| 920 | return 1; | 920 | return 1; |
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | static void free_conntrack_hash(struct hlist_head *hash, int vmalloced, | 923 | void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, int size) |
| 924 | int size) | ||
| 925 | { | 924 | { |
| 926 | if (vmalloced) | 925 | if (vmalloced) |
| 927 | vfree(hash); | 926 | vfree(hash); |
| @@ -929,6 +928,7 @@ static void free_conntrack_hash(struct hlist_head *hash, int vmalloced, | |||
| 929 | free_pages((unsigned long)hash, | 928 | free_pages((unsigned long)hash, |
| 930 | get_order(sizeof(struct hlist_head) * size)); | 929 | get_order(sizeof(struct hlist_head) * size)); |
| 931 | } | 930 | } |
| 931 | EXPORT_SYMBOL_GPL(nf_ct_free_hashtable); | ||
| 932 | 932 | ||
| 933 | void nf_conntrack_flush(void) | 933 | void nf_conntrack_flush(void) |
| 934 | { | 934 | { |
| @@ -962,14 +962,14 @@ void nf_conntrack_cleanup(void) | |||
| 962 | 962 | ||
| 963 | kmem_cache_destroy(nf_conntrack_cachep); | 963 | kmem_cache_destroy(nf_conntrack_cachep); |
| 964 | kmem_cache_destroy(nf_conntrack_expect_cachep); | 964 | kmem_cache_destroy(nf_conntrack_expect_cachep); |
| 965 | free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc, | 965 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc, |
| 966 | nf_conntrack_htable_size); | 966 | nf_conntrack_htable_size); |
| 967 | 967 | ||
| 968 | nf_conntrack_proto_fini(); | 968 | nf_conntrack_proto_fini(); |
| 969 | nf_conntrack_helper_fini(); | 969 | nf_conntrack_helper_fini(); |
| 970 | } | 970 | } |
| 971 | 971 | ||
| 972 | static struct hlist_head *alloc_hashtable(int *sizep, int *vmalloced) | 972 | struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced) |
| 973 | { | 973 | { |
| 974 | struct hlist_head *hash; | 974 | struct hlist_head *hash; |
| 975 | unsigned int size, i; | 975 | unsigned int size, i; |
| @@ -992,6 +992,7 @@ static struct hlist_head *alloc_hashtable(int *sizep, int *vmalloced) | |||
| 992 | 992 | ||
| 993 | return hash; | 993 | return hash; |
| 994 | } | 994 | } |
| 995 | EXPORT_SYMBOL_GPL(nf_ct_alloc_hashtable); | ||
| 995 | 996 | ||
| 996 | int set_hashsize(const char *val, struct kernel_param *kp) | 997 | int set_hashsize(const char *val, struct kernel_param *kp) |
| 997 | { | 998 | { |
| @@ -1009,7 +1010,7 @@ int set_hashsize(const char *val, struct kernel_param *kp) | |||
| 1009 | if (!hashsize) | 1010 | if (!hashsize) |
| 1010 | return -EINVAL; | 1011 | return -EINVAL; |
| 1011 | 1012 | ||
| 1012 | hash = alloc_hashtable(&hashsize, &vmalloced); | 1013 | hash = nf_ct_alloc_hashtable(&hashsize, &vmalloced); |
| 1013 | if (!hash) | 1014 | if (!hash) |
| 1014 | return -ENOMEM; | 1015 | return -ENOMEM; |
| 1015 | 1016 | ||
| @@ -1037,7 +1038,7 @@ int set_hashsize(const char *val, struct kernel_param *kp) | |||
| 1037 | nf_conntrack_hash_rnd = rnd; | 1038 | nf_conntrack_hash_rnd = rnd; |
| 1038 | write_unlock_bh(&nf_conntrack_lock); | 1039 | write_unlock_bh(&nf_conntrack_lock); |
| 1039 | 1040 | ||
| 1040 | free_conntrack_hash(old_hash, old_vmalloced, old_size); | 1041 | nf_ct_free_hashtable(old_hash, old_vmalloced, old_size); |
| 1041 | return 0; | 1042 | return 0; |
| 1042 | } | 1043 | } |
| 1043 | 1044 | ||
| @@ -1066,8 +1067,8 @@ int __init nf_conntrack_init(void) | |||
| 1066 | * entries. */ | 1067 | * entries. */ |
| 1067 | max_factor = 4; | 1068 | max_factor = 4; |
| 1068 | } | 1069 | } |
| 1069 | nf_conntrack_hash = alloc_hashtable(&nf_conntrack_htable_size, | 1070 | nf_conntrack_hash = nf_ct_alloc_hashtable(&nf_conntrack_htable_size, |
| 1070 | &nf_conntrack_vmalloc); | 1071 | &nf_conntrack_vmalloc); |
| 1071 | if (!nf_conntrack_hash) { | 1072 | if (!nf_conntrack_hash) { |
| 1072 | printk(KERN_ERR "Unable to create nf_conntrack_hash\n"); | 1073 | printk(KERN_ERR "Unable to create nf_conntrack_hash\n"); |
| 1073 | goto err_out; | 1074 | goto err_out; |
| @@ -1122,8 +1123,8 @@ out_free_expect_slab: | |||
| 1122 | err_free_conntrack_slab: | 1123 | err_free_conntrack_slab: |
| 1123 | kmem_cache_destroy(nf_conntrack_cachep); | 1124 | kmem_cache_destroy(nf_conntrack_cachep); |
| 1124 | err_free_hash: | 1125 | err_free_hash: |
| 1125 | free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc, | 1126 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc, |
| 1126 | nf_conntrack_htable_size); | 1127 | nf_conntrack_htable_size); |
| 1127 | err_out: | 1128 | err_out: |
| 1128 | return -ENOMEM; | 1129 | return -ENOMEM; |
| 1129 | } | 1130 | } |
