From 3ca5bffd2de92ee21ea733cb0b2716a0a975942d Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 24 Nov 2020 10:30:08 +0000 Subject: [PATCH] DHCP: If error adding the address in oneshot, exit with failure Otherwise we loop. It's unlikely oneshot would be used with IPv6 due to addresses having lifetimes. --- src/dhcp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dhcp.c b/src/dhcp.c index fdfd8b3d..86fe3e11 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -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. */ -- 2.47.3