Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: re-notify tx_queue_len after rolling back a failed change
@ 2026-11-25  2:54 SeungJong Ha
  2026-12-02 17:48 ` Paolo Abeni
  0 siblings, 1 reply; 2+ messages in thread
From: SeungJong Ha @ 2026-11-25  2:54 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, Jason Wang, John Fastabend
  Cc: netdev, SeungJong Ha

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>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 17:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  2:54 [PATCH net] net: re-notify tx_queue_len after rolling back a failed change SeungJong Ha
2026-12-02 17:48 ` Paolo Abeni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox