summaryrefslogtreecommitdiffhomepage
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
commitabddb8492c55482048b10788e00ec20e5ee3948f (patch)
treec120c38e63eccdea9cac4bd16d03b6d4919a6b9d /src/ratelimiter.c
parentce7e110ef3a0809e875b7c8a0008226ecda32518 (diff)
global: style nits
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
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;