dctcp_cwnd_event() calls tcp_plb_update_state_upon_rto() upon CA_EVENT_LOSS in tcp_enter_loss() to reset plb_consec_cong_rounds and pause PLB after an RTO triggers a path rehash. However, tcp_enter_loss() does not always correspond to an RTO rehash: 1. tcp_enter_loss() is called from 3 paths but the first two do not rehash the flow: - tcp_fastopen_synack_timer() - tcp_retransmit_timer() when !tp->snd_wnd - tcp_retransmit_timer() when tcp_write_timeout() returns 0 2. Even on the last path, tcp_enter_loss() skips CA_EVENT_LOSS if after(tp->high_seq, tp->snd_una) is true and the socket is in TCP_CA_CWR (e.g. after receiving ECN CE in DCTCP), TCP_CA_Recovery, or TCP_CA_Loss with icsk_retransmits > 0. In the second case, even when tcp_write_timeout() rehashes the flow, tcp_plb_update_state_upon_rto() is missed. Then, a subsequent tcp_plb_check_rehash() in dctcp_update_alpha() or dctcp_cwnd_event_tx_start() can immediately rehash the flow again, potentially back to the previous bad path. Let's move tcp_plb_update_state_upon_rto() just after __sk_rethink_txhash_reset_dst() in tcp_write_timeout(). Signed-off-by: Kuniyuki Iwashima --- net/ipv4/tcp_dctcp.c | 1 - net/ipv4/tcp_plb.c | 1 - net/ipv4/tcp_timer.c | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c index bc3724d1da90..bbfff24ed5f0 100644 --- a/net/ipv4/tcp_dctcp.c +++ b/net/ipv4/tcp_dctcp.c @@ -198,7 +198,6 @@ __bpf_kfunc static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) dctcp_ece_ack_update(sk, ev, &ca->prior_rcv_nxt, &ca->ce_state); break; case CA_EVENT_LOSS: - tcp_plb_update_state_upon_rto(sk); dctcp_react_to_loss(sk); break; default: diff --git a/net/ipv4/tcp_plb.c b/net/ipv4/tcp_plb.c index 26ca53d6fb9d..c21fcb7945c0 100644 --- a/net/ipv4/tcp_plb.c +++ b/net/ipv4/tcp_plb.c @@ -113,4 +113,3 @@ void tcp_plb_update_state_upon_rto(struct sock *sk) */ tp->plb_consec_cong_rounds = 0; } -EXPORT_SYMBOL_GPL(tcp_plb_update_state_upon_rto); diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 814fadb30749..a3210cda2515 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -297,6 +297,7 @@ static int tcp_write_timeout(struct sock *sk) } if (__sk_rethink_txhash_reset_dst(sk)) { + tcp_plb_update_state_upon_rto(sk); WRITE_ONCE(tp->timeout_rehash, tp->timeout_rehash + 1); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPTIMEOUTREHASH); } -- 2.56.1.915.g69d5ec7298-goog