[PATCH net-next 2/2] selftests: tc-testing: add DRR deficit refill regression tests
flat view
COOLING10d
From: Victor Nogueira <hidden>
Date: 2026-10-08 15:23:54
Also in:
linux-kselftest
Subsystem:
kernel selftest framework, the rest · Maintainers:
Shuah Khan, Shuah Khan, Linus Torvalds
Add two DRR cases. The first asserts the post-dequeue deficit of a class with quantum 256 after one 1514-byte packet is serviced: 256 + DIV_ROUND_UP(1514 - 256, 256) * 256 - 1514 = 22 bytes, read via 'tc -s class show' while a second packet is still queued behind a netem-delayed child qdisc. The second guards the service order of a multi-class round: with two active quantum-256 classes, the list head holding a 1514-byte packet and the next class a 514-byte one, the small packet becomes eligible first and is the one dequeued. A per-class bulk refill that advances each class to its own eligibility point would dequeue the head class instead. The two cases verify differently on purpose: the deficit case reads an xstats field that tc prints only through its FP format string (it is not present in JSON output at all), so it must use matchPattern; the order case asserts the class stats and uses matchJSON for the richer backlog/qlen coverage. Both cases use a netem child under DRR, which peeks NULL until its delay expires, so both emit a rate-limited "drr_dequeue: qdisc ... is non-work-conserving?" line into dmesg. That is pre-existing behaviour for any netem-under-classful test (the infra 1f1f case does the same) and is expected, not a failure. Both cases assert the loop-equivalence invariant (deficit convergence and service order) and pass on the unpatched kernel by construction; they pin it against a future rewrite. Signed-off-by: Victor Nogueira <redacted> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> --- .../tc-testing/tc-tests/qdiscs/drr.json | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+)
diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/drr.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/drr.json
index 2b61d8d79bde..bb0995d8358f 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/drr.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/drr.json@@ -86,5 +86,87 @@ "teardown": [ "$TC qdisc del dev $DUMMY root" ] + }, + { + "id": "3f3e", + "name": "DRR deficit refill converges to the loop-equivalent value", + "category": [ + "qdisc", + "drr" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP addr add 10.10.11.10/24 dev $DUMMY", + "$TC qdisc add dev $DUMMY root handle 1: drr", + "$TC class add dev $DUMMY parent 1: classid 1:1 drr quantum 256", + "$TC qdisc add dev $DUMMY parent 1:1 handle 10: netem delay 2s limit 10", + "$TC filter add dev $DUMMY parent 1: protocol ip prio 1 u32 match u32 0 0 flowid 1:1", + "ping -c 2 -s 1472 -i 1 10.10.11.11 -I $DUMMY -W 0.01 >/dev/null 2>&1 &" + ], + "cmdUnderTest": "sleep 2.5", + "expExitCode": "0", + "verifyCmd": "$TC -s class show dev $DUMMY", + "matchPattern": "deficit 22b", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DUMMY root" + ] + }, + { + "id": "57a1", + "name": "DRR skips only rounds where no class can dequeue (keeps order)", + "category": [ + "qdisc", + "drr" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP addr add 10.10.11.10/24 dev $DUMMY", + "$TC qdisc add dev $DUMMY root handle 1: drr", + "$TC class add dev $DUMMY parent 1: classid 1:1 drr quantum 256", + "$TC class add dev $DUMMY parent 1: classid 1:2 drr quantum 256", + "$TC qdisc add dev $DUMMY parent 1:1 handle 10: netem delay 2s limit 10", + "$TC qdisc add dev $DUMMY parent 1:2 handle 20: netem delay 2s limit 10", + "$TC filter add dev $DUMMY parent 1: protocol ip prio 1 u32 match ip dport 1111 0xffff flowid 1:1", + "$TC filter add dev $DUMMY parent 1: protocol ip prio 1 u32 match ip dport 2222 0xffff flowid 1:2", + "python3 -c \"import socket; a=socket.socket(socket.AF_INET,socket.SOCK_DGRAM); b=socket.socket(socket.AF_INET,socket.SOCK_DGRAM); a.sendto(b'A'*1472,('10.10.11.11',1111)); b.sendto(b'B'*472,('10.10.11.11',2222))\" >/dev/null 2>&1 &", + "sleep 1", + "python3 -c \"import socket; a=socket.socket(socket.AF_INET,socket.SOCK_DGRAM); b=socket.socket(socket.AF_INET,socket.SOCK_DGRAM); a.sendto(b'A'*1472,('10.10.11.11',1111)); b.sendto(b'B'*472,('10.10.11.11',2222))\" >/dev/null 2>&1 &" + ], + "cmdUnderTest": "sleep 1.5", + "expExitCode": "0", + "verifyCmd": "$TC -j -s class show dev $DUMMY", + "matchJSON": [ + { + "class": "drr", + "handle": "1:1", + "root": true, + "stats": { + "bytes": 0, + "packets": 0, + "backlog": 3028, + "qlen": 2 + } + }, + { + "class": "drr", + "handle": "1:2", + "root": true, + "stats": { + "bytes": 514, + "packets": 1, + "backlog": 514, + "qlen": 1 + } + } + ], + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DUMMY root" + ] } ]
--
2.43.0