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.
Tags: #dhcpcd
Differential Revision: https://dev.marples.name/D121
int n;
state = D_CSTATE(ifp);
- if (state == NULL || state->state != DHS_BOUND)
+ if (state == NULL || state->state != DHS_BOUND || !state->added)
return 0;
+ /* An address does have to exist. */
+ assert(state->addr);
+
TAILQ_INIT(&nroutes);
/* First, add a subnet route. */