45c037
diff -up dhcp-4.2.1b1/client/dhc6.c.retransmission dhcp-4.2.1b1/client/dhc6.c
45c037
--- dhcp-4.2.1b1/client/dhc6.c.retransmission	2011-01-28 08:40:56.000000000 +0100
45c037
+++ dhcp-4.2.1b1/client/dhc6.c	2011-01-28 08:39:22.000000000 +0100
45c037
@@ -361,7 +361,7 @@ dhc6_retrans_init(struct client_state *c
ed7e41
 static void
ed7e41
 dhc6_retrans_advance(struct client_state *client)
ed7e41
 {
ed7e41
-	struct timeval elapsed;
ed7e41
+	struct timeval elapsed, elapsed_after_RT;
ed7e41
 
ed7e41
 	/* elapsed = cur - start */
ed7e41
 	elapsed.tv_sec = cur_tv.tv_sec - client->start_time.tv_sec;
45c037
@@ -378,6 +378,8 @@ dhc6_retrans_advance(struct client_state
ed7e41
 		elapsed.tv_sec += 1;
ed7e41
 		elapsed.tv_usec -= 1000000;
ed7e41
 	}
ed7e41
+	elapsed_after_RT.tv_sec = elapsed.tv_sec;
ed7e41
+	elapsed_after_RT.tv_usec = elapsed.tv_usec;
ed7e41
 
ed7e41
 	/*
ed7e41
 	 * RT for each subsequent message transmission is based on the previous
45c037
@@ -415,13 +417,10 @@ dhc6_retrans_advance(struct client_state
ed7e41
 		elapsed.tv_usec -= 1000000;
ed7e41
 	}
ed7e41
 	if (elapsed.tv_sec >= client->MRD) {
ed7e41
-		/*
ed7e41
-		 * wake at RT + cur = start + MRD
ed7e41
-		 */
ed7e41
-		client->RT = client->MRD +
ed7e41
-			(client->start_time.tv_sec - cur_tv.tv_sec);
ed7e41
-		client->RT = client->RT * 100 +
ed7e41
-			(client->start_time.tv_usec - cur_tv.tv_usec) / 10000;
ed7e41
+		client->RT = client->MRD - elapsed_after_RT.tv_sec;
ed7e41
+		client->RT = client->RT * 100 - elapsed_after_RT.tv_usec / 10000;
ed7e41
+		if (client->RT < 0)
ed7e41
+			client->RT = 0;
ed7e41
 	}
ed7e41
 	client->txcount++;
ed7e41
 }
45c037
@@ -1497,7 +1496,7 @@ check_timing6 (struct client_state *clie
ed7e41
 	}
45c037
 
ed7e41
 	/* Check if finished (-1 argument). */
ed7e41
-	if ((client->MRD != 0) && (elapsed.tv_sec > client->MRD)) {
ed7e41
+	if ((client->MRD != 0) && (elapsed.tv_sec >= client->MRD)) {
ed7e41
 		log_info("Max retransmission duration exceeded.");
45c037
 		return(CHK_TIM_MRD_EXCEEDED);
ed7e41
 	}