[PATCH net-next] net: core: avoid WARN_ONCE for stale RX queue mappings

From: Li Xiasong

Date: Mon Aug 10 2026 - 08:32:16 EST


An skb may retain its recorded RX queue index while a network device
reduces its number of active RX queues. For example, when a TUN queue
is detached, queued skbs can still carry the queue's previous index.

Both get_rps_cpu() and netif_get_rxqueue() validate the index before
accessing the RX queue array. They safely fall back to local processing
or the first RX queue, so an invalid index does not cause an
out-of-bounds access.

Using WARN_ONCE() for this recoverable condition can unnecessarily
panic systems with panic_on_warn enabled. Replace it with
netdev_warn_once() to retain the diagnostic without emitting a WARN
splat.

Signed-off-by: Li Xiasong <lixiasong1@xxxxxxxxxx>
---
net/core/dev.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index af260ff5462a..5db98b0a853f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5126,10 +5126,11 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
u16 index = skb_get_rx_queue(skb);

if (unlikely(index >= dev->real_num_rx_queues)) {
- WARN_ONCE(dev->real_num_rx_queues > 1,
- "%s received packet on queue %u, but number "
- "of RX queues is %u\n",
- dev->name, index, dev->real_num_rx_queues);
+ if (dev->real_num_rx_queues > 1)
+ netdev_warn_once(dev,
+ "received packet on queue %u, but number "
+ "of RX queues is %u\n",
+ index, dev->real_num_rx_queues);
goto done;
}
rxqueue += index;
@@ -5443,11 +5444,11 @@ static struct netdev_rx_queue *netif_get_rxqueue(struct sk_buff *skb)
u16 index = skb_get_rx_queue(skb);

if (unlikely(index >= dev->real_num_rx_queues)) {
- WARN_ONCE(dev->real_num_rx_queues > 1,
- "%s received packet on queue %u, but number "
- "of RX queues is %u\n",
- dev->name, index, dev->real_num_rx_queues);
-
+ if (dev->real_num_rx_queues > 1)
+ netdev_warn_once(dev,
+ "received packet on queue %u, but number "
+ "of RX queues is %u\n",
+ index, dev->real_num_rx_queues);
return rxqueue; /* Return first rxqueue */
}
rxqueue += index;
--
2.34.1