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.
Roy Marples [Mon, 15 May 2017 12:10:17 +0000 (13:10 +0100)]
Prefix Delegation: build routes after all addresses delegated
Summary:
When addresses are delegated the routing for them needs to be
managed. But this can be done after all addresses have been
added because DaD will cause the scripts to be run shortly
after adding all of them.
The only problem with this approach is when dhcpcd is restarted
and adds a delegation which already exists. In this case,
dhcpcd will log it added the route after it ran the hook script.
This is of course incorrect because the route should already be
there and working - assuming dhcpcd is the sole changer of the route.
Fixes T117 because rebuilding the routes inside the enumeration
of interfaces may change the order of interfaces and thus break
the enumeration.
Test Plan:
Setup dhcpcd to request delegation to many interfaces.
Once delegation is assigned, drop and restore carrier on the upstream interface.
Observe dhcpcd assigns delegations to all interfaces with carriers.
Roy Marples [Mon, 24 Apr 2017 19:50:45 +0000 (20:50 +0100)]
DHCPv6: deprecate addresses on stale leases.
Summary:
When a DHCPv6 Address or Prefix Delegation is leased, it may not be renewed as a
different one could be assigned. In this situation, we should
prompt the kernel to prefer this new one by deprecating the old
one. This is achieved by setting it's pltime to zero.
Related to T114.
Test Plan:
Configure your DHCPv6 server to assign a delegation from Pool A.
Configure dhcpcd to lease a Prefix delegation and assign it
to a downstream interface.
Start dhcpcd.
Configure your DHCPv6 server to asssign a delegation from Pool B.
Down/Up the link dhcpcd is using.
dhcpcd should assign the new delegation and depreate the old
by marking it's pltime as zero.
Roy Marples [Wed, 26 Apr 2017 08:57:16 +0000 (09:57 +0100)]
IPv6: show actual address lifetimes being applied
Summary:
For IPv6, the acquisition time of the address is stored.
When adding the address during a refresh, the valid and preferred
times are decreased by the difference between the acquisition time
and the current time. This is not shown in the logs, but it should
be otherwise you could be confused by a prefix adding an address,
but it really came from a stale lease.
While here, if vltime overflows then log an error and zero it.
This effectively removes the address when it's added.
Related to T114.
Test Plan:
Configure your DHCPv6 server to lease a Prefix from Pool A.
Configure dhcpcd to request a Prefix Delegation and assign to
a downstream interface.
Start dhcpcd.
Configure your DHCPv6 server to lease a Prefix from Pool B.
Observe dhcpcd debug logs - it should note that addresses
previously assigned from group A have decreasing valid times.
Roy Marples [Tue, 2 May 2017 18:58:19 +0000 (19:58 +0100)]
DHCPv6: drop Prefix Delegations when dropping the lease.
Summary:
When dropping the lease, we should drop any Delegated Prefixes
as well, because they are from the lease.
Add a note to say if this needs to be changed, at least mark
the Delegated Prefixes as deprecated.
Fixes T114.
Test Plan:
Configure dhcpcd to request a Prefix Delegation and assign it to a downstream
interface.
Bring the interface down which dhcpcd requests the delegation from.
dhcpcd should remove the assigned delegation from the other interface.
Roy Marples [Mon, 24 Apr 2017 20:08:31 +0000 (21:08 +0100)]
prefix delegation: Remove deleted addresses from consideration
Summary:
Currently dhcpcd does not free addresses generated from stale
Prefix Delegation leases which then expire. As the address
isn't likely to come back anytime soon it should be freed.
Related to T114.
Test Plan:
Configure your DHCPv6 server to lease a Prefix from Pool A.
Configure dhcpcd to request a Prefix Delegation and assign to
a downstream interface.
Start dhcpcd.
Configure your DHCPv6 server to lease a Prefix from Pool B.
Observe dhcpcd debug logs - it should detect the kernel
removing the deleted address and not re-add it when the prefix
changes.
Roy Marples [Tue, 25 Apr 2017 19:47:53 +0000 (20:47 +0100)]
Because dhcpcd now binds to the interfaces LL address when not
running in master mode, the socket options SO_REUSEADDR and
SO_REUSEPORT can be dropped.
If there is a problem binding the socket, log an error.
Roy Marples [Tue, 11 Apr 2017 17:04:03 +0000 (18:04 +0100)]
Write syslog entries in logfile:
date tag[pid]: message
This does add a few more bytes, but it allows for the same log
analysis tools to be used.
When building SMALL, this code is removed and you just get the
message in the logfile.