]> git.ipfire.org Git - thirdparty/dhcpcd.git/log
thirdparty/dhcpcd.git
5 months agoDHCP: when ifa sees the bound address, always add it to state
Roy Marples [Wed, 16 Oct 2024 09:04:57 +0000 (10:04 +0100)] 
DHCP: when ifa sees the bound address, always add it to state

This should fix dhcpcd sending the correct DHCP message type
when entering the RENEW or REBIND state.

Fixes #355.

Co-authored-by: Zikai Chen <chenzikai@google.com>
5 months agoIPv6: Abort ND when roaming
Roy Marples [Fri, 7 Feb 2025 12:08:31 +0000 (12:08 +0000)] 
IPv6: Abort ND when roaming

5 months agoDHCP6: Fix --rebind on the control socket to really rebind
Roy Marples [Fri, 7 Feb 2025 12:04:43 +0000 (12:04 +0000)] 
DHCP6: Fix --rebind on the control socket to really rebind

Rather than start a REBIND and then change straight to CONFIRM.
Fixes #437.

5 months agoBSD: Improve NEWADDR == IFF_UP handling
Roy Marples [Fri, 7 Feb 2025 11:47:01 +0000 (11:47 +0000)] 
BSD: Improve NEWADDR == IFF_UP handling

On BSD when an address is added, the interface is automatically
brought up.
We can detect this by RTM_NEWADDR, but that lacks the IFF_UP flag.
We really want to stay in sync with RTM messages for flags, but
here we need to check the interface for IFF_UP if we think it's
not there. Only set that.

This fixes NEWADDR announcements for state transitions when
the interface is currently down.

5 months agoAlways send req for InfoRefreshTime option on Inform-Req (#446)
Colin McInnes [Wed, 5 Feb 2025 19:38:55 +0000 (13:38 -0600)] 
Always send req for InfoRefreshTime option on Inform-Req (#446)

RFC8415 says client must always request Information Request refresh time
option 32.
Client has other logic for handling if server does not include this in
the reply.

Resolves #445.

5 months agoDHCP: shrink code a little
Roy Marples [Wed, 5 Feb 2025 18:04:00 +0000 (18:04 +0000)] 
DHCP: shrink code a little

5 months agoprivsep: ASAN now works
Roy Marples [Wed, 5 Feb 2025 18:01:34 +0000 (18:01 +0000)] 
privsep: ASAN now works

On Linux at least, Fedora-41 tested.
`./configure --sanitize` sets it all up.

5 months agoUpdate route if lifetime needs changing (#441)
Colin McInnes [Wed, 5 Feb 2025 14:06:10 +0000 (08:06 -0600)] 
Update route if lifetime needs changing (#441)

Everything about IPv6 is lifetime, not expiry.
Only linux routes have an expiry.

OK, this is not consistent at all!
In the kernel RTA_EXPIRES is only set for IPv4 multicast routes
when emitting route changes and only read for IPv6 routes when
userland makes route changes.
We cannot set this for non IPv6 routes currently.

To make it worse, we set a UINT32 for IPv6 routes but read a
UINT64 for IPv4 multicast routes.

To make this even more totally bonkers, the expiry we set for
the IPv6 route can be read back via RTA_CACHEINE rta_expires
but we need to convert to divide it by hz.

Now we can read kernel route lifetime correctly, we can compare this to what we think it should be when building the routing table (allowing for some deviation due to processing time) and update if needed.

Fixes #428.

5 months agoprivsep: Exit cleanly when built for address sanitization on Linux
Roy Marples [Wed, 5 Feb 2025 13:35:49 +0000 (13:35 +0000)] 
privsep: Exit cleanly when built for address sanitization on Linux

5 months agoFix using multiple enterprise IDs with vendclass (Option 124 DHCP / Option 16 DHCPv6)
Stipe [Sat, 18 Jan 2025 11:46:20 +0000 (12:46 +0100)] 
Fix using multiple enterprise IDs with vendclass (Option 124 DHCP / Option 16 DHCPv6)

Fixes #328

5 months agoIPv6: Use lifetime_left function to reduce code size
Roy Marples [Wed, 15 Jan 2025 20:30:24 +0000 (20:30 +0000)] 
IPv6: Use lifetime_left function to reduce code size

No functional change intended.

5 months agoBSD: FreeBSD allows RTA_IFP correctly.
Roy Marples [Wed, 15 Jan 2025 19:06:52 +0000 (19:06 +0000)] 
BSD: FreeBSD allows RTA_IFP correctly.

Not that it allows the same IPv6 address on different interfaces
on the same network still, but that's a FreeBSD issue to fix later.

The last for #407

5 months agoBSD: Note that to replicate prior we can't have a default route
Roy Marples [Wed, 15 Jan 2025 18:51:46 +0000 (18:51 +0000)] 
BSD: Note that to replicate prior we can't have a default route

Add a comment for #425

5 months agorevert e3c5de1 (#425)
philomathic_life [Wed, 15 Jan 2025 10:30:03 +0000 (10:30 +0000)] 
revert e3c5de1 (#425)

5 months agoAdd route lifetime from Router Advertisement (#429)
Colin McInnes [Wed, 15 Jan 2025 10:29:14 +0000 (04:29 -0600)] 
Add route lifetime from Router Advertisement (#429)

Currently this is only for Linux and is fairly cosmetic as dhcpcd will
clean up expired routes itself as other OS's don't support route lifetimes.

7 months agoExit the timesyncd hook if not on systemd and not executable (#398) (#403)
Martin-Éric RACINE [Sun, 8 Dec 2024 09:49:44 +0000 (11:49 +0200)] 
Exit the timesyncd hook if not on systemd and not executable (#398) (#403)

Exit the timesyncd hook immediately if not running on a systemd host AND timesyncd is not executable.

7 months agolinux: Allow the __NR_rt_sigprocmask syscall
Scott Shambarger [Sat, 7 Dec 2024 16:37:28 +0000 (16:37 +0000)] 
linux: Allow the __NR_rt_sigprocmask syscall

Fixes recent glibc changes to getrandom() used by arc4random().
Fixes #421.

7 months agoIPv6: Discard NA packets with a zero length option
Roy Marples [Sat, 7 Dec 2024 10:25:44 +0000 (10:25 +0000)] 
IPv6: Discard NA packets with a zero length option

As per RFC 4861 4.6.

Fixes #415.

7 months agoDHCP: reduce buflen by 2 when creating a new RFC 3396 option
Billie Alsup [Sat, 7 Dec 2024 07:42:38 +0000 (07:42 +0000)] 
DHCP: reduce buflen by 2 when creating a new RFC 3396 option

Fixes #418 and potential buffer overflow.

8 months agoDHCPv6: Add support for sending Option 17 (VSIO) (#383) 378/head
spoljak-ent [Thu, 7 Nov 2024 13:15:49 +0000 (14:15 +0100)] 
DHCPv6: Add support for sending Option 17 (VSIO) (#383)

* DHCP: Add support for sending DHCP option 125 and DHCPv6 Option 17 (VSIO)

Note wireshark doesn't decode option 125 correctly when the it needs to be split into more options if it exceeds 255 bytes.
---------

Signed-off-by: Stipe Poljak (EXT) <stipe.poljak.ext@ericsson.com>
Co-authored-by: Roy Marples <roy@marples.name>
8 months agologerr: use LOG_NDELAY for openlog
Roy Marples [Thu, 31 Oct 2024 10:40:46 +0000 (10:40 +0000)] 
logerr: use LOG_NDELAY for openlog

This ensures openlog gets a fd so logging of errors can occur
within privsep where no log was written before entering privsep.
Also ensures that closelog does not close -1 on some platforms
where no logging took place.

8 months agoIPv6: Avoid uninitialized ifp state when adding address (#395)
Ken Simon [Tue, 29 Oct 2024 23:11:54 +0000 (19:11 -0400)] 
IPv6: Avoid uninitialized ifp state when adding address (#395)

In certain instances, `ifp->if_data[IF_DATA_IPV6]` was not yet
initialized when ipv6_addaddr adds the address to the state, and a
segfault would ensue. Mitigate this by ensuring the state is initialized
when adding the addresses.

fixes #394

8 months agoDon't set RLIMIT_FSIZE when dumping lease (#389)
Colin McInnes [Tue, 29 Oct 2024 15:30:59 +0000 (09:30 -0600)] 
Don't set RLIMIT_FSIZE when dumping lease (#389)

Check if output is a tty
If dumping lease, check stdout otherwise check stderr.

---------

Co-authored-by: Roy Marples <roy@marples.name>
8 months agoDHCP6: lastlease behavior after Confirm non-response (#387)
Jon Franklin [Tue, 29 Oct 2024 07:53:51 +0000 (02:53 -0500)] 
DHCP6: lastlease behavior after Confirm non-response (#387)

If lastlease is enabled, and dhcpcd is unable to confirm its prior
lease, after timeout, bind the lease and move to the REBIND state.
Confine lastlease behavior to the CONFIRM and REBIND states.

Co-authored-by: Jon Franklin <jon_franklin@dell.com>
8 months agolinux: ignore source-based routes (#372)
Scott Shambarger [Tue, 29 Oct 2024 07:52:45 +0000 (00:52 -0700)] 
linux: ignore source-based routes (#372)

Since source-based routes aren't used by dhcpcd, it's best if they
are ignored so that they aren't confused with default routes.

8 months agoIPv6: Improve comments on prior global for default route change
Roy Marples [Mon, 14 Oct 2024 17:03:18 +0000 (18:03 +0100)] 
IPv6: Improve comments on prior global for default route change

8 months agoApply lastlease behavior to DHCPv6 (#384)
Jon Franklin [Mon, 14 Oct 2024 12:58:24 +0000 (07:58 -0500)] 
Apply lastlease behavior to DHCPv6 (#384)

If no response is received to Confirm messages, instead of failing, go
ahead and use the lease, as recommended by RFC 8415 18.2.3.

8 months agoIPv6: allow any global address for default route
Roy Marples [Mon, 14 Oct 2024 09:48:23 +0000 (10:48 +0100)] 
IPv6: allow any global address for default route

Regardless if we are a router or not.
BSD IPv6 source address selection does really matter for this.

This fixes FreeBSD systes where the forwarding sysctl is set
by the routing script which starts late in the day where
dhcpcd is already running and won't get the default route applied
until another RA comes in which could be a while.

9 months agoDHCP6: add preference as a defined option
Roy Marples [Fri, 11 Oct 2024 17:16:26 +0000 (18:16 +0100)] 
DHCP6: add preference as a defined option

9 months agoFix help text formatting (#379)
jvfranklin [Thu, 10 Oct 2024 13:52:49 +0000 (08:52 -0500)] 
Fix help text formatting (#379)

9 months agolinux: Support old kernels by not including linux/if.h
Roy Marples [Thu, 10 Oct 2024 13:19:46 +0000 (14:19 +0100)] 
linux: Support old kernels by not including linux/if.h

I wish the linux team used #defines rather than enums, but heh ho.
Ensure we can test IFF_LOWER_UP, IFF_DORMANT and IFA_FLAGS
based on nearest matching #defines available when the respective
feature was comitted.

Fixes #373.

9 months agohooks: Document if_configured
Roy Marples [Thu, 10 Oct 2024 10:59:04 +0000 (11:59 +0100)] 
hooks: Document if_configured

Fixes #353

9 months agodhcpcd: stdout output sometimes empty when redirected to a file (#364)
Diego Santa cruz [Thu, 10 Oct 2024 10:45:34 +0000 (12:45 +0200)] 
dhcpcd: stdout output sometimes empty when redirected to a file (#364)

Running dhpcd --dumplease with input from stdin and redirecting stdout
to a file outputs nothing to the output. The reason is that printf /
fprintf is used to write the output but it is not explicitly flushed
when done, or before exiting, and stdout to files is fully buffered by
default while stdout to terminals is line buffered by default.

This adds calls to fflush() at the end of dhcp_print_option_encoding()
and script_dump(), plus one just before exiting dhcpcd.

Signed-off-by: Diego Santa Cruz <diego.santacruz@spinetix.com>
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

9 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>
9 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

10 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.

10 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.

10 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

10 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.

10 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

10 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

10 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

10 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!

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

10 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.

11 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

11 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>
11 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.

12 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

12 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.

12 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.

12 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.

12 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.

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

12 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.

12 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

12 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.

12 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.

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

12 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

12 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.

13 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

13 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

13 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.

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

Fixes #326

13 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

13 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.

13 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.

13 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.

14 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