Add a packetdrill test for the ROCCET idle restart on RTO. TLP is enabled, so the first RTO is affected; the test asserts that tp->snd_ssthresh stays at the prior cwnd (20) across the first and second RTOs. The test fails at the first RTO without the preceding fix (snd_ssthresh == 10) and passes with it. A variant with tcp_early_retrans=0 (no TLP) fails at the second RTO only. CONFIG_TCP_CONG_ADVANCED and CONFIG_TCP_CONG_ROCCET are added to the packetdrill config; ROCCET is only visible when advanced congestion control is enabled. Test written by Eric Dumazet. Suggested-by: Eric Dumazet Signed-off-by: Zhiqi Zhang --- .../testing/selftests/net/packetdrill/config | 2 + .../net/packetdrill/tcp_roccet_rto.pkt | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_roccet_rto.pkt diff --git a/tools/testing/selftests/net/packetdrill/config b/tools/testing/selftests/net/packetdrill/config index b7df8bf309..6e012141d5 100644 --- a/tools/testing/selftests/net/packetdrill/config +++ b/tools/testing/selftests/net/packetdrill/config @@ -6,6 +6,8 @@ CONFIG_NET_SCH_FIFO=y CONFIG_NET_SCH_FQ=y CONFIG_SYN_COOKIES=y CONFIG_SYSCTL=y +CONFIG_TCP_CONG_ADVANCED=y CONFIG_TCP_CONG_CUBIC=y +CONFIG_TCP_CONG_ROCCET=y CONFIG_TCP_MD5SIG=y CONFIG_TUN=y diff --git a/tools/testing/selftests/net/packetdrill/tcp_roccet_rto.pkt b/tools/testing/selftests/net/packetdrill/tcp_roccet_rto.pkt new file mode 100644 index 0000000000..dabaf07f32 --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_roccet_rto.pkt @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 +// Test that ROCCET does not take its "restart after idle" path on RTO. +// +// An RTO retransmit raises CA_EVENT_TX_START, because all outstanding +// packets were just marked lost (tcp_packets_in_flight() == 0) while +// tp->packets_out is not zero. If (now - tp->lsndtime) >= icsk_rto, +// roccet_cwnd_event_tx_start() used to overwrite the snd_ssthresh +// that tcp_enter_loss() had just set with TCP_INIT_CWND. +// +// TLP is enabled here. The RTO timer is rearmed for a full icsk_rto when +// the loss probe is sent, and the probe is the last transmit, so the +// very first RTO is affected. + +`./defaults.sh +./set_sysctls.py /proc/sys/net/ipv4/tcp_slow_start_after_idle=1` + + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 + +0 setsockopt(3, SOL_TCP, TCP_CONGESTION, "roccet", 6) = 0 + +0 bind(3, ..., ...) = 0 + +0 listen(3, 1) = 0 + + +0 < S 0:0(0) win 65535 + +0 > S. 0:0(0) ack 1 + +.1 < . 1:1(0) ack 1 win 511 + +0 accept(3, ..., ...) = 4 + +// ROCCET paces its packets: do not expect precise outgoing packets, +// rely on TCP_INFO instead. + +0 write(4, ..., 10000) = 10000 + +.1 < . 1:1(0) ack 10001 win 511 + +0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }% + +// RTT is 100ms, RTO is ~300ms. Nothing is acked from now on. + +0 write(4, ..., 20000) = 20000 + +// TLP fires ~250ms after the write. + +.4 %{ +assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state +assert tcpi_total_retrans == 1, tcpi_total_retrans +}% + +// First RTO, ~300ms after the TLP probe. +// ROCCET is still in LAUNCH state: ssthresh is set to the prior cwnd. + +.3 %{ +assert tcpi_ca_state == TCP_CA_Loss, tcpi_ca_state +assert tcpi_backoff == 1, tcpi_backoff +assert tcpi_total_retrans == 2, tcpi_total_retrans +assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd +assert tcpi_snd_ssthresh == 20, tcpi_snd_ssthresh +}% + +// Second RTO, ~600ms after the first one. + +.6 %{ +assert tcpi_ca_state == TCP_CA_Loss, tcpi_ca_state +assert tcpi_backoff == 2, tcpi_backoff +assert tcpi_total_retrans == 3, tcpi_total_retrans +assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd +assert tcpi_snd_ssthresh == 20, tcpi_snd_ssthresh +}% + +// Reset sysctls +`/tmp/sysctl_restore_${PPID}.sh` -- 2.54.0 (Apple Git-157)