aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-07-08 01:27:33 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-11 01:17:39 -0400
commit8e5105a0c36a059dfd0f0bb9e73ee7c97d306247 (patch)
treeb1bdbfeaa011544a3e1a5b3e44eca4bdd0bb8f7e /net/netfilter
parent61eb3107cd8e0302f95aae26206e552365daf290 (diff)
[NETFILTER]: nf_conntrack: round up hashsize to next multiple of PAGE_SIZE
Don't let the rest of the page go to waste. 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.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 035eb9f4a61e..54acac5c6ea7 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -965,12 +965,14 @@ void nf_conntrack_cleanup(void)
965 nf_conntrack_helper_fini(); 965 nf_conntrack_helper_fini();
966} 966}
967 967
968static struct list_head *alloc_hashtable(int size, int *vmalloced) 968static struct list_head *alloc_hashtable(int *sizep, int *vmalloced)
969{ 969{
970 struct list_head *hash; 970 struct list_head *hash;
971 unsigned int i; 971 unsigned int size, i;
972 972
973 *vmalloced = 0; 973 *vmalloced = 0;
974
975 size = *sizep = roundup(*sizep, PAGE_SIZE / sizeof(struct list_head));
974 hash = (void*)__get_free_pages(GFP_KERNEL, 976 hash = (void*)__get_free_pages(GFP_KERNEL,
975 get_order(sizeof(struct list_head) 977 get_order(sizeof(struct list_head)
976 * size)); 978 * size));
@@ -1003,7 +1005,7 @@ int set_hashsize(const char *val, struct kernel_param *kp)
1003 if (!hashsize) 1005 if (!hashsize)
1004 return -EINVAL; 1006 return -EINVAL;
1005 1007
1006 hash = alloc_hashtable(hashsize, &vmalloced); 1008 hash = alloc_hashtable(&hashsize, &vmalloced);
1007 if (!hash) 1009 if (!hash)
1008 return -ENOMEM; 1010 return -ENOMEM;
1009 1011
@@ -1053,19 +1055,19 @@ int __init nf_conntrack_init(void)
1053 if (nf_conntrack_htable_size < 16) 1055 if (nf_conntrack_htable_size < 16)
1054 nf_conntrack_htable_size = 16; 1056 nf_conntrack_htable_size = 16;
1055 } 1057 }
1056 nf_conntrack_max = 8 * nf_conntrack_htable_size; 1058 nf_conntrack_hash = alloc_hashtable(&nf_conntrack_htable_size,
1057
1058 printk("nf_conntrack version %s (%u buckets, %d max)\n",
1059 NF_CONNTRACK_VERSION, nf_conntrack_htable_size,
1060 nf_conntrack_max);
1061
1062 nf_conntrack_hash = alloc_hashtable(nf_conntrack_htable_size,
1063 &nf_conntrack_vmalloc); 1059 &nf_conntrack_vmalloc);
1064 if (!nf_conntrack_hash) { 1060 if (!nf_conntrack_hash) {
1065 printk(KERN_ERR "Unable to create nf_conntrack_hash\n"); 1061 printk(KERN_ERR "Unable to create nf_conntrack_hash\n");
1066 goto err_out; 1062 goto err_out;
1067 } 1063 }
1068 1064
1065 nf_conntrack_max = 8 * nf_conntrack_htable_size;
1066
1067 printk("nf_conntrack version %s (%u buckets, %d max)\n",
1068 NF_CONNTRACK_VERSION, nf_conntrack_htable_size,
1069 nf_conntrack_max);
1070
1069 nf_conntrack_cachep = kmem_cache_create("nf_conntrack", 1071 nf_conntrack_cachep = kmem_cache_create("nf_conntrack",
1070 sizeof(struct nf_conn), 1072 sizeof(struct nf_conn),
1071 0, 0, NULL, NULL); 1073 0, 0, NULL, NULL);