Skip to content

Commit 7629d1a

Browse files
congwangkuba-moo
authored andcommitted
selftests/tc-testing: Add test for HFSC queue emptying during peek operation
Add a selftest to exercise the condition where qdisc implementations like netem or codel might empty the queue during a peek operation. This tests the defensive code path in HFSC that checks the queue length again after peeking to handle this case. Based on the reproducer from Gerrard, improved by Jamal. Reported-by: Gerrard Tai <gerrard.tai@starlabs.sg> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Tested-by: Victor Nogueira <victor@mojatatu.com> Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Link: https://patch.msgid.link/20250417184732.943057-4-xiyou.wangcong@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6ccbda4 commit 7629d1a

File tree

1 file changed

+39
-0
lines changed
  • tools/testing/selftests/tc-testing/tc-tests/infra

1 file changed

+39
-0
lines changed

tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,44 @@
313313
"$TC qdisc del dev $DUMMY handle 1: root",
314314
"$IP addr del 10.10.10.10/24 dev $DUMMY || true"
315315
]
316+
},
317+
{
318+
"id": "a4c3",
319+
"name": "Test HFSC with netem/blackhole - queue emptying during peek operation",
320+
"category": [
321+
"qdisc",
322+
"hfsc",
323+
"netem",
324+
"blackhole"
325+
],
326+
"plugins": {
327+
"requires": "nsPlugin"
328+
},
329+
"setup": [
330+
"$IP link set dev $DUMMY up || true",
331+
"$IP addr add 10.10.10.10/24 dev $DUMMY || true",
332+
"$TC qdisc add dev $DUMMY handle 1:0 root drr",
333+
"$TC class add dev $DUMMY parent 1:0 classid 1:1 drr",
334+
"$TC class add dev $DUMMY parent 1:0 classid 1:2 drr",
335+
"$TC qdisc add dev $DUMMY parent 1:1 handle 2:0 plug limit 1024",
336+
"$TC qdisc add dev $DUMMY parent 1:2 handle 3:0 hfsc default 1",
337+
"$TC class add dev $DUMMY parent 3:0 classid 3:1 hfsc rt m1 5Mbit d 10ms m2 10Mbit",
338+
"$TC qdisc add dev $DUMMY parent 3:1 handle 4:0 netem delay 1ms",
339+
"$TC qdisc add dev $DUMMY parent 4:1 handle 5:0 blackhole",
340+
"ping -c 3 -W 0.01 -i 0.001 -s 1 10.10.10.10 -I $DUMMY > /dev/null 2>&1 || true",
341+
"$TC class change dev $DUMMY parent 3:0 classid 3:1 hfsc sc m1 5Mbit d 10ms m2 10Mbit",
342+
"$TC class del dev $DUMMY parent 3:0 classid 3:1",
343+
"$TC class add dev $DUMMY parent 3:0 classid 3:1 hfsc rt m1 5Mbit d 10ms m2 10Mbit",
344+
"ping -c 3 -W 0.01 -i 0.001 -s 1 10.10.10.10 -I $DUMMY > /dev/null 2>&1 || true"
345+
],
346+
"cmdUnderTest": "$TC class change dev $DUMMY parent 3:0 classid 3:1 hfsc sc m1 5Mbit d 10ms m2 10Mbit",
347+
"expExitCode": "0",
348+
"verifyCmd": "$TC -s qdisc show dev $DUMMY",
349+
"matchPattern": "qdisc hfsc 3:.*parent 1:2.*default 1",
350+
"matchCount": "1",
351+
"teardown": [
352+
"$TC qdisc del dev $DUMMY handle 1:0 root",
353+
"$IP addr del 10.10.10.10/24 dev $DUMMY || true"
354+
]
316355
}
317356
]

0 commit comments

Comments
 (0)