changeset 1712:7061e34b24bf draft

Restart the interface immediately after a NAK instead of waiting one second.
author Roy Marples <roy@marples.name>
date Sat, 22 Sep 2012 13:28:34 +0000
parents e2693c48bd70
children 602fe1248faf
files dhcpcd.c
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.c	Mon Sep 03 08:49:14 2012 +0000
+++ b/dhcpcd.c	Sat Sep 22 13:28:34 2012 +0000
@@ -530,9 +530,13 @@
 		close_sockets(iface);
 		/* If we constantly get NAKS then we should slowly back off */
 		add_timeout_sec(state->nakoff, start_interface, iface);
-		state->nakoff *= 2;
-		if (state->nakoff > NAKOFF_MAX)
-			state->nakoff = NAKOFF_MAX;
+		if (state->nakoff == 0)
+			state->nakoff = 1;
+		else {
+			state->nakoff *= 2;
+			if (state->nakoff > NAKOFF_MAX)
+				state->nakoff = NAKOFF_MAX;
+		}
 		return;
 	}
 
@@ -561,7 +565,7 @@
 	}
 
 	/* No NAK, so reset the backoff */
-	state->nakoff = 1;
+	state->nakoff = 0;
 
 	if ((type == 0 || type == DHCP_OFFER) &&
 	    state->state == DHS_DISCOVER)
@@ -1257,7 +1261,7 @@
 
 	ifs->state = DHS_INIT;
 	ifs->reason = "PREINIT";
-	ifs->nakoff = 1;
+	ifs->nakoff = 0;
 	configure_interface(iface, argc, argv);
 	if (!(options & DHCPCD_TEST))
 		run_script(iface);
@@ -1365,7 +1369,7 @@
 				    ifp->name,
 		    		    hwaddr_ntoa(ifp->hwaddr, ifp->hwlen));
 				ifp->state->interval = 0;
-				ifp->state->nakoff = 1;
+				ifp->state->nakoff = 0;
 				start_interface(ifp);
 			}
 		}