diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-23 19:02:18 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-23 19:12:51 +0200 |
commit | 68441fb05412baebbd17f407bf984ad7a81af630 (patch) | |
tree | 71fefcc3710232dea912be362cb83f383720edc0 /src/ratelimiter.c | |
parent | global: use ktime boottime instead of jiffies (diff) | |
download | wireguard-monolithic-historical-68441fb05412baebbd17f407bf984ad7a81af630.tar.xz wireguard-monolithic-historical-68441fb05412baebbd17f407bf984ad7a81af630.zip |
global: use fast boottime instead of normal boottime
Generally if we're inaccurate by a few nanoseconds, it doesn't matter.
Diffstat (limited to '')
-rw-r--r-- | src/ratelimiter.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ratelimiter.c b/src/ratelimiter.c index e35bf64..140d99e 100644 --- a/src/ratelimiter.c +++ b/src/ratelimiter.c @@ -57,7 +57,7 @@ static void gc_entries(struct work_struct *work) unsigned int i; struct ratelimiter_entry *entry; struct hlist_node *temp; - const u64 now = ktime_get_boot_ns(); + const u64 now = ktime_get_boot_fast_ns(); for (i = 0; i < table_size; ++i) { spin_lock(&table_lock); @@ -107,7 +107,7 @@ bool ratelimiter_allow(struct sk_buff *skb, struct net *net) * tokens, rather than as part of the rate. */ spin_lock(&entry->lock); - now = ktime_get_boot_ns(); + now = ktime_get_boot_fast_ns(); tokens = min_t(u64, TOKEN_MAX, entry->tokens + now - entry->last_time_ns); entry->last_time_ns = now; ret = tokens >= PACKET_COST; @@ -130,7 +130,7 @@ bool ratelimiter_allow(struct sk_buff *skb, struct net *net) entry->ip = data.ip; INIT_HLIST_NODE(&entry->hash); spin_lock_init(&entry->lock); - entry->last_time_ns = ktime_get_boot_ns(); + entry->last_time_ns = ktime_get_boot_fast_ns(); entry->tokens = TOKEN_MAX - PACKET_COST; spin_lock(&table_lock); hlist_add_head_rcu(&entry->hash, bucket); |