HomeFreeBSD

dhclient: Keep two clocks

Description

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

Details

Provenance
cpercivaAuthored on Tue, Apr 8, 10:50 PM
Reviewer
rGf0a38976b01e: dhclient: Use clock_gettime() instead of time()
Differential Revision
D49720: dhclient: Keep two clocks
Parents
rG63578bf225df: LinuxKPI: 802.11: enable fragmentation offload
Branches
Unknown
Tags
Unknown