ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz at gmail.com>
To: ell at lists.01.org
Subject: [PATCH] dhcp: Use bound_time for retransmission timers
Date: Wed, 11 May 2022 12:28:55 -0500	[thread overview]
Message-ID: <20220511172855.25992-1-denkenz@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2228 bytes --]

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

             reply	other threads:[~2022-05-11 17:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 17:28 Denis Kenzior [this message]
2022-05-13 13:53 [PATCH] dhcp: Use bound_time for retransmission timers Michael Johnson
2022-05-13 14:30 Denis Kenzior
2022-05-13 15:31 Michael Johnson
2022-05-13 15:40 Michael Johnson
2022-05-13 16:23 Denis Kenzior
2022-05-13 17:10 Michael Johnson
2022-05-18 16:21 Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220511172855.25992-1-denkenz@gmail.com \
    --to=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).