Skip to content

Commit 84c46dd

Browse files
netoptimizerdavem330
authored andcommitted
qdisc: catch misconfig of attaching qdisc to tx_queue_len zero device
It is a clear misconfiguration to attach a qdisc to a device with tx_queue_len zero, because some qdisc's (namely, pfifo, bfifo, gred, htb, plug and sfb) inherit/copy this value as their queue length. Why should the kernel catch such a misconfiguration? Because prior to introducing the IFF_NO_QUEUE device flag, userspace found a loophole in the qdisc config system that allowed them to achieve the equivalent of IFF_NO_QUEUE, which is to remove the qdisc code path entirely from a device. The loophole on older kernels is setting tx_queue_len=0, *prior* to device qdisc init (the config time is significant, simply setting tx_queue_len=0 doesn't trigger the loophole). This loophole is currently used by Docker[1] to get better performance and scalability out of the veth device. The Docker developers were warned[1] that they needed to adjust the tx_queue_len if ever attaching a qdisc. The OpenShift project didn't remember this warning and attached a qdisc, this were caught and fixed in[2]. [1] docker-archive/libcontainer#193 [2] openshift/origin#11126 Instead of fixing every userspace program that used this loophole, and forgot to reset the tx_queue_len, prior to attaching a qdisc. Let's catch the misconfiguration on the kernel side. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1159708 commit 84c46dd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

net/sched/sch_api.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,17 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
960960

961961
sch->handle = handle;
962962

963+
/* This exist to keep backward compatible with a userspace
964+
* loophole, what allowed userspace to get IFF_NO_QUEUE
965+
* facility on older kernels by setting tx_queue_len=0 (prior
966+
* to qdisc init), and then forgot to reinit tx_queue_len
967+
* before again attaching a qdisc.
968+
*/
969+
if ((dev->priv_flags & IFF_NO_QUEUE) && (dev->tx_queue_len == 0)) {
970+
dev->tx_queue_len = DEFAULT_TX_QUEUE_LEN;
971+
netdev_info(dev, "Caught tx_queue_len zero misconfig\n");
972+
}
973+
963974
if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) {
964975
if (qdisc_is_percpu_stats(sch)) {
965976
sch->cpu_bstats =

0 commit comments

Comments
 (0)