Skip to content

Commit

Permalink
DHCP: DECLINE address on ARP defend failure
Browse files Browse the repository at this point in the history
Also, drop the lease.
This should get us a new address from the DHCP server when we
re-enter DISCOVER to avoid looping on the same address and fail
again.
  • Loading branch information
rsmarples committed Dec 24, 2023
1 parent e65e82a commit 8ab7ca1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,11 @@ dhcp_expire(void *arg)
static void
dhcp_decline(struct interface *ifp)
{
struct dhcp_state *state = D_STATE(ifp);

// Set the expired state so we send over BPF as this could be
// an address defence failure.
state->added |= STATE_EXPIRED;
send_message(ifp, DHCP_DECLINE, NULL);
}
#endif
Expand Down Expand Up @@ -2098,8 +2102,12 @@ static void
dhcp_arp_defend_failed(struct arp_state *astate)
{
struct interface *ifp = astate->iface;
struct dhcp_state *state = D_STATE(ifp);

if (!(ifp->options->options & (DHCPCD_INFORM | DHCPCD_STATIC)))
dhcp_decline(ifp);
dhcp_drop(ifp, "EXPIRED");
dhcp_unlink(ifp->ctx, state->leasefile);
dhcp_start1(ifp);
}
#endif
Expand Down

0 comments on commit 8ab7ca1

Please sign in to comment.