philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-4.2.1-retransmission.patch

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