diff options
Diffstat (limited to 'src/ratelimiter.c')
-rw-r--r-- | src/ratelimiter.c | 6 |
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; |