From: Roy Marples Date: Thu, 20 Aug 2020 15:09:53 +0000 (+0100) Subject: DHCP: Mark the state as expired on lase lease extension X-Git-Tag: v9.2.0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=684895a84c40b4484c7e0d7ce555f7154d8e6d22;p=thirdparty%2Fdhcpcd.git DHCP: Mark the state as expired on lase lease extension Expired states do not claim any client IP to request from. --- diff --git a/src/dhcp.c b/src/dhcp.c index b309b01c..66e1379c 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -777,7 +777,7 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type) (type == DHCP_REQUEST && state->addr->mask.s_addr == lease->mask.s_addr && (state->new == NULL || IS_DHCP(state->new)) && - !(state->added & STATE_FAKE)))) + !(state->added & (STATE_FAKE | STATE_EXPIRED))))) bootp->ciaddr = state->addr->addr.s_addr; bootp->op = BOOTREQUEST; @@ -1745,7 +1745,7 @@ send_message(struct interface *ifp, uint8_t type, goto fail; len = (size_t)r; - if (!(state->added & STATE_FAKE) && + if (!(state->added & (STATE_FAKE | STATE_EXPIRED)) && state->addr != NULL && ipv4_iffindaddr(ifp, &state->lease.addr, NULL) != NULL) from.s_addr = state->lease.addr.s_addr; @@ -1915,7 +1915,10 @@ dhcp_expire(void *arg) struct interface *ifp = arg; if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) { + struct dhcp_state *state = D_STATE(ifp); + logwarnx("%s: DHCP lease expired, extending lease", ifp->name); + state->added |= STATE_EXPIRED; return; } diff --git a/src/ipv4.h b/src/ipv4.h index 3b933a71..bb3d5b2c 100644 --- a/src/ipv4.h +++ b/src/ipv4.h @@ -129,6 +129,7 @@ bool inet_getroutes(struct dhcpcd_ctx *, rb_tree_t *); #define STATE_ADDED 0x01 #define STATE_FAKE 0x02 +#define STATE_EXPIRED 0x04 int ipv4_deladdr(struct ipv4_addr *, int); struct ipv4_addr *ipv4_addaddr(struct interface *,