From: Roy Marples Date: Wed, 14 Nov 2012 10:10:57 +0000 (+0000) Subject: Restart the interface immediately after a NAK instead of X-Git-Tag: v5.6.3~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0811b4f2ad00bf57c34d98f8c4debc4737ed1bd9;p=thirdparty%2Fdhcpcd.git Restart the interface immediately after a NAK instead of waiting one second. --- diff --git a/dhcpcd.c b/dhcpcd.c index 9d300792..f5f51dd2 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -530,9 +530,13 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp, const struct i 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 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp, const struct i } /* 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 @@ init_state(struct interface *iface, int argc, char **argv) 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 @@ handle_hwaddr(const char *ifname, unsigned char *hwaddr, size_t hwlen) ifp->name, hwaddr_ntoa(ifp->hwaddr, ifp->hwlen)); ifp->state->interval = 0; - ifp->state->nakoff = 1; + ifp->state->nakoff = 0; start_interface(ifp); } }