Article View: linux.kernel.netdev
Article #24971[PATCH net-next] net: mana: Clamp the recorded RX queue in mana_select_queue()
From: Jon Maxwell
Date: Tue, 01 Dec 2026 04:43
Date: Tue, 01 Dec 2026 04:43
90 lines
14481 bytes
14481 bytes
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
Technical Details
Message-ID:
<20261201044330.3046262-1-jmaxwell37@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374704-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374704-linux-kernel-netdev=dewy.ru
From: jmaxwell37@gmail.com (Jon Maxwell)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next] net: mana: Clamp the recorded RX queue in mana_select_queue()
Date: Tue, 1 Dec 2026 15:43:30 +1100
Organization: Usenet Network
Message-ID: <20261201044330.3046262-1-jmaxwell37@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1615954"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ImHJ9wYa4sJqztiIB4nN5ymAraU= sha256:dBZDy01gHtKTMwo6BwO3bpy1B1ULgqTDKxpbzdWZ13g=
sha1:K5DSbjWpcPqxjDvLFiVpk/Z2ODg= sha256:TZPZZjzIUQx/lZiQ5acacW8nuXxoLx7nstJAL3OxZFc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id C150711723C; Tue, 1 Dec 2026 07:43:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 3Oe1mKAr3nYW;
Tue, 1 Dec 2026 07:43:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-374704-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id D54DF117233; Tue, 1 Dec 2026 07:43:46 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 02B82601B3C; Tue, 1 Dec 2026 04:43:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796100225;
b=AXbeYF2d+Q3QMiL6AVWUPXP/F1j4doaC4UAgWOl2pTVKAnUC4bi1K0OuyH5BpzD4wXwA
u9Z6vW97JPfWlc2Tumc7NfwafQ/4/V1h5VguDKEIxzQ9leiqVPdHPsmY57B1JoPIG0qJe
QlbtvKxlAoQo74JX8pYvQSKiGLqm/mydce773RO4uyxkPFMZ53TQu8nlF3UZBxVtWzq0V
CKHId8IdESp/shzKJXsuD/260iUeZ3s4rKMd38sSf5cBYHTKv1oPJGFaiftN1GexrncVN
4C5gESOCIsKAaHnZcvnyEZMUVIaumRCygOCC+mbRMcg2Wu2MHC2Vjc3AIdsayT+iOsw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796100225;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=;
b=qy8Qsseov9q1PgskFgDPEGRc2EGknhI1edfFxH3+Z9PRWiEvO8csGyiYD5PP/TMwdtn8
YpRaTebMy7md+Hdy0kPhJusbHlq7MeF6Ho6tCQrLqhzpHfuSpjXuKMjHtiTEas4P/S+/K
uomsQlu8SxxojkqqnxVUgq2/3AUpXsg/WjiQlsxvDsHHslGJ2Sjs88MUYCo/gzb4SvzxG
6xiUtCob0DEHr+OaSnE24sQdifsvBj7PdAaPCjzwflryI0gxPzoyKjV1ZJDPzgWNALReo
tQZhhCu3G1CuqrIRHoUuU9KaGufYf501xhy2AwjhAGrd6AVJVx/OksffQy9Y9OErm/w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yPo27khX;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BE34606A334;
Tue, 1 Dec 2026 04:43:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yPo27khX
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796100224;
b=FO6PQYcM9XwmrdSRC42irwIutR1KnLN4xuGqqBH2/QJBxKKTES18sIkJAAfVRO7rQkZc
6eB4QCIRPgt59irKE5NQpINfH9R4ZW7j9NiWI9anSE7P/ydKxz0VmSy77tV11s57RzdQS
VLEz2pIUzOW7EKlvDV15ee/az9nf8b8T59fZCX9sN//oPisczbBrtiQsd9heO2gTpyn9C
t+zvSHh0oJ3+Fu609a99zXAuprzy6hfbTi9/1G958l4+hRZvV4p2hnaaKWCUtoOdhHTHn
VMWvWPfpaqGXKHbjF70JoC6ugUVMALWHuihPlWDGPjnaRW4fcK+I9q5a9YHYN8DMdwA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796100224;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=;
b=3hM3kUj1Sey2oygdeh4p3FYUu7fsgC8FsAYiXM+QAcDL2eFXTJD0gnEWxeKxVE9scT30
OwwnO0MHW2p3Nev4rZAhkkCKTXbROoK6a2nqsYDClYeQtuI8bGTTJlBIqKe8XFtC3D0Ye
3lCz0eMnbC8+xIesDsxU7spqtA7biwuVAksHVcHe16FmHS27tHsgJP463xN9GhovFTKJC
/5wmR7t/H4Q7BlM2r785TmNT6aRu/axAJgs4aewRQKEHhoZ+31YAbHOtw4cTxbjD4OWCy
ploZOYZYJ8oVGV+ly8C8zvLQPgXMRsW0WCdqsFP/T0mvN+3L06nsU20Dn0dL8tHPK0Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yPo27khX;
arc=none smtp.remote-ip=74.125.82.51
X-Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AA76606A32C
for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 04:43:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0AA76606A32C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1aefd1bf74aso7059866c88.1
for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 20:43:43 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796100223; x=1796705023; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=;
b=yPo27khXaCxPnVbnWcFvvukYCE2Za9OM9AI4LxeKhCXs/SWrxfTermRm71XwlHTJAw
fOQjj5/3LwDQIzAAjNEhG4VCWUzLfL25ZqlWID9e7vacplEiJDZV6hko2IuHyk/kmvSq
Sxbt6PuftU3gbFrLTl3+ywRwY9kEgGbR1mqg/ukagNMDQV8xSGRrorOxvyP8mvUxoDXM
Q+OvwQqdjSOUYA16Mh07Sqj6bvonrjXsh/eRRrrZ5DUFE1Nep7kqmEx3TDgyu2vYBzKQ
kgS3rd5ENpwbuQZsvx0rAThyo8HlBKBQ45xXJeyd1KvYKEQnS6wNVPMrl8iRSs0aI/Ji
jsfA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796100223; x=1796705023;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=;
b=WynNRlS62uiKFcIEnlnLnk42lXdgj15vsanil4GdBvx7awcppSWRfL7g8YvhpGFefM
o54tDpSEDptzGrWev9w23SG2CCYWCwTbktC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u61RFI+qwaJmvrzCr7PNA
SMOvZ9jvZCwq0cVgsAD54L7Den0I7lpD+HLhOisTisg+1TPqdIDZmxHt3LdGzVJ+GebeVFlNHKJ
oWMsdo6LTW0cPiEYVdGcMz/yFfLiFboF4
X-Received: by 2002:a05:7023:a41:b0:1a7:77ae:11f6 with SMTP id a92af1059eb24-1b55691518fmr32707267c88.17.1796100222972;
Mon, 30 Nov 2026 20:43:42 -0800 (PST)
X-Received: from jmaxwell-thinkpadp1gen4i.redhat.corp (14-203-60-241.tpgi.com.au. [14.203.60.241])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm82311299c88.8.2026.11.30.20.43.36
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 30 Nov 2026 20:43:42 -0800 (PST)
X-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
X-Mailer: git-send-email 2.55.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list