opnsense-src/sbin/dhclient
Colin Percival d41725ab43 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

(cherry picked from commit 43d19e6a4c42ade0f276ceca18a09e2e3829fce4)
2025-04-22 21:50:31 -07:00
..
tests Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
alloc.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
bpf.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
clparse.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
conflex.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
convert.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
dhclient-script Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
dhclient-script.8 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
dhclient.8 dhclient: Update dhclient man page for n flag 2024-08-19 21:57:09 -07:00
dhclient.c dhclient: Keep two clocks 2025-04-22 21:50:31 -07:00
dhclient.conf Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
dhclient.conf.5 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
dhclient.leases.5 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
dhcp-options.5 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
dhcp.h dhclient: Ignore vendor-identifying DHCP options defined in RFC 3925 2024-10-12 14:11:04 +02:00
dhcpd.h dhclient: Keep two clocks 2025-04-22 21:50:31 -07:00
dhctoken.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
dispatch.c dhclient: Keep two clocks 2025-04-22 21:50:31 -07:00
errwarn.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
hash.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
inet.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend.options Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
options.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
packet.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
parse.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
privsep.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
privsep.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
tables.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
tree.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
tree.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00