🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by SeungJong Ha Wed, 25 Nov 2026 02:54
[PATCH net] net: re-notify tx_queue_len after rolling back a failed change
#22273
Author: SeungJong Ha
Date: Wed, 25 Nov 2026 02:54
65 lines
13111 bytes
If a NETDEV_CHANGE_TX_QUEUE_LEN notifier or the qdisc resize fails, the
old tx_queue_len is restored, but notifiers that already saw the new
one are not told. Notify them again and log if that fails, as
netif_change_name() does.

Discovered by a non-AI static analysis tool. The reproducer and the fix
were written with an AI coding assistant.

Reproduced on an unmodified kernel with error injection (failslab in
pfifo_fast_change_tx_queue_len()): "ip link set tun0 txqueuelen 100"
on a tun device with a pfifo_fast qdisc fails, yet the tun ring keeps
100 slots and the last RTM_NEWLINK reports 100, while tx_queue_len is
back to 500.

With this patch both are reverted. Selftests were not run.

Fixes: 08294a26e15d ("net: introduce NETDEV_CHANGE_TX_QUEUE_LEN")
Signed-off-by: SeungJong Ha <engineer.jjhama@gmail.com>
---
netif_set_mtu_ext() does the same re-notify but ignores the result.
This follows netif_change_name(), which also logs a failed rollback.

I found this with a static analysis tool I am developing.

The reproducer and the fix were written with Claude Code (Claude Opus
5.5) from the analyzer report. I reviewed all of it and re-ran the
reproducer myself.
---
 net/core/dev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index cd0796a1dbfd..56c2bb08a53b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10196,7 +10196,7 @@ EXPORT_SYMBOL(netif_set_mtu);
 int netif_change_tx_queue_len(struct net_device *dev, unsigned long new_len)
 {
 	unsigned int orig_len = dev->tx_queue_len;
-	int res;
+	int res, err;
 
 	if (new_len > S16_MAX)
 		return -ERANGE;
@@ -10217,6 +10217,11 @@ int netif_change_tx_queue_len(struct net_device *dev, unsigned long new_len)
 err_rollback:
 	netdev_err(dev, "refused to change device tx_queue_len\n");
 	WRITE_ONCE(dev->tx_queue_len, orig_len);
+	/* Notify everyone again so that they have a chance to revert. */
+	err = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
+	err = notifier_to_errno(err);
+	if (err)
+		netdev_err(dev, "tx_queue_len rollback failed: %d\n", err);
 	return res;
 }
 

---
base-commit: 4392bb809812ac79449cd0cf1f5e00469ee102d1
change-id: 20261124-tc1-txqlen-renotify-7f652bd32f0b

Best regards,
--  
SeungJong Ha <engineer.jjhama@gmail.com>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads