Skip to content

Commit 625b40d

Browse files
author
Paolo Abeni
committed
Merge branch 'net_sched-fix-hfsc-qlen-backlog-accounting-bug-and-add-selftest'
Cong Wang says: ==================== net_sched: Fix HFSC qlen/backlog accounting bug and add selftest This series addresses a long-standing bug in the HFSC qdisc where queue length and backlog accounting could become inconsistent if a packet is dropped during a peek-induced dequeue operation, and adds a corresponding selftest to tc-testing. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 407e0ef + c3572ac commit 625b40d

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

net/sched/sch_hfsc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,9 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
15691569
return err;
15701570
}
15711571

1572+
sch->qstats.backlog += len;
1573+
sch->q.qlen++;
1574+
15721575
if (first && !cl->cl_nactive) {
15731576
if (cl->cl_flags & HFSC_RSC)
15741577
init_ed(cl, len);
@@ -1584,9 +1587,6 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
15841587

15851588
}
15861589

1587-
sch->qstats.backlog += len;
1588-
sch->q.qlen++;
1589-
15901590
return NET_XMIT_SUCCESS;
15911591
}
15921592

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,5 +573,32 @@
573573
"teardown": [
574574
"$TC qdisc del dev $DEV1 handle 1: root"
575575
]
576+
},
577+
{
578+
"id": "831d",
579+
"name": "Test HFSC qlen accounting with DRR/NETEM/BLACKHOLE chain",
580+
"category": ["qdisc", "hfsc", "drr", "netem", "blackhole"],
581+
"plugins": { "requires": ["nsPlugin", "scapyPlugin"] },
582+
"setup": [
583+
"$IP link set dev $DEV1 up || true",
584+
"$TC qdisc add dev $DEV1 root handle 1: drr",
585+
"$TC filter add dev $DEV1 parent 1: basic classid 1:1",
586+
"$TC class add dev $DEV1 parent 1: classid 1:1 drr",
587+
"$TC qdisc add dev $DEV1 parent 1:1 handle 2: hfsc def 1",
588+
"$TC class add dev $DEV1 parent 2: classid 2:1 hfsc rt m1 8 d 1 m2 0",
589+
"$TC qdisc add dev $DEV1 parent 2:1 handle 3: netem",
590+
"$TC qdisc add dev $DEV1 parent 3:1 handle 4: blackhole"
591+
],
592+
"scapy": {
593+
"iface": "$DEV0",
594+
"count": 5,
595+
"packet": "Ether()/IP(dst='10.10.10.1', src='10.10.10.10')/ICMP()"
596+
},
597+
"cmdUnderTest": "$TC -s qdisc show dev $DEV1",
598+
"expExitCode": "0",
599+
"verifyCmd": "$TC -s qdisc show dev $DEV1",
600+
"matchPattern": "qdisc hfsc",
601+
"matchCount": "1",
602+
"teardown": ["$TC qdisc del dev $DEV1 root handle 1: drr"]
576603
}
577604
]

0 commit comments

Comments
 (0)