aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/ratelimiter.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-25 17:56:08 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 17:25:23 +0100
commite09ec4dc2af38fb44add2fac518a726ae605b400 (patch)
tree950512f15664d121e92677ec1c35a5b1b1b870dc /src/ratelimiter.c
parentqemu: work around ccache bugs (diff)
downloadwireguard-monolithic-historical-e09ec4dc2af38fb44add2fac518a726ae605b400.tar.xz
wireguard-monolithic-historical-e09ec4dc2af38fb44add2fac518a726ae605b400.zip
global: style nits
Diffstat (limited to 'src/ratelimiter.c')
-rw-r--r--src/ratelimiter.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ratelimiter.c b/src/ratelimiter.c
index a9caf32..8a73dd1 100644
--- a/src/ratelimiter.c
+++ b/src/ratelimiter.c
@@ -100,7 +100,8 @@ bool ratelimiter_allow(struct sk_buff *skb, struct net *net)
bool ret;
/* Inspired by nft_limit.c, but this is actually a slightly different
* algorithm. Namely, we incorporate the burst as part of the maximum
- * tokens, rather than as part of the rate. */
+ * tokens, rather than as part of the rate.
+ */
spin_lock(&entry->lock);
now = ktime_get_ns();
tokens = min_t(u64, TOKEN_MAX, entry->tokens + now - entry->last_time_ns);
@@ -149,7 +150,8 @@ int ratelimiter_init(void)
/* xt_hashlimit.c uses a slightly different algorithm for ratelimiting,
* but what it shares in common is that it uses a massive hashtable. So,
* we borrow their wisdom about good table sizes on different systems
- * dependent on RAM. This calculation here comes from there. */
+ * dependent on RAM. This calculation here comes from there.
+ */
table_size = (totalram_pages > (1U << 30) / PAGE_SIZE) ? 8192 : max_t(unsigned long, 16, roundup_pow_of_two((totalram_pages << PAGE_SHIFT) / (1U << 14) / sizeof(struct hlist_head)));
max_entries = table_size * 8;