[PATCH] dhcp: Use bound_time for retransmission timers

Denis Kenzior <denkenz at gmail.com>
Newsgroups dev.linux.lists.ell
Message-ID <[email protected]>
start_t is used to try and calculate the retransmission timeout value
when the client enters RENEWING or REBINDING state.  This works fine on
the first renewal since the client start timestamp and the lease bound
timestamp are very close.  Also, the RENEW request is sent immediately
whenever the T1 timer expires and most of the time it succeeds.

However, if this isn't a first renewal attempt and the RENEW request
sent when the T1 timer expires is not successful, then the renewal
timeout value could become too large.  Fix that by using the lease
bound_time for the retransmission timer calculation (as intended) intead
of the client start time (start_t).
---
 ell/dhcp.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ell/dhcp.c b/ell/dhcp.c
index 2d049005a135..01900f3b1d38 100644
--- a/ell/dhcp.c
+++ b/ell/dhcp.c
@@ -520,6 +520,7 @@ static void dhcp_client_timeout_resend(struct l_timeout *timeout,
 								void *user_data)
 {
 	struct l_dhcp_client *client = user_data;
+	struct l_dhcp_lease *lease = client->lease;
 	unsigned int next_timeout = 0;
 	int r;
 
@@ -555,12 +556,12 @@ static void dhcp_client_timeout_resend(struct l_timeout *timeout,
 
 	switch (client->state) {
 	case DHCP_STATE_RENEWING:
-		next_timeout = dhcp_rebind_renew_retry_time(client->start_t,
-							client->lease->t2);
+		next_timeout = dhcp_rebind_renew_retry_time(lease->bound_time,
+								lease->t2);
 		break;
 	case DHCP_STATE_REBINDING:
-		next_timeout = dhcp_rebind_renew_retry_time(client->start_t,
-						client->lease->lifetime);
+		next_timeout = dhcp_rebind_renew_retry_time(lease->bound_time,
+							lease->lifetime);
 		break;
 	case DHCP_STATE_REQUESTING:
 	case DHCP_STATE_SELECTING:
@@ -642,7 +643,7 @@ static void dhcp_client_t1_expired(struct l_timeout *timeout, void *user_data)
 	l_timeout_set_callback(client->timeout_lease, dhcp_client_t2_expired,
 				client, NULL);
 
-	next_timeout = dhcp_rebind_renew_retry_time(client->start_t,
+	next_timeout = dhcp_rebind_renew_retry_time(client->lease->bound_time,
 							client->lease->t2);
 	client->timeout_resend =
 		l_timeout_create_ms(dhcp_fuzz_secs(next_timeout),
-- 
2.32.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.