]> git.ipfire.org Git - thirdparty/dhcpcd.git/log
thirdparty/dhcpcd.git
9 months agoIPv6: Mark Route Information Routes as from RA 374/head
Roy Marples [Thu, 10 Oct 2024 10:10:11 +0000 (11:10 +0100)] 
IPv6: Mark Route Information Routes as from RA

9 months agoIPv6: Don't set IN6_IFF_TENTATIVE when the address exists
Roy Marples [Wed, 9 Oct 2024 10:19:56 +0000 (11:19 +0100)] 
IPv6: Don't set IN6_IFF_TENTATIVE when the address exists

We can only work it out when we know the address, not beforehand.

9 months agoDHCP6: Discard less preferred ADVERTISMENTs until IRT
Roy Marples [Tue, 8 Oct 2024 13:34:02 +0000 (14:34 +0100)] 
DHCP6: Discard less preferred ADVERTISMENTs until IRT

If we get a preference value of 255 then request immediately.
More RFC 8415 18.2.1 support, inspired by #376.

9 months agodhcp6: start request when advertise received after IRT (#376)
Scott Shambarger [Tue, 8 Oct 2024 13:26:04 +0000 (06:26 -0700)] 
dhcp6: start request when advertise received after IRT (#376)

After the initial solicit timeout, any received advertisements trigger
a request.  However, after the timeout, any advertisements will
never result in a request, and the client sends solicits forever.

This patch adds sends a request in response to an advertise if the
initial timeout has expired.

Cleanup: removes a check for an impossible state.

9 months agoBSD: Remove IPv6 sharing warning
Roy Marples [Mon, 7 Oct 2024 11:10:11 +0000 (12:10 +0100)] 
BSD: Remove IPv6 sharing warning

This doesn't seem to be needed for on recent FreeBSD and OpenBSD.

9 months agoRelease dhcpcd-10.1.0 v10.1.0
Roy Marples [Fri, 4 Oct 2024 21:22:24 +0000 (22:22 +0100)] 
Release dhcpcd-10.1.0

9 months agoFinal fix for prior
Roy Marples [Fri, 4 Oct 2024 16:35:09 +0000 (17:35 +0100)] 
Final fix for prior

9 months agoAnother fix for prior
Roy Marples [Fri, 4 Oct 2024 16:24:43 +0000 (16:24 +0000)] 
Another fix for prior

9 months agominor fix for prior
Roy Marples [Fri, 4 Oct 2024 16:11:26 +0000 (17:11 +0100)] 
minor fix for prior

9 months agodhcpcd: remove advertisement of addresses
Roy Marples [Fri, 4 Oct 2024 15:36:01 +0000 (15:36 +0000)] 
dhcpcd: remove advertisement of addresses

Address advertisemnt was used to allow IP address sharing to work.
It also required the DHCP server to allow the same IP for many
hosts, which modern DHCP servers deny you from doing.
Lastly, there are niggles with the implementation that are
impossible to fully fix due to how the various protocols work,
especially ARP.

All platforms dhcpcd supports allow better ways of doing this,
such as bonding (Linux), trunk(4) (OpenBSD), lagg(4) (Other BSDs).

ARP advertisements will only be made when addresses are added
OR defended against for kernels without RFC 5227 support.

9 months agoDHCP: Fix checksum validation
Roy Marples [Wed, 2 Oct 2024 06:49:36 +0000 (07:49 +0100)] 
DHCP: Fix checksum validation

in_cksum falls over with struct ip in a union of uint16_t with
some compilers.

The fix is to create a smaller pseudo header, fill in the bits
we need and then copy this to a uint8_t array which we then
send to in_cksum.

Tested on Debian-12 with clang-15 and CFLAGS=-Os

While here, just check that the UDP checksum check is zero
rather than zeroing it out and checking it matches.

Co-authored-by: Zikai Chen <chenzikai@google.com>
9 months agolinux: Only include linux/if.h if libc does not define IFF_DORMANT
Roy Marples [Tue, 1 Oct 2024 09:05:32 +0000 (10:05 +0100)] 
linux: Only include linux/if.h if libc does not define IFF_DORMANT

Hopefully fixes #373.

9 months agoImprove formatting of error
Roy Marples [Sat, 4 May 2024 14:03:00 +0000 (15:03 +0100)] 
Improve formatting of error

10 months agoInclude frame header in buffer length (#371)
acst1223 [Thu, 26 Sep 2024 07:56:28 +0000 (16:56 +0900)] 
Include frame header in buffer length (#371)

Since we are capturing packets at L2 we should not be using ETH_DATA_LEN
but ETH_FRAME_LEN to include also dst/src MAC and EtherType.

Co-authored-by: Andrzej Ostruszka <amo@semihalf.com>
10 months agoIPv6: DNSSL is an array of domains
Roy Marples [Mon, 23 Sep 2024 14:34:15 +0000 (14:34 +0000)] 
IPv6: DNSSL is an array of domains

As per RFC 8106 section 5.2.
Fixes #367

Thanks to Scott Shambarger.

10 months agoDHCP: Fix deleting expired leased addresses
Roy Marples [Wed, 11 Sep 2024 10:47:22 +0000 (11:47 +0100)] 
DHCP: Fix deleting expired leased addresses

10 months agoIPv6: Only advertise addresses when needed
Roy Marples [Wed, 11 Sep 2024 09:28:58 +0000 (10:28 +0100)] 
IPv6: Only advertise addresses when needed

Remember when we have advertised an address.
If we want to advertise it again, check this first.
If we still want to advertise it, clear this flag for all other
matching addresses.
Clear advertised flags from all addresses on carrier up.

This reduces needless NA spam from dhcpcd when the IPv6 Router
is needlessly chatty with RA.

10 months agoDHCP6: Fix INFO_REFRESH_TIME option
Roy Marples [Thu, 5 Sep 2024 13:22:53 +0000 (14:22 +0100)] 
DHCP6: Fix INFO_REFRESH_TIME option

Fixes #329 thanks to jvfranklin.

10 months agodhcp: get_option_uint* only accept options with correct len (#357)
taoyl-g [Thu, 5 Sep 2024 13:14:25 +0000 (22:14 +0900)] 
dhcp: get_option_uint* only accept options with correct len (#357)

RFC8925 mentions "The client MUST ignore the IPv6-Only Preferred option
if the length field value is not 4."

10 months agoIPv6: Return errors from ip6_forwarding
Roy Marples [Wed, 4 Sep 2024 11:18:10 +0000 (12:18 +0100)] 
IPv6: Return errors from ip6_forwarding

On all OS 0 is disabled and >0 is enabled.
So return -1 on any error which is returned to the main process so
we could log a diagnostic in the future.

While where allow privsep to actually get the sysctl for Capsicum.

10 months agoIPv6ND: Don't warn about no global addresses for default route
Roy Marples [Wed, 4 Sep 2024 10:48:46 +0000 (11:48 +0100)] 
IPv6ND: Don't warn about no global addresses for default route

If we are not installing a default route.

10 months agoprivsep: Capsicum needs root to access ipv6 forwarding sysctl
Roy Marples [Tue, 3 Sep 2024 08:37:47 +0000 (09:37 +0100)] 
privsep: Capsicum needs root to access ipv6 forwarding sysctl

Optimise the flow so that if we do have a global address on the
source interface we avoid the sysctl via the privileged process.

Generally the only time we don't is when we de-configure an
interface or we are configuring an interface where there is
no autoconf prefix from the RA and the only globals come
from a DHCPv6 Prefix Delegation to other interfaces which
requires us to be a router.

10 months agoIPv6: Ignore loopback address for any global consideration
Roy Marples [Sun, 1 Sep 2024 15:42:29 +0000 (16:42 +0100)] 
IPv6: Ignore loopback address for any global consideration

11 months agoDHCP6: IPV6_AF_DELEGATEDPFX -> IPV6_AF_PFXDELEGATION
Roy Marples [Fri, 30 Aug 2024 14:09:17 +0000 (15:09 +0100)] 
DHCP6: IPV6_AF_DELEGATEDPFX -> IPV6_AF_PFXDELEGATION

This is easier to see the difference with IPV6_AF_DELEGAGTED.

11 months agoDHCP6: Mark everything excpept delegated addresses as stale
Roy Marples [Fri, 30 Aug 2024 08:37:36 +0000 (09:37 +0100)] 
DHCP6: Mark everything excpept delegated addresses as stale

When parsing a lease.
A Prefix Delegation is part of a lease and should follow the same
rules for being stale as an address.

11 months agoDHCP6: Fix Prefix Delegation pltime and vltime
Roy Marples [Thu, 29 Aug 2024 10:13:41 +0000 (11:13 +0100)] 
DHCP6: Fix Prefix Delegation pltime and vltime

While here fix deleting non exteneded deprecated addresses

11 months agoIPv6: Add the added address to state
Roy Marples [Wed, 28 Aug 2024 18:04:53 +0000 (19:04 +0100)] 
IPv6: Add the added address to state

We used to rely on route(4) adding it to state based on RTM_NEWADDR
but the message could get lost if the socket overflows.
Work around this by always adding the address to the state.

11 months agoRelease dhcpcd-10.0.10 v10.0.10
Roy Marples [Wed, 21 Aug 2024 15:04:53 +0000 (16:04 +0100)] 
Release dhcpcd-10.0.10

11 months agoRevert d49db34 and add a comment as to why it's needed.
Roy Marples [Wed, 21 Aug 2024 15:02:27 +0000 (16:02 +0100)] 
Revert d49db34 and add a comment as to why it's needed.

Fixes #352

11 months agoRelease dhcpcd-10.0.9 v10.0.9
Roy Marples [Wed, 21 Aug 2024 10:51:59 +0000 (11:51 +0100)] 
Release dhcpcd-10.0.9

11 months agoWell, changes were made in 2024!
Roy Marples [Wed, 21 Aug 2024 10:51:24 +0000 (11:51 +0100)] 
Well, changes were made in 2024!

11 months agolinux: make if_getnetworknamespace static
Roy Marples [Wed, 21 Aug 2024 10:30:51 +0000 (11:30 +0100)] 
linux: make if_getnetworknamespace static

11 months agoUpdate privsep-linux.c to allow statx (#349)
Jabrwock [Wed, 21 Aug 2024 10:38:58 +0000 (04:38 -0600)] 
Update privsep-linux.c to allow statx (#349)

Add statx to SECCOMP_ALLOW

11 months agoDHCP6: Remove the dhcp6_pd_addr packed struct
Roy Marples [Thu, 1 Aug 2024 17:03:39 +0000 (18:03 +0100)] 
DHCP6: Remove the dhcp6_pd_addr packed struct

Some compilers just don't support this.
We need to manually copy this in and out.

Fixes #347.

11 months agoIPv4LL: Harden the noconfigure option.
Roy Marples [Thu, 1 Aug 2024 22:57:39 +0000 (23:57 +0100)] 
IPv4LL: Harden the noconfigure option.

This path should not be hit with the prior patch, but just in-case
harden the logic incase we don't have the address added.

11 months agoIPv4LL: If we are not configuring, abort if address does not exist
Roy Marples [Thu, 1 Aug 2024 16:06:51 +0000 (17:06 +0100)] 
IPv4LL: If we are not configuring, abort if address does not exist

Fixes a segfault as we would not add the address and we would
expect to find it.

12 months agoDHCP: No longer set interface mtu (#346)
Roy Marples [Mon, 29 Jul 2024 15:17:08 +0000 (16:17 +0100)] 
DHCP: No longer set interface mtu (#346)

We've been enforcing an interface MTU that is slightly larger
than the minimum for some time.
Instead, log an error than the MTU is smaller than the minimum
to send a BOOTP message.

The DHCP MTU is only used when adding routes as setting the
interface MTU can cause a PHY reset which is bad.

Fixes #345

12 months agoDHCP: Handle option 108 correctly when receiving 0.0.0.0 OFFER (#342)
taoyl-g [Thu, 25 Jul 2024 10:50:59 +0000 (19:50 +0900)] 
DHCP: Handle option 108 correctly when receiving 0.0.0.0 OFFER (#342)

* DHCP: Handle option 108 correctly when receiving 0.0.0.0 OFFER

According to RFC8925 section 3.3.1, when the server supports both option
108 (IPv6-Only Preferred) and option 116 (Auto-Configure), and the
client only sends IPv6-Only Preferred option, then the server SHOULD
return 0.0.0.0 as the offered address, and not setting the
Auto-Configure option.

However, in our current client code, the IPv6-Only Preferred option in a
0.0.0.0 OFFER is only handled correctly when the Auto-Configure option
is present. This patch fixes this issue.

---------

Co-authored-by: Roy Marples <roy@marples.name>
12 months agoIPv4LL: Restart ARP probling on address conflict (#340)
Leo Ruan [Thu, 25 Jul 2024 08:37:11 +0000 (16:37 +0800)] 
IPv4LL: Restart ARP probling on address conflict (#340)

* IPv4LL: Restart ARP probling on address conflict

When IPv4LL address conflict is detected, it is failed to restart IPv4LL
since IPv4LL is running. The commit fixes the problem by restarting ARP
probing instead of restarting IPv4LL.

---------

Co-authored-by: Roy Marples <roy@marples.name>
12 months agoDHCP6: Don't remove state in DISCOVER
Roy Marples [Fri, 14 Jun 2024 16:29:35 +0000 (17:29 +0100)] 
DHCP6: Don't remove state in DISCOVER

As we might still have config that failed to CONFIRM/REBIND.
Try and remove timers more sensibly rather than blaket statements
so that expire timeout still works.

12 months agoDHCP6: Persist configuration on confirm/rebind failure
Roy Marples [Tue, 9 Jul 2024 12:39:07 +0000 (13:39 +0100)] 
DHCP6: Persist configuration on confirm/rebind failure

only expire the lease once the last address has expired.
This is more in accordance with RFC8415 18.2.
Note, we still require an initial confirm/rebind on link state
change to ensure the configuration for link is valid.

Extending the lastlease in DHCP6 has been removed.

Fixes #174.

12 months agoDHCP: Remove an assertation in get_lease if ia is NULL
Roy Marples [Tue, 9 Jul 2024 12:26:24 +0000 (13:26 +0100)] 
DHCP: Remove an assertation in get_lease if ia is NULL

It's very unlikely that is would be NULL and it only
triggers when a STATIC or INFORM address is ripped out under us.

13 months agolinux: allow roaming without IFF_DORMANT
Roy Marples [Thu, 27 Jun 2024 05:27:22 +0000 (06:27 +0100)] 
linux: allow roaming without IFF_DORMANT

IFF_DORMANT is apparently only set by supplicants.
For roaming without supplicants, we need to check that IFF_UP and
IFF_LOWER_UP are set, but IFF_RUNNING is not.

Thanks to Boris Krasnovskiy for the patch.
Fixes #335.

While here, remove our define if IFF_LOWER_UP as we can now include
linux/if.h

13 months agoDHCP6: Add commentary around why we read leases
Roy Marples [Wed, 26 Jun 2024 13:09:41 +0000 (14:09 +0100)] 
DHCP6: Add commentary around why we read leases

Fixes #336.

13 months agoprivsep: Sweep ELE_ERROR away for BPF
Roy Marples [Wed, 26 Jun 2024 11:30:42 +0000 (12:30 +0100)] 
privsep: Sweep ELE_ERROR away for BPF

It's just noise and we'll handle NETDOWN in the loop.
We sometimes see it on Linux when a wireless interface "roams"
in fake testing.

13 months agoDHCP6: Don't remove delegated prefix addresses on start or fail
Roy Marples [Wed, 26 Jun 2024 08:36:35 +0000 (09:36 +0100)] 
DHCP6: Don't remove delegated prefix addresses on start or fail

In the event where an interface is first delegated and then
started, we don't want the reading of a lease file to remove the
delegated prefixes or addresses.
Neither do we want any DHCP6 failure to remove the delegated
addresses.

As such, we also can't test the actual DHCP6 state when building
routes. Instead, just change the test for a delegated prefix
or not so we can still prefer non delegated routes.

While here, fix reject routes being restored for privsep.

Fixes #333.

13 months agoDHCP6: Don't remove delegated prefix addresses on start
Roy Marples [Tue, 25 Jun 2024 10:40:14 +0000 (11:40 +0100)] 
DHCP6: Don't remove delegated prefix addresses on start

In the event where an interface is first delegated and then
started, we don't want the reading of a lease file to remove the
delegated prefixes or addresses.

As such, we also can't test the actual DHCP6 state when building
routes. Instead, just change the test for a delegated prefix
or not so we can still prefer non delegated routes.

Fixes #333.

13 months agoIPv6: make more readable (nfc)
Roy Marples [Mon, 24 Jun 2024 11:05:58 +0000 (12:05 +0100)] 
IPv6: make more readable (nfc)

13 months agoIPv6: Delay for LL address before delay for start
Roy Marples [Mon, 24 Jun 2024 11:04:03 +0000 (12:04 +0100)] 
IPv6: Delay for LL address before delay for start

This syncs with DHCPv6 when waiting for LL.

13 months agoFix prior patch which might also fix #333
Roy Marples [Mon, 24 Jun 2024 11:01:36 +0000 (12:01 +0100)] 
Fix prior patch which might also fix #333

13 months agoIPv6: DUPLICATED could be announced by RTM_DELADDR
Roy Marples [Fri, 21 Jun 2024 11:58:38 +0000 (12:58 +0100)] 
IPv6: DUPLICATED could be announced by RTM_DELADDR

This at least is true on Linux when addresses are not permanent.
As such, update address flags on all paths and run DAD hooks
even for address deletions.

This helps to give reason to the messages that pid 0 has deleted
your newly added address.

13 months agolinux: Prefer local over address when both in netlink RTA
Roy Marples [Mon, 17 Jun 2024 22:50:31 +0000 (23:50 +0100)] 
linux: Prefer local over address when both in netlink RTA

Fixes #332.

13 months agoImprove and document prior.
Roy Marples [Mon, 17 Jun 2024 09:04:16 +0000 (10:04 +0100)] 
Improve and document prior.

13 months agoForce dumplease to parse stdin
Brett Holman [Sat, 20 Jan 2024 01:43:26 +0000 (18:43 -0700)] 
Force dumplease to parse stdin

Checking if data exists in the stdin buffer via an ioctl is
unreliable. Allow a user to pass '-' to force stdin parsing.
This provides a fix that will allow "no interfaces" to still
mean "dump all interfaces".

Fixes #285

13 months agoconfigure: add --enable-ntp
Roy Marples [Sat, 15 Jun 2024 13:02:30 +0000 (14:02 +0100)] 
configure: add --enable-ntp

It just uncomments the option to request ntp_servers in dhcpcd.conf.
Fixes #331.

14 months agoRelease dhcpcd-10.0.8 v10.0.8
Roy Marples [Fri, 24 May 2024 16:01:54 +0000 (17:01 +0100)] 
Release dhcpcd-10.0.8

14 months agoFix compile for builds without ARP
Roy Marples [Fri, 24 May 2024 15:54:24 +0000 (15:54 +0000)] 
Fix compile for builds without ARP

14 months agoconfigure: fix the closefrom test
Roy Marples [Fri, 24 May 2024 12:23:37 +0000 (13:23 +0100)] 
configure: fix the closefrom test

Fixes #327.

14 months agoSpell ADVERTISEMENT correctly.
Roy Marples [Fri, 24 May 2024 11:59:32 +0000 (12:59 +0100)] 
Spell ADVERTISEMENT correctly.

Fixes #326

14 months agoRelease dhcpcd-10.0.7 v10.0.7
Roy Marples [Fri, 24 May 2024 10:41:54 +0000 (11:41 +0100)] 
Release dhcpcd-10.0.7

14 months agoDHCP: use request_time, fallback_time and ipv4ll_time
Roy Marples [Fri, 24 May 2024 10:30:29 +0000 (10:30 +0000)] 
DHCP: use request_time, fallback_time and ipv4ll_time

Rather than reboot time.

This allows reboot time of zero to skip the using old leases
while still allowing REQUESTs to gracefully fallback to DISCOVER.

request_time has a default of 180 seconds to mirror the DHCPv6
equivalent.
fallback_time and ipv4_ll time have a default of 5 seconds
to mirror the default reboot time.

Fixes #325 and affects #255.

14 months agoDHCP6: Wait for IRT to elapse before requesting advertisments
Roy Marples [Fri, 17 May 2024 22:12:26 +0000 (22:12 +0000)] 
DHCP6: Wait for IRT to elapse before requesting advertisments

RFC 8415 15 and 18.2.1 list this as a MUST.

Fixes #317.

14 months agohooks/30-hostname: Exit with 0 if setting hostname is not needed
Benjamin Drung [Tue, 7 May 2024 09:20:04 +0000 (11:20 +0200)] 
hooks/30-hostname: Exit with 0 if setting hostname is not needed

If the hostname is already set before dhcpcd is started, `need_hostname`
will hit the "No old hostname" case and will call `false` to return 1.
`set_hostname` will return with the same return value. Then
`30-hostname` will exit with the same exit value:

```
dhcpcd-10.0.6 starting
dev: loaded udev
DUID 00:03:00:01:3c:97:0e:e9:32:3c
enp0s25: IAID 0e:e9:32:3c
enp0s25: soliciting a DHCP lease
enp0s25: offered 192.168.3.61 from 192.168.1.7
enp0s25: ignoring offer of 192.168.3.61 from 192.168.1.8
enp0s25: probing address 192.168.3.61/20
enp0s25: leased 192.168.3.61 for 3600 seconds
enp0s25: adding route to 192.168.0.0/20
enp0s25: adding default route via 192.168.1.1
script_status: /usr/lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 1
exiting due to oneshot
dhcpcd exited
```

Return with value 0 in case setting the hostname is not needed.

Bug-Ubuntu: https://launchpad.net/bugs/2064926
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
14 months agoDHCPv6: Don't re-INFORM if the RA changes
Roy Marples [Sat, 4 May 2024 22:33:11 +0000 (23:33 +0100)] 
DHCPv6: Don't re-INFORM if the RA changes

RFC 8415 21.23
If the Reply to an Information-request message does not contain this
option, the client MUST behave as if the option with the value
IRT_DEFAULT was provided.

So we should not be influenced by only the RA changing the pl/vl
times of it's addresses.

14 months agoprivsep: Reduce fd use
Roy Marples [Sat, 4 May 2024 11:33:24 +0000 (12:33 +0100)] 
privsep: Reduce fd use

On start close all FD's above stderr.
Close some fd's we don't need in processes spawned from priv.
Ensure we init some FD's to -1 to ensure we don't close stdin.
If DEBUG_FD is defined, we log FD's opened by pid.
Audit process FD usage and document it so I don't forget it.

Fixes #316.

14 months agoAdd compat support for closefrom cribbed from libbsd
Roy Marples [Sat, 20 Apr 2024 19:06:22 +0000 (20:06 +0100)] 
Add compat support for closefrom cribbed from libbsd

We had compat support in older dhcpcd but we want it faster
when linux supports faster, because, you know, fast.

15 months agodhcpcd: Only drop/release address family specified when given
Roy Marples [Sat, 20 Apr 2024 13:48:10 +0000 (13:48 +0000)] 
dhcpcd: Only drop/release address family specified when given

Fixes #311

15 months agoFix time_offset to be int to match RFC-2132
Colin McInnes [Fri, 26 Apr 2024 18:03:00 +0000 (12:03 -0600)] 
Fix time_offset to be int to match RFC-2132

https://datatracker.ietf.org/doc/html/rfc2132#section-3.4

time_offset (dhcp v4 option 2) should be int32, not uint32, as it can
indicate a time offset east (positive) or west (negative) of zero
meridian.

15 months agohooks: stop wpa_supplicant on STOPPED
Roy Marples [Sat, 13 Apr 2024 10:16:58 +0000 (11:16 +0100)] 
hooks: stop wpa_supplicant on STOPPED

Taken from Void Linux package

15 months agolinux: modern kernels can create stable private addresses
Roy Marples [Mon, 8 Apr 2024 08:30:03 +0000 (09:30 +0100)] 
linux: modern kernels can create stable private addresses

Just improve the comment.
Closes #301

15 months agoRespect IPV6_PREFERRED_ONLY flag on DHS_NONE state
Taoyu Li [Tue, 12 Mar 2024 02:38:28 +0000 (11:38 +0900)] 
Respect IPV6_PREFERRED_ONLY flag on DHS_NONE state

Current IPv6_PREFERRED_ONLY (option 108) handling code is only effective
when current state is DHS_DISCOVER and DHS_REBOOT. However, when we
receive multiple ACKs upon our REQUEST, the first ACK will trigger the
use_v6only code path and dhcp_drop() us into DHS_NONE state, as a result
the option 108 on the second ACK won't be handled correctly and we'll
bind to the lease instead.

This patch fixes the issue by adding DHS_NONE as a state to respect
option 108 as well.

15 months agocompat: stub out _rs_forkhandler for compat/arc4random.c
Roy Marples [Tue, 2 Apr 2024 08:55:18 +0000 (09:55 +0100)] 
compat: stub out _rs_forkhandler for compat/arc4random.c

We need to keep the fd open at fork, but we retained the code to
handle a fork.

The original update to chacha avoided this by guarding the call
but left the code alive which produced an unused function warning
on the GitHub Ubuntu runner.
This update fixes that.

16 months agoDHCP6: Remove leading space from delegated_dhcp6_prefix
Roy Marples [Thu, 28 Mar 2024 16:50:32 +0000 (16:50 +0000)] 
DHCP6: Remove leading space from delegated_dhcp6_prefix

16 months agoadd RFC4191 support (#297)
Daniel Goertzen [Sat, 9 Mar 2024 01:27:57 +0000 (19:27 -0600)] 
add RFC4191 support (#297)

* add RFC4191 support

- handles route information options from RAs.
- refactor `sa_fromprefix()` to expose lower level functionality
- refactor `ipv6nd_rtprefix()` to be usable outside of `struct ra` context

* changes as requested by RM

- mostly minor/cosmetic changes
- functional change: "no longer a default router" warning moved to capture changes from routeinfo options

* simplify routeinfo_find/new

17 months agoDefine the Azure Endpoint and other site-specific options (#299)
Lloyd Parkes [Sun, 25 Feb 2024 12:21:12 +0000 (01:21 +1300)] 
Define the Azure Endpoint and other site-specific options (#299)

Added the azureendpoint site-specific option as an ipaddress
definition to make it easier for Azure VMs using dhcpcd to get their
WireServer endpoint address.

Added binhex definitions for all otherwise undefined site-specific
options so that site-specific hooks can use them.

17 months agoMove dhcp(v4) packet size check earlier (#295)
Petr Menšík [Fri, 16 Feb 2024 16:15:35 +0000 (17:15 +0100)] 
Move dhcp(v4) packet size check earlier (#295)

dhcp_handlebootp handled zero sized packets correctly, but
dhcp_redirect_dhcp did not have such protection. Move size check before
both of them. Size when called from dhcp_packet is checked by
is_packet_udp_bootp call. Only dhcp_recvmsg needs earlier checking to be
added.

Fixes #283

19 months agoDHCP: DECLINE address on ARP defend failure
Roy Marples [Sun, 24 Dec 2023 12:07:25 +0000 (12:07 +0000)] 
DHCP: DECLINE address on ARP defend failure

Also, drop the lease.
This should get us a new address from the DHCP server when we
re-enter DISCOVER to avoid looping on the same address and fail
again.

19 months agodhcpcd: Add support for arp persist defence (#273)
pradeep-brightsign [Thu, 21 Dec 2023 10:26:09 +0000 (10:26 +0000)] 
dhcpcd: Add support for arp persist defence (#273)

RFC 5227 recommends 3 ways to deal with address conflict detection.
a) Stop everything.
b) Defend and then stop on fail - this is what dhcpcd currently does.
c) Notify and carry on.

The current change implements the option c. A new option arp_persistdefence
has been added and when this is enabled, the a defence is attempted upon a
conflict and when that fails, an error is logged on every other conflict
within the DEFEND_INTERVAL and the current IP address is retained.

Fixes #272

19 months agoRelease dhcpcd-10.0.6 v10.0.6
Roy Marples [Mon, 18 Dec 2023 15:39:51 +0000 (15:39 +0000)] 
Release dhcpcd-10.0.6

19 months agoDHCP6: For Prefix Delegation, the - interface means no assignment
Roy Marples [Mon, 18 Dec 2023 12:22:13 +0000 (12:22 +0000)] 
DHCP6: For Prefix Delegation, the - interface means no assignment

- is an invalid interface name.
So we take this to mean don't assign the Delegated Prefix to
any interfaces.
The reject route for the Delegated Prefix is still installed.

Fixes #270

19 months agoDHCP6: Improve logging when changing IA type
Roy Marples [Mon, 18 Dec 2023 12:15:10 +0000 (12:15 +0000)] 
DHCP6: Improve logging when changing IA type

Changing from PD to IA or IA to PD can result in a diagnostic
when there is no address to confirm AND we haven't loaded
a lease.
This improves the check and no more Success errors should
be reported.

19 months agoFully configure an interface when being activated.
Roy Marples [Sun, 10 Dec 2023 07:34:19 +0000 (07:34 +0000)] 
Fully configure an interface when being activated.

We need the full configuration - for example dhcpcd.conf
might have environment options for the hooks for the interface
being activated.

Because we now guard against starting protocols with IF_ACTIVE_USER
this is safe.

Fixes #257.

19 months agoFix year
Roy Marples [Tue, 12 Dec 2023 07:13:29 +0000 (07:13 +0000)] 
Fix year

19 months agoDocument that limiting address protocol can affect signalling dhcpcd
Roy Marples [Sun, 10 Dec 2023 08:27:30 +0000 (08:27 +0000)] 
Document that limiting address protocol can affect signalling dhcpcd

Fixes #264

20 months agoFix an unused var warning for capsicum for prior
Roy Marples [Mon, 13 Nov 2023 16:05:04 +0000 (16:05 +0000)] 
Fix an unused var warning for capsicum for prior

20 months agoFix privsep builds for prior.
Roy Marples [Mon, 13 Nov 2023 15:54:50 +0000 (15:54 +0000)] 
Fix privsep builds for prior.

20 months agodhcpcd: Remove stdio callback and detach on daemonise
Roy Marples [Mon, 13 Nov 2023 10:29:58 +0000 (10:29 +0000)] 
dhcpcd: Remove stdio callback and detach on daemonise

For some reason, the stdio callback is extremely flaky on
*some* Linux based distributions making it very hard to debug some
things.
Removing it is fine because we now enforce that we have file descriptors
for stdin, stdout and stdrr on launch and dup them to /dev/null on daemonise.

It's also interesting to see behavioural differences between
some socketpair implementations that emit a HANGUP and some don't.

As such, we now close the fork socket on daemonise once more AND
in the fork_cb depending on if we hangup or read zero first.

Fixes #262

20 months agocontrol: Abort control recv path on hangup
Roy Marples [Mon, 13 Nov 2023 10:24:15 +0000 (10:24 +0000)] 
control: Abort control recv path on hangup

This fixes a crash when we try and re-use it in another function.

20 months agodhcpcd: Detach from launcher before stopping root process
Roy Marples [Sun, 12 Nov 2023 12:16:53 +0000 (12:16 +0000)] 
dhcpcd: Detach from launcher before stopping root process

This fixes non privsep builds where the launcher reports dhcpcd
hungup. Unsure why this happens, but it should not be a problem.

While here, shutdown has no effect on non STREAM sockets and
remove the silly error logging in fork_cb that we read an
error. We already printed the error so this makes no sense.

Hopefully fixes #262.

20 months agocontrol: Fix hangup for non privsep builds
Roy Marples [Sun, 12 Nov 2023 11:30:01 +0000 (11:30 +0000)] 
control: Fix hangup for non privsep builds

Fix related to #262.

20 months agoRelease dhcpcd-10.0.5 v10.0.5
Roy Marples [Fri, 10 Nov 2023 14:25:12 +0000 (14:25 +0000)] 
Release dhcpcd-10.0.5

20 months agoprivsep: Note that unveil(2) is not needed
Roy Marples [Fri, 10 Nov 2023 12:02:19 +0000 (12:02 +0000)] 
privsep: Note that unveil(2) is not needed

As we are in a chroot.
https://www.mail-archive.com/misc@openbsd.org/msg171664.html

20 months agoprivsep: Allow dup3 on Linux
Roy Marples [Thu, 9 Nov 2023 09:21:20 +0000 (09:21 +0000)] 
privsep: Allow dup3 on Linux

It seems some libc will really call dup3 rather than dup2.
Another fix for #260.

20 months agodev: Don't fail to start if we cannot open the dev plugin path
Roy Marples [Wed, 8 Nov 2023 14:27:36 +0000 (14:27 +0000)] 
dev: Don't fail to start if we cannot open the dev plugin path

We accidently returned stdin fd in this case - return -1 instead.

20 months agodhcpcd: Close fork_fd on hangup
Roy Marples [Wed, 8 Nov 2023 11:09:52 +0000 (11:09 +0000)] 
dhcpcd: Close fork_fd on hangup

Closing it early results in zero length reads in some situations.
Logging that we forked via the launcher process also make more sense
and allows us to use log* functions.

While here, handle error condtions better by forcing a return
rather than handling an invalid state.

Fixes #260.

20 months agoconfigure: guard config.h with #ifdef CONFIG_H
Roy Marples [Wed, 8 Nov 2023 10:10:35 +0000 (10:10 +0000)] 
configure: guard config.h with #ifdef CONFIG_H

Rename CONFIG_H guard in defs.h to DEFS_H
This avoids a redeclaration issue on DragonFly.

21 months agoIPv4LL: Don't start if already started
Roy Marples [Mon, 23 Oct 2023 15:25:13 +0000 (15:25 +0000)] 
IPv4LL: Don't start if already started

It's just pointless noise.
A follow-on fix for #255.

21 months agoDHCP: re-enter DISCOVER phase if server doesn't reply to our REQUEST
Roy Marples [Mon, 23 Oct 2023 15:24:00 +0000 (15:24 +0000)] 
DHCP: re-enter DISCOVER phase if server doesn't reply to our REQUEST

Use the reboot timeout as per the initial DISCOVER timeout.

Fixes #255

21 months agoExpose memset_s on FreeBSD
Roy Marples [Mon, 23 Oct 2023 14:39:20 +0000 (15:39 +0100)] 
Expose memset_s on FreeBSD

21 months agoFix tests or #252.
Roy Marples [Mon, 23 Oct 2023 14:31:02 +0000 (15:31 +0100)] 
Fix tests or #252.