Commit Graph

1689 Commits

Author SHA1 Message Date
spoljak-ent
371c7c69bc
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>
2024-11-07 13:15:49 +00:00
Roy Marples
fd2f663416 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.
2024-10-31 10:40:46 +00:00
Ken Simon
e354743c4a
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
2024-10-29 23:11:54 +00:00
Colin McInnes
550c2bb5da
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>
2024-10-29 15:30:59 +00:00
Jon Franklin
1b573da6cd
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>
2024-10-29 07:53:51 +00:00
Scott Shambarger
fa4e1dd574
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.
2024-10-29 07:52:45 +00:00
Roy Marples
c4c757f05c IPv6: Improve comments on prior global for default route change 2024-10-14 18:03:18 +01:00
Jon Franklin
d97fe0281a
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.
2024-10-14 13:58:24 +01:00
Roy Marples
c1d1a885ae 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.
2024-10-14 10:56:18 +01:00
Roy Marples
d4d3b115c1 DHCP6: add preference as a defined option 2024-10-11 18:16:38 +01:00
jvfranklin
0215f9b0fe
Fix help text formatting (#379) 2024-10-10 14:52:49 +01:00
Roy Marples
8ef970d172 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.
2024-10-10 14:19:46 +01:00
Diego Santa cruz
dc9cbc3e56
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>
2024-10-10 11:45:34 +01:00
Roy Marples
d6c8537360 IPv6: Mark Route Information Routes as from RA 2024-10-10 11:10:11 +01:00
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