diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-23 04:20:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-23 06:08:37 +0200 |
commit | d0bd6dc67d81236f66cb763c3d47dd6b5d7581a6 (patch) | |
tree | 6b3669f075d28267e50bda153a32e9b7ea9ff30b /src/timers.h | |
parent | tools: fix misspelling of strchrnul in comment (diff) | |
download | wireguard-monolithic-historical-d0bd6dc67d81236f66cb763c3d47dd6b5d7581a6.tar.xz wireguard-monolithic-historical-d0bd6dc67d81236f66cb763c3d47dd6b5d7581a6.zip |
global: use ktime boottime instead of jiffies
Since this is a network protocol, expirations need to be accounted for,
even across system suspend. On real systems, this isn't a problem, since
we're clearing all keys before suspend. But on Android, where we don't
do that, this is something of a problem. So, we switch to using boottime
instead of jiffies.
Diffstat (limited to '')
-rw-r--r-- | src/timers.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/timers.h b/src/timers.h index 6c67a6a..5a691c8 100644 --- a/src/timers.h +++ b/src/timers.h @@ -19,4 +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) +{ + return !ktime_after(ktime_add_ns(birthday, expiration_seconds * NSEC_PER_SEC), ktime_get_boottime()); +} + #endif /* _WG_TIMERS_H */ |