Commit 9d23aac8 authored by Paolo Abeni's avatar Paolo Abeni

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/20230711210103.597831-1-pctammela@mojatatu.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents b0b0ab6f 137f6219
...@@ -381,8 +381,13 @@ static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight, ...@@ -381,8 +381,13 @@ static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight,
u32 lmax) u32 lmax)
{ {
struct qfq_sched *q = qdisc_priv(sch); struct qfq_sched *q = qdisc_priv(sch);
struct qfq_aggregate *new_agg = qfq_find_agg(q, lmax, weight); struct qfq_aggregate *new_agg;
/* 'lmax' can range from [QFQ_MIN_LMAX, pktlen + stab overhead] */
if (lmax > QFQ_MAX_LMAX)
return -EINVAL;
new_agg = qfq_find_agg(q, lmax, weight);
if (new_agg == NULL) { /* create new aggregate */ if (new_agg == NULL) { /* create new aggregate */
new_agg = kzalloc(sizeof(*new_agg), GFP_ATOMIC); new_agg = kzalloc(sizeof(*new_agg), GFP_ATOMIC);
if (new_agg == NULL) if (new_agg == NULL)
...@@ -423,10 +428,17 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, ...@@ -423,10 +428,17 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
else else
weight = 1; weight = 1;
if (tb[TCA_QFQ_LMAX]) if (tb[TCA_QFQ_LMAX]) {
lmax = nla_get_u32(tb[TCA_QFQ_LMAX]); lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
else } else {
/* MTU size is user controlled */
lmax = psched_mtu(qdisc_dev(sch)); lmax = psched_mtu(qdisc_dev(sch));
if (lmax < QFQ_MIN_LMAX || lmax > QFQ_MAX_LMAX) {
NL_SET_ERR_MSG_MOD(extack,
"MTU size out of bounds for qfq");
return -EINVAL;
}
}
inv_w = ONE_FP / weight; inv_w = ONE_FP / weight;
weight = ONE_FP / inv_w; weight = ONE_FP / inv_w;
......
...@@ -213,5 +213,91 @@ ...@@ -213,5 +213,91 @@
"$TC qdisc del dev $DUMMY handle 1: root", "$TC qdisc del dev $DUMMY handle 1: root",
"$IP link del dev $DUMMY type dummy" "$IP link del dev $DUMMY type dummy"
] ]
},
{
"id": "85ee",
"name": "QFQ with big MTU",
"category": [
"qdisc",
"qfq"
],
"plugins": {
"requires": "nsPlugin"
},
"setup": [
"$IP link add dev $DUMMY type dummy || /bin/true",
"$IP link set dev $DUMMY mtu 2147483647 || /bin/true",
"$TC qdisc add dev $DUMMY handle 1: root qfq"
],
"cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100",
"expExitCode": "2",
"verifyCmd": "$TC class show dev $DUMMY",
"matchPattern": "class qfq 1:",
"matchCount": "0",
"teardown": [
"$IP link del dev $DUMMY type dummy"
]
},
{
"id": "ddfa",
"name": "QFQ with small MTU",
"category": [
"qdisc",
"qfq"
],
"plugins": {
"requires": "nsPlugin"
},
"setup": [
"$IP link add dev $DUMMY type dummy || /bin/true",
"$IP link set dev $DUMMY mtu 256 || /bin/true",
"$TC qdisc add dev $DUMMY handle 1: root qfq"
],
"cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100",
"expExitCode": "2",
"verifyCmd": "$TC class show dev $DUMMY",
"matchPattern": "class qfq 1:",
"matchCount": "0",
"teardown": [
"$IP link del dev $DUMMY type dummy"
]
},
{
"id": "5993",
"name": "QFQ with stab overhead greater than max packet len",
"category": [
"qdisc",
"qfq",
"scapy"
],
"plugins": {
"requires": [
"nsPlugin",
"scapyPlugin"
]
},
"setup": [
"$IP link add dev $DUMMY type dummy || /bin/true",
"$IP link set dev $DUMMY up || /bin/true",
"$TC qdisc add dev $DUMMY handle 1: stab mtu 2048 tsize 512 mpu 0 overhead 999999999 linklayer ethernet root qfq",
"$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100",
"$TC qdisc add dev $DEV1 clsact",
"$TC filter add dev $DEV1 ingress protocol ip flower dst_ip 1.3.3.7/32 action mirred egress mirror dev $DUMMY"
],
"cmdUnderTest": "$TC filter add dev $DUMMY parent 1: matchall classid 1:1",
"scapy": [
{
"iface": "$DEV0",
"count": 22,
"packet": "Ether(type=0x800)/IP(src='10.0.0.10',dst='1.3.3.7')/TCP(sport=5000,dport=10)"
}
],
"expExitCode": "0",
"verifyCmd": "$TC -s qdisc ls dev $DUMMY",
"matchPattern": "dropped 22",
"matchCount": "1",
"teardown": [
"$TC qdisc del dev $DUMMY handle 1: root qfq"
]
} }
] ]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment