]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: If error adding the address in oneshot, exit with failure
authorRoy Marples <roy@marples.name>
Tue, 24 Nov 2020 10:30:08 +0000 (10:30 +0000)
committerRoy Marples <roy@marples.name>
Tue, 24 Nov 2020 10:30:08 +0000 (10:30 +0000)
Otherwise we loop.
It's unlikely oneshot would be used with IPv6 due to addresses
having lifetimes.

src/dhcp.c

index fdfd8b3d208e834f8207a00d89d10d44198d0be1..86fe3e1134d9ba2edd575498fd135eec449556db 100644 (file)
@@ -2365,8 +2365,15 @@ dhcp_bind(struct interface *ifp)
        }
 
        /* Add the address */
-       if (ipv4_applyaddr(ifp) == NULL)
+       if (ipv4_applyaddr(ifp) == NULL) {
+               /* There was an error adding the address.
+                * If we are in oneshot, exit with a failure. */
+               if (ctx->options & DHCPCD_ONESHOT) {
+                       loginfox("exiting due to oneshot");
+                       eloop_exit(ctx->eloop, EXIT_FAILURE);
+               }
                return;
+       }
 
        /* Close the BPF filter as we can now receive DHCP messages
         * on a UDP socket. */