Skip to content

Commit

Permalink
DHCP: re-enter DISCOVER phase if server doesn't reply to our REQUEST
Browse files Browse the repository at this point in the history
Use the reboot timeout as per the initial DISCOVER timeout.

Fixes #255
  • Loading branch information
rsmarples committed Oct 23, 2023
1 parent e8b6541 commit d408e74
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,13 +1895,30 @@ 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)
{
struct interface *ifp = 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);
}

Expand Down

0 comments on commit d408e74

Please sign in to comment.