Skip to content

Commit e0aea48

Browse files
congwangpaniakin-aws
authored andcommitted
sch_qfq: make qfq_qlen_notify() idempotent
commit 55f9eca upstream. qfq_qlen_notify() always deletes its class from its active list with list_del_init() _and_ calls qfq_deactivate_agg() when the whole list becomes empty. To make it idempotent, just skip everything when it is not in the active list. Also change other list_del()'s to list_del_init() just to be extra safe. Reported-by: Gerrard Tai <gerrard.tai@starlabs.sg> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250403211033.166059-5-xiyou.wangcong@gmail.com Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
1 parent 6db06ce commit e0aea48

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/sched/sch_qfq.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static void qfq_deactivate_class(struct qfq_sched *q, struct qfq_class *cl)
355355
struct qfq_aggregate *agg = cl->agg;
356356

357357

358-
list_del(&cl->alist); /* remove from RR queue of the aggregate */
358+
list_del_init(&cl->alist); /* remove from RR queue of the aggregate */
359359
if (list_empty(&agg->active)) /* agg is now inactive */
360360
qfq_deactivate_agg(q, agg);
361361
}
@@ -484,6 +484,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
484484

485485
cl->common.classid = classid;
486486
cl->deficit = lmax;
487+
INIT_LIST_HEAD(&cl->alist);
487488

488489
cl->qdisc = qdisc_create_dflt(sch->dev_queue,
489490
&pfifo_qdisc_ops, classid);
@@ -995,7 +996,7 @@ static struct sk_buff *agg_dequeue(struct qfq_aggregate *agg,
995996
cl->deficit -= (int) len;
996997

997998
if (cl->qdisc->q.qlen == 0) /* no more packets, remove from list */
998-
list_del(&cl->alist);
999+
list_del_init(&cl->alist);
9991000
else if (cl->deficit < qdisc_pkt_len(cl->qdisc->ops->peek(cl->qdisc))) {
10001001
cl->deficit += agg->lmax;
10011002
list_move_tail(&cl->alist, &agg->active);
@@ -1425,6 +1426,8 @@ static void qfq_qlen_notify(struct Qdisc *sch, unsigned long arg)
14251426
struct qfq_sched *q = qdisc_priv(sch);
14261427
struct qfq_class *cl = (struct qfq_class *)arg;
14271428

1429+
if (list_empty(&cl->alist))
1430+
return;
14281431
qfq_deactivate_class(q, cl);
14291432
}
14301433

0 commit comments

Comments
 (0)