Skip to content

Commit c77d62f

Browse files
yuchungchengdavem330
authored andcommitted
tcp: separate loss marking and state update on RTO
Previously when TCP times out, it first updates cwnd and ssthresh, marks packets lost, and then updates congestion state again. This was fine because everything not yet delivered is marked lost, so the inflight is always 0 and cwnd can be safely set to 1 to retransmit one packet on timeout. But the inflight may not always be 0 on timeout if TCP changes to mark packets lost based on packet sent time. Therefore we must first mark the packet lost, then set the cwnd based on the (updated) inflight. This is not a pure refactor. Congestion control may potentially break if it uses (not yet updated) inflight to compute ssthresh. Fortunately all existing congestion control modules does not do that. Also it changes the inflight when CA_LOSS_EVENT is called, and only westwood processes such an event but does not use inflight. This change has two other minor side benefits: 1) consistent with Fast Recovery s.t. the inflight is updated first before tcp_enter_recovery flips state to CA_Recovery. 2) avoid intertwining loss marking with state update, making the code more readable. Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Reviewed-by: Soheil Hassas Yeganeh <[email protected]> Reviewed-by: Priyaranjan Jha <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2ad55f5 commit c77d62f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/tcp_input.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,8 @@ void tcp_enter_loss(struct sock *sk)
19551955
struct net *net = sock_net(sk);
19561956
bool new_recovery = icsk->icsk_ca_state < TCP_CA_Recovery;
19571957

1958+
tcp_timeout_mark_lost(sk);
1959+
19581960
/* Reduce ssthresh if it has not yet been made inside this window. */
19591961
if (icsk->icsk_ca_state <= TCP_CA_Disorder ||
19601962
!after(tp->high_seq, tp->snd_una) ||
@@ -1969,8 +1971,6 @@ void tcp_enter_loss(struct sock *sk)
19691971
tp->snd_cwnd_cnt = 0;
19701972
tp->snd_cwnd_stamp = tcp_jiffies32;
19711973

1972-
tcp_timeout_mark_lost(sk);
1973-
19741974
/* Timeout in disordered state after receiving substantial DUPACKs
19751975
* suggests that the degree of reordering is over-estimated.
19761976
*/

0 commit comments

Comments
 (0)