n0-computer / n0-computer/net-tools
check_wall_time_advance uses Instant which can't detect sleep
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 29
- Forks
- 36
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 6
Description
The sleep detection in check_wall_time_advance is based on Instant which is based on CLOCK_MONOTONIC on Linux/Android and that means the time spent during sleep is ignored and the Instant won't jump after wakeup. So, the sleep can't be detected. A better alternative would be e.g. CLOCK_BOOTTIME or maybe at least SystemTime which would work on all platforms. I haven't checked if Instant would also be problematic on some other platforms. At least my VPN project stopped working properly after wakeups and part of the issue seems to be caused by usages of Instant.
Here's the relevant part from the std::time::Instant docstring:
/// | Platform | System call |
/// |-----------|----------------------------------------------------------------------|
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
/// | UNIX | [clock_gettime] with `CLOCK_MONOTONIC` |
/// | Darwin | [clock_gettime] with `CLOCK_UPTIME_RAW` |
/// | VXWorks | [clock_gettime] with `CLOCK_MONOTONIC` |
/// | SOLID | `get_tim` |
/// | WASI | [__wasi_clock_time_get] with `monotonic` |
/// | Windows | [QueryPerformanceCounter] |
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating check_wall_time_advance and trace how it uses Instant for sleep detection. Compare the available clock alternatives across the platforms supported by net-tools, then verify that elapsed sleep time is detected after a wakeup without breaking normal wall-time advancement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100