mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 16:20:55 +07:00
tcp: track the packet timings in RACK
This patch is the first half of the RACK loss recovery. RACK loss recovery uses the notion of time instead of packet sequence (FACK) or counts (dupthresh). It's inspired by the previous FACK heuristic in tcp_mark_lost_retrans(): when a limited transmit (new data packet) is sacked, then current retransmitted sequence below the newly sacked sequence must been lost, since at least one round trip time has elapsed. But it has several limitations: 1) can't detect tail drops since it depends on limited transmit 2) is disabled upon reordering (assumes no reordering) 3) only enabled in fast recovery ut not timeout recovery RACK (Recently ACK) addresses these limitations with the notion of time instead: a packet P1 is lost if a later packet P2 is s/acked, as at least one round trip has passed. Since RACK cares about the time sequence instead of the data sequence of packets, it can detect tail drops when later retransmission is s/acked while FACK or dupthresh can't. For reordering RACK uses a dynamically adjusted reordering window ("reo_wnd") to reduce false positives on ever (small) degree of reordering. This patch implements tcp_advanced_rack() which tracks the most recent transmission time among the packets that have been delivered (ACKed or SACKed) in tp->rack.mstamp. This timestamp is the key to determine which packet has been lost. Consider an example that the sender sends six packets: T1: P1 (lost) T2: P2 T3: P3 T4: P4 T100: sack of P2. rack.mstamp = T2 T101: retransmit P1 T102: sack of P2,P3,P4. rack.mstamp = T4 T205: ACK of P4 since the hole is repaired. rack.mstamp = T101 We need to be careful about spurious retransmission because it may falsely advance tp->rack.mstamp by an RTT or an RTO, causing RACK to falsely mark all packets lost, just like a spurious timeout. We identify spurious retransmission by the ACK's TS echo value. If TS option is not applicable but the retransmission is acknowledged less than min-RTT ago, it is likely to be spurious. We refrain from using the transmission time of these spurious retransmissions. The second half is implemented in the next patch that marks packet lost using RACK timestamp. 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:
parent
625a5e109a
commit
659a8ad56f
@ -194,6 +194,12 @@ struct tcp_sock {
|
||||
u32 window_clamp; /* Maximal window to advertise */
|
||||
u32 rcv_ssthresh; /* Current window clamp */
|
||||
|
||||
/* Information of the most recently (s)acked skb */
|
||||
struct tcp_rack {
|
||||
struct skb_mstamp mstamp; /* (Re)sent time of the skb */
|
||||
u8 advanced; /* mstamp advanced since last lost marking */
|
||||
u8 reord; /* reordering detected */
|
||||
} rack;
|
||||
u16 advmss; /* Advertised MSS */
|
||||
u8 unused;
|
||||
u8 nonagle : 4,/* Disable Nagle algorithm? */
|
||||
|
@ -1750,6 +1750,11 @@ int tcpv4_offload_init(void);
|
||||
void tcp_v4_init(void);
|
||||
void tcp_init(void);
|
||||
|
||||
/* tcp_recovery.c */
|
||||
|
||||
extern void tcp_rack_advance(struct tcp_sock *tp,
|
||||
const struct skb_mstamp *xmit_time, u8 sacked);
|
||||
|
||||
/*
|
||||
* Save and compile IPv4 options, return a pointer to it
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@ obj-y := route.o inetpeer.o protocol.o \
|
||||
inet_timewait_sock.o inet_connection_sock.o \
|
||||
tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
|
||||
tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \
|
||||
tcp_recovery.o \
|
||||
tcp_offload.o datagram.o raw.o udp.o udplite.o \
|
||||
udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \
|
||||
fib_frontend.o fib_semantics.o fib_trie.o \
|
||||
|
@ -1173,6 +1173,8 @@ static u8 tcp_sacktag_one(struct sock *sk,
|
||||
return sacked;
|
||||
|
||||
if (!(sacked & TCPCB_SACKED_ACKED)) {
|
||||
tcp_rack_advance(tp, xmit_time, sacked);
|
||||
|
||||
if (sacked & TCPCB_SACKED_RETRANS) {
|
||||
/* If the segment is not tagged as lost,
|
||||
* we do not clear RETRANS, believing
|
||||
@ -2256,6 +2258,16 @@ static bool tcp_tsopt_ecr_before(const struct tcp_sock *tp, u32 when)
|
||||
before(tp->rx_opt.rcv_tsecr, when);
|
||||
}
|
||||
|
||||
/* skb is spurious retransmitted if the returned timestamp echo
|
||||
* reply is prior to the skb transmission time
|
||||
*/
|
||||
static bool tcp_skb_spurious_retrans(const struct tcp_sock *tp,
|
||||
const struct sk_buff *skb)
|
||||
{
|
||||
return (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS) &&
|
||||
tcp_tsopt_ecr_before(tp, tcp_skb_timestamp(skb));
|
||||
}
|
||||
|
||||
/* Nothing was retransmitted or returned timestamp is less
|
||||
* than timestamp of the first retransmission.
|
||||
*/
|
||||
@ -3135,6 +3147,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
|
||||
|
||||
if (sacked & TCPCB_SACKED_ACKED)
|
||||
tp->sacked_out -= acked_pcount;
|
||||
else if (tcp_is_sack(tp) && !tcp_skb_spurious_retrans(tp, skb))
|
||||
tcp_rack_advance(tp, &skb->skb_mstamp, sacked);
|
||||
if (sacked & TCPCB_LOST)
|
||||
tp->lost_out -= acked_pcount;
|
||||
|
||||
|
@ -548,6 +548,8 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
|
||||
tcp_ecn_openreq_child(newtp, req);
|
||||
newtp->fastopen_rsk = NULL;
|
||||
newtp->syn_data_acked = 0;
|
||||
newtp->rack.mstamp.v64 = 0;
|
||||
newtp->rack.advanced = 0;
|
||||
|
||||
newtp->saved_syn = req->saved_syn;
|
||||
req->saved_syn = NULL;
|
||||
|
32
net/ipv4/tcp_recovery.c
Normal file
32
net/ipv4/tcp_recovery.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <linux/tcp.h>
|
||||
#include <net/tcp.h>
|
||||
|
||||
/* Record the most recently (re)sent time among the (s)acked packets */
|
||||
void tcp_rack_advance(struct tcp_sock *tp,
|
||||
const struct skb_mstamp *xmit_time, u8 sacked)
|
||||
{
|
||||
if (tp->rack.mstamp.v64 &&
|
||||
!skb_mstamp_after(xmit_time, &tp->rack.mstamp))
|
||||
return;
|
||||
|
||||
if (sacked & TCPCB_RETRANS) {
|
||||
struct skb_mstamp now;
|
||||
|
||||
/* If the sacked packet was retransmitted, it's ambiguous
|
||||
* whether the retransmission or the original (or the prior
|
||||
* retransmission) was sacked.
|
||||
*
|
||||
* If the original is lost, there is no ambiguity. Otherwise
|
||||
* we assume the original can be delayed up to aRTT + min_rtt.
|
||||
* the aRTT term is bounded by the fast recovery or timeout,
|
||||
* so it's at least one RTT (i.e., retransmission is at least
|
||||
* an RTT later).
|
||||
*/
|
||||
skb_mstamp_get(&now);
|
||||
if (skb_mstamp_us_delta(&now, xmit_time) < tcp_min_rtt(tp))
|
||||
return;
|
||||
}
|
||||
|
||||
tp->rack.mstamp = *xmit_time;
|
||||
tp->rack.advanced = 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user