Skip to content

Commit 9d23aac

Browse files
author
Paolo Abeni
committed
Merge branch 'net-sched-fixes-for-sch_qfq'
Pedro Tammela says: ==================== net/sched: fixes for sch_qfq Patch 1 fixes a regression introduced in 6.4 where the MTU size could be bigger than 'lmax'. Patch 3 fixes an issue where the code doesn't account for qdisc_pkt_len() returning a size bigger then 'lmax'. Patches 2 and 4 are selftests for the issues above. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents b0b0ab6 + 137f621 commit 9d23aac

File tree

2 files changed

+101
-3
lines changed

2 files changed

+101
-3
lines changed

net/sched/sch_qfq.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,13 @@ static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight,
381381
u32 lmax)
382382
{
383383
struct qfq_sched *q = qdisc_priv(sch);
384-
struct qfq_aggregate *new_agg = qfq_find_agg(q, lmax, weight);
384+
struct qfq_aggregate *new_agg;
385385

386+
/* 'lmax' can range from [QFQ_MIN_LMAX, pktlen + stab overhead] */
387+
if (lmax > QFQ_MAX_LMAX)
388+
return -EINVAL;
389+
390+
new_agg = qfq_find_agg(q, lmax, weight);
386391
if (new_agg == NULL) { /* create new aggregate */
387392
new_agg = kzalloc(sizeof(*new_agg), GFP_ATOMIC);
388393
if (new_agg == NULL)
@@ -423,10 +428,17 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
423428
else
424429
weight = 1;
425430

426-
if (tb[TCA_QFQ_LMAX])
431+
if (tb[TCA_QFQ_LMAX]) {
427432
lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
428-
else
433+
} else {
434+
/* MTU size is user controlled */
429435
lmax = psched_mtu(qdisc_dev(sch));
436+
if (lmax < QFQ_MIN_LMAX || lmax > QFQ_MAX_LMAX) {
437+
NL_SET_ERR_MSG_MOD(extack,
438+
"MTU size out of bounds for qfq");
439+
return -EINVAL;
440+
}
441+
}
430442

431443
inv_w = ONE_FP / weight;
432444
weight = ONE_FP / inv_w;

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,91 @@
213213
"$TC qdisc del dev $DUMMY handle 1: root",
214214
"$IP link del dev $DUMMY type dummy"
215215
]
216+
},
217+
{
218+
"id": "85ee",
219+
"name": "QFQ with big MTU",
220+
"category": [
221+
"qdisc",
222+
"qfq"
223+
],
224+
"plugins": {
225+
"requires": "nsPlugin"
226+
},
227+
"setup": [
228+
"$IP link add dev $DUMMY type dummy || /bin/true",
229+
"$IP link set dev $DUMMY mtu 2147483647 || /bin/true",
230+
"$TC qdisc add dev $DUMMY handle 1: root qfq"
231+
],
232+
"cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100",
233+
"expExitCode": "2",
234+
"verifyCmd": "$TC class show dev $DUMMY",
235+
"matchPattern": "class qfq 1:",
236+
"matchCount": "0",
237+
"teardown": [
238+
"$IP link del dev $DUMMY type dummy"
239+
]
240+
},
241+
{
242+
"id": "ddfa",
243+
"name": "QFQ with small MTU",
244+
"category": [
245+
"qdisc",
246+
"qfq"
247+
],
248+
"plugins": {
249+
"requires": "nsPlugin"
250+
},
251+
"setup": [
252+
"$IP link add dev $DUMMY type dummy || /bin/true",
253+
"$IP link set dev $DUMMY mtu 256 || /bin/true",
254+
"$TC qdisc add dev $DUMMY handle 1: root qfq"
255+
],
256+
"cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100",
257+
"expExitCode": "2",
258+
"verifyCmd": "$TC class show dev $DUMMY",
259+
"matchPattern": "class qfq 1:",
260+
"matchCount": "0",
261+
"teardown": [
262+
"$IP link del dev $DUMMY type dummy"
263+
]
264+
},
265+
{
266+
"id": "5993",
267+
"name": "QFQ with stab overhead greater than max packet len",
268+
"category": [
269+
"qdisc",
270+
"qfq",
271+
"scapy"
272+
],
273+
"plugins": {
274+
"requires": [
275+
"nsPlugin",
276+
"scapyPlugin"
277+
]
278+
},
279+
"setup": [
280+
"$IP link add dev $DUMMY type dummy || /bin/true",
281+
"$IP link set dev $DUMMY up || /bin/true",
282+
"$TC qdisc add dev $DUMMY handle 1: stab mtu 2048 tsize 512 mpu 0 overhead 999999999 linklayer ethernet root qfq",
283+
"$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100",
284+
"$TC qdisc add dev $DEV1 clsact",
285+
"$TC filter add dev $DEV1 ingress protocol ip flower dst_ip 1.3.3.7/32 action mirred egress mirror dev $DUMMY"
286+
],
287+
"cmdUnderTest": "$TC filter add dev $DUMMY parent 1: matchall classid 1:1",
288+
"scapy": [
289+
{
290+
"iface": "$DEV0",
291+
"count": 22,
292+
"packet": "Ether(type=0x800)/IP(src='10.0.0.10',dst='1.3.3.7')/TCP(sport=5000,dport=10)"
293+
}
294+
],
295+
"expExitCode": "0",
296+
"verifyCmd": "$TC -s qdisc ls dev $DUMMY",
297+
"matchPattern": "dropped 22",
298+
"matchCount": "1",
299+
"teardown": [
300+
"$TC qdisc del dev $DUMMY handle 1: root qfq"
301+
]
216302
}
217303
]

0 commit comments

Comments
 (0)