aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/compat/compat.h4
-rw-r--r--src/ratelimiter.c4
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;