Skip to content

Commit 75dbdaa

Browse files
committed
Merge branch 'net_sched-fix-a-regression-in-sch_htb'
Cong Wang says: ==================== net_sched: fix a regression in sch_htb This patchset contains a fix for the regression reported by Alan and a selftest to cover that case. Please see each patch description for more details. ==================== Link: https://patch.msgid.link/20250428232955.1740419-1-xiyou.wangcong@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents ebd297a + 6389028 commit 75dbdaa

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

net/sched/sch_htb.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ static void htb_add_to_wait_tree(struct htb_sched *q,
348348
*/
349349
static inline void htb_next_rb_node(struct rb_node **n)
350350
{
351-
*n = rb_next(*n);
351+
if (*n)
352+
*n = rb_next(*n);
352353
}
353354

354355
/**
@@ -609,8 +610,8 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl)
609610
*/
610611
static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl)
611612
{
612-
WARN_ON(!cl->prio_activity);
613-
613+
if (!cl->prio_activity)
614+
return;
614615
htb_deactivate_prios(q, cl);
615616
cl->prio_activity = 0;
616617
}
@@ -1485,8 +1486,6 @@ static void htb_qlen_notify(struct Qdisc *sch, unsigned long arg)
14851486
{
14861487
struct htb_class *cl = (struct htb_class *)arg;
14871488

1488-
if (!cl->prio_activity)
1489-
return;
14901489
htb_deactivate(qdisc_priv(sch), cl);
14911490
}
14921491

@@ -1740,8 +1739,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg,
17401739
if (cl->parent)
17411740
cl->parent->children--;
17421741

1743-
if (cl->prio_activity)
1744-
htb_deactivate(q, cl);
1742+
htb_deactivate(q, cl);
17451743

17461744
if (cl->cmode != HTB_CAN_SEND)
17471745
htb_safe_rb_erase(&cl->pq_node,
@@ -1949,8 +1947,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
19491947
/* turn parent into inner node */
19501948
qdisc_purge_queue(parent->leaf.q);
19511949
parent_qdisc = parent->leaf.q;
1952-
if (parent->prio_activity)
1953-
htb_deactivate(q, parent);
1950+
htb_deactivate(q, parent);
19541951

19551952
/* remove from evt list because of level change */
19561953
if (parent->cmode != HTB_CAN_SEND) {

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,5 +538,40 @@
538538
"$TC qdisc del dev $DUMMY handle 1:0 root",
539539
"$IP addr del 10.10.10.10/24 dev $DUMMY || true"
540540
]
541+
},
542+
{
543+
"id": "62c4",
544+
"name": "Test HTB with FQ_CODEL - basic functionality",
545+
"category": [
546+
"qdisc",
547+
"htb",
548+
"fq_codel"
549+
],
550+
"plugins": {
551+
"requires": [
552+
"nsPlugin",
553+
"scapyPlugin"
554+
]
555+
},
556+
"setup": [
557+
"$TC qdisc add dev $DEV1 root handle 1: htb default 11",
558+
"$TC class add dev $DEV1 parent 1: classid 1:1 htb rate 10kbit",
559+
"$TC class add dev $DEV1 parent 1:1 classid 1:11 htb rate 10kbit prio 0 quantum 1486",
560+
"$TC qdisc add dev $DEV1 parent 1:11 fq_codel quantum 300 noecn",
561+
"sleep 0.5"
562+
],
563+
"scapy": {
564+
"iface": "$DEV0",
565+
"count": 5,
566+
"packet": "Ether()/IP(dst='10.10.10.1', src='10.10.10.10')/TCP(sport=12345, dport=80)"
567+
},
568+
"cmdUnderTest": "$TC -s qdisc show dev $DEV1",
569+
"expExitCode": "0",
570+
"verifyCmd": "$TC -s qdisc show dev $DEV1 | grep -A 5 'qdisc fq_codel'",
571+
"matchPattern": "Sent [0-9]+ bytes [0-9]+ pkt",
572+
"matchCount": "1",
573+
"teardown": [
574+
"$TC qdisc del dev $DEV1 handle 1: root"
575+
]
541576
}
542577
]

0 commit comments

Comments
 (0)