* [PATCH iwl-net 1/5] iavf: fix null pointer dereference in iavf_detect_recover_hung
2026-04-13 7:30 [PATCH iwl-net 0/5] iavf: five correctness fixes Aleksandr Loktionov
@ 2026-04-13 7:30 ` Aleksandr Loktionov
2026-04-15 12:48 ` Simon Horman
2026-04-13 7:30 ` [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq Aleksandr Loktionov
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Aleksandr Loktionov @ 2026-04-13 7:30 UTC (permalink / raw)
To: intel-wired-lan, anthony.l.nguyen, aleksandr.loktionov
Cc: netdev, Kiran Patil
From: Kiran Patil <kiran.patil@intel.com>
During a concurrent reset, q_vectors are freed and re-allocated while
the watchdog task may still be iterating rings in
iavf_detect_recover_hung(). Dereferencing a NULL q_vector inside
iavf_force_wb() results in a crash. Guard against this by skipping
rings whose q_vector is NULL.
Also move the tx_ring declaration into the loop body and drop the
redundant outer NULL initialisation, which the compiler can never
observe since an array-element address is always non-NULL.
Fixes: 9c6c12595b73 ("i40e: Detection and recovery of TX queue hung logic moved to service_task from tx_timeout")
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_txrx.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
index 363c42b..e7e7fc9 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
@@ -176,7 +176,6 @@ static void iavf_force_wb(struct iavf_vsi *vsi, struct iavf_q_vector *q_vector)
**/
void iavf_detect_recover_hung(struct iavf_vsi *vsi)
{
- struct iavf_ring *tx_ring = NULL;
struct net_device *netdev;
unsigned int i;
int packets;
@@ -195,8 +194,11 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi)
return;
for (i = 0; i < vsi->back->num_active_queues; i++) {
- tx_ring = &vsi->back->tx_rings[i];
- if (tx_ring && tx_ring->desc) {
+ struct iavf_ring *tx_ring = &vsi->back->tx_rings[i];
+
+ if (!tx_ring || !tx_ring->q_vector)
+ continue;
+ if (tx_ring->desc) {
/* If packet counter has not changed the queue is
* likely stalled, so force an interrupt for this
* queue.
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH iwl-net 1/5] iavf: fix null pointer dereference in iavf_detect_recover_hung
2026-04-13 7:30 ` [PATCH iwl-net 1/5] iavf: fix null pointer dereference in iavf_detect_recover_hung Aleksandr Loktionov
@ 2026-04-15 12:48 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2026-04-15 12:48 UTC (permalink / raw)
To: aleksandr.loktionov
Cc: Simon Horman, intel-wired-lan, kiran.patil, sylwesterx.dziedziuch,
netdev, anthony.l.nguyen, avinash.dayanand
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
iavf: fix null pointer dereference in iavf_detect_recover_hung
During a concurrent reset, q_vectors are freed and re-allocated while
the watchdog task may still be iterating rings in
iavf_detect_recover_hung(). Dereferencing a NULL q_vector inside
iavf_force_wb() results in a crash. Guard against this by skipping
rings whose q_vector is NULL.
> Fixes: 9c6c12595b73 ("i40e: Detection and recovery of TX queue hung logic moved to service_task from tx_timeout")
The Fixes tag points to commit 9c6c12595b73, but that commit only modified
the i40e driver and did not introduce the iavf_detect_recover_hung function.
The bug was actually introduced by commit 07d44190a389 ("i40e/i40evf: Detect
and recover hung queue scenario"), which added iavf_detect_recover_hung with
the code pattern 'if (tx_ring && tx_ring->desc)' that calls
iavf_force_wb(vsi, tx_ring->q_vector) without checking if q_vector is NULL.
Should the Fixes tag be:
Fixes: 07d44190a389 ("i40e/i40evf: Detect and recover hung queue scenario")
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
> index 363c42bf3dcf..e7e7fc9a5c68 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
[ ... ]
> @@ -195,8 +194,11 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi)
> return;
>
> for (i = 0; i < vsi->back->num_active_queues; i++) {
> - tx_ring = &vsi->back->tx_rings[i];
> - if (tx_ring && tx_ring->desc) {
> + struct iavf_ring *tx_ring = &vsi->back->tx_rings[i];
> +
> + if (!tx_ring || !tx_ring->q_vector)
> + continue;
The check `if (!tx_ring || ...)` tests whether tx_ring is NULL, but tx_ring
is assigned as `&vsi->back->tx_rings[i]`, which is the address of an array
element. This address is always non-NULL by C language rules, as noted in
the commit message itself: "the compiler can never observe since an
array-element address is always non-NULL."
This creates misleading logic. Other similar code in the driver correctly
omits such checks (for example, in iavf_virtchnl.c and elsewhere in
iavf_txrx.c).
Should this be simplified to just check the q_vector:
if (!tx_ring->q_vector)
continue;
> + if (tx_ring->desc) {
> /* If packet counter has not changed the queue is
> * likely stalled, so force an interrupt for this
> * queue.
[ ... ]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq
2026-04-13 7:30 [PATCH iwl-net 0/5] iavf: five correctness fixes Aleksandr Loktionov
2026-04-13 7:30 ` [PATCH iwl-net 1/5] iavf: fix null pointer dereference in iavf_detect_recover_hung Aleksandr Loktionov
@ 2026-04-13 7:30 ` Aleksandr Loktionov
2026-04-13 11:53 ` Przemek Kitszel
2026-04-15 13:26 ` Simon Horman
2026-04-13 7:30 ` [PATCH iwl-net 3/5] iavf: prevent VSI corruption when ring params changed during reset Aleksandr Loktionov
` (2 subsequent siblings)
4 siblings, 2 replies; 12+ messages in thread
From: Aleksandr Loktionov @ 2026-04-13 7:30 UTC (permalink / raw)
To: intel-wired-lan, anthony.l.nguyen, aleksandr.loktionov; +Cc: netdev
From: Piotr Gardocki <piotrx.gardocki@intel.com>
When request_irq() fails the interrupt vector was not registered for
the driver. Calling free_irq() on a vector that was never successfully
requested triggers a kernel warning. Drop the erroneous free_irq()
call from the error path.
Fixes: 5eae00c57f5e ("i40evf: main driver core")
Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index dad001a..ab5f5adc 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -587,7 +587,6 @@ static int iavf_request_misc_irq(struct iavf_adapter *adapter)
dev_err(&adapter->pdev->dev,
"request_irq for %s failed: %d\n",
adapter->misc_vector_name, err);
- free_irq(adapter->msix_entries[0].vector, netdev);
}
return err;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq
2026-04-13 7:30 ` [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq Aleksandr Loktionov
@ 2026-04-13 11:53 ` Przemek Kitszel
2026-04-15 13:26 ` Simon Horman
1 sibling, 0 replies; 12+ messages in thread
From: Przemek Kitszel @ 2026-04-13 11:53 UTC (permalink / raw)
To: Aleksandr Loktionov; +Cc: netdev, intel-wired-lan, anthony.l.nguyen
On 4/13/26 09:30, Aleksandr Loktionov wrote:
> From: Piotr Gardocki <piotrx.gardocki@intel.com>
>
> When request_irq() fails the interrupt vector was not registered for
> the driver. Calling free_irq() on a vector that was never successfully
> requested triggers a kernel warning. Drop the erroneous free_irq()
> call from the error path.
>
> Fixes: 5eae00c57f5e ("i40evf: main driver core")
> Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/iavf/iavf_main.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index dad001a..ab5f5adc 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -587,7 +587,6 @@ static int iavf_request_misc_irq(struct iavf_adapter *adapter)
> dev_err(&adapter->pdev->dev,
> "request_irq for %s failed: %d\n",
> adapter->misc_vector_name, err);
> - free_irq(adapter->msix_entries[0].vector, netdev);
> }
> return err;
> }
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
next time please CC netdev on IWL submissions
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq
2026-04-13 7:30 ` [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq Aleksandr Loktionov
2026-04-13 11:53 ` Przemek Kitszel
@ 2026-04-15 13:26 ` Simon Horman
1 sibling, 0 replies; 12+ messages in thread
From: Simon Horman @ 2026-04-15 13:26 UTC (permalink / raw)
To: aleksandr.loktionov
Cc: 'Simon Horman', intel-wired-lan, anthony.l.nguyen, netdev,
kiran.patil
From: 'Simon Horman' <horms@kernel.org>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev
---
iavf: fix error path in iavf_request_misc_irq
This patch drops the free_irq() call from the error path of
iavf_request_misc_irq() when request_irq() fails. This is intended to
prevent a kernel warning when freeing an unrequested vector.
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index dad001abc9086..ab5f5adc2d3c2 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -587,7 +587,6 @@ static int iavf_request_misc_irq(struct iavf_adapter *adapter)
> dev_err(&adapter->pdev->dev,
> "request_irq for %s failed: %d\n",
> adapter->misc_vector_name, err);
> - free_irq(adapter->msix_entries[0].vector, netdev);
Does this patch completely fix the warning?
If request_irq() fails, iavf_request_misc_irq() returns an error but leaves
adapter->msix_entries allocated.
In caller error handling paths like iavf_disable_vf() which clean up after a
failure, iavf_free_misc_irq() is called:
static void iavf_free_misc_irq(struct iavf_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
if (!adapter->msix_entries)
return;
free_irq(adapter->msix_entries[0].vector, netdev);
}
Since adapter->msix_entries is still allocated, the check passes and free_irq()
is called on the unrequested vector anyway, triggering the exact same warning.
Does the driver need to explicitly track whether the IRQ was successfully
requested?
> }
> return err;
> }
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH iwl-net 3/5] iavf: prevent VSI corruption when ring params changed during reset
2026-04-13 7:30 [PATCH iwl-net 0/5] iavf: five correctness fixes Aleksandr Loktionov
2026-04-13 7:30 ` [PATCH iwl-net 1/5] iavf: fix null pointer dereference in iavf_detect_recover_hung Aleksandr Loktionov
2026-04-13 7:30 ` [PATCH iwl-net 2/5] iavf: fix error path in iavf_request_misc_irq Aleksandr Loktionov
@ 2026-04-13 7:30 ` Aleksandr Loktionov
2026-04-15 13:28 ` Simon Horman
2026-04-13 7:30 ` [PATCH iwl-net 4/5] iavf: fix TC boundary check in iavf_handle_tclass Aleksandr Loktionov
2026-04-13 7:30 ` [PATCH iwl-net 5/5] iavf: return 0 when TC flower filter not found after qdisc teardown Aleksandr Loktionov
4 siblings, 1 reply; 12+ messages in thread
From: Aleksandr Loktionov @ 2026-04-13 7:30 UTC (permalink / raw)
To: intel-wired-lan, anthony.l.nguyen, aleksandr.loktionov
Cc: netdev, Sylwester Dziedziuch
From: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Changing ring parameters via ethtool triggers a VF reset and queue
reconfiguration. If ethtool is called again before the first reset
completes, the second reset races with uninitialised queue state and
can corrupt the VSI resource tree on the PF side.
Return -EAGAIN from iavf_set_ringparam() when the adapter is already
resetting or its queues are disabled.
Fixes: fbb7ddfef253 ("i40evf: core ethtool functionality")
Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index 1cd1f3f..3909131 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -495,6 +495,11 @@ static int iavf_set_ringparam(struct net_device *netdev,
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
return -EINVAL;
+ if (adapter->state == __IAVF_RESETTING ||
+ (adapter->state == __IAVF_RUNNING &&
+ adapter->flags & IAVF_FLAG_QUEUES_DISABLED))
+ return -EAGAIN;
+
if (ring->tx_pending > IAVF_MAX_TXD ||
ring->tx_pending < IAVF_MIN_TXD ||
ring->rx_pending > IAVF_MAX_RXD ||
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH iwl-net 3/5] iavf: prevent VSI corruption when ring params changed during reset
2026-04-13 7:30 ` [PATCH iwl-net 3/5] iavf: prevent VSI corruption when ring params changed during reset Aleksandr Loktionov
@ 2026-04-15 13:28 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2026-04-15 13:28 UTC (permalink / raw)
To: aleksandr.loktionov
Cc: 'Simon Horman', intel-wired-lan, anthony.l.nguyen, netdev,
kiran.patil
From: 'Simon Horman' <horms@kernel.org>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev
---
iavf: prevent VSI corruption when ring params changed during reset
Changing ring parameters via ethtool triggers a VF reset and queue
reconfiguration. If ethtool is called again before the first reset
completes, the second reset races with uninitialised queue state and
can corrupt the VSI resource tree on the PF side. Return -EAGAIN from
iavf_set_ringparam() when the adapter is already resetting or its queues
are disabled.
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> index 1cd1f3f2930a0..390913170315f 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> @@ -495,6 +495,11 @@ static int iavf_set_ringparam(struct net_device *netdev,
> if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
> return -EINVAL;
>
> + if (adapter->state == __IAVF_RESETTING ||
> + (adapter->state == __IAVF_RUNNING &&
> + adapter->flags & IAVF_FLAG_QUEUES_DISABLED))
> + return -EAGAIN;
> +
Is there a lockless Time-Of-Check to Time-Of-Use race here?
iavf_set_ringparam() is called from ethtool under rtnl_lock(), but the
background iavf_reset_task() synchronizes using netdev_lock(). Because iavf
does not set netdev->request_ops_lock = true, the ethtool core does not
acquire netdev_lock() for iavf_set_ringparam().
This allows adapter->state to transition to __IAVF_RESETTING immediately
after this lockless check.
Furthermore, calling iavf_reset_step() later in this function without
holding netdev_lock() allows the hardware reset sequence to execute
concurrently from both the ethtool thread and the workqueue, which could
lead to VSI resource corruption.
Could this open-coded state check miss pending resets?
If a reset is scheduled (e.g., by a watchdog timeout setting
IAVF_FLAG_RESET_NEEDED) but the worker task hasn't started yet,
adapter->state will still be __IAVF_RUNNING. This check will pass, and
iavf_set_ringparam() will proceed to mutate ring parameters and execute
iavf_reset_step(), racing with the previously scheduled iavf_reset_task.
Can this be addressed by also checking for IAVF_FLAG_RESET_NEEDED and
IAVF_FLAG_RESET_PENDING?
Also, the commit message notes that triggering a VF reset before the first
one completes causes VSI resource tree corruption. Both iavf_set_channels()
and iavf_change_mtu() also dynamically reconfigure queues and
unconditionally trigger resets by calling iavf_reset_step(adapter).
Should these functions be updated to include a similar state check to
prevent the same VSI resource tree corruption on the PF side?
> if (ring->tx_pending > IAVF_MAX_TXD ||
> ring->tx_pending < IAVF_MIN_TXD ||
> ring->rx_pending > IAVF_MAX_RXD ||
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH iwl-net 4/5] iavf: fix TC boundary check in iavf_handle_tclass
2026-04-13 7:30 [PATCH iwl-net 0/5] iavf: five correctness fixes Aleksandr Loktionov
` (2 preceding siblings ...)
2026-04-13 7:30 ` [PATCH iwl-net 3/5] iavf: prevent VSI corruption when ring params changed during reset Aleksandr Loktionov
@ 2026-04-13 7:30 ` Aleksandr Loktionov
2026-04-15 13:46 ` Simon Horman
2026-04-13 7:30 ` [PATCH iwl-net 5/5] iavf: return 0 when TC flower filter not found after qdisc teardown Aleksandr Loktionov
4 siblings, 1 reply; 12+ messages in thread
From: Aleksandr Loktionov @ 2026-04-13 7:30 UTC (permalink / raw)
To: intel-wired-lan, anthony.l.nguyen, aleksandr.loktionov
Cc: netdev, Avinash Dayanand
From: Avinash Dayanand <avinash.dayanand@intel.com>
The condition `tc < adapter->num_tc` admits any tc value equal to or
greater than num_tc, bypassing the destination-port validation and
allowing traffic to be steered to a non-existent traffic class. Change
the comparison to `tc > adapter->num_tc` to correctly reject
out-of-range TC values.
Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
Signed-off-by: Avinash Dayanand <avinash.dayanand@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index ab5f5adc..5e4035b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -4062,7 +4062,7 @@ static int iavf_handle_tclass(struct iavf_adapter *adapter, u32 tc,
{
if (tc == 0)
return 0;
- if (tc < adapter->num_tc) {
+ if (tc > adapter->num_tc) {
if (!filter->f.data.tcp_spec.dst_port) {
dev_err(&adapter->pdev->dev,
"Specify destination port to redirect to traffic class other than TC0\n");
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH iwl-net 4/5] iavf: fix TC boundary check in iavf_handle_tclass
2026-04-13 7:30 ` [PATCH iwl-net 4/5] iavf: fix TC boundary check in iavf_handle_tclass Aleksandr Loktionov
@ 2026-04-15 13:46 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2026-04-15 13:46 UTC (permalink / raw)
To: Aleksandr Loktionov
Cc: intel-wired-lan, anthony.l.nguyen, netdev, Avinash Dayanand
On Mon, Apr 13, 2026 at 09:30:34AM +0200, Aleksandr Loktionov wrote:
> From: Avinash Dayanand <avinash.dayanand@intel.com>
>
> The condition `tc < adapter->num_tc` admits any tc value equal to or
> greater than num_tc, bypassing the destination-port validation and
> allowing traffic to be steered to a non-existent traffic class. Change
> the comparison to `tc > adapter->num_tc` to correctly reject
> out-of-range TC values.
>
> Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
> Signed-off-by: Avinash Dayanand <avinash.dayanand@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
I am a bit confused by this logic.
With this patch applied:
1) For tc <= adapter->num_tc, which I assume is valid TCs (other than 0,
in which case the function returns earlier), the filter destination port
is skipped.
But the failure path for that checks logs:
"Specify destination port to redirect to traffic class other than TC0\n"
This does not seem consistent.
2) For tc > adapter->num_tc, which I assume is invalid TCs,
the function will eventually assign fields of filter->f and succeed
if filter has a valid destination port.
This doesn't seem to be in keeping with the patch description.
3) The above two points aside, is there an out by 1 condition in
the condition tc > adapter->num_tc. It seems to imply
that tc == adapter->num_tc is a valid tc. But I suspect that
is not hte case.
In short, I'm wondering if the function should look something like this
(completely untested):
/**
* iavf_handle_tclass - Forward to a traffic class on the device
* @adapter: board private structure
* @tc: traffic class index on the device
* @filter: pointer to cloud filter structure
*/
static int iavf_handle_tclass(struct iavf_adapter *adapter, u32 tc,
struct iavf_cloud_filter *filter)
{
if (tc == 0)
return 0;
if (tc >= adapter->num_tc) {
// dev_err(...);
return -EINVAL;
}
if (!filter->f.data.tcp_spec.dst_port) {
dev_err(&adapter->pdev->dev,
"Specify destination port to redirect to traffic class other than TC0\n");
return -EINVAL;
}
/* redirect to a traffic class on the same device */
filter->f.action = VIRTCHNL_ACTION_TC_REDIRECT;
filter->f.action_meta = tc;
return 0;
}
> ---
> drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index ab5f5adc..5e4035b 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -4062,7 +4062,7 @@ static int iavf_handle_tclass(struct iavf_adapter *adapter, u32 tc,
> {
> if (tc == 0)
> return 0;
> - if (tc < adapter->num_tc) {
> + if (tc > adapter->num_tc) {
> if (!filter->f.data.tcp_spec.dst_port) {
> dev_err(&adapter->pdev->dev,
> "Specify destination port to redirect to traffic class other than TC0\n");
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH iwl-net 5/5] iavf: return 0 when TC flower filter not found after qdisc teardown
2026-04-13 7:30 [PATCH iwl-net 0/5] iavf: five correctness fixes Aleksandr Loktionov
` (3 preceding siblings ...)
2026-04-13 7:30 ` [PATCH iwl-net 4/5] iavf: fix TC boundary check in iavf_handle_tclass Aleksandr Loktionov
@ 2026-04-13 7:30 ` Aleksandr Loktionov
2026-04-15 13:53 ` Simon Horman
4 siblings, 1 reply; 12+ messages in thread
From: Aleksandr Loktionov @ 2026-04-13 7:30 UTC (permalink / raw)
To: intel-wired-lan, anthony.l.nguyen, aleksandr.loktionov
Cc: netdev, Kiran Patil
From: Kiran Patil <kiran.patil@intel.com>
When an egress qdisc is destroyed, the driver proactively deletes all
associated cloud filters to prevent stale hardware state, decrementing
num_cloud_filters to zero in the process.
The kernel netdev layer is unaware of this implicit cleanup and may
still try to delete the same filters individually. If the filter is
not found in the driver's list and num_cloud_filters is already zero,
return 0 instead of -EINVAL to avoid confusing upper layers that
believe the filter is still offloaded in hardware.
Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 5e4035b..05aaae9 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -4175,7 +4175,16 @@ static int iavf_delete_clsflower(struct iavf_adapter *adapter,
if (filter) {
filter->del = true;
adapter->aq_required |= IAVF_FLAG_AQ_DEL_CLOUD_FILTER;
- } else {
+ } else if (adapter->num_cloud_filters) {
+ /* When the egress qdisc is detached the driver implicitly
+ * deletes all associated cloud filters to prevent stale
+ * hardware entries, reducing num_cloud_filters to zero.
+ * The netdev layer is unaware of this implicit cleanup and
+ * may still request deletion of individual filters. Only
+ * return -EINVAL when a filter lookup fails and
+ * num_cloud_filters is non-zero, indicating a genuine
+ * lookup failure rather than a post-teardown stale delete.
+ */
err = -EINVAL;
}
spin_unlock_bh(&adapter->cloud_filter_list_lock);
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH iwl-net 5/5] iavf: return 0 when TC flower filter not found after qdisc teardown
2026-04-13 7:30 ` [PATCH iwl-net 5/5] iavf: return 0 when TC flower filter not found after qdisc teardown Aleksandr Loktionov
@ 2026-04-15 13:53 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2026-04-15 13:53 UTC (permalink / raw)
To: Aleksandr Loktionov
Cc: intel-wired-lan, anthony.l.nguyen, netdev, Kiran Patil
On Mon, Apr 13, 2026 at 09:30:35AM +0200, Aleksandr Loktionov wrote:
> From: Kiran Patil <kiran.patil@intel.com>
>
> When an egress qdisc is destroyed, the driver proactively deletes all
> associated cloud filters to prevent stale hardware state, decrementing
> num_cloud_filters to zero in the process.
>
> The kernel netdev layer is unaware of this implicit cleanup and may
> still try to delete the same filters individually. If the filter is
> not found in the driver's list and num_cloud_filters is already zero,
> return 0 instead of -EINVAL to avoid confusing upper layers that
> believe the filter is still offloaded in hardware.
>
> Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
> Signed-off-by: Kiran Patil <kiran.patil@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Sashiko has some comments on this function - which do not
seem related to the logic this patch touches.
I'd encourage you to take a look at some point as a follow-up activity.
...
^ permalink raw reply [flat|nested] 12+ messages in thread