Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jesper Dangaard Brouer and committed by
David S. Miller
bf6dba76 09be4c47

+14 -3
+14 -3
net/sched/sch_generic.c
··· 1037 1037 ops = &pfifo_fast_ops; 1038 1038 1039 1039 qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL); 1040 - if (!qdisc) { 1041 - netdev_info(dev, "activation failed\n"); 1040 + if (!qdisc) 1042 1041 return; 1043 - } 1042 + 1044 1043 if (!netif_is_multiqueue(dev)) 1045 1044 qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 1046 1045 dev_queue->qdisc_sleeping = qdisc; ··· 1064 1065 qdisc->ops->attach(qdisc); 1065 1066 } 1066 1067 } 1068 + 1069 + /* Detect default qdisc setup/init failed and fallback to "noqueue" */ 1070 + if (dev->qdisc == &noop_qdisc) { 1071 + netdev_warn(dev, "default qdisc (%s) fail, fallback to %s\n", 1072 + default_qdisc_ops->id, noqueue_qdisc_ops.id); 1073 + dev->priv_flags |= IFF_NO_QUEUE; 1074 + netdev_for_each_tx_queue(dev, attach_one_default_qdisc, NULL); 1075 + dev->qdisc = txq->qdisc_sleeping; 1076 + qdisc_refcount_inc(dev->qdisc); 1077 + dev->priv_flags ^= IFF_NO_QUEUE; 1078 + } 1079 + 1067 1080 #ifdef CONFIG_NET_SCHED 1068 1081 if (dev->qdisc != &noop_qdisc) 1069 1082 qdisc_hash_add(dev->qdisc, false);