Roy Marples [Thu, 20 Apr 2023 11:00:32 +0000 (12:00 +0100)]
chore: update build system to publish signed github releases
We rely on the GitHub CLI tools to do this.
We publish the compressed source tarball and a detached PGP
signature for it.
We add the SHA256 checksum of the tarball as a note on the release.
Automatic links to the changes are also given.
Roy Marples [Tue, 7 Feb 2023 18:25:45 +0000 (18:25 +0000)]
DHCP6: Request OPTION_NTP_SERVER to mirror DHCP
RFC 5908 deprecates OPTION_SNTP_SERVERS.
However we can support both at the same time as our scripts
will uniqify the results if there are stupidly any duplicates.
Roy Marples [Fri, 6 Jan 2023 11:14:45 +0000 (11:14 +0000)]
privsep: Try sending error if we cannot send the message.
There is an error sending a reply from an INET6 sysctl RT dump
on FreeBSD-14 using the dhcpcd-9 branch.
It seems to be related to capsicum and doesn't happen on FreeBSD-13.
We should handle the error gracefully and allow dhcpcd to try to
contuinue regardless.
xvuko [Thu, 5 Jan 2023 09:02:52 +0000 (10:02 +0100)]
dhcp: Fix classless link local static routes (#161)
Detecting host routes based on address comparison is not needed in
classless routes as /32 mask can be explicitly used. This detecting
mechanism did cause issues when gateway was set to 0.0.0.0 (link local
routes).
Laszlo Toth [Fri, 23 Dec 2022 13:31:43 +0000 (08:31 -0500)]
arp: ignore invalid ARP probes according to RFC5227 (#145)
Some network devices can send probes where the source address in the frame
does not match the sender in the ARP request, due to firmware bugs or
crafted packets.
Without verification this can cause to fail the defense, so we lose the
address, then request a new one. This might lead to the DHCP address pool
being exhausted and all sorts of problems like frequent IP changes.
A real life example is that some Cisco devices can send ARP probes in bursts,
where the frame's source address is clearly invalid, so hosts running dhcpcd
release addresses frequently, e.g., Raspberry Pis.
Example output:
"invalid ARP probe, sender hw address mismatch (00:be:75:xx:xx:xx, 00:00:00:yy:yy:yy)"
RFC5227, Section 1.1 describes that the two addresses must match in case
of ARP probes, so add the extra check and log a warning if we receive an
invalid packet like that.
Roy Marples [Fri, 2 Sep 2022 11:54:25 +0000 (12:54 +0100)]
privsep: Don't find processes we just asked to stop
We could rebind a lease, get a NAK and enter DISCOVER.
We need to restart the BPF in the middle as the BPF filter could
change.
As such, add a started flag to each privsep process and when
searching for a process by id only find started ones.
If we ask them to stop then the started flag is removed.
Fixes errors about writing to stopping processes an unknown
processes exiting.
Roy Marples [Tue, 30 Aug 2022 12:46:31 +0000 (13:46 +0100)]
privsep: Open OS sockets for the privileged process at startup
Rather than opening / closing on demand.
This mirrors the behaviour of dhcpcd without privsep and ensures
that dhcpcd always has the resource available to do it's operations
to ensure the network stays up.
This also has the advantage of working around a recent FreeBSD-14
capsicum issue where opening a route socket in the privileged
process without capsicum fails with the same error as if it was
in capsicum.
Roy Marples [Tue, 30 Aug 2022 09:48:11 +0000 (10:48 +0100)]
inet6: Support Tokenised IPv6 Identifiers
https://datatracker.ietf.org/doc/id/draft-chown-6man-tokenised-ipv6-identifiers-02.txt
Didn't quite make it to a RFC, but it's easy to implement and seems
a nice to have.
Roy Marples [Mon, 29 Aug 2022 16:58:18 +0000 (17:58 +0100)]
DHCP6: T1, T2, vltime and pltime SHOULD be zero from client messages
See RFC 8415 21.4, 21.6, 21.21 and 21.22.
As such it's impossible to request a lease time as such and we
MUST use the vltimes and pltimes sent by the server.
This addresses the concern in #116 but does fix it as it's not a dhcpcd
problem.
Roy Marples [Mon, 8 Aug 2022 15:47:55 +0000 (16:47 +0100)]
inet6: Support RFC 4862 5.5.3.e in regards to Valid Lifetime
1. If the received Valid Lifetime is greater than 2 hours or
greater than RemainingLifetime, set the valid lifetime of the
corresponding address to the advertised Valid Lifetime.
2. If RemainingLifetime is less than or equal to 2 hours, ignore
the Prefix Information option with regards to the valid
lifetime.
3. Otherwise, reset the valid lifetime of the corresponding
address to 2 hours.
Adam Dinwoodie [Fri, 29 Jul 2022 06:14:41 +0000 (07:14 +0100)]
Always skip hooks ending in ~ (#113)
dhcpcd-run-hooks is intended to skip hooks with filenames ending in `~`,
but the test only works if `$skip_hooks` is defined and not empty.
Refactor the test such that files ending in `~` are always skipped, as
appears to be the intent of this code.
Ben Woods [Sat, 13 Nov 2021 13:53:58 +0000 (21:53 +0800)]
Add epair(4) to the ignored interface types list (#73)
The FreeBSD epair(4) interface type can be thought of as a virtual patch cable.
The epair interfaces come in pairs, with network traffic being passed between the 2 pairs.
The basic intent is to provide connectivity between two virtual network stack instances.
This interface type does not typically require an IP address, as it is passing traffic
between other virtual networks/interfaces which obtain their own IP address.
Therefore, add this interface type to the list that will be ignored by dhcpcd.
Roy Marples [Fri, 12 Nov 2021 14:24:11 +0000 (14:24 +0000)]
privsep: Only set RLIMIT_NOFILES for supported platforms
Basically only for NetBSD, DragonFlyBSD, kqueue or epoll platforms.
All others will use poll(2) and return EINVAL if nfds > RLIMIT_NOFILES.
Trying to work out our nfs limit relies on already listening to
all FD's which may not be the case and was problematic.
Luckily all platforms aside from Solaris have new file creation
sandboxed away aside from accept(2) so this should still be safe.
Roy Marples [Thu, 14 Oct 2021 05:31:11 +0000 (06:31 +0100)]
DHCP: Set INFORM state only when we are about to inform
As we may not find an address right away.
While here, tidy up and comment code about deriving the address
when none is specified for inform and static setups.
Philip Paeps [Tue, 12 Oct 2021 08:07:28 +0000 (16:07 +0800)]
privsep: Fix getting interface VLANID on BSD (#58)
Include relevant headers for the definition of SIOCGETVLAN. This fixes
DHCPv6 Prefix Delegation where a prefix is delegated to several VLAN
interfaces on the same physical interface.
Roy Marples [Fri, 1 Oct 2021 15:25:53 +0000 (16:25 +0100)]
DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM
This can occur if the RA reduces the prefix times in accordance
with it's own lifetimes for example.
dhcpcd only checks if the RA contents have changed to trigger a
new INFORM.
Stefan Sperling [Tue, 31 Aug 2021 09:31:15 +0000 (11:31 +0200)]
Fix rt_cmp_dest() for equivalent network prefixes with different netmasks. (#52)
When rt_add() decides that it must delete+add a route in order to change
the routing table entry, a wrong RB tree lookup result can throw it off
the rails. In the case observed, a static /64 prefix was deleted from
vlan1 while dhcpcd intended to delete its reject route bound to lo0.
Given two routes in the table, the loopback reject route installed by
dhcpd for my /48 prefix, and a cloning route for a /64 prefix on vlan1:
When searching the OS routing table dhcpcd attempts to tell routes apart
based only on the masked destination address. In the above case the masked
destinations look identical. The only difference is the length of the netmask.
The function rt_cmp_dest() didn't detect this and returned the /64 route
while dhcpcd was in fact searching for the /48 route.
This patch fixes the lookup by running rt_cmp_netmask() if the masked
destination comparison via sa_cmp() leaves us with a tie. With this change
dhcpcd deletes the /48 route as intended, and leaves the /64 route alone.
I had to move the rt_cmp_dest() function down since it needs to use the
static helper function rt_cmp_netmask(), which happened to be defined
just below rt_cmp_dest().
Why am I using an overlapping static prefix? The answer is that my ISP
assigns a static /48 prefix but won't route IPv6 unless my router sends
a DHCPv6 request when it connects via PPPoE. I configure static IPv6 subnets
on LAN interfaces and have configured dhcpcd to obtain a /48 prefix lease
without setting addresses on any internal interfaces.
My dhcpcd.conf contains:
ipv6only
noipv6rs
duid
persistent
option rapid_commit
require dhcp_server_identifier
script ""
allowinterfaces pppoe0
interface pppoe0
ia_pd 1 /2001:db8::/48
This problem was found on OpenBSD, in case that matters for reproduction
of the issue.