From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796374575; b=3n/SyjGTnGY1G/icgJDqqK4GXBh+d+/w6UZbif++FfpprJLiWXU2k7k+iYRVU4YNaqsx F2HEVJ0Xw/Xzlc6Vy1K/1GNQgTYzhoVsrd7aZHZSsoDS0NNlIF4febbpLTQ7BfmVZJTQ2 ihedoofkWKfUtFui3+j0yGrSMaSoDeT4uB7eDLMUXTaNsLeI1RbueYigF5+DVmDnnhYIy 85qh28lrHeEd9jcSfc4uQOZmjMkSf6oYCuow0gbhISgHX39QrsupeXBX/Kqp8ZNMKQU1Y uZfUAbJHo5nQmRvI/CH2XpY4zrRHYpMLntZzF+9Kj+7knPnNbH4ZhmNYX+/vXtUX/+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796374575; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=4BfDN4+JGdAiiy0Z3nIMtKMY6EkziFPv/2/8f/CYA/w=; b=q6LxuIjtdz6HqChFJ5Bj5w1v7nXXjU14Ep2ZZ0Ks+el2RXQyzk71Jjmth2Kd/5vs8Ti1 tdvLqBFnWdqYqiBMWTPiAIdt/NuVzc/XR1u+If/nqOeC5YCqm2BC4HqKLFc+kzWkHOOmZ qRD48cjodWpgHSwQb6L4cGOuTzzu7iDDQ9hdJr1QF92vhPptXWMpZ3J3ohthvTNx/YdB5 J9S8QUSu4cixaG23oPK/4uuMyz1Xpm6COH7BFjPzv6N64ywHMqkscyurDfOrd259BRYYU d/4WZvOI3FmGkYSCbmCECCdbW/DerxfxC6ui4SwZWLtCQMTaApZkHWZFGMm9bykZkwA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=lS8NfM7g; arc=none smtp.remote-ip=209.85.215.200 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5D77606A332 for ; Fri, 4 Dec 2026 08:56:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5D77606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=lS8NfM7g Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cdb91e288d7so721788a12.3 for ; Fri, 04 Dec 2026 00:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796374574; x=1796979374; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4BfDN4+JGdAiiy0Z3nIMtKMY6EkziFPv/2/8f/CYA/w=; b=lS8NfM7gfvZV6ZqfdZkMj6SWQRRARDtaQvr7rHRJ5vMqSL0pmJySV40XgGz0Gj5oCZ ZL9se9atd8i0fv5RwWrTGLzDJIC5WskzNrHrs8hpdVYk/WNEgFBLXeEfsQEaYs0g2uh1 jaoG/SyXpLZUe3CiUacDPdqh6cYzhKxV2Fj2f/k8XMB5SWY8E29RV+400dbMvIus06UH sXpwZUYpZ9y2+yonvFFuFYiAomlg2WjrlBaRTBQv+HBTBEQzME5npRo4ccf84ZtRhnAg T66ZM63SHYlwiiZz/lcvhJXKKGqhIv/vkedbGxEmeYgOvAlIYw9nwSHt1O9InJTmDCUW Qxmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796374574; x=1796979374; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4BfDN4+JGdAiiy0Z3nIMtKMY6EkziFPv/2/8f/CYA/w=; b=JwXHHMjN4bbfkZJSfU/AcBA/axDnVeIcZ9uOPm27WQ3LqvvBE3i8i+VZFr+9cboZzi Ro9Wiz3UZjb6zHzvyC5MRWH0IBGzEKuFKG0BXzLuIV6s3eosS3Ng2pFZErrg7739wmbQ hJrDdp5EzAK9lPo/WqSdBZUvhQtW+huwISo50HqMEnYQiTHzZg5gfqindVdtaHKt33G4 p1Harp+bIUVZIphL229wJGk/1wdLCY/1pfOIebsCsrHoOc7s0oBeamW81O+ysOMfmLhc /xk44a/z/DxYZ1rBZvoXThvAI9mhJ1EfJPYwDgjUEKdQm4qcfw1PKeNPMIgJbmXXTw8V c/zQ== X-Forwarded-Encrypted: i=1; AL+hErFWHViPARwTVSe3mnlHPrubQtMPgV6pT0rnpxQRbwu2jPugjDClvjejIm2hOc35q4QgaDSMJlc=@vger.kernel.org X-Gm-Message-State: APuU4Z+0rb7JZHbQfHCUBOd4vxD7aF5L6k5YKV/XjKSWaZ7PL78PWYAJ Ba3QK3MMS5VAfF1DksowQ/HXd5RdP6YY2sZxzFUJPW1Hzt7M9BbGjBGpOsJ23rmEW+CPNEv0T4x 6X7ZlZQ== X-Received: from pgby26-n2.prod.google.com ([2002:a05:6a02:651a:20b0:ce0:ea6a:4819]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:eec5:20b0:3e1:d75e:651e with SMTP id adf61e73a8af0-41562527407mr953525637.16.1796374573798; Fri, 04 Dec 2026 00:56:13 -0800 (PST) Date: Fri, 4 Dec 2026 17:54:39 +0900 In-Reply-To: <20261204085551.1518105-1-kuniyu@google.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261204085551.1518105-1-kuniyu@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204085551.1518105-10-kuniyu@google.com> Subject: [PATCH v1 net-next 09/10] selftest: packetdrill: Add tests for Generic PLB. From: Kuniyuki Iwashima To: Eric Dumazet , Neal Cardwell , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: Simon Horman , Yuchung Cheng , Kuniyuki Iwashima , Kuniyuki Iwashima , netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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