File 0025-dhcp-4.2.x-dhcpv6-retransmission-until-MRD.872609.patch of Package dhcp.1901

Author: Jiri Popelka <jpopelka@redhat.com>
References: bsc#872609, ISC-Bugs#21238
Upstream: yes

In client initiated message exchanges stop retransmission upon
reaching the MRD rather than at some point after it (#559153)
(Submitted to dhcp-bugs@isc.org - [ISC-Bugs #21238])

diff --git a/client/dhc6.c b/client/dhc6.c
index f8ad25d..63cbb65 100644
--- a/client/dhc6.c
+++ b/client/dhc6.c
@@ -365,7 +365,7 @@ dhc6_retrans_init(struct client_state *client)
 static void
 dhc6_retrans_advance(struct client_state *client)
 {
-	struct timeval elapsed;
+	struct timeval elapsed, elapsed_after_RT;
 
 	/* elapsed = cur - start */
 	elapsed.tv_sec = cur_tv.tv_sec - client->start_time.tv_sec;
@@ -382,6 +382,8 @@ dhc6_retrans_advance(struct client_state *client)
 		elapsed.tv_sec += 1;
 		elapsed.tv_usec -= 1000000;
 	}
+	elapsed_after_RT.tv_sec = elapsed.tv_sec;
+	elapsed_after_RT.tv_usec = elapsed.tv_usec;
 
 	/*
 	 * RT for each subsequent message transmission is based on the previous
@@ -419,13 +421,10 @@ dhc6_retrans_advance(struct client_state *client)
 		elapsed.tv_usec -= 1000000;
 	}
 	if (elapsed.tv_sec >= client->MRD) {
-		/*
-		 * wake at RT + cur = start + MRD
-		 */
-		client->RT = client->MRD +
-			(client->start_time.tv_sec - cur_tv.tv_sec);
-		client->RT = client->RT * 100 +
-			(client->start_time.tv_usec - cur_tv.tv_usec) / 10000;
+		client->RT = client->MRD - elapsed_after_RT.tv_sec;
+		client->RT = client->RT * 100 - elapsed_after_RT.tv_usec / 10000;
+		if (client->RT < 0)
+			client->RT = 0;
 	}
 	client->txcount++;
 }
@@ -1502,7 +1501,7 @@ check_timing6 (struct client_state *client, u_int8_t msg_type,
 	}
 
 	/* Check if finished (-1 argument). */
-	if ((client->MRD != 0) && (elapsed.tv_sec > client->MRD)) {
+	if ((client->MRD != 0) && (elapsed.tv_sec >= client->MRD)) {
 		log_info("Max retransmission duration exceeded.");
 		return(CHK_TIM_MRD_EXCEEDED);
 	}
openSUSE Build Service is sponsored by