From: Roy Marples Date: Fri, 12 Dec 2014 21:51:48 +0000 (+0000) Subject: Clarify timeout and reboot timeout, make it more sane. X-Git-Tag: v6.6.6~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b24c152eabe8fd97cf8ec9b82f7d6dc05461b5d0;p=thirdparty%2Fdhcpcd.git Clarify timeout and reboot timeout, make it more sane. --- diff --git a/dhcp.c b/dhcp.c index 4fd3294b..7ac49be1 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1724,27 +1724,17 @@ dhcp_discover(void *arg) struct interface *ifp = arg; struct dhcp_state *state = D_STATE(ifp); struct if_options *ifo = ifp->options; - time_t timeout = ifo->timeout; - - /* If we're rebooting then we need to shorten the normal timeout - * to ensure we try for a fallback or IPv4LL address. */ - if (state->state == DHS_REBOOT) { - if (ifo->reboot >= timeout) - timeout = 2; - else - timeout = ifo->reboot; - } state->state = DHS_DISCOVER; state->xid = dhcp_xid(ifp); eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); if (ifo->fallback) eloop_timeout_add_sec(ifp->ctx->eloop, - timeout, dhcp_fallback, ifp); + ifo->reboot, dhcp_fallback, ifp); else if (ifo->options & DHCPCD_IPV4LL && !IN_LINKLOCAL(htonl(state->addr.s_addr))) eloop_timeout_add_sec(ifp->ctx->eloop, - timeout, ipv4ll_start, ifp); + ifo->reboot, ipv4ll_start, ifp); if (ifo->options & DHCPCD_REQUEST) syslog(LOG_INFO, "%s: soliciting a DHCP lease (requesting %s)", ifp->name, inet_ntoa(ifo->req_addr)); @@ -2111,46 +2101,41 @@ dhcp_reboot(struct interface *ifp) dhcp_static(ifp); return; } - if (ifo->reboot == 0 || state->offer == NULL) { - dhcp_discover(ifp); - return; - } if (ifo->options & DHCPCD_INFORM) { syslog(LOG_INFO, "%s: informing address of %s", ifp->name, inet_ntoa(state->lease.addr)); - } else if (state->offer->cookie == 0) { + dhcp_inform(ifp); + return; + } + if (ifo->reboot == 0 || state->offer == NULL) { + dhcp_discover(ifp); return; - } else { - syslog(LOG_INFO, "%s: rebinding lease of %s", - ifp->name, inet_ntoa(state->lease.addr)); } + if (state->offer->cookie == 0) + return; + + syslog(LOG_INFO, "%s: rebinding lease of %s", + ifp->name, inet_ntoa(state->lease.addr)); state->xid = dhcp_xid(ifp); state->lease.server.s_addr = 0; eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); /* Need to add this before dhcp_expire and friends. */ - if (!ifo->fallback && ifo->reboot && ifo->options & DHCPCD_IPV4LL && + if (!ifo->fallback && ifo->options & DHCPCD_IPV4LL && !IN_LINKLOCAL(htonl(state->addr.s_addr))) eloop_timeout_add_sec(ifp->ctx->eloop, ifo->reboot, ipv4ll_start, ifp); - if (ifo->fallback) - eloop_timeout_add_sec(ifp->ctx->eloop, - ifo->reboot, dhcp_fallback, ifp); - else if (ifo->options & DHCPCD_LASTLEASE && state->lease.frominfo) + if (ifo->options & DHCPCD_LASTLEASE && state->lease.frominfo) eloop_timeout_add_sec(ifp->ctx->eloop, ifo->reboot, dhcp_timeout, ifp); - else if (!(ifo->options & DHCPCD_INFORM && - ifp->ctx->options & (DHCPCD_MASTER | DHCPCD_DAEMONISED))) + else if (!(ifo->options & DHCPCD_INFORM)) eloop_timeout_add_sec(ifp->ctx->eloop, ifo->reboot, dhcp_expire, ifp); - /* Don't bother ARP checking as the server could NAK us first. */ - if (ifo->options & DHCPCD_INFORM) - dhcp_inform(ifp); - else { - /* Don't call dhcp_request as that would change the state */ - send_request(ifp); - } + + /* Don't bother ARP checking as the server could NAK us first. + * Don't call dhcp_request as that would change the state */ + send_request(ifp); } void diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 70c5ff9d..a30982bb 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -425,10 +425,6 @@ is working on a single interface then will exit when a timeout occurs, otherwise .Nm will fork into the background. -If using IPv4LL then -.Nm -start the IPv4LL process after the timeout and then wait a little longer -before really timing out. .It Fl u , Fl Fl userclass Ar class Tags the DHCPv4 message with the userclass .Ar class . @@ -480,10 +476,17 @@ then waits until this process has exited. Allow .Ar reboot seconds before moving to the discover phase if we have an old lease to use. +Allow +.Ar reboot +seconds before starting fallback states from the discover phase. +IPv4LL is started when the first +.Ar reboot +timeout is reached. The default is 5 seconds. A setting of 0 seconds causes .Nm to skip the reboot phase and go straight into discover. +This has no effect on DHCPv6 other than skipping the reboot phase. .El .Ss Restricting behaviour .Nm