Blame SOURCES/dhcp-4.2.0-honor-expired.patch

54343e
diff -up dhcp-4.2.0/client/dhc6.c.honor-expired dhcp-4.2.0/client/dhc6.c
54343e
--- dhcp-4.2.0/client/dhc6.c.honor-expired	2010-10-07 12:55:37.000000000 +0200
54343e
+++ dhcp-4.2.0/client/dhc6.c	2010-10-07 12:56:43.000000000 +0200
54343e
@@ -1405,6 +1405,32 @@ start_info_request6(struct client_state 
54343e
 		go_daemon();
54343e
 }
54343e
 
54343e
+/* Run through the addresses in lease and return true if there's any unexpired.
54343e
+ * Return false otherwise.
54343e
+ */
54343e
+isc_boolean_t
54343e
+unexpired_address_in_lease(struct dhc6_lease *lease)
54343e
+{
54343e
+	struct dhc6_ia *ia;
54343e
+	struct dhc6_addr *addr;
54343e
+
54343e
+	for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
54343e
+		for (addr = ia->addrs ; addr != NULL ; addr = addr->next) {
54343e
+			if (addr->flags & DHC6_ADDR_EXPIRED)
54343e
+				continue;
54343e
+
54343e
+			if (addr->starts + addr->max_life > cur_time) {
54343e
+				return ISC_TRUE;
54343e
+			}
54343e
+		}
54343e
+	}
54343e
+
54343e
+	log_info("PRC: Previous lease is devoid of active addresses."
54343e
+		 "  Re-initializing.");
54343e
+
54343e
+	return ISC_FALSE;
54343e
+}
54343e
+
54343e
 /*
54343e
  * start_confirm6() kicks off an "init-reboot" version of the process, at
54343e
  * startup to find out if old bindings are 'fair' and at runtime whenever
54343e
@@ -1417,8 +1446,10 @@ start_confirm6(struct client_state *clie
54343e
 
54343e
 	/* If there is no active lease, there is nothing to check. */
54343e
 	if ((client->active_lease == NULL) ||
54343e
-	    !active_prefix(client) ||
54343e
-	    client->active_lease->released) {
54343e
+		!active_prefix(client) ||
54343e
+		client->active_lease->released ||
54343e
+		!unexpired_address_in_lease(client->active_lease)) {
54343e
+		dhc6_lease_destroy(&client->active_lease, MDL);
54343e
 		start_init6(client);
54343e
 		return;
54343e
 	}