Skip to contentSkip to conversation

tcp: fix RTO calculated from cached RTT

PATCH Applied Neal Cardwell 4 participants 4 messages Sep 17, 2013

Subsystems (3)
lore
Share & tools
lore

Neal Cardwell

author maintainer
#0 lore raw

PATCH 1/1 tcp: fix RTO calculated from cached RTT

Commit 1b7fdd2ab5852 ("tcp: do not use cached RTT for RTT estimation") did not correctly account for the fact that crtt is the RTT shifted left 3 bits. Fix the calculation to consistently reflect this fact.

Cc Eric Dumazet <[email protected]>
Cc Yuchung Cheng <[email protected]>
---
 net/ipv4/tcp_metrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/tcp_metrics.c +3 -1
index 4a22f3e..52f3c6b 100644
@@ -502,7 +502,9 @@ reset:
 	 * ACKs, wait for troubles.
 	 */
 	if (crtt > tp->srtt) {
-		inet_csk(sk)->icsk_rto = crtt + max(crtt >> 2, tcp_rto_min(sk));
+		/* Set RTO like tcp_rtt_estimator(), but from cached RTT. */
+		crtt >>= 3;
+		inet_csk(sk)->icsk_rto = crtt + max(2 * crtt, tcp_rto_min(sk));
 	} else if (tp->srtt == 0) {
 		/* RFC6298: 5.7 We've failed to get a valid RTT sample from
 		 * 3WHS. This is most likely due to retransmission,
Signature · 1 line
1.8.4
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Neal Cardwell

Commit 1b7fdd2ab5852 ("tcp: do not use cached RTT for RTT estimation") did not correctly account for the fact that crtt is the RTT shifted left 3 bits. Fix the calculation to consistently reflect this fact.

Cc Eric Dumazet <[email protected]>
Cc Yuchung Cheng <[email protected]>
---
 net/ipv4/tcp_metrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Instead of rto = 3*crtt, we had rto = 10*crtt, which was indeed suboptimal ;)

Acked-by on v1 1/1
#2 lore raw
In reply to Neal Cardwell
Quoted 10 lines · Neal Cardwell

Commit 1b7fdd2ab5852 ("tcp: do not use cached RTT for RTT estimation") did not correctly account for the fact that crtt is the RTT shifted left 3 bits. Fix the calculation to consistently reflect this fact.

Cc Eric Dumazet <[email protected]>
Cc Yuchung Cheng <[email protected]>
---
 net/ipv4/tcp_metrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Thanks for discovering and fixing it!

Quoted 19 lines
net/ipv4/tcp_metrics.c +3 -2
index 4a22f3e..52f3c6b 100644
@@ -502,7 +502,9 @@ reset:
         * ACKs, wait for troubles.
         */
        if (crtt > tp->srtt) {
-               inet_csk(sk)->icsk_rto = crtt + max(crtt >> 2, tcp_rto_min(sk));
+               /* Set RTO like tcp_rtt_estimator(), but from cached RTT. */
+               crtt >>= 3;
+               inet_csk(sk)->icsk_rto = crtt + max(2 * crtt, tcp_rto_min(sk));
        } else if (tp->srtt == 0) {
                /* RFC6298: 5.7 We've failed to get a valid RTT sample from
                 * 3WHS. This is most likely due to retransmission,
--

1.8.4

maintainer Applied
#3 lore raw

From: Yuchung Cheng <[email protected]>
Date: Tue, 17 Sep 2013 07:32:38 -0700

Quoted 11 lines · Neal Cardwell
Quoted 10 lines

Commit 1b7fdd2ab5852 ("tcp: do not use cached RTT for RTT estimation") did not correctly account for the fact that crtt is the RTT shifted left 3 bits. Fix the calculation to consistently reflect this fact.

Cc Eric Dumazet <[email protected]>
Cc Yuchung Cheng <[email protected]>
---
 net/ipv4/tcp_metrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 3 lines

Thanks for discovering and fixing it!

Applied, thanks everyone.