5796 Commits

Author SHA1 Message Date
Roy Marples
83eafa0975 route: Routes may not have an interface assinged
As such, we cannot access dhcpcd_ctx so we can't use the free
route list.
Fixes #571.
2025-12-28 12:17:45 +00:00
Roy Marples
117742d755
options: Ensure ldop is not NULL dereferenced (#568)
ldop itself cannot be non NULL as it points to the location.
but *ldop CAN be NULL.

Fixes #567.
2025-12-21 08:31:52 +00:00
Roy Marples
2de751b369
IPv4: Ignore DHCP state when building routes (#557)
* IPv4: Ignore DHCP state when building routes

As this will change periodically.
We only care if the state (address) has been added.

Fixes #440 thanks to JognSmit.
2025-12-04 09:26:57 +00:00
Colin McInnes
a16c625bb9
Fix fallback_time option (#562)
Fallback time option was updating request_time instead of fallback_time.

Resolves #561
2025-12-03 09:41:04 +00:00
Roy Marples
9c48f4c7dd DHCP6: Don't restart INFORM timers on subsequent failure. 2025-11-18 12:08:26 +00:00
Roy Marples
385ff246cb Release dhcpcd-10.3.0 v10.3.0 2025-11-14 15:38:04 +00:00
Roy Marples
4d41f7d752 eloop: remove epoll_pwait2 support
It's just not there on musl, detecting it at compile time
is hit and miss on glibc due to mismatched kernel headers.
2025-11-14 15:34:51 +00:00
Roy Marples
8880b8afca eloop: Simplify ppoll a little 2025-11-14 15:05:39 +00:00
Roy Marples
3d3a3847fe install queue.h 2025-11-14 14:52:33 +00:00
Roy Marples
658f69dc71 eloop: Work with fortified compilers 2025-11-14 14:52:19 +00:00
Roy Marples
69fa922fa5 Adapt to new eloop. 2025-11-14 13:08:58 +00:00
Roy Marples
95f91f5ba1 eloop: Replace the inner eloop concept with waitfd
This is what we really want and saves the massive headache of
managing two loops.
2025-11-14 13:08:21 +00:00
Roy Marples
b6671a7757 BSD: Reject routes are not cloned/connected routes
Likewise, if we change from a reject to a non reject route
we need to remove it rather than changing it as some BSD
kernels preserve the RTF_GATEWAY flag.
2025-11-13 14:40:02 +00:00
Roy Marples
49d21813a3 script: STOP should not set if_down=true 2025-11-13 11:20:18 +00:00
Roy Marples
7efcb063cd eloop: formatting 2025-11-11 13:18:39 +00:00
Roy Marples
665b573d47
Protocols will notify when dhcpcd can exit (#536)
* Protocols will notify when dhcpcd can exit

DHCPv6 RELEASE requires the addresses to be dropped before
a RELEASE message is sent.
We now wait for an acknowledgement or a timeout before notifying
that DHCPv6 has stopped for the interface.

DHCPv4 RELEASE is the other way around, there is no acknowledgement.
So we wait for 1 second after sending the message before removing
the address and notifying DHCP has stopped for the interface.

If we are not releasing then we notify dhcpcd that the protocol has
stopped right away when we drop the lease.

dhcpcd will exit once there are no running protocols for the
interfaces.

Fixes #513.
Hopefully #535, #519 and #509 as well.

Co-authored-by: Sime Zupanovic (EXT) <sime.zupanovic.ext@ericsson.com>
2025-11-11 13:13:03 +00:00
Roy Marples
b573b9d87b eloop: Try and fix clean compile on all BSD 2025-11-11 11:32:12 +00:00
Roy Marples
0c26b5715d eloop: Fix epoll for prior 2025-11-11 11:20:31 +00:00
Roy Marples
be3fd20f7c eloop: Simplify kqueue implementation
Easier to read, reduces binary size at a small cost of
more kevents when forking and keeping fd's which
is acceptable.
2025-11-11 11:07:21 +00:00
Roy Marples
2059c208ae dhcpcd: log error on eloop_signal_set_cb failure 2025-11-11 10:36:36 +00:00
Roy Marples
c8d32f001b privsep: we might not have a root process 2025-11-11 07:21:09 +00:00
Roy Marples
9912225a21 eloop: Fix kqueue on FreeBSD 2025-11-10 22:22:02 +00:00
Roy Marples
20cee56872 compat: Fix sha256 on Dragonfly at least 2025-11-10 22:02:49 +00:00
Roy Marples
9c69fb33d0 eloop: exit all eloops when stopping on signals 2025-11-10 20:00:20 +00:00
Roy Marples
c2068c057b eloop: for kqueue and epoll, grow the receiving event list as needed. 2025-11-10 19:44:01 +00:00
Roy Marples
4c91b77920 privsep: Drain the log when the root process is exiting
So we stand a better chance of printing the exit messages.
2025-11-05 10:00:55 +00:00
Roy Marples
8abf6b4894 eloop: total events to listen to is nfds, not nevents
Only important for kqueue when there are only signals and timeouts
in play.
2025-11-03 09:44:55 +00:00
Roy Marples
0f4b283de0 NetBSD: Delete RTF_CONNECTED route when changing it.
We need to flush anything dynamically created.
2025-11-02 06:46:48 +00:00
Roy Marples
8e1b036ad2 Fix compile on Alpine linux 2025-10-31 08:18:55 +00:00
Roy Marples
e35e6c8d74 Fix eloop test 2025-10-31 07:38:38 +00:00
Roy Marples
3b187a7fcc privsep: Fix reading results from root process
Should be the final fallout from the new eloop.
2025-10-31 07:29:10 +00:00
Roy Marples
760a3d27f7 Fix compile with rbtree and queue on Linux 2025-10-31 07:28:53 +00:00
Roy Marples
da32038b02 eloop: Fix a memory leak 2025-10-31 07:27:33 +00:00
Roy Marples
d5536a344f Fix some fallout from prior 2025-10-30 19:08:32 +00:00
Roy Marples
60594cd12a Adjust for new eloop.
Needs more testing.
2025-10-30 14:09:28 +00:00
Roy Marples
c4d6af24d3 eloop: Import latest from dhcpsd
Finally have kqueue and epoll working for a multi-process
setup.
The secret sauce was that after forking the fd for polling
is invalid and as such should not be closed blindly.
2025-10-30 14:07:54 +00:00
Roy Marples
e13bfe32b9 Use rbtree from vendor
It is unexpected for this to exist on anything other than NetBSD.
2025-10-30 13:55:08 +00:00
Roy Marples
b65a54c7a6 Merge branch 'vendor/RBTREE' 2025-10-30 11:53:06 +00:00
Roy Marples
64f653bba5 Use queue.h from vendor area rather than system supplied
It just makes things easier really than working it out all the
time for differing OS's.
2025-10-30 11:35:32 +00:00
Roy Marples
f5b6f55272 Merge branch 'vendor/QUEUE' 2025-10-30 11:30:58 +00:00
Roy Marples
078c042eab Import rbtree.c v1.2 and rbtree.h v1.14 from NetBSD 2025-10-30 11:22:30 +00:00
Roy Marples
aa96ab1516 Import queue.h v1.77 from NetBSD 2025-10-30 11:19:40 +00:00
Roy Marples
6fc45c222d Add vendor area 2025-10-30 11:16:29 +00:00
Roy Marples
2e3b0e548a When stopping all interfaces at exit and releasing, remove persistance. 2025-09-30 17:19:43 +01:00
Roy Marples
6e0483302b ipv6: respect slaac hwaddr to really use the hwaddr
If the interface has one, otherwise it will fall back to using
the first ipv6 link-local address as before.
2025-09-30 13:52:33 +01:00
Roy Marples
593c0a3353 Add a .clangd file to aid lsp. 2025-09-30 09:43:04 +01:00
Roy Marples
195e8bdc38 route: Don't change them when exiting with persistence.
If an interface stops, it might affect the routing priority.
When dhcpcd is exiting we want to avoid this behaviour to keep
the system running as best as.
2025-09-30 09:42:11 +01:00
Gleb Smirnoff
b709538cbb
privsep: enforce message boundaries with MSG_EOR on our messages (#533)
privsep: enforce message boundaries with MSG_EOR on our messages

The nature of the SOCK_SEQPACKET, that privsep modules uses, is stream.
See:

https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_10_06

To guarantee that a reader will never read two messages in one read
operation, the writer shall put end of record markers.

The problem exposed itself in FreeBSD 15.0 that started to follow the
specification better than before.

Other SOCK_SEQPACKET usage considerations: a) as long as our reader
provides a receive buffer that would fit the largest message our writer
would ever send, we are good with regards to not a reading a partial
message b) as long as our writer always write full messages with one
write, we don't need use of MSG_WAITALL in reader.

Fixes #530

Co-authored-by: Roy Marples <roy@marples.name>
2025-09-30 08:54:35 +01:00
Roy Marples
6dcb1569fc ND Route Information Option prefix is optional
As the length could be zero and is RFC compliant.
Fixes #527.
2025-09-13 12:45:50 +01:00
Roy Marples
4b7065a78f DHCP: Put the message type option first
There is no ordering requirement from any RFC other than the
recommendations in RFC 7844.
But it seems some DHCP servers really want the message type as
the first option.

Fixes #522.
2025-09-02 15:40:10 +01:00