Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: SeungJong Ha <engineer.jjhama@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Jason Wang <jasowangio@gmail.com>,
	John Fastabend <john.fastabend@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] net: re-notify tx_queue_len after rolling back a failed change
Date: Wed, 2 Dec 2026 18:48:19 +0100	[thread overview]
Message-ID: <a5c8b7da-c87f-4f66-80c4-3998d2e4d814@redhat.com> (raw)
In-Reply-To: <20261125-tc1-txqlen-renotify-v1-1-6c8e9c4d0503@gmail.com>

On 11/25/26 03:54, SeungJong Ha wrote:
> 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);
Does the above fix anything in practice? If the previous notifier call
failed, we are low on memory, and even this call will fail. If the
the qdisc change failed, it will leave the queue with unreverted
partial changes applied.

This change does not looks worthy to me.

/P

      reply	other threads:[~2026-12-02 17:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5c8b7da-c87f-4f66-80c4-3998d2e4d814@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=engineer.jjhama@gmail.com \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox