Skip to contentSkip to conversation

iavf: fix VLAN filter lost on add/delete race

PATCH In review Petr Oros 3 participants 4 messages Feb 25 – Mar 11

Subsystems (3)
lore
Share & tools
lore

Petr Oros

author
#0 lore raw

PATCH 1/1 iavf: fix VLAN filter lost on add/delete race

When iavf_add_vlan() finds an existing filter in IAVF_VLAN_REMOVE state, it transitions the filter to IAVF_VLAN_ACTIVE assuming the pending delete can simply be cancelled. However, there is no guarantee that iavf_del_vlans() has not already processed the delete AQ request and removed the filter from the PF. In that case the filter remains in the driver's list as IAVF_VLAN_ACTIVE but is no longer programmed on the NIC. Since iavf_add_vlans() only picks up filters in IAVF_VLAN_ADD state, the filter is never re-added, and spoof checking drops all traffic for that VLAN.

  CPU0                       CPU1                     Workqueue
  ----                       ----                     ---------
  iavf_del_vlan(vlan 100)
    f->state = REMOVE
    schedule AQ_DEL_VLAN
                             iavf_add_vlan(vlan 100)
                               f->state = ACTIVE
                                                      iavf_del_vlans()
                                                        f is ACTIVE, skip
                                                      iavf_add_vlans()
                                                        f is ACTIVE, skip

Filter is ACTIVE in driver but absent from NIC.

Transition to IAVF_VLAN_ADD instead and schedule IAVF_FLAG_AQ_ADD_VLAN_FILTER so iavf_add_vlans() re-programs the filter. A duplicate add is idempotent on the PF.

Fixes 0c0da0e95105 ("iavf: refactor VLAN filter states")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +6 -3
index 4b0fc8f354bc90..6046b93c7f3472 100644
@@ -782,10 +782,13 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter,
 		adapter->num_vlan_filters++;
 		iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER);
 	} else if (f->state == IAVF_VLAN_REMOVE) {
-		/* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed.
-		 * We can safely only change the state here.
+		/* Re-add the filter since we cannot tell whether the
+		 * pending delete has already been processed by the PF.
+		 * A duplicate add is harmless.
 		 */
-		f->state = IAVF_VLAN_ACTIVE;
+		f->state = IAVF_VLAN_ADD;
+		iavf_schedule_aq_request(adapter,
+					 IAVF_FLAG_AQ_ADD_VLAN_FILTER);
 	}
 
 clearout:
Signature · 1 line
2.52.0
#1 lore raw
Quoted 23 lines · Petr Oros

When iavf_add_vlan() finds an existing filter in IAVF_VLAN_REMOVE state, it transitions the filter to IAVF_VLAN_ACTIVE assuming the pending delete can simply be cancelled. However, there is no guarantee that iavf_del_vlans() has not already processed the delete AQ request and removed the filter from the PF. In that case the filter remains in the driver's list as IAVF_VLAN_ACTIVE but is no longer programmed on the NIC. Since iavf_add_vlans() only picks up filters in IAVF_VLAN_ADD state, the filter is never re-added, and spoof checking drops all traffic for that VLAN.

  CPU0                       CPU1                     Workqueue
  ----                       ----                     ---------
  iavf_del_vlan(vlan 100)
    f->state = REMOVE
    schedule AQ_DEL_VLAN
                             iavf_add_vlan(vlan 100)
                               f->state = ACTIVE
                                                      iavf_del_vlans()
                                                        f is ACTIVE, skip
                                                      iavf_add_vlans()
                                                        f is ACTIVE, skip
Quoted 1 line

Filter is ACTIVE in driver but absent from NIC.

I don't get it. If, as the diagram shows, iavf_del_vlans() skipped it, then how does the filter become absent from NIC?

Michal

Quoted 35 lines

Transition to IAVF_VLAN_ADD instead and schedule IAVF_FLAG_AQ_ADD_VLAN_FILTER so iavf_add_vlans() re-programs the filter. A duplicate add is idempotent on the PF.

Fixes 0c0da0e95105 ("iavf: refactor VLAN filter states")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +6 -4
index 4b0fc8f354bc90..6046b93c7f3472 100644
@@ -782,10 +782,13 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter,
                adapter->num_vlan_filters++;
                iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER);
        } else if (f->state == IAVF_VLAN_REMOVE) {
-               /* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed.
-                * We can safely only change the state here.
+               /* Re-add the filter since we cannot tell whether the
+                * pending delete has already been processed by the PF.
+                * A duplicate add is harmless.
                 */
-               f->state = IAVF_VLAN_ACTIVE;
+               f->state = IAVF_VLAN_ADD;
+               iavf_schedule_aq_request(adapter,
+                                        IAVF_FLAG_AQ_ADD_VLAN_FILTER);
        }
 
 clearout:
--

2.52.0

author
#2 lore raw
Quoted 23 lines · Michal Schmidt
Quoted 22 lines · Petr Oros

When iavf_add_vlan() finds an existing filter in IAVF_VLAN_REMOVE state, it transitions the filter to IAVF_VLAN_ACTIVE assuming the pending delete can simply be cancelled. However, there is no guarantee that iavf_del_vlans() has not already processed the delete AQ request and removed the filter from the PF. In that case the filter remains in the driver's list as IAVF_VLAN_ACTIVE but is no longer programmed on the NIC. Since iavf_add_vlans() only picks up filters in IAVF_VLAN_ADD state, the filter is never re-added, and spoof checking drops all traffic for that VLAN.

   CPU0                       CPU1                     Workqueue
   ----                       ----                     ---------
   iavf_del_vlan(vlan 100)
     f->state = REMOVE
     schedule AQ_DEL_VLAN
                              iavf_add_vlan(vlan 100)
                                f->state = ACTIVE
                                                       iavf_del_vlans()
                                                         f is ACTIVE, skip
                                                       iavf_add_vlans()
                                                         f is ACTIVE, skip
Quoted 3 lines
Quoted 1 line

Filter is ACTIVE in driver but absent from NIC.

I don't get it. If, as the diagram shows, iavf_del_vlans() skipped it, then how does the filter become absent from NIC?

VLAN teardown            Workqueue           VLAN setup
-------------            ---------           ----------

iavf_del_vlan(100)
f->state = REMOVE
schedule AQ_DEL_VLAN
iavf_open()
restore_filters()
f is REMOVE, skip
iavf_add_vlan(100)
f->state = ACTIVE

iavf_del_vlans()
f is ACTIVE, skip
iavf_add_vlans()
f is ACTIVE, skip

Is it clear like this?

Quoted 37 lines

Michal

Quoted 35 lines

Transition to IAVF_VLAN_ADD instead and schedule IAVF_FLAG_AQ_ADD_VLAN_FILTER so iavf_add_vlans() re-programs the filter. A duplicate add is idempotent on the PF.

Fixes 0c0da0e95105 ("iavf: refactor VLAN filter states")
---
  drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +6 -4
index 4b0fc8f354bc90..6046b93c7f3472 100644
@@ -782,10 +782,13 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter,
                 adapter->num_vlan_filters++;
                 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER);
         } else if (f->state == IAVF_VLAN_REMOVE) {
-               /* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed.
-                * We can safely only change the state here.
+               /* Re-add the filter since we cannot tell whether the
+                * pending delete has already been processed by the PF.
+                * A duplicate add is harmless.
                  */
-               f->state = IAVF_VLAN_ACTIVE;
+               f->state = IAVF_VLAN_ADD;
+               iavf_schedule_aq_request(adapter,
+                                        IAVF_FLAG_AQ_ADD_VLAN_FILTER);
         }
 
  clearout:
--

2.52.0

#3 lore raw
Quoted 83 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Petr Oros
Sent: Wednesday, February 25, 2026 3:57 PM
To: Schmidt, Michal <[email protected]>
Cc: [email protected]; Kitszel, Przemyslaw <[email protected]>; Eric Dumazet <[email protected]>; Ahmed Zaki <[email protected]>; Andrew Lunn <[email protected]>; Nguyen, Anthony L <[email protected]>; intel-wired- [email protected]; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; David S. Miller <[email protected]>; linux- [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] iavf: fix VLAN filter lost on add/delete race

Quoted 24 lines · Michal Schmidt
Quoted 23 lines · Petr Oros

When iavf_add_vlan() finds an existing filter in IAVF_VLAN_REMOVE state, it transitions the filter to IAVF_VLAN_ACTIVE assuming the pending delete can simply be cancelled. However, there is no guarantee that iavf_del_vlans() has not already processed the delete AQ request and removed the filter from the PF. In that case the filter remains in the driver's list as IAVF_VLAN_ACTIVE but is no longer programmed on the NIC. Since iavf_add_vlans() only picks up filters in IAVF_VLAN_ADD state, the filter is never re-added, and spoof checking drops all traffic for that VLAN.

   CPU0                       CPU1                     Workqueue
   ----                       ----                     ---------
   iavf_del_vlan(vlan 100)
     f->state = REMOVE
     schedule AQ_DEL_VLAN
                              iavf_add_vlan(vlan 100)
                                f->state = ACTIVE
                                                       iavf_del_vlans()
                                                         f is ACTIVE, skip
                                                       iavf_add_vlans()
                                                         f is ACTIVE,

skip

Quoted 3 lines
Quoted 1 line

Filter is ACTIVE in driver but absent from NIC.

I don't get it. If, as the diagram shows, iavf_del_vlans() skipped it, then how does the filter become absent from NIC?

VLAN teardown            Workqueue           VLAN setup
-------------            ---------           ----------

iavf_del_vlan(100)
f->state = REMOVE
schedule AQ_DEL_VLAN
iavf_open()
restore_filters()
f is REMOVE, skip
iavf_add_vlan(100)
f->state = ACTIVE

iavf_del_vlans()
f is ACTIVE, skip
iavf_add_vlans()
f is ACTIVE, skip

Is it clear like this?

Quoted 13 lines

Michal

Quoted 11 lines

Transition to IAVF_VLAN_ADD instead and schedule IAVF_FLAG_AQ_ADD_VLAN_FILTER so iavf_add_vlans() re-programs the filter. A duplicate add is idempotent on the PF.

Fixes 0c0da0e95105 ("iavf: refactor VLAN filter states")
---
  drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
Quoted 6 lines

drivers/net/ethernet/intel/iavf/iavf_main.c iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter

Quoted 6 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
index 4b0fc8f354bc90..6046b93c7f3472 100644
@@ -782,10 +782,13 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter

*adapter,

Quoted 20 lines
Quoted 2 lines

drivers/net/ethernet/intel/iavf/iavf_main.c iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter · line 783

Quoted 2 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
                 adapter->num_vlan_filters++;
                 iavf_schedule_aq_request(adapter,

IAVF_FLAG_AQ_ADD_VLAN_FILTER);

Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -4
         } else if (f->state == IAVF_VLAN_REMOVE) {
-               /* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed.
-                * We can safely only change the state here.
+               /* Re-add the filter since we cannot tell whether the
+                * pending delete has already been processed by the PF.
+                * A duplicate add is harmless.
                  */
-               f->state = IAVF_VLAN_ACTIVE;
+               f->state = IAVF_VLAN_ADD;
+               iavf_schedule_aq_request(adapter,
+
+ IAVF_FLAG_AQ_ADD_VLAN_FILTER);
         }
 
  clearout:
--

2.52.0