Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/tc-testing: Create test cases for adding qdiscs to invalid qdisc parents

As described in a previous commit [1], Lion's patch [2] revealed an ancient
bug in the qdisc API. Whenever a user tries to add a qdisc to an
invalid parent (not a class, root, or ingress qdisc), the qdisc API will
detect this after qdisc_create is called. Some qdiscs (like fq_codel, pie,
and sfq) call functions (on their init callback) which assume the parent is
valid, so qdisc_create itself may have caused a NULL pointer dereference in
such cases.

This commit creates 3 TDC tests that attempt to add fq_codel, pie and sfq
qdiscs to invalid parents

- Attempts to add an fq_codel qdisc to an hhf qdisc parent
- Attempts to add a pie qdisc to a drr qdisc parent
- Attempts to add an sfq qdisc to an inexistent hfsc classid (which would
belong to a valid hfsc qdisc)

[1] https://lore.kernel.org/all/20250707210801.372995-1-victor@mojatatu.com/
[2] https://lore.kernel.org/netdev/d912cbd7-193b-4269-9857-525bee8bbb6a@gmail.com/

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Link: https://patch.msgid.link/20250712145035.705156-1-victor@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Victor Nogueira and committed by
Jakub Kicinski
e18f3486 60ada4fe

+66
+66
tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json
··· 672 672 "teardown": [ 673 673 "$TC qdisc del dev $DUMMY root handle 1: drr" 674 674 ] 675 + }, 676 + { 677 + "id": "be28", 678 + "name": "Try to add fq_codel qdisc as a child of an hhf qdisc", 679 + "category": [ 680 + "qdisc", 681 + "fq_codel", 682 + "hhf" 683 + ], 684 + "plugins": { 685 + "requires": "nsPlugin" 686 + }, 687 + "setup": [ 688 + "$TC qdisc add dev $DUMMY root handle a: hhf" 689 + ], 690 + "cmdUnderTest": "$TC qdisc add dev $DUMMY parent a: handle b: fq_codel", 691 + "expExitCode": "2", 692 + "verifyCmd": "$TC -j qdisc ls dev $DUMMY handle b:", 693 + "matchJSON": [], 694 + "teardown": [ 695 + "$TC qdisc del dev $DUMMY root" 696 + ] 697 + }, 698 + { 699 + "id": "fcb5", 700 + "name": "Try to add pie qdisc as a child of a drr qdisc", 701 + "category": [ 702 + "qdisc", 703 + "pie", 704 + "drr" 705 + ], 706 + "plugins": { 707 + "requires": "nsPlugin" 708 + }, 709 + "setup": [ 710 + "$TC qdisc add dev $DUMMY root handle a: drr" 711 + ], 712 + "cmdUnderTest": "$TC qdisc add dev $DUMMY parent a: handle b: pie", 713 + "expExitCode": "2", 714 + "verifyCmd": "$TC -j qdisc ls dev $DUMMY handle b:", 715 + "matchJSON": [], 716 + "teardown": [ 717 + "$TC qdisc del dev $DUMMY root" 718 + ] 719 + }, 720 + { 721 + "id": "7801", 722 + "name": "Try to add fq qdisc as a child of an inexistent hfsc class", 723 + "category": [ 724 + "qdisc", 725 + "sfq", 726 + "hfsc" 727 + ], 728 + "plugins": { 729 + "requires": "nsPlugin" 730 + }, 731 + "setup": [ 732 + "$TC qdisc add dev $DUMMY root handle a: hfsc" 733 + ], 734 + "cmdUnderTest": "$TC qdisc add dev $DUMMY parent a:fff2 sfq limit 4", 735 + "expExitCode": "2", 736 + "verifyCmd": "$TC -j qdisc ls dev $DUMMY handle b:", 737 + "matchJSON": [], 738 + "teardown": [ 739 + "$TC qdisc del dev $DUMMY root" 740 + ] 675 741 } 676 742 ]