git: 5120ea0d8871 - main - sctp: improve heartbeat timer computation PR: 278666 Reviewed by: Albin Hellqvist MFC after: 3 days Pull Request: https://reviews.freebsd.org/D45107

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Fri, 10 May 2024 20:20:01 UTC
The branch main has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=5120ea0d8871fd5d56a8fb70117b727b9d8a4e62

commit 5120ea0d8871fd5d56a8fb70117b727b9d8a4e62
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-05-10 18:58:01 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-05-10 19:02:56 +0000

    sctp: improve heartbeat timer computation
    PR:             278666
    Reviewed by:    Albin Hellqvist
    MFC after:      3 days
    Pull Request:   https://reviews.freebsd.org/D45107
---
 sys/netinet/sctputil.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index 22d45d150544..17e49b413464 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -2289,19 +2289,19 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
 		} else {
 			to_ticks = net->RTO;
 		}
-		rndval = sctp_select_initial_TSN(&inp->sctp_ep);
-		jitter = rndval % to_ticks;
-		if (to_ticks > 1) {
-			to_ticks >>= 1;
-		}
-		if (jitter < (UINT32_MAX - to_ticks)) {
-			to_ticks += jitter;
-		} else {
-			to_ticks = UINT32_MAX;
-		}
 		if (!((net->dest_state & SCTP_ADDR_UNCONFIRMED) &&
 		    (net->dest_state & SCTP_ADDR_REACHABLE)) &&
 		    ((net->dest_state & SCTP_ADDR_PF) == 0)) {
+			if (to_ticks > 1) {
+				rndval = sctp_select_initial_TSN(&inp->sctp_ep);
+				jitter = rndval % to_ticks;
+				to_ticks >>= 1;
+				if (jitter < (UINT32_MAX - to_ticks)) {
+					to_ticks += jitter;
+				} else {
+					to_ticks = UINT32_MAX;
+				}
+			}
 			if (net->heart_beat_delay < (UINT32_MAX - to_ticks)) {
 				to_ticks += net->heart_beat_delay;
 			} else {