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