From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f227.google.com (mail-pf1-f227.google.com [209.85.210.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 647FB3E0228 for ; Mon, 4 May 2026 14:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.227 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777906432; cv=none; b=LxAL6xf/RrfZG96nQfzEz//2L5hiDxEohNgzTqu4H+9xEcX+PNWM1Eo66HnYMWUKpt8UixbTvFR0dab/nehDrDQQNRmuMRGDuk9Hq/7Xe5mVDKohP4z5WtqhCHapGW8nq7EBaC73f9YASAzP6V9edigSDQkQZqaFkbAvrfEI450= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777906432; c=relaxed/simple; bh=NHQizhHkJFek9eWTi5oYmtlX7dFb8feNSqydNnqPYoo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hej1BdtzjtW0hPIprYmBIWlIn6MHUx507IjOICGrRUQB3JpMxaIUaqhFGSmBrrsNLxzzsDT70ouqbY+t68B0NkCX1c8u6UhJXsS+jVtKOmnp2ie1Obk9d+nYYW55Je6xiLIfsTd70lUEHuEvNjc7iMdH7qz/M9iTdIN8DnyQxDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=JFv78a2P; arc=none smtp.client-ip=209.85.210.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JFv78a2P" Received: by mail-pf1-f227.google.com with SMTP id d2e1a72fcca58-8368a5d79d3so115958b3a.0 for ; Mon, 04 May 2026 07:53:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777906431; x=1778511231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NHQizhHkJFek9eWTi5oYmtlX7dFb8feNSqydNnqPYoo=; b=T3l6IXfH4uNTBxfe42QtRY/I9LFWh9mCKHkddbeGQlrZioWsEimUfeTKKWcKsrNDoQ qnZPy7wL8AOkmOTUDhFgH5gl4EACdDwsy4NE1r4Oec2vzi+Cq9ULI1kLJ1UC9Pvmk5ls VSZgI4F6w81xAzc1Z2NkV+jl8NnJLScIhafG2RmGhaFaWzWrNtbIS0sit7fR4oMpU19K hMbd0pycO3Z5/DVAPva6hjW2dVQMvjMMFy01kQB4OGP+08jP6fqwnSMCgqP0uBJjykOq lwRwpgO0wXgJB4gzSVccv8aOMlQgzY6pONNIhcXdRvjw8UskXZWCMbLlY8gv3swHpgh4 a30A== X-Forwarded-Encrypted: i=1; AFNElJ+IUoXJ6xMXSJsJhxxM38n8aarcpn0XdhximrDm/3WzrMSS+GoEiqVJD039Nqjk9Jyopjxd3ADoTEri3yI=@vger.kernel.org X-Gm-Message-State: AOJu0YyTKZeEWialiWg8wzJsPp43Q9Xj9kbF3AZ5dX69lytBt1gs0xku eiX1brdVfm4EPRfGBI2kQOxjHaE0Ssgtc6WxnhNoF1xHHqf1fXLAQOz6tZr0iK9fLnNNVCiIPIM tlxO2nNO+FYyc9IghUwRtJBPx69GmZ2pEiJeg/UYgq5FKzei/q8i/rGjVV+czfAG2FQtupyZJ2r dHGUx8zR4RlgQ8U7zzfhKAAbjCEQEmpTsaTIxcv1jaSFBBSnAW/jQSUn4oOhfHhJzIa9KiNMH5b Ia3ICEWrviX9BFNnogWilM= X-Gm-Gg: AeBDievKkqMEvjwZPr8XyCY9LoKpWQlYlxThL+uOsZUHaoCdSBWmuttPGhyrvrngmDf 90LWU1wI+sG/sa0YKTZQJ2kyjQZrNebnxkn+Jajx+SvcvUIsUCm0rhcvhjrFHgjAdZniB91MtQn Qv6pdpx3F1w480VwrXXfCMZxho0R2gikZed0QqsrYxKaAL0xxncfKimx1U/YbXKRhnNTVl4qK/Z uQ1cb671nrWcIKGoJ2NRR1ea837nik2Ytk2qvEGORHgnbXd9amnmt7Y2ITCydul7WMngVzk7usD s8VuNHL/Syo2c8Es/0V0Gu34igp7PVvykMyk6c3isP2n4aY8c4Dep9sVdYRaOOtHbsoyLw8Fbs4 t5tUjUUEntVrAEU5gW0NYkofOgIXXxFzEq4usx2y9UlPCANI6+yNSKl0ctKnN81+2dMBYhgm1hY s2w7hQYZ0Pcf93w04rPD84k4HnZsvzbPfsIfsGcJ3nFBdK1Zpu+Sf55/rGdUno0f/FSfbj X-Received: by 2002:a05:6a00:a220:b0:835:3f0b:db71 with SMTP id d2e1a72fcca58-8353f0be322mr3948422b3a.6.1777906430505; Mon, 04 May 2026 07:53:50 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-21.dlp.protect.broadcom.com. [144.49.247.21]) by smtp-relay.gmail.com with ESMTPS id d2e1a72fcca58-83846887af5sm179108b3a.5.2026.05.04.07.53.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2026 07:53:50 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-8ee2dfd63beso45085285a.1 for ; Mon, 04 May 2026 07:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1777906429; x=1778511229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NHQizhHkJFek9eWTi5oYmtlX7dFb8feNSqydNnqPYoo=; b=JFv78a2PpDkIaHme3ck10Nit/5VwzBWCjaZgNBbnVbjs+P61VvgvHWjklObHY5UsXP i0nRUt78bmjxNx1Wy5lNmBPGn8oYv+YjWcVVDPl1gra+6aZA7bnhkr96igmKS9128Ukx yzBuQbAVxgj1+hMhr5/9md8y3eDeVzbaF6zgI= X-Forwarded-Encrypted: i=1; AFNElJ9/OYPIn4dh726sNhV3BYFB3ATRD9ncM5lpT33tgPM3KNgyGuqtGCYg1X1yQci83aEuwVMy+074+oL42Ek=@vger.kernel.org X-Received: by 2002:a05:620a:404d:b0:8ef:2118:aecd with SMTP id af79cd13be357-8fd127b737dmr1008302285a.0.1777906429113; Mon, 04 May 2026 07:53:49 -0700 (PDT) X-Received: by 2002:a05:620a:404d:b0:8ef:2118:aecd with SMTP id af79cd13be357-8fd127b737dmr1008297585a.0.1777906428521; Mon, 04 May 2026 07:53:48 -0700 (PDT) Received: from photon-d7fac424c0d3 ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8fc2c91fb3bsm1046315985a.41.2026.05.04.07.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 07:53:48 -0700 (PDT) From: Ankit Jain To: edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org Cc: davem@davemloft.net, pabeni@redhat.com, ncardwell@google.com, kuniyu@google.com, horms@kernel.org, shuah@kernel.org, quic_subashab@quicinc.com, quic_stranche@quicinc.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, karen.badiryan@broadcom.com, ajay.kaher@broadcom.com, alexey.makhalov@broadcom.com, vamsi-krishna.brahmajosyula@broadcom.com, yin.ding@broadcom.com, tapas.kundu@broadcom.com, Ankit Jain Subject: [PATCH net v2 2/2] selftests/net: add packetdrill test for locked SO_RCVBUF SWS Date: Mon, 4 May 2026 14:49:45 +0000 Message-ID: <20260504144945.13477-3-ankit-aj.jain@broadcom.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260504144945.13477-1-ankit-aj.jain@broadcom.com> References: <20260504144945.13477-1-ankit-aj.jain@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Add a packetdrill test to verify that TCP does not aggressively penalize the `scaling_ratio` when an application explicitly locks the receive buffer via SO_RCVBUF. This test establishes a connection with a very small MSS, then injects small payloads. On buggy kernels, the payload-to-truesize memory penalty drops the `scaling_ratio` to 1, which shrinks the dynamically calculated window and causes Silly Window Syndrome (SWS). The test asserts that `tcpi_rcv_ssthresh` (the exposed window clamp) remains protected and stays at a healthy level. Signed-off-by: Ankit Jain --- .../net/packetdrill/tcp_locked_rcvbuf_sws.pkt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.pkt diff --git a/tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.pkt b/tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.pkt new file mode 100644 index 000000000000..96d3a0813548 --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.pkt @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +// Test that TCP does not apply aggressive truesize penalties +// to the scaling_ratio when the application has explicitly locked +// the receive buffer, preventing Silly Window Syndrome. + +// 1. Create a socket and lock SO_RCVBUF to 32K +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 ++0 setsockopt(3, SOL_SOCKET, SO_RCVBUF, [32768], 4) = 0 ++0 bind(3, ..., ...) = 0 ++0 listen(3, 1) = 0 + +// 2. Establish connection with a TINY MSS (48 bytes) +// This forces the kernel's rcv_mss expectation to initialize at rock bottom. ++0 < S 0:0(0) win 65535 ++0 > S. 0:0(0) ack 1 <...> ++0 < . 1:1(0) ack 1 win 65535 ++0 accept(3, ..., ...) = 4 + +// 3. Inject 100 bytes. +// 100 is > 48, so this forces tcp_measure_rcv_mss() to recalculate the scaling ratio. +// Because the payload (100B) is small compared to the sk_buff truesize, +// kernels without the fix will incorrectly drop the scaling_ratio. ++0.1 < P. 1:101(100) ack 1 win 65535 ++0 > . 1:1(0) ack 101 <...> + +// 4. Inject 110 bytes to bypass the length jitter optimization and force +// a second recalculation, driving the scaling_ratio to 1 and crushing the clamp. ++0.1 < P. 101:211(110) ack 1 win 65535 ++0 > . 1:1(0) ack 211 <...> + +// 5. Assert the window clamp (tcpi_rcv_ssthresh) is protected from the penalty. ++0.1 %{ +assert tcpi_rcv_ssthresh > 15000, f"BUG DETECTED: scaling_ratio crushed! rcv_ssthresh={tcpi_rcv_ssthresh}" +}% -- 2.53.0