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>
This commit is contained in:

committed by
David S. Miller

parent
043b87d759
commit
bef0622308
@@ -61,32 +61,28 @@ static void tcp_rack_detect_loss(struct sock *sk, u32 *reo_timeout)
|
|||||||
list_for_each_entry_safe(skb, n, &tp->tsorted_sent_queue,
|
list_for_each_entry_safe(skb, n, &tp->tsorted_sent_queue,
|
||||||
tcp_tsorted_anchor) {
|
tcp_tsorted_anchor) {
|
||||||
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
|
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
|
||||||
|
s32 remaining;
|
||||||
|
|
||||||
if (tcp_rack_sent_after(tp->rack.mstamp, skb->skb_mstamp,
|
/* Skip ones marked lost but not yet retransmitted */
|
||||||
tp->rack.end_seq, scb->end_seq)) {
|
if ((scb->sacked & TCPCB_LOST) &&
|
||||||
/* Step 3 in draft-cheng-tcpm-rack-00.txt:
|
!(scb->sacked & TCPCB_SACKED_RETRANS))
|
||||||
* A packet is lost if its elapsed time is beyond
|
continue;
|
||||||
* the recent RTT plus the reordering window.
|
|
||||||
*/
|
|
||||||
u32 elapsed = tcp_stamp_us_delta(tp->tcp_mstamp,
|
|
||||||
skb->skb_mstamp);
|
|
||||||
s32 remaining = tp->rack.rtt_us + reo_wnd - elapsed;
|
|
||||||
|
|
||||||
if (remaining < 0) {
|
if (!tcp_rack_sent_after(tp->rack.mstamp, skb->skb_mstamp,
|
||||||
tcp_rack_mark_skb_lost(sk, skb);
|
tp->rack.end_seq, scb->end_seq))
|
||||||
list_del_init(&skb->tcp_tsorted_anchor);
|
break;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip ones marked lost but not yet retransmitted */
|
|
||||||
if ((scb->sacked & TCPCB_LOST) &&
|
|
||||||
!(scb->sacked & TCPCB_SACKED_RETRANS))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
/* A packet is lost if it has not been s/acked beyond
|
||||||
|
* the recent RTT plus the reordering window.
|
||||||
|
*/
|
||||||
|
remaining = tp->rack.rtt_us + reo_wnd -
|
||||||
|
tcp_stamp_us_delta(tp->tcp_mstamp, skb->skb_mstamp);
|
||||||
|
if (remaining < 0) {
|
||||||
|
tcp_rack_mark_skb_lost(sk, skb);
|
||||||
|
list_del_init(&skb->tcp_tsorted_anchor);
|
||||||
|
} else {
|
||||||
/* Record maximum wait time (+1 to avoid 0) */
|
/* Record maximum wait time (+1 to avoid 0) */
|
||||||
*reo_timeout = max_t(u32, *reo_timeout, 1 + remaining);
|
*reo_timeout = max_t(u32, *reo_timeout, 1 + remaining);
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user