diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-06 11:49:06 -0500 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-23 14:29:44 +0100 |
commit | f63abcd5d7a8c88dc02af87297acc879f6845bd9 (patch) | |
tree | 8b484bff03707af377536fd09b943f7d30916e98 | |
parent | 81286d78f5d7655a3cf9d3c61403363bab5f4be9 (diff) |
ratelimiter: totalram_pages is now a function
Reported-by: Alex Xu <alex@alxu.ca>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/compat/compat.h | 4 | ||||
-rw-r--r-- | src/ratelimiter.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h index 4ffe387..15cf8bb 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -748,6 +748,10 @@ static inline void crypto_xor_cpy(u8 *dst, const u8 *src1, const u8 *src2, #define hlist_add_behind(a, b) hlist_add_after(b, a) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) +#define totalram_pages() totalram_pages +#endif + /* https://github.com/ClangBuiltLinux/linux/issues/7 */ #if defined( __clang__) && (!defined(CONFIG_CLANG_VERSION) || CONFIG_CLANG_VERSION < 80000) #include <linux/bug.h> diff --git a/src/ratelimiter.c b/src/ratelimiter.c index 82d1379..b3b1d25 100644 --- a/src/ratelimiter.c +++ b/src/ratelimiter.c @@ -170,9 +170,9 @@ int wg_ratelimiter_init(void) * we borrow their wisdom about good table sizes on different systems * dependent on RAM. This calculation here comes from there. */ - table_size = (totalram_pages > (1U << 30) / PAGE_SIZE) ? 8192 : + table_size = (totalram_pages() > (1U << 30) / PAGE_SIZE) ? 8192 : max_t(unsigned long, 16, roundup_pow_of_two( - (totalram_pages << PAGE_SHIFT) / + (totalram_pages() << PAGE_SHIFT) / (1U << 14) / sizeof(struct hlist_head))); max_entries = table_size * 8; |