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 | f8b3991e881a64f47412082ae15c08285eb6880b (patch) | |
tree | c5308716de6dc4765ed466e73f5bf70829f9ecfd /src/compat | |
parent | 66518b5ce61f74375c120a872a168585dc392ba7 (diff) |
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.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/compat')
-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 |