Roy Marples [Tue, 24 Oct 2017 22:11:15 +0000 (23:11 +0100)]
bpf: store flags in state for a better abort
There are cases when dhcp may close and open an ARP socket
during an ARP read. This means the fd will not be -1, so we need
to set BPF_EOF when closing the socket.
Roy Marples [Mon, 23 Oct 2017 23:13:09 +0000 (00:13 +0100)]
dhcp: arp announce existing address before reboot
This updates upstream ARP tables to send their ACK to the
interface we want to receive the message on and not one
which is not in use but has the same IP address.
Doing this means we no longer need to open DHCP sockets for
interfaces we're not interested in.
Roy Marples [Thu, 5 Oct 2017 07:05:08 +0000 (08:05 +0100)]
We don't actually care about the number of added routes, just
it we failed or not.
So just return 0 on success and -1 on failure to work around
a gcc check where signed int could overflow.
This should be impossible anyway due to the protocol limits of
DHCP and RA.
Roy Marples [Tue, 3 Oct 2017 14:50:27 +0000 (15:50 +0100)]
Compile eloop with config.h by default and bring in compat modules.
This allows us to build this test AND dhcpcd exactly the same,
which is important as they build eloop.o in the same place.
Roy Marples [Tue, 3 Oct 2017 11:00:52 +0000 (12:00 +0100)]
Don't special case not deleteing the IPv6 default route.
dhcpcd now manages this the same as any other route as dhcpcd is
either in charge of IPv6 or it's not.
Roy Marples [Fri, 15 Sep 2017 11:56:09 +0000 (12:56 +0100)]
arp: RFC5227 kernels need to send ARP too
Now that IP address sharing is handled with ARP announcements.
This fixes the issue where RFC5227 kernels would fail to compile
if not compiled for ARPING as well.
Roy Marples [Mon, 28 Aug 2017 22:43:19 +0000 (23:43 +0100)]
dhcp6: listen to each DHCP address for messages
Summary:
This allows dhcpcd to receive unicast DHCPv6 messages to non LL
addresses in non master mode.
Fixes T123.
Test Plan:
* Setup your DHCPv6 server to send the unicast option
* Start dhcpcd for a specific interface
* Watch it ask for confirmation and receive replies to messages
Roy Marples [Tue, 25 Jul 2017 10:43:12 +0000 (11:43 +0100)]
Persist shared IP address on interfaces.
Summary:
Send unicast DHCP messages by BPF rather than a UDP socket.
Open a BPF socket for all interfaces whether active or not.
Redirect packets to the correct interface based on xid and chaddr.
Announce the primary address via ARP when any address is added or deleted.
Remove the now redundant prefer another address code.
Fixes T126.
Test Plan:
Setup your DHCP server to assign the same address to many interfaces
on the same host.
On the host, start dhcpcd and bring up/down/activate the interfaces
in a random order.
Pinging another host on the network should be possible at all times
if any interface is up.
Roy Marples [Tue, 25 Jul 2017 10:00:44 +0000 (11:00 +0100)]
dhcp6: implement lastlease and lastleaseextend
Summary:
This has resulted in a fair churn of code, but in summary:
* TIMEDOUT state introduced
* lease binding split out from handledata
* generic fail function introduced to attempt rebind
of lastlease
* extended addresses are remembered and purged when a
lease is re-negotiated
* defaults of 0 are no longer hard coded for most timers
Fixes T128.
Test Plan:
Obtain a dhcp6 lease, kill dhcpcd and the dhcp6 server.
run with `--lastlease` and check it's applied correctly.
Also, observe timers to ensure it renews, rebinds and expires.
Do same, but now with `--lastleaseextend as well`.
Observe same timers, but it should not expire but become an
infinite lease until a new one appears.
Roy Marples [Tue, 25 Jul 2017 09:14:06 +0000 (10:14 +0100)]
dhcpcd starts inactive interfaces erroneously.
Summary: If ifp->active is not IF_ACTIVE_USER only find DHCPv6 delegations for the interface on carrier up.
Test Plan:
Allow DHCP on all interfaces, but set one interface in denyinterfaces.
Assign this interface a delegation from another interface.
This interface should not start DHCP.
Roy Marples [Thu, 6 Jul 2017 16:13:51 +0000 (17:13 +0100)]
Unset $ifsuffix for non protocol reasons
Summary:
The default was to assume unspecified reasons were DHCP.
This is bad for non protocol events such as NOCARRIER which could
cause a dhcpcd instance running IPv6 only to wipe out the DNS
records created by a separate dhcpcd instance handling IPv4.
Fixes T129.
Test Plan:
Start `dhcpcd -4 -K eth0`.
Observe that a resolvconf entry is created for eth0.dhcp.
Start `dhcpcd -6 eth0`.
Observe that a resolvconf entry is created for eth0.dhcp6.
Bring the carrier down for eth0.
Because the -4 instance is ignoring carrier, it is expected that
the eth0.dhcp resolvconf entry is preserved.
Roy Marples [Thu, 18 May 2017 13:54:16 +0000 (14:54 +0100)]
dhcp: return routes when renewing
Summary:
If we only return our routes in the BOUND state, our working
routes could be deleted if we're in the RENEWING state and another
interface applies it's routes.
Fixes T118.
Test Plan:
start dhcpcd on two interfaces and ensure both get a lease
kill the DHCP server an one interface and wait for renewal.
when one interface renews, no routes should be deleted.
Roy Marples [Sat, 24 Jun 2017 16:36:12 +0000 (17:36 +0100)]
Fix crash when creating routes for a non preferred lease.
Summary:
When dhcpcd shares the same IP address across interfaces, the
non preferred leases have the address deleted but remain in
the BOUND state.
We need to check that the address has been added, otherwise
we crash when building some routes.
Thanks to Jason A. Donenfeld <Jason@zx2c4.com> for the report.
Test Plan:
Ensure the lowest metric interface is denied in denyinterfaces.
Setup your DHCP server to share the same IP addres to all the host interfaces.
Start dhcpcd.
Activate the denied interface via `dhcpcd -n $interface`.
dhcpcd should not crash when binding the routes.
Roy Marples [Sat, 20 May 2017 12:51:41 +0000 (13:51 +0100)]
Hardware Address validation
Summary:
The all zero's and all one's hardware address are reserved.
As such, they should not be used in dhcpcd.
Likewise, Router Solicitation messages should not contain an
all zero source address option.
Fixes T119.
Test Plan:
Request IPv6RA over a PPP interface on a suitable OS which assigns
an all zero's or all one's hardware address.