Skip to content

Commit df00859

Browse files
congwangPaolo Abeni
authored andcommitted
sch_drr: make drr_qlen_notify() idempotent
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>
1 parent 5ba8b83 commit df00859

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
@@ -105,6 +105,7 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
105105
return -ENOBUFS;
106106

107107
gnet_stats_basic_sync_init(&cl->bstats);
108+
INIT_LIST_HEAD(&cl->alist);
108109
cl->common.classid = classid;
109110
cl->quantum = quantum;
110111
cl->qdisc = qdisc_create_dflt(sch->dev_queue,
@@ -229,7 +230,7 @@ static void drr_qlen_notify(struct Qdisc *csh, unsigned long arg)
229230
{
230231
struct drr_class *cl = (struct drr_class *)arg;
231232

232-
list_del(&cl->alist);
233+
list_del_init(&cl->alist);
233234
}
234235

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

395396
bstats_update(&cl->bstats, skb);
396397
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)