dhcp,dhcp6,icmp6,time: Convert timestamps to CLOCK_BOOTTIME

The frame reception timestamps obtained for DHCPv4, DHCPv6 and ICMPv6
frames from the kernel are based on CLOCK_REALTIME, there's no option to
switch them to CLOCK_BOOTTIME, which we use across our retransmission and
renew logic.  Add a time-private.h utility to convert the timestamps
right where we read them from recvmsg() to produce CLOCK_BOOTTIME based
times.  This isn't 100% bulletproof because the offset between the two
clocks can vary between the time the frame was received by the kernel and
the time we read the offset.  The probability is very low though and we
have no better solution at this time other than fixing it in the kernel.
Using CLOCK_REALTIME for frame reception timestamps seems to mainly
create potential for problems in the common usages.

Fixes: c78ad1bb6d7e ("dhcp: Set lease expiry based on frame reception times")
5 files changed