Skip to content

Commit bef0622

Browse files
yuchungchengdavem330
authored andcommitted
tcp: a small refactor of RACK loss detection
Refactor the RACK loop to improve readability and speed up the checks. Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 043b87d commit bef0622

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

net/ipv4/tcp_recovery.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,28 @@ static void tcp_rack_detect_loss(struct sock *sk, u32 *reo_timeout)
6161
list_for_each_entry_safe(skb, n, &tp->tsorted_sent_queue,
6262
tcp_tsorted_anchor) {
6363
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
64+
s32 remaining;
6465

65-
if (tcp_rack_sent_after(tp->rack.mstamp, skb->skb_mstamp,
66-
tp->rack.end_seq, scb->end_seq)) {
67-
/* Step 3 in draft-cheng-tcpm-rack-00.txt:
68-
* A packet is lost if its elapsed time is beyond
69-
* the recent RTT plus the reordering window.
70-
*/
71-
u32 elapsed = tcp_stamp_us_delta(tp->tcp_mstamp,
72-
skb->skb_mstamp);
73-
s32 remaining = tp->rack.rtt_us + reo_wnd - elapsed;
74-
75-
if (remaining < 0) {
76-
tcp_rack_mark_skb_lost(sk, skb);
77-
list_del_init(&skb->tcp_tsorted_anchor);
78-
continue;
79-
}
80-
81-
/* Skip ones marked lost but not yet retransmitted */
82-
if ((scb->sacked & TCPCB_LOST) &&
83-
!(scb->sacked & TCPCB_SACKED_RETRANS))
84-
continue;
66+
/* Skip ones marked lost but not yet retransmitted */
67+
if ((scb->sacked & TCPCB_LOST) &&
68+
!(scb->sacked & TCPCB_SACKED_RETRANS))
69+
continue;
8570

71+
if (!tcp_rack_sent_after(tp->rack.mstamp, skb->skb_mstamp,
72+
tp->rack.end_seq, scb->end_seq))
73+
break;
74+
75+
/* A packet is lost if it has not been s/acked beyond
76+
* the recent RTT plus the reordering window.
77+
*/
78+
remaining = tp->rack.rtt_us + reo_wnd -
79+
tcp_stamp_us_delta(tp->tcp_mstamp, skb->skb_mstamp);
80+
if (remaining < 0) {
81+
tcp_rack_mark_skb_lost(sk, skb);
82+
list_del_init(&skb->tcp_tsorted_anchor);
83+
} else {
8684
/* Record maximum wait time (+1 to avoid 0) */
8785
*reo_timeout = max_t(u32, *reo_timeout, 1 + remaining);
88-
} else {
89-
break;
9086
}
9187
}
9288
}

0 commit comments

Comments
 (0)