You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows => QueryPerformanceCounter
macOS => mach_absolute_time
Linux => clock_gettime
These timers do not exhibit the same behavior when the OS is asleep
Windows:
QueryPerformanceCounter reads the performance counter and returns the total number of ticks that have occurred since the Windows operating system was started, including the time when the machine was in a sleep state such as standby, hibernate, or connected standby.
Currently the timers in boringtun use std::time::Instant. This timer
does not increment while the machine is asleep on macOS and Linux
meaning the device does not know to properly handshake on wake from
sleep.
To solve this we use `CLOCK_BOOTTIME` on Linux/Android and
`CLOCK_MONOTONIC` on macOS/iOS to get the actual duration since the last
handshake.
Fixes#316
Currently the timers in boringtun use std::time::Instant. This timer
does not increment while the machine is asleep on macOS and Linux
meaning the device does not know to properly handshake on wake from
sleep.
To solve this we use `CLOCK_BOOTTIME` on Linux/Android and
`CLOCK_MONOTONIC` on macOS/iOS to get the actual duration since the last
handshake.
Fixes#316
boringtun relies on on std::time::Instant to deal with handshake timeout, session timeout, keep-alive, etc. Under the hood, std::time::Instant uses the following APIs (https://doc.rust-lang.org/std/time/struct.Instant.html#underlying-system-calls)
Windows => QueryPerformanceCounter
macOS => mach_absolute_time
Linux => clock_gettime
These timers do not exhibit the same behavior when the OS is asleep
Windows:
https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
macOS:
https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time
Linux (I couldn't find any docs).
I think std::time::Instant maybe the wrong clock to use here? My main concern is macOS. After waking from sleep the timers are not properly updated.
There is already a change out for rust std::time::Instant here: rust-lang/rust#88714
The text was updated successfully, but these errors were encountered: