From 67b93011313a7c91d64b05c0e1078e3bee113b63 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 1 Sep 2020 12:24:42 +0100 Subject: [PATCH] DHCP: optimize prior for systems without IPv4 address lifetimes --- src/ipv4.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ipv4.c b/src/ipv4.c index e460630c..92ecdbd0 100644 --- a/src/ipv4.c +++ b/src/ipv4.c @@ -629,11 +629,6 @@ ipv4_addaddr(struct interface *ifp, const struct in_addr *addr, struct ipv4_addr *replaced_ia; #endif - if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) { - /* We don't want the kernel to expire the address. */ - vltime = pltime = DHCP_INFINITE_LIFETIME; - } - if ((state = ipv4_getstate(ifp)) == NULL) { logerr(__func__); return NULL; @@ -666,8 +661,13 @@ ipv4_addaddr(struct interface *ifp, const struct in_addr *addr, ia->mask = *mask; ia->brd = *bcast; #ifdef IP_LIFETIME - ia->vltime = vltime; - ia->pltime = pltime; + if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) { + /* We don't want the kernel to expire the address. */ + ia->vltime = ia->pltime = DHCP_INFINITE_LIFETIME; + } else { + ia->vltime = vltime; + ia->pltime = pltime; + } #else UNUSED(vltime); UNUSED(pltime); -- 2.47.2