From: Sergey Temerkhanov <sergey.temerkhanov@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org
Subject: [PATCH iwl-net v2 3/4] ixgbe: Restore previous XDP program on ixgbe_setup_tc() failure
Date: Tue, 22 Sep 2026 11:35:57 +0000 [thread overview]
Message-ID: <20260922113558.2288111-4-sergey.temerkhanov@intel.com> (raw)
In-Reply-To: <20260922113558.2288111-1-sergey.temerkhanov@intel.com>
When enabling or disabling an XDP program requires a queue
reconfiguration, ixgbe_xdp_setup() swaps in the new program with
xchg() before calling ixgbe_setup_tc(). If ixgbe_setup_tc() fails,
the adapter was left pointing at the new program even though the
reconfiguration did not complete, leaking the reference to the old
program and leaving inconsistent state.
ixgbe_setup_tc() may have already reconfigured the queues for the new
program before failing. The XDP ring layout then no longer matches the
previous program, for example when removing a program has removed the
XDP TX rings. Restore the previous program and rebuild the queues for
it so adapter->xdp_prog remains consistent with the ring configuration.
Otherwise, a later open could run XDP without XDP TX rings and
dereference a NULL ring. ixgbe_setup_tc() handles the device having
been left down by the failed reconfiguration.
Fixes: 3fe1d0a48d21 ("ixgbe: XDP: fix checker warning from rcu pointer")
Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>
Reviewed-by: Przemyslaw Korba <przemyslaw.korba@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 40 ++++++++++++++++++-
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 1f23a035a90b..6ef51b822a50 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7348,6 +7348,25 @@ static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter)
ixgbe_free_rx_resources(adapter->rx_ring[i]);
}
+static bool ixgbe_ring_resources_allocated(struct ixgbe_adapter *adapter)
+{
+ int i;
+
+ for (i = 0; i < adapter->num_tx_queues; i++)
+ if (adapter->tx_ring[i] && adapter->tx_ring[i]->desc)
+ return true;
+
+ for (i = 0; i < adapter->num_xdp_queues; i++)
+ if (adapter->xdp_ring[i] && adapter->xdp_ring[i]->desc)
+ return true;
+
+ for (i = 0; i < adapter->num_rx_queues; i++)
+ if (adapter->rx_ring[i] && adapter->rx_ring[i]->desc)
+ return true;
+
+ return false;
+}
+
/**
* ixgbe_max_xdp_frame_size - returns the maximum allowed frame size for XDP
* @adapter: device handle, pointer to adapter
@@ -9921,6 +9940,7 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
{
struct ixgbe_adapter *adapter = ixgbe_from_netdev(dev);
struct ixgbe_hw *hw = &adapter->hw;
+ bool running;
/* Hardware supports up to 8 traffic classes */
if (tc > adapter->dcb_cfg.num_tcs.pg_tcs)
@@ -9933,7 +9953,17 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
* match packet buffer alignment. Unfortunately, the
* hardware is not flexible enough to do this dynamically.
*/
- if (netif_running(dev))
+ if (!netif_device_present(dev))
+ return -ENETDOWN;
+
+ running = netif_running(dev);
+
+ /* If a previous ixgbe_open() failed, the netdev can still be
+ * administratively up after IRQs and ring resources have already been
+ * released. Skip ixgbe_close() only in that state; ixgbe_down() leaves
+ * resources for ixgbe_close() to release.
+ */
+ if (running && ixgbe_ring_resources_allocated(adapter))
ixgbe_close(dev);
else
ixgbe_reset(adapter);
@@ -10972,8 +11002,14 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
synchronize_rcu();
err = ixgbe_setup_tc(dev, adapter->hw_tcs);
- if (err)
+ if (err) {
+ xchg(&adapter->xdp_prog, old_prog);
+ err = ixgbe_setup_tc(dev, adapter->hw_tcs);
+ /* An ndo_bpf error leaves old_prog attached in the core. */
+ if (err)
+ return err;
return -EINVAL;
+ }
if (!prog)
xdp_features_clear_redirect_target(dev);
} else {
--
2.53.0
next prev parent reply other threads:[~2026-09-22 11:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 11:35 [PATCH iwl-net v2 0/4] ixgbe: fix FCoE/XDP issues and PCI reset handling Sergey Temerkhanov
2026-09-22 11:35 ` [PATCH iwl-net v2 1/4] ixgbe: Refactor device operations to check whether netdev is available Sergey Temerkhanov
2026-09-25 17:22 ` Simon Horman
2026-09-22 11:35 ` [PATCH iwl-net v2 2/4] ixgbe: Fix FCoE refcount taking for unsupported adapters Sergey Temerkhanov
2026-09-25 17:23 ` Simon Horman
2026-09-22 11:35 ` Sergey Temerkhanov [this message]
2026-09-25 17:23 ` [PATCH iwl-net v2 3/4] ixgbe: Restore previous XDP program on ixgbe_setup_tc() failure Simon Horman
2026-09-22 11:35 ` [PATCH iwl-net v2 4/4] ixgbe: Implement PCI reset handler Sergey Temerkhanov
2026-09-25 17:24 ` Simon Horman
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=20260922113558.2288111-4-sergey.temerkhanov@intel.com \
--to=sergey.temerkhanov@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.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