Commit e57a784d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

pkt_sched: set root qdisc before change() in attach_default_qdiscs()

After commit 95dc1929 ("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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59bcaed5
...@@ -273,8 +273,11 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle) ...@@ -273,8 +273,11 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle)
void qdisc_list_add(struct Qdisc *q) void qdisc_list_add(struct Qdisc *q)
{ {
struct Qdisc *root = qdisc_dev(q)->qdisc;
WARN_ON_ONCE(root == &noop_qdisc);
if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS))
list_add_tail(&q->list, &qdisc_dev(q)->qdisc->list); list_add_tail(&q->list, &root->list);
} }
EXPORT_SYMBOL(qdisc_list_add); EXPORT_SYMBOL(qdisc_list_add);
......
...@@ -718,8 +718,8 @@ static void attach_default_qdiscs(struct net_device *dev) ...@@ -718,8 +718,8 @@ static void attach_default_qdiscs(struct net_device *dev)
} else { } else {
qdisc = qdisc_create_dflt(txq, &mq_qdisc_ops, TC_H_ROOT); qdisc = qdisc_create_dflt(txq, &mq_qdisc_ops, TC_H_ROOT);
if (qdisc) { if (qdisc) {
qdisc->ops->attach(qdisc);
dev->qdisc = qdisc; dev->qdisc = qdisc;
qdisc->ops->attach(qdisc);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment