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