Skip to content

Commit 55f9eca

Browse files
congwangPaolo Abeni
authored andcommitted
sch_qfq: make qfq_qlen_notify() idempotent
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 <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Acked-by: Jamal Hadi Salim <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 51eb3b6 commit 55f9eca

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
@@ -347,7 +347,7 @@ static void qfq_deactivate_class(struct qfq_sched *q, struct qfq_class *cl)
347347
struct qfq_aggregate *agg = cl->agg;
348348

349349

350-
list_del(&cl->alist); /* remove from RR queue of the aggregate */
350+
list_del_init(&cl->alist); /* remove from RR queue of the aggregate */
351351
if (list_empty(&agg->active)) /* agg is now inactive */
352352
qfq_deactivate_agg(q, agg);
353353
}
@@ -474,6 +474,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
474474
gnet_stats_basic_sync_init(&cl->bstats);
475475
cl->common.classid = classid;
476476
cl->deficit = lmax;
477+
INIT_LIST_HEAD(&cl->alist);
477478

478479
cl->qdisc = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
479480
classid, NULL);
@@ -982,7 +983,7 @@ static struct sk_buff *agg_dequeue(struct qfq_aggregate *agg,
982983
cl->deficit -= (int) len;
983984

984985
if (cl->qdisc->q.qlen == 0) /* no more packets, remove from list */
985-
list_del(&cl->alist);
986+
list_del_init(&cl->alist);
986987
else if (cl->deficit < qdisc_pkt_len(cl->qdisc->ops->peek(cl->qdisc))) {
987988
cl->deficit += agg->lmax;
988989
list_move_tail(&cl->alist, &agg->active);
@@ -1415,6 +1416,8 @@ static void qfq_qlen_notify(struct Qdisc *sch, unsigned long arg)
14151416
struct qfq_sched *q = qdisc_priv(sch);
14161417
struct qfq_class *cl = (struct qfq_class *)arg;
14171418

1419+
if (list_empty(&cl->alist))
1420+
return;
14181421
qfq_deactivate_class(q, cl);
14191422
}
14201423

0 commit comments

Comments
 (0)