From: Roy Marples Date: Sun, 30 Aug 2020 07:03:01 +0000 (+0100) Subject: DHCP: Request offered IP when using lastlease X-Git-Tag: v9.2.0~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3818775343b0ef2de0860e45a4a9200e9688ce41;p=thirdparty%2Fdhcpcd.git DHCP: Request offered IP when using lastlease Also, set expired state on using last lease rather than last lease extension. --- diff --git a/src/dhcp.c b/src/dhcp.c index 66e1379c..6c816273 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -836,7 +836,7 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type) if (type == DHCP_DECLINE || (type == DHCP_REQUEST && (state->addr == NULL || - state->added & STATE_FAKE || + state->added & (STATE_FAKE | STATE_EXPIRED) || lease->addr.s_addr != state->addr->addr.s_addr))) { putip = true; @@ -2367,19 +2367,6 @@ dhcp_bind(struct interface *ifp) eloop_event_add(ctx->eloop, state->udp_rfd, dhcp_handleifudp, ifp); } -static void -dhcp_lastlease(void *arg) -{ - struct interface *ifp = arg; - struct dhcp_state *state = D_STATE(ifp); - - loginfox("%s: timed out contacting a DHCP server, using last lease", - ifp->name); - dhcp_bind(ifp); - state->interval = 0; - dhcp_discover(ifp); -} - static size_t dhcp_message_new(struct bootp **bootp, const struct in_addr *addr, const struct in_addr *mask) @@ -2478,6 +2465,26 @@ dhcp_arp_bind(struct interface *ifp) } #endif +static void +dhcp_lastlease(void *arg) +{ + struct interface *ifp = arg; + struct dhcp_state *state = D_STATE(ifp); + + loginfox("%s: timed out contacting a DHCP server, using last lease", + ifp->name); +#if defined(ARP) || defined(KERNEL_RFC5227) + dhcp_arp_bind(ifp); +#else + dhcp_bind(ifp); +#endif + /* Set expired here because dhcp_bind() -> ipv4_addaddr() will reset + * state */ + state->added |= STATE_EXPIRED; + state->interval = 0; + dhcp_discover(ifp); +} + static void dhcp_static(struct interface *ifp) {