changeset 2946:dfebb30d292a draft

Test if we fake loaded a lease so we can report the correct state.
author Roy Marples <roy@marples.name>
date Fri, 13 Feb 2015 11:28:17 +0000
parents 6960feec8c1d
children 840e0cd4bd3b
files dhcp.c
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp.c	Tue Feb 10 08:54:33 2015 +0000
+++ b/dhcp.c	Fri Feb 13 11:28:17 2015 +0000
@@ -1895,7 +1895,8 @@
 				    "time, forcing to %"PRIu32" seconds",
 				    ifp->name, lease->renewaltime);
 			}
-			syslog(lease->addr.s_addr == state->addr.s_addr ?
+			syslog(lease->addr.s_addr == state->addr.s_addr &&
+			    !(state->added & STATE_FAKE) ?
 			    LOG_DEBUG : LOG_INFO,
 			    "%s: leased %s for %"PRIu32" seconds", ifp->name,
 			    inet_ntoa(lease->addr), lease->leasetime);
@@ -1908,7 +1909,7 @@
 		return;
 	}
 	if (state->reason == NULL) {
-		if (state->old && state->new->cookie != htonl(MAGIC_COOKIE)) {
+		if (state->old && !(state->added | STATE_FAKE)) {
 			if (state->old->yiaddr == state->new->yiaddr &&
 			    lease->server.s_addr)
 				state->reason = "RENEW";
@@ -3207,14 +3208,9 @@
 		return;
 	}
 
-	if (state->offer == NULL || state->offer->cookie == 0) {
-		/* If we don't have an address yet, enter the reboot
-		 * state to ensure at least fallback in short order. */
-		if (state->addr.s_addr == INADDR_ANY ||
-		    state->added & STATE_FAKE)
-			state->state = DHS_REBOOT;
+	if (state->offer == NULL || state->offer->cookie == 0)
 		dhcp_discover(ifp);
-	} else
+	else
 		dhcp_reboot(ifp);
 }