summaryrefslogtreecommitdiffstatshomepage
path: root/src/ratelimiter.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-07-04 05:52:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-07-04 16:48:22 +0200
commit39a91ca75fb7bd9318e484704e0e44a2bda1744a (patch)
treedd1adbb4be1cf2bc139b4f9c35089700908bb3d2 /src/ratelimiter.c
parentgitignore: ignore split DWARF debug info (diff)
downloadwireguard-monolithic-historical-39a91ca75fb7bd9318e484704e0e44a2bda1744a.tar.xz
wireguard-monolithic-historical-39a91ca75fb7bd9318e484704e0e44a2bda1744a.zip
ratelimiter: use kvzalloc for hash table allocation
Diffstat (limited to 'src/ratelimiter.c')
-rw-r--r--src/ratelimiter.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/ratelimiter.c b/src/ratelimiter.c
index b3fdd4c..ebad1f4 100644
--- a/src/ratelimiter.c
+++ b/src/ratelimiter.c
@@ -2,9 +2,8 @@
#include "ratelimiter.h"
#include <linux/siphash.h>
-#include <linux/vmalloc.h>
+#include <linux/mm.h>
#include <linux/slab.h>
-#include <linux/hashtable.h>
#include <net/ip.h>
static struct kmem_cache *entry_cache;
@@ -154,18 +153,16 @@ int ratelimiter_init(void)
table_size = (totalram_pages > (1 << 30) / PAGE_SIZE) ? 8192 : max_t(unsigned long, 16, roundup_pow_of_two((totalram_pages << PAGE_SHIFT) / (1 << 14) / sizeof(struct hlist_head)));
max_entries = table_size * 8;
- table_v4 = vmalloc(table_size * sizeof(struct hlist_head));
+ table_v4 = kvzalloc(table_size * sizeof(struct hlist_head), GFP_KERNEL);
if (!table_v4)
goto err_kmemcache;
- __hash_init(table_v4, table_size);
#if IS_ENABLED(CONFIG_IPV6)
- table_v6 = vmalloc(table_size * sizeof(struct hlist_head));
+ table_v6 = kvzalloc(table_size * sizeof(struct hlist_head), GFP_KERNEL);
if (!table_v6) {
- vfree(table_v4);
+ kvfree(table_v4);
goto err_kmemcache;
}
- __hash_init(table_v6, table_size);
#endif
queue_delayed_work(system_power_efficient_wq, &gc_work, HZ);
@@ -187,9 +184,9 @@ void ratelimiter_uninit(void)
cancel_delayed_work_sync(&gc_work);
gc_entries(NULL);
synchronize_rcu();
- vfree(table_v4);
+ kvfree(table_v4);
#if IS_ENABLED(CONFIG_IPV6)
- vfree(table_v6);
+ kvfree(table_v6);
#endif
kmem_cache_destroy(entry_cache);
}