]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: optimize prior for systems without IPv4 address lifetimes
authorRoy Marples <roy@marples.name>
Tue, 1 Sep 2020 11:24:42 +0000 (12:24 +0100)
committerRoy Marples <roy@marples.name>
Tue, 1 Sep 2020 11:24:42 +0000 (12:24 +0100)
src/ipv4.c

index e460630cee748626504f4fc335ae4df91681e0d8..92ecdbd0f1b10ec00a6a912f3cb6b508e8748d4c 100644 (file)
@@ -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);