Commit Graph

5651 Commits

Author SHA1 Message Date
Roy Marples
58230c23e2 IPv6: Don't set IN6_IFF_TENTATIVE when the address exists
We can only work it out when we know the address, not beforehand.
2024-10-09 11:22:00 +01:00
Roy Marples
fdeb8c7945 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.
2024-10-08 14:34:02 +01:00
Scott Shambarger
2870767a79
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.
2024-10-08 14:26:04 +01:00
Roy Marples
e3c5de14f0 BSD: Remove IPv6 sharing warning
This doesn't seem to be needed for on recent FreeBSD and OpenBSD.
2024-10-07 12:10:11 +01:00
Roy Marples
57c3506a56 Release dhcpcd-10.1.0 2024-10-04 22:22:24 +01:00
Roy Marples
9432d91efe Final fix for prior 2024-10-04 17:35:09 +01:00
Roy Marples
8cd4e07a5e Another fix for prior 2024-10-04 16:24:43 +00:00
Roy Marples
5228ee5a6d minor fix for prior 2024-10-04 17:11:26 +01:00
Roy Marples
acbac12169 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.
2024-10-04 15:36:01 +00:00
Roy Marples
dcef5d9bca 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>
2024-10-02 15:46:27 +01:00
Roy Marples
80c010a3bc linux: Only include linux/if.h if libc does not define IFF_DORMANT
Hopefully fixes #373.
2024-10-01 10:05:32 +01:00
Roy Marples
47e2a36346 Improve formatting of error 2024-10-01 09:44:25 +01:00
acst1223
005111278c
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>
2024-09-26 08:56:28 +01:00
Roy Marples
793825f70e IPv6: DNSSL is an array of domains
As per RFC 8106 section 5.2.
Fixes #367

Thanks to Scott Shambarger.
2024-09-23 14:34:15 +00:00
Roy Marples
aa1cd7e88e DHCP: Fix deleting expired leased addresses 2024-09-11 11:47:22 +01:00
Roy Marples
d0fef9f768 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.
2024-09-11 10:33:40 +01:00
Roy Marples
4f9648737c DHCP6: Fix INFO_REFRESH_TIME option
Fixes #329 thanks to jvfranklin.
2024-09-05 14:22:53 +01:00
taoyl-g
72a2628276
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."
2024-09-05 14:14:25 +01:00
Roy Marples
82e16d16bf 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.
2024-09-04 12:18:10 +01:00
Roy Marples
64627345a9 IPv6ND: Don't warn about no global addresses for default route
If we are not installing a default route.
2024-09-04 11:48:46 +01:00
Roy Marples
b22ef29e3e 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.
2024-09-04 10:51:12 +01:00
Roy Marples
ae3d1b550a IPv6: Ignore loopback address for any global consideration 2024-09-01 16:42:29 +01:00
Roy Marples
a2821d8f6a DHCP6: IPV6_AF_DELEGATEDPFX -> IPV6_AF_PFXDELEGATION
This is easier to see the difference with IPV6_AF_DELEGAGTED.
2024-08-30 15:09:17 +01:00
Roy Marples
88a93ff274 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.
2024-08-30 09:37:36 +01:00
Roy Marples
6cb9e8b74f DHCP6: Fix Prefix Delegation pltime and vltime
While here fix deleting non exteneded deprecated addresses
2024-08-29 11:13:55 +01:00
Roy Marples
82c24ee1ad 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.
2024-08-28 19:04:53 +01:00
Roy Marples
ab5ec18e75 Release dhcpcd-10.0.10 2024-08-21 16:04:53 +01:00
Roy Marples
9b123d03e9 Revert d49db34 and add a comment as to why it's needed.
Fixes #352
2024-08-21 16:02:27 +01:00
Roy Marples
257f59c267 Release dhcpcd-10.0.9 2024-08-21 11:51:59 +01:00
Roy Marples
923c9b8326 Well, changes were made in 2024! 2024-08-21 11:51:24 +01:00
Roy Marples
d49db342b1 linux: make if_getnetworknamespace static 2024-08-21 11:40:04 +01:00
Jabrwock
8ad760b9e0
Update privsep-linux.c to allow statx (#349)
Add statx to SECCOMP_ALLOW
2024-08-21 11:38:58 +01:00
Roy Marples
96d3912e33 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.
2024-08-02 09:28:34 +01:00
Roy Marples
23841dd9e0 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.
2024-08-01 23:57:39 +01:00
Roy Marples
c6a8fa1e6a 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.
2024-08-01 17:06:51 +01:00
Roy Marples
5ac1235b99
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
2024-07-29 16:17:08 +01:00
taoyl-g
9330dbb44f
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>
2024-07-25 11:50:59 +01:00
Leo Ruan
65f5692a12
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>
2024-07-25 09:37:11 +01:00
Roy Marples
fff58e65f5 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.
2024-07-09 13:39:45 +01:00
Roy Marples
896f9f8cf7 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.
2024-07-09 13:39:07 +01:00
Roy Marples
81a3d19f15 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.
2024-07-09 13:26:24 +01:00
Roy Marples
b6cbf299bc 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
2024-06-27 06:32:23 +01:00
Roy Marples
d451274d1a DHCP6: Add commentary around why we read leases
Fixes #336.
2024-06-26 14:09:41 +01:00
Roy Marples
ea10a3d887 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.
2024-06-26 12:30:42 +01:00
Roy Marples
4908d931fc 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.
2024-06-26 09:36:35 +01:00
Roy Marples
8bc7607216 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.
2024-06-25 12:08:45 +01:00
Roy Marples
410fae4e55 IPv6: make more readable (nfc) 2024-06-24 12:05:58 +01:00
Roy Marples
7ffa777c1e IPv6: Delay for LL address before delay for start
This syncs with DHCPv6 when waiting for LL.
2024-06-24 12:04:03 +01:00
Roy Marples
612dec0bc0 Fix prior patch which might also fix #333 2024-06-24 12:01:36 +01:00
Roy Marples
34d4ccbd0e 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.
2024-06-21 13:03:06 +01:00