Roy Marples [Mon, 19 Mar 2018 15:39:05 +0000 (15:39 +0000)]
link: detect buffer overflow / desync and relearn interface state
It's possible for the internal kernel buffer that reports network
events to overflow.
On Linux and NetBSD* this is handled by ENOBUFS being returned
by recv(2). On OpenBSD there is a special route(4) message RTM_DESYNC.
All other OS's don't seem to report this error, so dhcpcd cannot
detect it.
* I will commit a patch to NetBSD soon for this and will request a
pullup to NetBSD-8.
Roy Marples [Sat, 10 Mar 2018 11:50:08 +0000 (11:50 +0000)]
dhcp6: deny unicast in non master mode
It seems that some DHCP6 servers or firewalls really insist on the
client sending from the correct source port.
This is the safest thing for the time being.
Roy Marples [Tue, 13 Feb 2018 10:33:06 +0000 (10:33 +0000)]
dhcp: reset interval during init
This fixes NetBSD where the lease is persisted at carrier down.
When the carrier comes back up again we need the interval
to reset to zero so that DHCP happens quicker.
Roy Marples [Fri, 2 Feb 2018 11:24:58 +0000 (11:24 +0000)]
inet6: simplify setup of kernel
Rename if_checkipv6 to if_setup_inet6 so it's more descriptive.
simpify code as we don't really care about the result.
Restore the prior behavior of not disabling kernel RA handling
if dhcpcd is not doing it.
Roy Marples [Fri, 5 Jan 2018 17:29:27 +0000 (17:29 +0000)]
eloop-bench: fix reading the last write
The last write was never read from the pipe in the run, so many
runs filled the kernel buffer causing an error which was not seen
because the pipe was blocking.
Set the pipes to non blocking and improve the exit conditions,
also ensuring the bench returns any error back.
While here add more timings and run critera.
Roy Marples [Thu, 7 Dec 2017 15:12:18 +0000 (15:12 +0000)]
dhcp: when unicasting, don't use a L2 broadcast
This relies change now relies on the kernel supporting IP_PKTINFO
to select the correct outbound interface which may not
always be the case due to routing.
Roy Marples [Tue, 14 Nov 2017 16:41:59 +0000 (16:41 +0000)]
DHCPv6: confirm lease on carrier up
On some platforms which preserve state when carrier goes down,
such as NetBSD-8, the state does not enter the CONFIRM state.
Add more logic to dhcp6_start so that we can better control this
from the various call points.
Roy Marples [Mon, 6 Nov 2017 12:15:53 +0000 (12:15 +0000)]
dhcp6: redirect message to interface with matching xid
When unicasting and receiving unicasted messages, it's possible
that the outgoing and incoming interfaces don't match where the
address and/or prefix are.
To solve this, don't dictate the outgoing interface when unicasting
and match the incoming xid to one we have sent on another interface.
Roy Marples [Wed, 25 Oct 2017 13:56:23 +0000 (14:56 +0100)]
DHCPv6: listen on all IPv6 addresses for active interface
Simplify the process of selecting addresses to listen for DHCPv6
replies on by listening on all addresses for active interfaces
when not in master mode.
Always send from a socket not bound to an address to ensure
unicast in non master mode works fine. The downside of this approach
is that we no longer send from the DHCPv6 client port, but this
seems to work fine, at least with ISC DHCPd.
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.