Skip to content

Commit e57a784

Browse files
edumazetdavem330
authored andcommitted
pkt_sched: set root qdisc before change() in attach_default_qdiscs()
After commit 95dc192 ("pkt_sched: give visibility to mq slave qdiscs") we call disc_list_add() while the device qdisc might be the noop_qdisc one. This shows up as duplicates in "tc qdisc show", as all inactive devices point to noop_qdisc. Fix this by setting dev->qdisc to the new qdisc before calling ops->change() in attach_default_qdiscs() Add a WARN_ON_ONCE() to catch any future similar problem. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 59bcaed commit e57a784

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

net/sched/sch_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,11 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle)
273273

274274
void qdisc_list_add(struct Qdisc *q)
275275
{
276+
struct Qdisc *root = qdisc_dev(q)->qdisc;
277+
278+
WARN_ON_ONCE(root == &noop_qdisc);
276279
if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS))
277-
list_add_tail(&q->list, &qdisc_dev(q)->qdisc->list);
280+
list_add_tail(&q->list, &root->list);
278281
}
279282
EXPORT_SYMBOL(qdisc_list_add);
280283

net/sched/sch_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,8 @@ static void attach_default_qdiscs(struct net_device *dev)
718718
} else {
719719
qdisc = qdisc_create_dflt(txq, &mq_qdisc_ops, TC_H_ROOT);
720720
if (qdisc) {
721-
qdisc->ops->attach(qdisc);
722721
dev->qdisc = qdisc;
722+
qdisc->ops->attach(qdisc);
723723
}
724724
}
725725
}

0 commit comments

Comments
 (0)