Add two test cases for the pfifo_fast ring size cap: 1. Init path: set txqueuelen to 100000000, attempt to attach pfifo_fast. On a fixed kernel the qdisc add is rejected with -ERANGE (exit code 2). On an unfixed kernel the allocation either succeeds or triggers OOM. 2. Resize path: attach pfifo_fast with default txqueuelen, then raise txqueuelen to 100000000. On a fixed kernel the resize is rejected with -ERANGE and txqueuelen rolls back to the original value (1000). On an unfixed kernel the ring is resized to the oversized value. Signed-off-by: Jamal Hadi Salim --- .../tc-tests/qdiscs/pfifo_fast.json | 60 +++++++++++++++++-- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/pfifo_fast.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/pfifo_fast.json index 30da27fe8806..46b54ae37a91 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/pfifo_fast.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/pfifo_fast.json @@ -9,8 +9,7 @@ "plugins": { "requires": "nsPlugin" }, - "setup": [ - ], + "setup": [], "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root pfifo_fast", "expExitCode": "0", "verifyCmd": "$TC qdisc show dev $DUMMY", @@ -30,8 +29,7 @@ "plugins": { "requires": "nsPlugin" }, - "setup": [ - ], + "setup": [], "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root pfifo_fast", "expExitCode": "0", "verifyCmd": "$TC -s qdisc show dev $DUMMY", @@ -81,8 +79,7 @@ "verifyCmd": "$TC qdisc show dev $DUMMY", "matchPattern": "qdisc pfifo_fast 1: root refcnt [0-9]+ bands 3 priomap", "matchCount": "0", - "teardown": [ - ] + "teardown": [] }, { "id": "4385", @@ -105,5 +102,56 @@ "teardown": [ "$TC qdisc del dev $DUMMY handle 1: root" ] + }, + { + "id": "7d12", + "name": "Reject pfifo_fast init with tx_queue_len exceeding S16_MAX", + "category": [ + "qdisc", + "pfifo_fast" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link set dev $DUMMY txqueuelen 100000000" + ], + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root pfifo_fast", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "qdisc pfifo_fast 1: root", + "matchCount": "0", + "teardown": [ + "$IP link set dev $DUMMY txqueuelen 1000", + [ + "$TC qdisc del dev $DUMMY handle 1: root", + 0, + 1, + 2, + 255 + ] + ] + }, + { + "id": "d09b", + "name": "Reject pfifo_fast resize when tx_queue_len exceeds S16_MAX", + "category": [ + "qdisc", + "pfifo_fast" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DUMMY handle 1: root pfifo_fast" + ], + "cmdUnderTest": "$IP link set dev $DUMMY txqueuelen 100000000", + "expExitCode": "2", + "verifyCmd": "$IP link show dev $DUMMY", + "matchPattern": "qlen 1000$", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DUMMY handle 1: root" + ] } ] -- 2.43.0