tcp_plb_loss_rate.pkt verifies that rehash happens when cur_rate drops sharply. tcp_plb_loss_rto_suspend.pkt verifies Generic PLB is also suspended for net.ipv4.tcp_plb_suspend_rto_sec seconds. tcp_plb_loss_tlp.pkt verifies spurious TLP does not rehash but TLP loss rehashes the flow. Signed-off-by: Kuniyuki Iwashima --- .../net/packetdrill/tcp_plb_loss_rate.pkt | 83 +++++++++ .../packetdrill/tcp_plb_loss_rto_suspend.pkt | 166 ++++++++++++++++++ .../net/packetdrill/tcp_plb_loss_tlp.pkt | 102 +++++++++++ 3 files changed, 351 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_plb_loss_rate.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_plb_loss_rto_suspend.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_plb_loss_tlp.pkt diff --git a/tools/testing/selftests/net/packetdrill/tcp_plb_loss_rate.pkt b/tools/testing/selftests/net/packetdrill/tcp_plb_loss_rate.pkt new file mode 100644 index 000000000000..2e81fde34e60 --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_plb_loss_rate.pkt @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Test TCP Generic PLB: rate-drop triggered PLB rehash in Fast Recovery. +// - Phase 1: 4 Fast Recovery rounds (< 5) -> no rehash. +// - Phase 2: Record non-app-limited plb_max_rate, then drop cur_rate +// upon entering the 5th Fast Recovery -> rehash. + +`./defaults.sh +sysctl -q net.ipv4.tcp_early_retrans=0 +sysctl -q net.ipv4.tcp_plb_loss_rehash_prob=255` + + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 + +0 bind(3, ..., ...) = 0 + +0 listen(3, 1) = 0 + +// Use 10ms handshake RTT (srtt ~ 10ms, RTO ~ 210ms > 50ms rate-drop wait). + +.01 < S 0:0(0) win 32792 + +0 > S. 0:0(0) ack 1 + +.01 < . 1:1(0) ack 1 win 320 + +0 accept(3, ..., ...) = 4 + +// Grow cwnd to 40 in Slow Start and record high plb_max_rate (~1125B / 10ms). + +0 write(4, ..., 3000) = 3000 + +0 > (flowlabel 0x1) P. 1:1001(1000) ack 1 + +.01 < . 1:1(0) ack 1001 win 320 + +0 > (flowlabel 0x1) P. 1001:3001(2000) ack 1 + +.01 < . 1:1(0) ack 3001 win 320 + +// Phase 1: 4 Fast Recovery rounds (plb_loss_recoveries = 1..4 < 5 -> no rehash). + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3001:3401(400) ack 1 + +.01 < . 1:1(0) ack 3001 win 320 + +0 > (flowlabel 0x1) . 3001:3101(100) ack 1 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +.01 < . 1:1(0) ack 3401 win 320 + + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3401:3801(400) ack 1 + +.01 < . 1:1(0) ack 3401 win 320 + +0 > (flowlabel 0x1) . 3401:3501(100) ack 1 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +.01 < . 1:1(0) ack 3801 win 320 + + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3801:4201(400) ack 1 + +.01 < . 1:1(0) ack 3801 win 320 + +0 > (flowlabel 0x1) . 3801:3901(100) ack 1 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +.01 < . 1:1(0) ack 4201 win 320 + + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 4201:4601(400) ack 1 + +.01 < . 1:1(0) ack 4201 win 320 + +0 > (flowlabel 0x1) . 4201:4301(100) ack 1 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +.01 < . 1:1(0) ack 4601 win 320 + +0 %{ assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state }% + +// Phase 2 (5th recovery with delivery rate drop -> rehash): cwnd == 9. +// Write 9 + 4 = 13 segments (1300B). +// Batch 1 (900B) is sent with is_app_limited = 1. + +.01 write(4, ..., 1300) = 1300 + +0 > (flowlabel 0x1) . 4601:5501(900) ack 1 + +// ACK Batch 1 at +.01: clears app_limited and clocks out Batch 2 (400B) +// with is_app_limited = 0. + +.01 < . 1:1(0) ack 5501 win 320 + +0 > (flowlabel 0x1) P. 5501:5901(400) ack 1 + +// Lose 5501:5601. +// 1st SACK at +.05 updates rate sample to 1 segment / 50ms with is_app_limited = 0. +// 2nd SACK makes sacked_out == 3 and enters Fast Recovery on the 5th recovery. + +.05 < . 1:1(0) ack 5501 win 320 + +0 < . 1:1(0) ack 5501 win 320 + +// Rate-drop on 5th recovery triggers rehash: +// Fast retransmit has flowlabel 0x2 and tcpi_rehash == 1. + +0 > (flowlabel 0x2) . 5501:5601(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +// Clean finish. + +.01 < . 1:1(0) ack 5901 win 320 diff --git a/tools/testing/selftests/net/packetdrill/tcp_plb_loss_rto_suspend.pkt b/tools/testing/selftests/net/packetdrill/tcp_plb_loss_rto_suspend.pkt new file mode 100644 index 000000000000..c44f7c65c8e5 --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_plb_loss_rto_suspend.pkt @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Test TCP Generic PLB: RTO reset of plb_loss_recoveries and RTO suspension. +// - Pre-RTO: 1 Fast Recovery sets plb_loss_recoveries = 1. +// - RTO: rehashes the socket, sets plb_pause_until to [1.0s, 2.0s), +// and resets plb_loss_recoveries to 0. +// - Phase 1: 5 Fast Recoveries within < 1.0s reach plb_loss_recoveries == 5 +// with rate_prob == 255, but rehash is suppressed by plb_pause_until. +// - Phase 2: After > 2.0s, 4 Fast Recoveries (< 5) do not rehash, and the +// 5th Fast Recovery clears plb_pause_until and triggers PLB rehash. + +`./defaults.sh +sysctl -q net.ipv4.tcp_early_retrans=0 +sysctl -q net.ipv4.tcp_plb_loss_rehash_prob=255 +sysctl -q net.ipv4.tcp_plb_suspend_rto_sec=1` + + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 + +0 bind(3, ..., ...) = 0 + +0 listen(3, 1) = 0 + +// Use 10ms handshake RTT. + +.01 < S 0:0(0) win 32792 + +0 > S. 0:0(0) ack 1 + +.01 < . 1:1(0) ack 1 win 320 + +0 accept(3, ..., ...) = 4 + +// Grow cwnd to 40 in Slow Start and record high plb_max_rate (~1125B / 10ms). + +0 write(4, ..., 3000) = 3000 + +0 > (flowlabel 0x1) P. 1:1001(1000) ack 1 + +.01 < . 1:1(0) ack 1001 win 320 + +0 > (flowlabel 0x1) P. 1001:3001(2000) ack 1 + +.01 < . 1:1(0) ack 3001 win 320 + +// Pre-RTO Fast Recovery: plb_loss_recoveries becomes 1. + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3001:3401(400) ack 1 + +.01 < . 1:1(0) ack 3001 win 320 + +0 > (flowlabel 0x1) . 3001:3101(100) ack 1 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +.01 < . 1:1(0) ack 3401 win 320 + +// RTO: rehashes flowlabel to 0x2 (tcpi_rehash == 1), sets pause_until to [1s, 2s), +// and resets plb_loss_recoveries from 1 to 0. + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x1) P. 3401:3501(100) ack 1 ++.19~+.27 > (flowlabel 0x2) P. 3401:3501(100) ack 1 + +.01 < . 1:1(0) ack 3501 win 320 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +// Phase 1: 5 Fast Recoveries within < 1.0s since RTO. +// Recovery 1 (plb_loss_recoveries == 1): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 3501:3601(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 3601:3701(100) ack 1 + +.01 < . 1:1(0) ack 3501 win 320 + +0 > (flowlabel 0x2) P. 3501:3601(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 3701 win 320 + +// Recovery 2 (plb_loss_recoveries == 2): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 3701:3801(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 3801:3901(100) ack 1 + +.01 < . 1:1(0) ack 3701 win 320 + +0 > (flowlabel 0x2) P. 3701:3801(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 3901 win 320 + +// Recovery 3 (plb_loss_recoveries == 3): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 3901:4001(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4001:4101(100) ack 1 + +.01 < . 1:1(0) ack 3901 win 320 + +0 > (flowlabel 0x2) P. 3901:4001(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 4101 win 320 + +// Recovery 4 (plb_loss_recoveries == 4): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4101:4201(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4201:4301(100) ack 1 + +.01 < . 1:1(0) ack 4101 win 320 + +0 > (flowlabel 0x2) P. 4101:4201(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 4301 win 320 + +// Deliver non-app-limited data and wait 50ms to establish low rate sample +// (rate_prob == 255) before Recovery 5 in Phase 1: + +0 write(4, ..., 300) = 300 + +0 > (flowlabel 0x2) . 4301:4501(200) ack 1 + +.01 < . 1:1(0) ack 4501 win 320 + +0 > (flowlabel 0x2) P. 4501:4601(100) ack 1 + +.05 < . 1:1(0) ack 4601 win 320 + +// Recovery 5 (plb_loss_recoveries reaches 5 and resets to 0; suppressed by pause_until): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4601:4701(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4701:4801(100) ack 1 + +.01 < . 1:1(0) ack 4601 win 320 + +0 > (flowlabel 0x2) P. 4601:4701(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 4801 win 320 + +// Phase 2: Wait 2.5s (> 2.0s max suspension window). +// Recovery 1 in Phase 2 (plb_loss_recoveries == 1): + +2.5 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4801:4901(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 4901:5001(100) ack 1 + +.01 < . 1:1(0) ack 4801 win 320 + +0 > (flowlabel 0x2) P. 4801:4901(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 5001 win 320 + +// Recovery 2 in Phase 2 (plb_loss_recoveries == 2): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5001:5101(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5101:5201(100) ack 1 + +.01 < . 1:1(0) ack 5001 win 320 + +0 > (flowlabel 0x2) P. 5001:5101(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 5201 win 320 + +// Recovery 3 in Phase 2 (plb_loss_recoveries == 3): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5201:5301(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5301:5401(100) ack 1 + +.01 < . 1:1(0) ack 5201 win 320 + +0 > (flowlabel 0x2) P. 5201:5301(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 5401 win 320 + +// Recovery 4 in Phase 2 (plb_loss_recoveries == 4): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5401:5501(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5501:5601(100) ack 1 + +.01 < . 1:1(0) ack 5401 win 320 + +0 > (flowlabel 0x2) P. 5401:5501(100) ack 1 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +.01 < . 1:1(0) ack 5601 win 320 + +// Deliver non-app-limited data and wait 50ms to establish low rate sample: + +0 write(4, ..., 300) = 300 + +0 > (flowlabel 0x2) . 5601:5801(200) ack 1 + +.01 < . 1:1(0) ack 5801 win 320 + +0 > (flowlabel 0x2) P. 5801:5901(100) ack 1 + +.05 < . 1:1(0) ack 5901 win 320 + +// Recovery 5 in Phase 2 (plb_loss_recoveries reaches 5 -> clears pause_until and rehashes): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 5901:6001(100) ack 1 + +.02 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 6001:6101(100) ack 1 + +.01 < . 1:1(0) ack 5901 win 320 + +0 > (flowlabel 0x3) P. 5901:6001(100) ack 1 + +0 %{ assert tcpi_rehash == 2, tcpi_rehash }% + +.01 < . 1:1(0) ack 6101 win 320 diff --git a/tools/testing/selftests/net/packetdrill/tcp_plb_loss_tlp.pkt b/tools/testing/selftests/net/packetdrill/tcp_plb_loss_tlp.pkt new file mode 100644 index 000000000000..d6c8ee5d184e --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_plb_loss_tlp.pkt @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Test TCP Generic PLB: TLP loss probe triggered PLB rehash. +// - Setup: Establish high plb_max_rate and 4 Fast Recoveries +// so plb_loss_recoveries == 4. +// - Part A: Spurious TLP acked by DSACK does not call +// tcp_plb_check_rehash_loss() -> no rehash. +// - Part B: Real tail loss detected by TLP (after(ack, tp->tlp_high_seq)) +// increments plb_loss_recoveries to 5 and triggers PLB rehash. + +`./defaults.sh +sysctl -q net.ipv4.tcp_plb_loss_rehash_prob=255` + + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 + +0 bind(3, ..., ...) = 0 + +0 listen(3, 1) = 0 + +// Use 10ms handshake RTT. + +.01 < S 0:0(0) win 32792 + +0 > S. 0:0(0) ack 1 + +.01 < . 1:1(0) ack 1 win 320 + +0 accept(3, ..., ...) = 4 + +// Grow cwnd to 40 in Slow Start and record high plb_max_rate (~1125B / 10ms). + +0 write(4, ..., 3000) = 3000 + +0 > (flowlabel 0x1) P. 1:1001(1000) ack 1 + +.01 < . 1:1(0) ack 1001 win 320 + +0 > (flowlabel 0x1) P. 1001:3001(2000) ack 1 + +.01 < . 1:1(0) ack 3001 win 320 + +// Trigger 4 Fast Recovery rounds so plb_loss_recoveries == 4 (< 5). + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3001:3401(400) ack 1 + +.01 < . 1:1(0) ack 3001 win 320 + +0 > (flowlabel 0x1) . 3001:3101(100) ack 1 + +.01 < . 1:1(0) ack 3401 win 320 + + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3401:3801(400) ack 1 + +.01 < . 1:1(0) ack 3401 win 320 + +0 > (flowlabel 0x1) . 3401:3501(100) ack 1 + +.01 < . 1:1(0) ack 3801 win 320 + + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 3801:4201(400) ack 1 + +.01 < . 1:1(0) ack 3801 win 320 + +0 > (flowlabel 0x1) . 3801:3901(100) ack 1 + +.01 < . 1:1(0) ack 4201 win 320 + + +0 write(4, ..., 400) = 400 + +0 > (flowlabel 0x1) P. 4201:4601(400) ack 1 + +.01 < . 1:1(0) ack 4201 win 320 + +0 > (flowlabel 0x1) . 4201:4301(100) ack 1 + +.01 < . 1:1(0) ack 4601 win 320 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +// Part A: DSACK TLP (no actual loss) must NOT call tcp_plb_check_rehash_loss(). +// cwnd == 9. Write 9 + 2 = 11 segments (1100B) so Batch 2 (5501:5701, 200B) +// is clocked out with is_app_limited = 0. + +0 write(4, ..., 1100) = 1100 + +0 > (flowlabel 0x1) . 4601:5501(900) ack 1 + +.01 < . 1:1(0) ack 5501 win 320 + +0 > (flowlabel 0x1) P. 5501:5701(200) ack 1 + +// With packets_out == 2 > 1 and srtt == 10ms, TLP probe fires +// at 2 * srtt + 2ms = 22ms: ++.018~+.040 > (flowlabel 0x1) P. 5601:5701(100) ack 1 + +// Wait +.05 (< 210ms RTO) and ACK 5601 (1 segment / ~72ms with is_app_limited = 0), +// rearming RTO while keeping tlp_high_seq == 5701. + +.05 < . 1:1(0) ack 5601 win 320 + +// Wait +.05 and receive DSACK. FLAG_DSACK_TLP skips tcp_plb_check_rehash_loss(), +// so plb_loss_recoveries stays 4 and no rehash occurs. + +.05 < . 1:1(0) ack 5701 win 320 + +0 %{ assert tcpi_rehash == 0, tcpi_rehash }% + +// Part B: TLP Loss Recovery (after(ack, tp->tlp_high_seq)) calls +// tcp_plb_check_rehash_loss(), incrementing plb_loss_recoveries to 5. +// Write 2 segments (200B) so packets_out == 2 > 1: + +0 write(4, ..., 200) = 200 + +0 > (flowlabel 0x1) P. 5701:5901(200) ack 1 + +// With packets_out == 2 > 1 and srtt ~ 18ms, TLP probe fires at +// 2 * srtt + 2ms ~ 38ms (tlp_high_seq = 5901): ++.028~+.055 > (flowlabel 0x1) P. 5801:5901(100) ack 1 + +// Sender transmits new data while TLP is in flight (tlp_high_seq remains 5901): + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x1) P. 5901:6001(100) ack 1 + +// Peer cumulatively ACKs 6001 (ack 6001 > tlp_high_seq 5901). +// tcp_process_tlp_ack() runs before tcp_rate_gen(), sees +// after(ack, tp->tlp_high_seq) on the 5th recovery, and triggers rehash! + +.01 < . 1:1(0) ack 6001 win 320 + +0 %{ assert tcpi_rehash == 1, tcpi_rehash }% + +// Outbound packet now has flowlabel 0x2. + +0 write(4, ..., 100) = 100 + +0 > (flowlabel 0x2) P. 6001:6101(100) ack 1 + +.01 < . 1:1(0) ack 6101 win 320 -- 2.56.1.915.g69d5ec7298-goog