From: Jon Maxwell <jmaxwell37@gmail.com>
To: haiyangz@microsoft.com
Cc: wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org,
dipayanroy@linux.microsoft.com, ernis@linux.microsoft.com,
longli@microsoft.com, gargaditya@linux.microsoft.com,
hamzamahfooz@linux.microsoft.com, linux-hyperv@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
jmaxwell37@gmail.com
Subject: [PATCH net-next] net: mana: Clamp the recorded RX queue in mana_select_queue()
Date: Tue, 1 Dec 2026 15:43:30 +1100 [thread overview]
Message-ID: <20261201044330.3046262-1-jmaxwell37@gmail.com> (raw)
mana_select_queue() falls back to the RX queue recorded in the skb when
the socket-cached TX queue is unusable:
txq = sk_tx_queue_get(skb->sk);
if (txq < 0 || skb->ooo_okay || txq >= ndev->real_num_tx_queues) {
if (skb_rx_queue_recorded(skb))
txq = skb_get_rx_queue(skb);
else
txq = mana_get_tx_queue(ndev, skb, txq);
}
return txq;
The bounds check only decides whether the socket-cached value has to be
recomputed; it does not validate the value that is returned. The
recorded RX queue belongs to whichever device the skb was received on,
so when a packet is forwarded from an interface with more queues than
the MANA port has, an out of range index is returned and
netdev_core_pick_tx() complains:
enPX selects TX queue 43, but real number of TX queues is 32
enPX selects TX queue 42, but real number of TX queues is 32
enPX selects TX queue 33, but real number of TX queues is 32
netdev_cap_txqueue() then forces every one of those packets onto TX
queue 0, so besides the log spam all affected flows collapse onto a
single queue.
This is easy to hit on Azure when container traffic is forwarded out of
a MANA VF: veth sizes its queues with num_possible_cpus(), while mana
sizes them with num_online_cpus(). On a guest with more possible than
online CPUs the veth devices end up with more queues than the VF, and
the index chosen on the veth survives into the VF transmit path.
Wrap the recorded queue into range, the same thing the generic path does
in skb_tx_hash() and that mlx5e_txq_to_ch_ix() does for mlx5e. A single
subtraction is not enough: the recorded index can be an arbitrary
multiple of real_num_tx_queues, so use a modulo and keep it off the fast
path with an unlikely() check. Read real_num_tx_queues once while at
it, so that all three tests agree on one value even if the queue count
is changed concurrently. The other two sources are already bounded: the
socket-cached index is range checked above, and mana_get_tx_queue()
returns an indirection table entry, which is always below
apc->num_queues.
Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)")
Signed-off-by: Jon Maxwell <jmaxwell37@gmail.com>
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 95bf153c3e1a..eafba38488e8 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -684,18 +684,26 @@ static int mana_get_tx_queue(struct net_device *ndev, struct sk_buff *skb,
static u16 mana_select_queue(struct net_device *ndev, struct sk_buff *skb,
struct net_device *sb_dev)
{
+ int num_txq = READ_ONCE(ndev->real_num_tx_queues);
int txq;
- if (ndev->real_num_tx_queues == 1)
+ if (num_txq == 1)
return 0;
txq = sk_tx_queue_get(skb->sk);
- if (txq < 0 || skb->ooo_okay || txq >= ndev->real_num_tx_queues) {
- if (skb_rx_queue_recorded(skb))
+ if (txq < 0 || skb->ooo_okay || txq >= num_txq) {
+ if (skb_rx_queue_recorded(skb)) {
+ /* The queue was recorded by another device, which may
+ * have many more queues than this port, so wrap it
+ * into range like skb_tx_hash() does.
+ */
txq = skb_get_rx_queue(skb);
- else
+ if (unlikely(txq >= num_txq))
+ txq %= num_txq;
+ } else {
txq = mana_get_tx_queue(ndev, skb, txq);
+ }
}
return txq;
--
2.55.0
reply other threads:[~2026-12-01 4:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201044330.3046262-1-jmaxwell37@gmail.com \
--to=jmaxwell37@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=dipayanroy@linux.microsoft.com \
--cc=edumazet@kernel.org \
--cc=ernis@linux.microsoft.com \
--cc=gargaditya@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hamzamahfooz@linux.microsoft.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wei.liu@kernel.org \
/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
all inboxes | Powered by JetHome®