Roy Marples [Tue, 4 Feb 2020 15:21:40 +0000 (15:21 +0000)]
BSD: When applying RA base information, ensure flags are correct
For some resaon, under privsep only, SIOCGIFINFO_IN6 returns 0
in flags even though the kernel seems to set it correctly.
SIOCSIFINFO_IN6 *will* overwrite flags regardless, so ensure
it has the correct value for dhcpcd.
Roy Marples [Tue, 21 Jan 2020 16:17:18 +0000 (16:17 +0000)]
privsep: chroot the master process
This means that the privileged actioneer process needs to cleanup
sockets and pidfile.
It also has some reliance on how dhcpcd is started to create
a decent chroot area AND copy the configuration file to it.
Roy Marples [Fri, 17 Jan 2020 17:18:45 +0000 (17:18 +0000)]
OpenBSD: Support privacy extensions
If course, OpenBSD is really different from other BSD's.
IN6_IFF_PRIVACY is their IN6_IFF_TEMPORARY.
Temporary addresses are on by default, you need to turn them
off on OpenBSD via ifconfig.
Temporary addresss timings are not configurable and the address
itself is always preferred over non temporary addresses within the
same scope.
Roy Marples [Wed, 15 Jan 2020 14:28:24 +0000 (14:28 +0000)]
Implement Anonymity Profiles for DHCP Clients, RFC 7844
This works by randomising the hardware address when carrier is down
and using this to construct a DUID LL which is used over any saved
DUID. IAID is defaulted to zero and hostname + FQDN are disabled.
Then every possible option is masked out except for essential ones.
It's possible to request options *after* anonymous option which
will enable it. This is RFC compliant and allows 100% flexability
in letting the user decide what, if any, details leek out.
This is disabled by default.
Only works on NetBSD, other OS coming shortly.
Roy Marples [Wed, 8 Jan 2020 20:13:20 +0000 (20:13 +0000)]
ioctl: The POSIX signature differs from BSD and glibc
BSD and glibc have the signature for request as unsigned long.
musl and Solaris have a signed int.
As such, we need to detect this at compile time and adjust the
signature of our internal ioctl functions to match.
To keep the onwire format the same, memcpy the request to the
unsigned long request and back again, thus preserving the signedness.
Roy Marples [Tue, 7 Jan 2020 22:15:09 +0000 (22:15 +0000)]
DHCP6: Calulate ReTransmission using milliseconds
This is the exact formula in RFC8415 Section 15, the prior one
was not so exact.
This makes the code a lot simpler and removes the need for
complicated timespec handling.
Roy Marples [Tue, 7 Jan 2020 14:15:14 +0000 (14:15 +0000)]
eloop: reduce timers rather than calculating expiry
This saves the need to store a created date per timer, we just need
to know when the timers were last changed which we can store in the
eloop.
This makes it easier to make the actual timeout for polling.
While here, add the eloop_timespec_diff function to workout the
elapsed time from usp to tsp even when time has wrapped on one or
both times.
This works if time wraps on the maximal size time_t allows AND
we know that tsp is always newer than usp.
Roy Marples [Wed, 1 Jan 2020 11:18:49 +0000 (11:18 +0000)]
eloop: Allow for for timeouts greater than time_t and time wrapping
On some systems time_t is int32_t.
However, on wire timeouts are generally uint32_t.
As such, we need to avoid using timespec internally except to
record when the timeout was created. Instead, record the timeout
as unsigned int seconds and long nanoseconds.
On long running systems using time_t as int32_t, monotonic time
would wrap after approximately 68 years. It's highly unlikely dhcpcd
would be running for so long, but just incase it does, the code
should now cope.
Roy Marples [Wed, 1 Jan 2020 22:35:56 +0000 (22:35 +0000)]
Merge pull request #12 from andersk/ra-time-units
The RA times are provided in milliseconds, but commit 569051c8aa8fc297eb8edb7bd228e0fd353d30c1 (dhcpcd-8.1.3~18) “Linux:
prefer ms RA times” incorrectly scaled them by an extra factor of 1000
before writing them to retrans_time_ms and base_reachable_time_ms.
Instead, write the values in milliseconds directly to the *_ms files,
and correctly convert to jiffies or seconds for the other files if
necessary.
Anders Kaseorg [Wed, 1 Jan 2020 19:42:47 +0000 (11:42 -0800)]
Linux: fix RA time unit confusion
The RA times are provided in milliseconds, but commit 569051c8aa8fc297eb8edb7bd228e0fd353d30c1 (dhcpcd-8.1.3~18) “Linux:
prefer ms RA times” incorrectly scaled them by an extra factor of 1000
before writing them to retrans_time_ms and base_reachable_time_ms.
Instead, write the values in milliseconds directly to the *_ms files,
and correctly convert to jiffies or seconds for the other files if
necessary.