[Bug 283256] CLOCK_MONOTONIC in dhclient
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 283256] CLOCK_MONOTONIC in dhclient"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 13 Apr 2025 02:11:10 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283256
--- Comment #4 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:
URL:
https://cgit.FreeBSD.org/src/commit/?id=43d19e6a4c42ade0f276ceca18a09e2e3829fce4
commit 43d19e6a4c42ade0f276ceca18a09e2e3829fce4
Author: Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-04-08 22:50:01 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-04-13 02:09:56 +0000
dhclient: Keep two clocks
Until July 2024, dhclient kept track of time as seconds-since-epoch as
a time_t. This was a problem because (a) we wanted sub-second timeouts
and (b) timeouts didn't always do the right thing if the system clock
changed.
Switching to using CLOCK_MONOTONIC and struct timespec fixed those
issues but introduced a new problem: CLOCK_MONOTONIC values were being
intepreted as seconds-since-epoch and written to the dhclient.leases
file, causing confusion with DHCP leases expiring in early 1970.
Attempt to compromise between these by keeping track of both times;
any type within dhclient which is a time_t now refers to seconds past
the epoch, while any struct timespec value is a CLOCK_MONOTONIC time.
PR: 283256
Reviewed by: dch
Fixes: f0a38976b01e ("dhclient: Use clock_gettime() instead of time()")
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D49720
sbin/dhclient/dhclient.c | 50 +++++++++++++++++++++---------------------------
sbin/dhclient/dhcpd.h | 4 ++--
sbin/dhclient/dispatch.c | 14 +++++++++-----
3 files changed, 33 insertions(+), 35 deletions(-)
--
You are receiving this mail because:
You are the assignee for the bug.