Article View: linux.kernel.netdev
Article #24794[PATCH net v6 2/7] igb: don't touch rings that don't exist when disabling an XSK pool
From: Antonio Quartulli
Date: Mon, 30 Nov 2026 21:37
Date: Mon, 30 Nov 2026 21:37
121 lines
14579 bytes
14579 bytes
xsk_get_pool_from_qid() checks the queue id against the stack's real
queue counts, which can be higher than the number of rings the device
has: on 82576, enabling VFs leaves a single Tx queue while keeping two
Rx queues, and a runtime suspend frees all rings. Disabling the pool of
such a queue, e.g. one bound to queue 1 before enabling VFs, then passes
a NULL Tx ring to igb_txrx_ring_disable(), and a NULL Rx ring too if the
socket is closed while the device is runtime suspended.
Only disable and re-enable the rings the device has: skip the queue if
it has no Rx ring, and only the Tx part if it has no Tx ring, so that
an Rx ring using the pool still stops using it.
Tested with the 82576 emulated by QEMU and a zero-copy AF_XDP socket on
queue 1: closing it after enabling a VF no longer oopses and the Rx ring
no longer references the pool afterwards (checked with a debug print, as
QEMU doesn't spread traffic over the PF queues with VFs), and without
VFs queue 1 keeps receiving after the close. Not run under KASAN.
Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
Cc: stable@vger.kernel.org # 6.14+
Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/
Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v6: the message and comment name the runtime suspended case instead of
the MSI fallback, which only reaches this check with patch 4 (Sashiko);
no code changes
v5: the message also mentions the runtime suspended case (no code
changes)
v4: also handle queues with an Rx but no Tx ring, as with VFs (Sashiko):
tear down the Rx ring and skip only the Tx part; tested with a
zero-copy AF_XDP socket; subject was "don't disable rings that don't exist
..."
v3: new patch.
drivers/net/ethernet/intel/igb/igb_xsk.c | 38 +++++++++++++++++-------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
index ce4a7b5..b6234e3 100644
--- a/drivers/net/ethernet/intel/igb/igb_xsk.c
+++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
@@ -31,15 +31,22 @@ static int igb_realloc_rx_buffer_info(struct igb_ring *ring, bool pool_present)
return 0;
}
+/* With VFs, the device has a single Tx queue but can have more Rx queues */
+static struct igb_ring *igb_xsk_tx_ring(struct igb_adapter *adapter, u16 qid)
+{
+ return qid < adapter->num_tx_queues ? adapter->tx_ring[qid] : NULL;
+}
+
static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid)
{
- struct igb_ring *tx_ring = adapter->tx_ring[qid];
+ struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid);
struct igb_ring *rx_ring = adapter->rx_ring[qid];
struct e1000_hw *hw = &adapter->hw;
- set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
-
- wr32(E1000_TXDCTL(tx_ring->reg_idx), 0);
+ if (tx_ring) {
+ set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
+ wr32(E1000_TXDCTL(tx_ring->reg_idx), 0);
+ }
wr32(E1000_RXDCTL(rx_ring->reg_idx), 0);
synchronize_net();
@@ -47,24 +54,27 @@ static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid)
/* Rx/Tx share the same napi context. */
napi_disable(&rx_ring->q_vector->napi);
- igb_clean_tx_ring(tx_ring);
+ if (tx_ring) {
+ igb_clean_tx_ring(tx_ring);
+ memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats));
+ }
igb_clean_rx_ring(rx_ring);
-
memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats));
- memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats));
}
static void igb_txrx_ring_enable(struct igb_adapter *adapter, u16 qid)
{
- struct igb_ring *tx_ring = adapter->tx_ring[qid];
+ struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid);
struct igb_ring *rx_ring = adapter->rx_ring[qid];
- igb_configure_tx_ring(adapter, tx_ring);
+ if (tx_ring)
+ igb_configure_tx_ring(adapter, tx_ring);
igb_configure_rx_ring(adapter, rx_ring);
synchronize_net();
- clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
+ if (tx_ring)
+ clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
/* call igb_desc_unused which always leaves
* at least 1 descriptor unused to make sure
@@ -148,7 +158,13 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid)
return -EINVAL;
rx_ring = adapter->rx_ring[qid];
- if_running = netif_running(adapter->netdev) && igb_xdp_is_enabled(adapter);
+ /* The stack can know more queues than the device has, e.g. while
+ * runtime suspended, which frees the rings: skip the rings it
+ * doesn't have.
+ */
+ if_running = netif_running(adapter->netdev) &&
+ igb_xdp_is_enabled(adapter) &&
+ qid < adapter->num_rx_queues;
if (if_running)
igb_txrx_ring_disable(adapter, qid);
--
2.56.1
Technical Details
Message-ID:
<20261130213740.3323814-3-antonio@mandelbit.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374471-linux-kernel-netdev=dewy.ruReferences:
<20261130213740.3323814-1-antonio@mandelbit.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374471-linux-kernel-netdev=dewy.ru From: antonio@mandelbit.com (Antonio Quartulli) Newsgroups: linux.kernel.netdev Subject: [PATCH net v6 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Date: Mon, 30 Nov 2026 22:37:32 +0100 Organization: Usenet Network Message-ID: <20261130213740.3323814-3-antonio@mandelbit.com> References: <20261130213740.3323814-1-antonio@mandelbit.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1544088"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3Bm5q9LMU2tKbhf0X4QGdXVqjAU= sha256:ipvvxr/zCvCkV213zY/rRFNwLPT2L43q68gDe573V70= sha1:38l03BIolDKTm9q+fUKhdjREF8o= sha256:awitqtWJxTGT8RRrSquV7IuTZMjnu1cgp+0QqydwQuI= 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 6BF2412600E; Tue, 1 Dec 2026 00:38:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, 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=mandelbit.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 m31YPRQsqiR0; Tue, 1 Dec 2026 00:38:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374471-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id B9BF812600F; Tue, 1 Dec 2026 00:38:30 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 7AE2F32155; Mon, 30 Nov 2026 21:38:08 +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=1796074682; b=S46dWNQHyYb5LGEpZAQNF/yGPZjqsAdhBYoflT3KivCYBqTxo7p4HSL5JyI47DAbMGE4 U1NXujVT43ORSfmBioL/S0UTsJUJXn1q9uIIBmkX9bBL2kDLtAiGyHMwrjawLiJrYLPpZ JXuDYr5OoPUIcJFPM4sguSANLggTk8GRtd2HhAXaDBubr0z+2kC/VJCRlrAnKMTxIBywK v6AN6LwirQqLApKd3TYkkosX2cgh0InALPfTVMmSomPhI2NdxWT5ejm1Zcs+YR73QEl7s oHzO/qQSKGgMECJLF+Igp4lY85PlYO6ptQVMUa4vu/cccYt+DnvO/VA3UZwalqPxNDA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796074682; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=MEqkuIH0Uttlf4pInxz7Ok5UHDLyQVoc0vrAlDMlGVY=; b=eQ87xiQPXXozrzNgzk8lMC5wSFWQUsfq4LSSsshOrBMkWHY9K2fiJ/0cUORljTUgNBem +iGg7ZRf5809zPmLGk4SZ5DvqolzJcHhg71BuBPQHslpFwlD46NyHv9bMM2tSambuRle/ cOzGbZj4MGMm7x2+uAIp5RfTMVCv3juVHotVESDJ2/jHlsCX8tDCNCwjsNLoAhFFx8ycB filj5kVWZPCVhEWxcM+dARsO/f1M2WBAySbpxyrrR3kR+w0eL9hLULnqrTOE8YRfjRzYb 8H0nA23cF/A/OG8KR+pX55x+RZC+mc7hSeq/97/Vl2gq+ExZstMqjjBAtHGPgNc7H+w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=YH9Cq6HV; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.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 01C23606A6B8; Mon, 30 Nov 2026 21:38:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=YH9Cq6HV X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.40 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796074681; b=cf4CUdtuqBiZRSyyoerIqc2YwxVETzoUzypncFDVSEq/QU49wEc0N3B5UakETBK6SYu6 NcoP0vs3BqTudDy5OC/OHGvOpgJLuhXJ5DwRJmcWsi53Bm3Kau3VBIJKbrjNvok0syAn3 b0YcYKDkX9ADYd8L+hL2a61r2me8Jss2+qviIqWD1WXwaChp5xqbVU5j+8OJxLWiVIbor DzxDiEAoUchoDqjEt5iHLJmzl+UhCdVuG1PjXSC1zxnAzQrgMVGKcv18j3Lb0cmswdgVb QjGHZcCWKcsxLRrEIrnMrrWW+kSKGNNnd51NzPX1wNx8s8CF6xbV2QlQMLCSsgzPxlA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796074681; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=MEqkuIH0Uttlf4pInxz7Ok5UHDLyQVoc0vrAlDMlGVY=; b=OmYXf0FeFTNfGpl6SDrtgT7kfFnAoh5+97r7O/A3zpvsNKN09n32MyldBfBDa/oNFdzz H73bwMWKPgwVeq5SsRr1Z5M2YZbt19IXkPZsMk1MbUVVZmLXOwCwO6qFhdVNMmlJAlUgv HgmaMUd3dV7FcWAFRy3BGFHhyTW5xrZdnDbDfEZ+G3y0gUGU1KvxuEDE7QEDYLbxY99hy 2IjTN6WEGP2sf4vgTiefSy57GG6EtrA4xzsHnw2Jfpj+csM9D3kx8M2QctcNMrBF11oym ilB/y7IDv1hJdcquEYXHyDM7akMx6yzcb7aM/xi4e3qYHaS1MebFeXEuemFKY+q5zOA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=YH9Cq6HV; arc=none smtp.remote-ip=195.10.208.40 X-Received: from mout-b-210.mailbox.org (mout-b-210.mailbox.org [195.10.208.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7636F606A686; Mon, 30 Nov 2026 21:38:00 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7636F606A686 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com X-Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-210.mailbox.org (Postfix) with ESMTPS id 4jdcnV4yldzFqYy; Mon, 30 Nov 2026 22:37:50 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796074670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MEqkuIH0Uttlf4pInxz7Ok5UHDLyQVoc0vrAlDMlGVY=; b=YH9Cq6HVLQICLzJ4o1uqMcOUSqrgowVyCtzjq2wAK3+v2RJWYn3LPAzJlrBncEdksPNWSO bc7X9OGCuNIBwy8XbNPn6W58gqdAj3EL23L8T7jyFJMWoamIqH+N6YAvZzJSaQaSCbMPAY zipVn+UdsSYJzTl0bTWDBRB4Quj8BUY/yZkREeTl1NbVx5UEoNCVwMtkEuqpM3B1yb5m4e cI4Mo1OwXPLgiE3ByS11uy7pEGpkxAJtINzA70u1mpvkW1joiP63L1K45wfj3eCJg9pkL4 HFOqbW0PxTuvxA2HY/ZCdSO+23gvfNlqjqmthlukeg9xS7N8C9O7qdVgZHQegw== X-Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=antonio@mandelbit.com X-Cc: Antonio Quartulli <antonio@mandelbit.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Janis Edvarts Lacis <janislacis06@gmail.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Stanislav Fomichev <sdf@fomichev.me>, Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>, Kurt Kanzenbach <kurt@linutronix.de>, Maciej Fijalkowski <maciej.fijalkowski@intel.com>, Heiner Kallweit <hkallweit1@gmail.com>, Joe Damato <joe@dama.to>, "Rafael J. Wysocki" <rafael@kernel.org>, Sven Auhagen <sven.auhagen@voleatech.de>, netdev@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261130213740.3323814-1-antonio@mandelbit.com> 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 X-Rspamd-Queue-Id: 4jdcnV4yldzFqYy