]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: DECLINE address on ARP defend failure
authorRoy Marples <roy@marples.name>
Sun, 24 Dec 2023 12:07:25 +0000 (12:07 +0000)
committerRoy Marples <roy@marples.name>
Sun, 24 Dec 2023 12:07:25 +0000 (12:07 +0000)
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.

src/dhcp.c

index 014ce6cfd5f99afef3a5d045f86611a6e0b038c6..a58e1db21c12047b6fa7063ec7d1647a759b5c79 100644 (file)
@@ -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
@@ -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