Skip to content

Commit bf6dba7

Browse files
netoptimizerdavem330
authored andcommitted
net: sched: fallback to qdisc noqueue if default qdisc setup fail
Currently if the default qdisc setup/init fails, the device ends up with qdisc "noop", which causes all TX packets to get dropped. With the introduction of sysctl net/core/default_qdisc it is possible to change the default qdisc to be more advanced, which opens for the possibility that Qdisc_ops->init() can fail. This patch detect these kind of failures, and choose to fallback to qdisc "noqueue", which is so simple that its init call will not fail. This allows the interface to continue functioning. V2: As this also captures memory failures, which are transient, the device is not kept in IFF_NO_QUEUE state. This allows the net_device to retry to default qdisc assignment. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 09be4c4 commit bf6dba7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

net/sched/sch_generic.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,9 @@ static void attach_one_default_qdisc(struct net_device *dev,
10371037
ops = &pfifo_fast_ops;
10381038

10391039
qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL);
1040-
if (!qdisc) {
1041-
netdev_info(dev, "activation failed\n");
1040+
if (!qdisc)
10421041
return;
1043-
}
1042+
10441043
if (!netif_is_multiqueue(dev))
10451044
qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT;
10461045
dev_queue->qdisc_sleeping = qdisc;
@@ -1065,6 +1064,18 @@ static void attach_default_qdiscs(struct net_device *dev)
10651064
qdisc->ops->attach(qdisc);
10661065
}
10671066
}
1067+
1068+
/* Detect default qdisc setup/init failed and fallback to "noqueue" */
1069+
if (dev->qdisc == &noop_qdisc) {
1070+
netdev_warn(dev, "default qdisc (%s) fail, fallback to %s\n",
1071+
default_qdisc_ops->id, noqueue_qdisc_ops.id);
1072+
dev->priv_flags |= IFF_NO_QUEUE;
1073+
netdev_for_each_tx_queue(dev, attach_one_default_qdisc, NULL);
1074+
dev->qdisc = txq->qdisc_sleeping;
1075+
qdisc_refcount_inc(dev->qdisc);
1076+
dev->priv_flags ^= IFF_NO_QUEUE;
1077+
}
1078+
10681079
#ifdef CONFIG_NET_SCHED
10691080
if (dev->qdisc != &noop_qdisc)
10701081
qdisc_hash_add(dev->qdisc, false);

0 commit comments

Comments
 (0)