Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Tue, 17 Nov 2026 23:13
Re: [PATCH v2 net-next 7/7] selftest: packetdrill: Add test for tcp_collapse().
Author: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 23:13
Date: Tue, 17 Nov 2026 23:13
131 lines
13119 bytes
13119 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] tcp_rcv_collapse_bloated.pkt cannot catch a regression in the
high-density/unread-bytes check, tcp_collapse_skb_bloated(), even…
- [Low] The last step of tcp_rcv_collapse_bloated.pkt claims to 'verify
data integrity', but `read(4, ..., 300000) = 279900` only checks the…
--
selftest: packetdrill: Add test for tcp_collapse().
This adds a packetdrill test, tcp_rcv_collapse_bloated.pkt. It queues a
mix of high-density and low-density skbs, shrinks SO_RCVBUF to trigger
tcp_prune_queue()->tcp_collapse(), and then checks TcpExtTCPRcvCollapsed
to confirm that exactly 30 skbs were collapsed. It also changes
ksft_runner.sh to skip any script whose PAGE_SIZE define does not match
getconf PAGESIZE.
> diff --git a/tools/testing/selftests/net/packetdrill/tcp_rcv_collapse_bloated.pkt b/tools/testing/selftests/net/packetdrill/tcp_rcv_collapse_bloated.pkt
> new file mode 100644
> index 0000000000000..90e8be86968f8
> --- /dev/null
> +++ b/tools/testing/selftests/net/packetdrill/tcp_rcv_collapse_bloated.pkt
> @@ -0,0 +1,135 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// Test that tcp_collapse() only collapses bloated skb runs, skips leading
> +// and trailing high-density skbs, skips isolated bloated skbs when collapsing
> +// them would not shrink truesize, and properly recovers receive buffer space.
[ ... ]
> +// 1. Queue two high-density 62,000 B segments (each adds 15 pages of frag
> +// truesize with enough margin across NET_SKB_PAD, L1_CACHE_BYTES, and
> +// MAX_SKB_FRAGS configs).
> +// Read 100 bytes from the first one so before(skb->seq, tp->copied_seq) is true.
> + +0 < P. 1:62001(62000) ack 1 win 65535
> + * > . 1:1(0) ack 62001
> + +0 read(4, ..., 100) = 100
[Severity: Low]
Can this test catch a regression in the density check itself?
The header comment says the test checks that tcp_collapse() skips
leading and trailing high-density skbs. The partial read here is meant to
cover the copied_seq case. However, every high-density skb is 62,000 B.
That is already larger than TCP_COLLAPSE_MAX_TOTAL_SIZE, which is
16 * 3776 = 60416 on 4K pages.
Because of this, two other checks in tcp_collapse() settle the outcome
for these skbs, whatever tcp_collapse_skb_bloated() returns. First, the
second loop stops any run from extending into a 62,000 B skb:
net/ipv4/tcp_input.c:tcp_collapse() {
...
if ((list || !before(TCP_SKB_CB(n)->seq, sub_end)) &&
(TCP_SKB_CB(n)->end_seq - start >= TCP_COLLAPSE_MAX_TOTAL_SIZE ||
!tcp_collapse_skb_bloated(n, sub_end,
TCP_COLLAPSE_SCALING_RATIO)))
break;
...
}
Second, the truesize comparison always skips a single 62,000 B skb:
if (old_truesize <= new_truesize) {
start = sub_end;
skb = n;
goto restart;
}
Here new_truesize = 16 * SKB_TRUESIZE(3776) + compute_skb_truesize(~1.5K)
= 69632 + 2304 = 71936. That is above the roughly 65792 truesize implied
by the rmem figures in the test.
If tcp_collapse_skb_bloated() is forced to always return true, the walk
over the queue looks like this:
skb1 (start = copied_seq = 101): breaks at skb2 because
124001 - 101 >= 60416, then the truesize check skips it
skb2: breaks at the isolated skb (63000 >= 60416), then skipped
isolated skb: breaks at skb3 (63000 >= 60416); old 2304 <= new
compute_skb_truesize(1000) = 2304, so skipped
skb3: breaks at the first small skb, then skipped
30-skb run: collapses, then breaks at the trailing skb
(92000 >= 60416)
trailing skb: the truesize check skips it
That still gives exactly 30 for TcpExtTCPRcvCollapsed, so the test
passes. It would also pass if the old before(TCP_SKB_CB(skb)->seq, start)
trigger came back in the first loop. In this test, the
!tcp_collapse_skb_bloated() break in the second loop never ends a run.
The test does catch the pre-series behaviour. But would a later
regression in tcp_collapse_skb_bloated(), or in the copied_seq-based
unread computation, pass this test unnoticed?
One option is to use high-density skbs small enough that a run stays
under TCP_COLLAPSE_MAX_TOTAL_SIZE, and where collapsing them would reduce
truesize. Then the density check would be what decides the outcome.
[ ... ]
> +// Read all remaining queued data to verify data integrity.
> + +0 read(4, ..., 300000) = 279900
[Severity: Low]
Does this read() actually verify data integrity? With the "..." buffer
form, packetdrill only checks the return value. The injected payloads are
also all identical zero-filled bytes.
Suppose the copy loop in tcp_collapse() used the wrong offset or source
skb:
int offset = start - TCP_SKB_CB(skb)->seq;
...
if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
or reordered bytes inside the collapsed range. read() would still return
279900, and the test would pass.
Should the comment say that this step only checks the byte count? Or
could the test send non-uniform payloads and verify their contents?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116230555.2305867-1-kuniyu%40google.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads