changeset 2199:bb26f6bc07fc draft

Fix NAK backoff
author Roy Marples <roy@marples.name>
date Thu, 12 Dec 2013 10:24:14 +0000
parents a27494b93e8e
children bdc70c92e7a1
files dhcp.c
diffstat 1 files changed, 6 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp.c	Tue Dec 10 13:15:19 2013 +0000
+++ b/dhcp.c	Thu Dec 12 10:24:14 2013 +0000
@@ -1607,20 +1607,13 @@
 	struct interface *ifp = arg;
 	struct dhcp_state *state = D_STATE(ifp);
 
-	state->interval = 0;
-	if (state->addr.s_addr == 0) {
-		/* We failed to reboot, so enter discovery. */
-		state->lease.addr.s_addr = 0;
-		dhcp_discover(ifp);
-		return;
-	}
-
 	syslog(LOG_ERR, "%s: DHCP lease expired", ifp->name);
 	eloop_timeout_delete(NULL, ifp);
 	dhcp_drop(ifp, "EXPIRE");
 	unlink(state->leasefile);
-	if (ifp->carrier != LINK_DOWN)
-		start_interface(ifp);
+
+	state->interval = 0;
+	dhcp_discover(ifp);
 }
 
 void
@@ -2064,7 +2057,7 @@
 }
 
 static void
-dhcp_handle(struct interface *iface, struct dhcp_message **dhcpp,
+dhcp_handledhcp(struct interface *iface, struct dhcp_message **dhcpp,
     const struct in_addr *from)
 {
 	struct dhcp_state *state = D_STATE(iface);
@@ -2098,7 +2091,7 @@
 		}
 		dhcp_close(iface);
 		/* If we constantly get NAKS then we should slowly back off */
-		eloop_timeout_add_sec(state->nakoff, start_interface, iface);
+		eloop_timeout_add_sec(state->nakoff, dhcp_discover, iface);
 		if (state->nakoff == 0)
 			state->nakoff = 1;
 		else {
@@ -2370,7 +2363,7 @@
 			    hwaddr_ntoa(dhcp->chaddr, sizeof(dhcp->chaddr)));
 			continue;
 		}
-		dhcp_handle(iface, &dhcp, &from);
+		dhcp_handledhcp(iface, &dhcp, &from);
 		if (state->raw_fd == -1)
 			break;
 	}