mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 21:44:23 -04:00
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>
This commit is contained in:
@@ -652,6 +652,10 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (ctl->limit == 1) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "invalid limit");
|
||||
return -EINVAL;
|
||||
}
|
||||
sch_tree_lock(sch);
|
||||
if (ctl->quantum)
|
||||
q->quantum = ctl->quantum;
|
||||
|
||||
21
tools/testing/selftests/tc-testing/scripts/sfq_rejects_limit_1.py
Executable file
21
tools/testing/selftests/tc-testing/scripts/sfq_rejects_limit_1.py
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Script that checks that SFQ rejects a limit of 1 at the kernel
|
||||
# level. We can't use iproute2's tc because it does not accept a limit
|
||||
# of 1.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
from pyroute2 import IPRoute
|
||||
from pyroute2.netlink.exceptions import NetlinkError
|
||||
|
||||
ip = IPRoute()
|
||||
ifidx = ip.link_lookup(ifname=sys.argv[1])
|
||||
|
||||
try:
|
||||
ip.tc('add', 'sfq', ifidx, limit=1)
|
||||
sys.exit(1)
|
||||
except NetlinkError:
|
||||
sys.exit(0)
|
||||
@@ -208,5 +208,25 @@
|
||||
"teardown": [
|
||||
"$TC qdisc del dev $DUMMY handle 1: root"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "4d6f",
|
||||
"name": "Check that limit of 1 is rejected",
|
||||
"category": [
|
||||
"qdisc",
|
||||
"sfq"
|
||||
],
|
||||
"plugins": {
|
||||
"requires": "nsPlugin"
|
||||
},
|
||||
"setup": [
|
||||
],
|
||||
"cmdUnderTest": "./scripts/sfq_rejects_limit_1.py $DUMMY",
|
||||
"expExitCode": "0",
|
||||
"verifyCmd": "$TC qdisc show dev $DUMMY",
|
||||
"matchPattern": "sfq",
|
||||
"matchCount": "0",
|
||||
"teardown": [
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user