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/compat/compat.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/compat/compat.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h index ba2f028..d0efdb9 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -84,13 +84,6 @@ #define IP6_ECN_set_ce(a, b) IP6_ECN_set_ce(b) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) -#define time_is_before_jiffies64(a) time_after64(get_jiffies_64(), a) -#define time_is_after_jiffies64(a) time_before64(get_jiffies_64(), a) -#define time_is_before_eq_jiffies64(a) time_after_eq64(get_jiffies_64(), a) -#define time_is_after_eq_jiffies64(a) time_before_eq64(get_jiffies_64(), a) -#endif - #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && IS_ENABLED(CONFIG_IPV6) && !defined(ISRHEL7) #include <net/ipv6.h> struct ipv6_stub_type { @@ -335,9 +328,17 @@ static inline int get_random_bytes_wait(void *buf, int nbytes) #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) && !defined(ISRHEL7) #include <linux/ktime.h> -static inline u64 ktime_get_ns(void) +static inline u64 ktime_get_boot_ns(void) +{ + return ktime_to_ns(ktime_get_boottime()); +} +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) && !defined(ISRHEL7) +#include <linux/ktime.h> +static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2) { - return ktime_to_ns(ktime_get()); + return ktime_compare(cmp1, cmp2) > 0; } #endif |