Skip to content

Commit 939865a

Browse files
congwangpaniakin-aws
authored andcommitted
sch_drr: make drr_qlen_notify() idempotent
commit df00859 upstream. drr_qlen_notify() always deletes the DRR class from its active list with list_del(), therefore, it is not idempotent and not friendly to its callers, like fq_codel_dequeue(). Let's make it idempotent to ease qdisc_tree_reduce_backlog() callers' life. 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-3-xiyou.wangcong@gmail.com Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> [mheyne: conflict due to missing commit 67c9e62 ("net: sched: Protect Qdisc::bstats with u64_stats")] Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
1 parent f4253b1 commit 939865a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

net/sched/sch_drr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
110110
if (cl == NULL)
111111
return -ENOBUFS;
112112

113+
INIT_LIST_HEAD(&cl->alist);
113114
cl->common.classid = classid;
114115
cl->quantum = quantum;
115116
cl->qdisc = qdisc_create_dflt(sch->dev_queue,
@@ -227,7 +228,7 @@ static void drr_qlen_notify(struct Qdisc *csh, unsigned long arg)
227228
{
228229
struct drr_class *cl = (struct drr_class *)arg;
229230

230-
list_del(&cl->alist);
231+
list_del_init(&cl->alist);
231232
}
232233

233234
static int drr_dump_class(struct Qdisc *sch, unsigned long arg,
@@ -391,7 +392,7 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch)
391392
if (unlikely(skb == NULL))
392393
goto out;
393394
if (cl->qdisc->q.qlen == 0)
394-
list_del(&cl->alist);
395+
list_del_init(&cl->alist);
395396

396397
bstats_update(&cl->bstats, skb);
397398
qdisc_bstats_update(sch, skb);
@@ -431,7 +432,7 @@ static void drr_reset_qdisc(struct Qdisc *sch)
431432
for (i = 0; i < q->clhash.hashsize; i++) {
432433
hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
433434
if (cl->qdisc->q.qlen)
434-
list_del(&cl->alist);
435+
list_del_init(&cl->alist);
435436
qdisc_reset(cl->qdisc);
436437
}
437438
}

0 commit comments

Comments
 (0)