From: Roy Marples Date: Mon, 23 Oct 2023 15:24:00 +0000 (+0000) Subject: DHCP: re-enter DISCOVER phase if server doesn't reply to our REQUEST X-Git-Tag: v10.0.5~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d408e74bdcefd7905da0d9cc1bae6e155a4a5bb2;p=thirdparty%2Fdhcpcd.git DHCP: re-enter DISCOVER phase if server doesn't reply to our REQUEST Use the reboot timeout as per the initial DISCOVER timeout. Fixes #255 --- diff --git a/src/dhcp.c b/src/dhcp.c index e029cee3..014ce6cf 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -1895,6 +1895,20 @@ dhcp_discover(void *arg) send_discover(ifp); } +static void +dhcp_requestfailed(void *arg) +{ + struct interface *ifp = arg; + struct dhcp_state *state = D_STATE(ifp); + + logwarnx("%s: failed to request the lease", ifp->name); + free(state->offer); + state->offer = NULL; + state->offer_len = 0; + state->interval = 0; + dhcp_discover(ifp); +} + static void dhcp_request(void *arg) { @@ -1902,6 +1916,9 @@ dhcp_request(void *arg) struct dhcp_state *state = D_STATE(ifp); state->state = DHS_REQUEST; + // Handle the server being silent to our request. + eloop_timeout_add_sec(ifp->ctx->eloop, ifp->options->reboot, + dhcp_requestfailed, ifp); send_request(ifp); }