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.

Merge branch 'net_sched-sch_sfq-reject-limit-of-1'

Octavian Purdila says:

====================
net_sched: sch_sfq: reject limit of 1

The implementation does not properly support limits of 1. Add an
in-kernel check, in addition to existing iproute2 check, since other
tools may be used for configuration.

This patch set also adds a selfcheck to test that a limit of 1 is
rejected.

An alternative (or in addition) we could fix the implementation by
setting q->tail to NULL in sfq_drop if this is the last slot we marked
empty, e.g.:

--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -317,8 +317,11 @@ static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)
/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
x = q->tail->next;
slot = &q->slots[x];
- q->tail->next = slot->next;
q->ht[slot->hash] = SFQ_EMPTY_SLOT;
+ if (x == slot->next)
+ q->tail = NULL; /* no more active slots */
+ else
+ q->tail->next = slot->next;
goto drop;
}
====================

Link: https://patch.msgid.link/20241204030520.2084663-1-tavip@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+45
+4
net/sched/sch_sfq.c
··· 652 652 if (!p) 653 653 return -ENOMEM; 654 654 } 655 + if (ctl->limit == 1) { 656 + NL_SET_ERR_MSG_MOD(extack, "invalid limit"); 657 + return -EINVAL; 658 + } 655 659 sch_tree_lock(sch); 656 660 if (ctl->quantum) 657 661 q->quantum = ctl->quantum;
+21
tools/testing/selftests/tc-testing/scripts/sfq_rejects_limit_1.py
··· 1 + #!/usr/bin/env python3 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Script that checks that SFQ rejects a limit of 1 at the kernel 5 + # level. We can't use iproute2's tc because it does not accept a limit 6 + # of 1. 7 + 8 + import sys 9 + import os 10 + 11 + from pyroute2 import IPRoute 12 + from pyroute2.netlink.exceptions import NetlinkError 13 + 14 + ip = IPRoute() 15 + ifidx = ip.link_lookup(ifname=sys.argv[1]) 16 + 17 + try: 18 + ip.tc('add', 'sfq', ifidx, limit=1) 19 + sys.exit(1) 20 + except NetlinkError: 21 + sys.exit(0)
+20
tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json
··· 208 208 "teardown": [ 209 209 "$TC qdisc del dev $DUMMY handle 1: root" 210 210 ] 211 + }, 212 + { 213 + "id": "4d6f", 214 + "name": "Check that limit of 1 is rejected", 215 + "category": [ 216 + "qdisc", 217 + "sfq" 218 + ], 219 + "plugins": { 220 + "requires": "nsPlugin" 221 + }, 222 + "setup": [ 223 + ], 224 + "cmdUnderTest": "./scripts/sfq_rejects_limit_1.py $DUMMY", 225 + "expExitCode": "0", 226 + "verifyCmd": "$TC qdisc show dev $DUMMY", 227 + "matchPattern": "sfq", 228 + "matchCount": "0", 229 + "teardown": [ 230 + ] 211 231 } 212 232 ]