[PATCH RFC net-next 0/5] net: make tx_queue_len changes all-or-nothing

From: SeungJong Ha

Date: Sun Dec 06 2026 - 09:44:59 EST


This follows the discussion of v1 [1], a different fix that sent
NETDEV_CHANGE_TX_QUEUE_LEN again after a failed change. I proposed
preallocating instead [2].

The only listener that can fail is the driver of the device itself
(tun, macvtap or ipvtap), and its resize already changes all rings or
none. So only the qdiscs need a separate allocation step:

prepare qdiscs -> resize device rings -> set tx_queue_len
-> swap qdisc rings -> notify

Patches 1-3 do not depend on patches 4-5.

Questions:
- Is rtnl_link_ops the right place for the callback? A ndo does not
work because macvtap and ipvtap use the net_device_ops of macvlan
and ipvlan.
- Patch 5 ignores the return value of the notifier, so an out-of-tree
listener can no longer veto the change. No in-tree one does after
patch 4. The only in-tree listener left is rtnetlink, for
RTM_NEWLINK. I kept the event like the ones of other link
attributes, but it could become a direct rtmsg_ifinfo() call.
Should it be removed?
- The three new Qdisc_ops are not documented, like the other ones.
Their contract: all three run once per tx queue, so more than once
for a root qdisc shared by them, and commit and abort must do
nothing when nothing is pending. Should it be written down next to
them?

All new qdisc rings are allocated before any old one is freed, so a
change needs more memory at once.

I found this with a prototype static analysis tool I am developing.
It flags error paths that return after a change was already made
visible to other code.

The analysis, the reproducer and the fix were written with Claude Code
(Claude Opus 5.5). I reviewed every line of the patches and the commit
messages, and re-ran the reproducer myself.

Tested in a QEMU VM on net-next d5cf954cebe4 with KASAN, lockdep and
kmemleak. failslab failed each allocation of the resize in turn.
Before, 37 of 64 runs left some qdiscs at the new length; after, none.
tun, macvtap and ipvtap no longer announce a refused length in
RTM_NEWLINK. All rings follow on growing and shrinking. tc-testing
pfifo_fast.json and fifo.json give the same results before and after.
Not tested on hardware.

[1] https://lore.kernel.org/netdev/20261125-tc1-txqlen-renotify-v1-1-6c8e9c4d0503@xxxxxxxxx/
[2] https://lore.kernel.org/netdev/CAGAB666kgzt9SF+QgAQ3ZnwhP3624P64Z89e5+uUrW0Pkkkdzg@xxxxxxxxxxxxxx/

Signed-off-by: SeungJong Ha <engineer.jjhama@xxxxxxxxx>
---
SeungJong Ha (5):
ptr_ring: drop the unused gfp argument of __ptr_ring_swap_queue()
ptr_ring: split ptr_ring_resize_multiple_bh() into alloc and swap
net_sched: change tx_queue_len on all tx queues or on none
net: resize tun and tap rings from rtnl_link_ops
net: change tx_queue_len only after all allocations succeeded

drivers/net/ipvlan/ipvtap.c | 13 ++++--
drivers/net/macvtap.c | 13 ++++--
drivers/net/tap.c | 7 ++-
drivers/net/tun.c | 73 +++++++++++++++---------------
include/linux/if_tap.h | 4 +-
include/linux/ptr_ring.h | 86 +++++++++++++++++++++++++----------
include/linux/skb_array.h | 14 +++---
include/net/rtnetlink.h | 5 +++
include/net/sch_generic.h | 10 ++++-
net/core/dev.c | 24 ++++++----
net/sched/sch_generic.c | 106 ++++++++++++++++++++++++++++++++++----------
11 files changed, 235 insertions(+), 120 deletions(-)
---
base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
change-id: 20261205-tc1-txqlen-commit-42c8f03df652

Best regards,
--
SeungJong Ha <engineer.jjhama@xxxxxxxxx>