Blame SOURCES/dhcp-4.2.1-retransmission.patch

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