aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/timers.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 19:02:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 19:12:51 +0200
commit245f0bd331330c80e28e56e95c85ebacf7570ac2 (patch)
treed863021b9fe555e3d77a4d84baa553d94ea63c0c /src/timers.h
parentglobal: use ktime boottime instead of jiffies (diff)
downloadwireguard-linux-compat-245f0bd331330c80e28e56e95c85ebacf7570ac2.tar.xz
wireguard-linux-compat-245f0bd331330c80e28e56e95c85ebacf7570ac2.zip
global: use fast boottime instead of normal boottime
Generally if we're inaccurate by a few nanoseconds, it doesn't matter. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.h')
-rw-r--r--src/timers.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/timers.h b/src/timers.h
index 5a691c8..1c46555 100644
--- a/src/timers.h
+++ b/src/timers.h
@@ -19,9 +19,9 @@ void timers_handshake_complete(struct wireguard_peer *peer);
void timers_session_derived(struct wireguard_peer *peer);
void timers_any_authenticated_packet_traversal(struct wireguard_peer *peer);
-static inline bool has_expired(ktime_t birthday, u64 expiration_seconds)
+static inline bool has_expired(u64 birthday_nanoseconds, u64 expiration_seconds)
{
- return !ktime_after(ktime_add_ns(birthday, expiration_seconds * NSEC_PER_SEC), ktime_get_boottime());
+ return (s64)(birthday_nanoseconds + expiration_seconds * NSEC_PER_SEC) <= (s64)ktime_get_boot_fast_ns();
}
#endif /* _WG_TIMERS_H */