ice: fix DFLT Rx rule handling for promisc and switchdev
Subsystems (3)
v5 cover ice: fix DFLT Rx rule handling for promisc and switchdev
Fixes for the promiscuous and allmulticast handling of the ice PF VSI, and two fixes for the teardown paths they rely on.
Patch 1 stops the service task in ice_remove() before the PF is torn down, where it was stopped before commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths"). Patch 3 queues a filter sync when a switchdev session ends, and a session that still runs when the driver is removed ends in ice_remove().
Patch 2 refuses to leave switchdev mode while subfunction ports exist. Leaving it then orphans the session, and patch 3 resyncs the uplink only when a session ends.
Patch 3 lets the eswitch own the promiscuous configuration of the uplink while a switchdev session runs and resyncs the uplink filters from the netdev flags when the session ends, so the uplink no longer ends a session without its catch-all Rx rule or with a stale promisc state.
Patch 4 subscribes PF VSIs to multicast with one VLAN agnostic promisc rule pair instead of a pair per VID, so a wide VLAN trunk on several bridge ports no longer exhausts the switch lookup table. A port with a vid 2-4094 trunk goes from 12292 to 4104 FLU entries.
v1 to v4 were posted to iwl-net, and v4 went into the iwl pull request of 2026-11-13, where the Sashiko review found real problems in both patches [1][2]. This version reworks both and replaces v4. It is posted directly to net, with intel-wired-lan in Cc, as discussed in the thread on that pull request [3].
The final v5 also differs from what I described in my replies to that review. Patch 4 no longer keeps per-VID rules for any PF VSI, so the per-VID re-add, the rollback and the vid 0 recipe swap handling I described there are gone, and ice_clear_promisc() clears only the VLAN agnostic pair. Instead of skipping the allmulti branch for a promiscuous VSI, the subscription is reconciled from both flags in one place, and with patch 4 the resync of patch 3 no longer drops the multicast rules or clears IFF_ALLMULTI. In patch 3 a new VSI state bit keeps every filter sync away from the uplink promisc configuration while a session runs, and patch 1 makes sure that the sync queued at the end of a session cannot use a freed netdev when the PF goes away.
"ice: restore DDP state during PFR recovery", which Tony sent to net in the pull request of 2026-11-25 [4], also stops the service task in ice_remove(), but before ice_free_vfs(). Patch 1 keeps the place after ice_free_vfs() that commit f844d5212cb0 ("ice: Fix removing driver while bare-metal VFs pass traffic") chose, so that VF drivers in the host still get answers from the PF while they are removed. The two apply together without a conflict, and ice_remove() then stops the service task both before and after ice_free_vfs(), so one of the two calls should go.
Patch 4 builds on the ice_vsi_sync_fltr() changes of patch 3, which needs the switchdev code from v6.10, so 6.6 and 6.1 need manual backports of patches 3 and 4. The loss of the uplink VLAN filters across a switchdev session that patch 3 mentions is older than this series, and with patch 3 it also shows after a promiscuous session. I will send a fix for it separately.
Changes since v4:
- Posted to net directly instead of iwl-net.
- New patches 1 and 2, found while reworking the switchdev fix.
- Patch order swapped, the switchdev fix goes before the multicast one.
- Patch 3, previously "ice: preserve uplink DFLT Rx rule on switchdev release", reworked as described above.
- Patch 4, previously "ice: skip per-VLAN promisc rules when default VSI Rx rule is set", reworked as described above. It now also keeps the multicast subscription of a promiscuous VSI when allmulti is cleared, unless another VSI holds the DFLT rule.
- Dropped the Reviewed-by and Tested-by tags of v4, both patches changed too much to keep them.
- All commit messages say how the problems were found and how the fixes were tested.
Link to v4:
https://lore.kernel.org/all/[email protected]/
Link to v3:
https://lore.kernel.org/all/[email protected]/
Link to v2:
https://lore.kernel.org/all/[email protected]/
Link to v1:
https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
Petr Oros (4):
ice: stop the service task before the PF is unloaded
ice: do not leave switchdev mode while representors exist
ice: resync uplink filters after a switchdev session
ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 39 ++++ drivers/net/ethernet/intel/ice/ice_main.c | 233 +++++++------------ 3 files changed, 124 insertions(+), 149 deletions(-)
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
Signature · 1 line
2.56.1
PATCH v5 1/4 ice: stop the service task before the PF is unloaded
Commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") moved the service task stop and the cancel of the AdminQ event waiters from after ice_free_vfs() to the end of ice_remove(). Since then a queued or running service task can still walk pf->vsi[] while ice_remove_arfs(), ice_unload() and ice_deinit() free the aRFS filters, the netdev, the LAG and the VSIs. A last run that takes longer than a timer period also arms the service timer again after the stop at the end has deleted it, and the timer then fires after the PF is freed.
Stop the service task and cancel the waiters after ice_free_vfs() again. The stop in ice_deinit_dev() stays and deletes a timer armed by the last run. As before that commit, a devlink flash that is still running when the driver is removed fails, at the latest when its next AdminQ wait times out.
Found by AI code review. Validated on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) with a test-only 12 s delay in ice_sync_fltr_subtask() after it took the VSI pointer, armed right before a promisc change and rmmod ice. Without this patch KASAN reports a slab-use-after-free in ice_vsi_fltr_changed() on the freed main VSI, and the kernel then faults in call_timer_fn() on the timer function of the unloaded module. With it rmmod waits for the run and nothing is reported. Also tested by removing the driver during switchdev sessions and with four VFs bound to iavf. No kernel selftests cover this.
---
v5:
- New patch. The uplink resync in patch 3 queues a filter sync when a switchdev session ends, and a session that still runs when the driver is removed ends in ice_remove().
--- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +3 -1
@@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)ice_free_vfs (pf); } +ice_service_task_stop (pf); +ice_aq_cancel_waiting_tasks (pf); +if (!ice_is_safe_mode (pf))ice_remove_arfs (pf);
@@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)ice_deinit_hw (&pf->hw);ice_deinit_dev (pf); -ice_aq_cancel_waiting_tasks (pf);set_bit (ICE_DOWN , pf->state); }
Signature · 1 line
2.56.1
Re: [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded
Quoted 51 lines · Petr Oros
Commit
8a37f9e2ff40("ice: moveice_deinit_dev()to the end of deinit paths") moved the service task stop and the cancel of the AdminQ event waiters from afterice_free_vfs()to the end ofice_remove(). Since then a queued or running service task can still walk pf->vsi[] whileice_remove_arfs(),ice_unload()andice_deinit()free the aRFS filters, the netdev, the LAG and the VSIs. A last run that takes longer than a timer period also arms the service timer again after the stop at the end has deleted it, and the timer then fires after the PF is freed.Stop the service task and cancel the waiters after
ice_free_vfs()again. The stop inice_deinit_dev()stays and deletes a timer armed by the last run. As before that commit, a devlink flash that is still running when the driver is removed fails, at the latest when its next AdminQ wait times out.Found by AI code review. Validated on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) with a test-only 12 s delay in
ice_sync_fltr_subtask()after it took the VSI pointer, armed right before a promisc change and rmmod ice. Without this patch KASAN reports a slab-use-after-free inice_vsi_fltr_changed()on the freed main VSI, and the kernel then faults incall_timer_fn()on the timer function of the unloaded module. With it rmmod waits for the run and nothing is reported. Also tested by removing the driver during switchdev sessions and with four VFs bound to iavf. No kernel selftests cover this.Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")Signed-off-by Petr Oros <[email protected]>---
v5:
- New patch. The uplink resync in patch 3 queues a filter sync when a switchdev session ends, and a session that still runs when the driver is removed ends inice_remove().--- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_main.c +3
-0@@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)ice_free_vfs (pf); } +ice_service_task_stop (pf); +ice_aq_cancel_waiting_tasks (pf); +if (!ice_is_safe_mode (pf))ice_remove_arfs (pf);
drivers/net/ethernet/intel/ice/ice_main.c static void ice_remove(struct pci_dev *pdev) · line 5415
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-1@@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)ice_deinit_hw (&pf->hw);ice_deinit_dev (pf); -ice_aq_cancel_waiting_tasks (pf);set_bit (ICE_DOWN , pf->state); }
Re: [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded
In reply to Petr OrosQuoted 41 lines · Petr Oros
Commit
8a37f9e2ff40("ice: moveice_deinit_dev()to the end of deinit paths") moved the service task stop and the cancel of the AdminQ event waiters from afterice_free_vfs()to the end ofice_remove(). Since then a queued or running service task can still walk pf->vsi[] whileice_remove_arfs(),ice_unload()andice_deinit()free the aRFS filters, the netdev, the LAG and the VSIs. A last run that takes longer than a timer period also arms the service timer again after the stop at the end has deleted it, and the timer then fires after the PF is freed.Stop the service task and cancel the waiters after
ice_free_vfs()again. The stop inice_deinit_dev()stays and deletes a timer armed by the last run. As before that commit, a devlink flash that is still running when the driver is removed fails, at the latest when its next AdminQ wait times out.Found by AI code review. Validated on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) with a test-only 12 s delay in
ice_sync_fltr_subtask()after it took the VSI pointer, armed right before a promisc change and rmmod ice. Without this patch KASAN reports a slab-use-after-free inice_vsi_fltr_changed()on the freed main VSI, and the kernel then faults incall_timer_fn()on the timer function of the unloaded module. With it rmmod waits for the run and nothing is reported. Also tested by removing the driver during switchdev sessions and with four VFs bound to iavf. No kernel selftests cover this.Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")Signed-off-by Petr Oros <[email protected]>---
v5:
- New patch. The uplink resync in patch 3 queues a filter sync when a switchdev session ends, and a session that still runs when the driver is removed ends inice_remove().--- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0
drivers/net/ethernet/intel/ice/ice_main.c static void ice_remove(struct pci_dev *pdev) · line 5392
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_main.c +3
-0@@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)ice_free_vfs (pf); } +ice_service_task_stop (pf); +ice_aq_cancel_waiting_tasks (pf); +
makes sense, thank you!
(would be fine for me to pick this particular patch directly to netdev too, have not read the rest of the series through)
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-1if (!ice_is_safe_mode (pf))ice_remove_arfs (pf);@@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)ice_deinit_hw (&pf->hw);ice_deinit_dev (pf); -ice_aq_cancel_waiting_tasks (pf);set_bit (ICE_DOWN , pf->state); }
[email protected]
AI reviewRe: [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded
In reply to Petr OrosThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 2 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] The patch moves the early ice_service_task_stop() only in ice_remove().
- [High] The patch handles the "last run re-arms the service timer after the stop, and the timer fires after the PF is freed" race only in the…
- [Medium] The early ice_service_task_stop() in ice_remove() (ice_main.c:5390) does not stop the service work from being queued…
--
ice: stop the service task before the PF is unloaded
This patch moves ice_service_task_stop() and ice_aq_cancel_waiting_tasks() in ice_remove() back to right after ice_free_vfs(). The service task is then stopped before the aRFS filters, netdev, LAG and VSIs are freed. The stop in ice_deinit_dev() is kept so that it deletes a timer re-armed by the last run.
drivers/net/ethernet/intel/ice/ice_main.c static void ice_remove(struct pci_dev *pdev) · line 5392
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_main.c +3
-0@@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)ice_free_vfs (pf); } +ice_service_task_stop (pf); +ice_aq_cancel_waiting_tasks (pf); +
[Severity: High]
The same ordering problem seems to remain on the other paths that unload the PF. ice_devlink_reinit_down() in devlink/devlink.c does:
ice_unload(pf); rtnl_lock(); ice_vsi_decfg(ice_get_main_vsi(pf)); rtnl_unlock(); ice_deinit_pf(pf); ice_deinit_hw(&pf->hw); ice_deinit_dev(pf);
Nothing sets ICE_SERVICE_DIS before ice_deinit_dev(), so the service timer keeps queueing serv_task during this whole sequence:
- ice_unload()->ice_decfg_netdev() calls free_netdev(vsi->netdev).
- ice_deinit_pf() destroys sw_mutex, tc_mutex and lag_mutex, frees the avail_txqs/avail_rxqs bitmaps and frees the misc IRQ.
- ice_deinit_hw() destroys the control queues.
Can a run of ice_sync_fltr_subtask()->ice_vsi_sync_fltr() that has already read vsi->netdev keep using netdev->flags and netif_addr_lock_bh(netdev) after free_netdev()?
A devlink dev reload with action driver_reinit can trigger this while a filter sync is pending, for example after a promisc or multicast change through ice_set_rx_mode().
The probe error unwind in ice_probe() looks similar:
unroll_load:
ice_unload(pf); unroll_init: devl_unlock(priv_to_devlink(pf)); ice_deinit(pf); [ ... ] unroll_hw_init: ice_deinit_hw(hw); if (need_dev_deinit) ice_deinit_dev(pf);
When this unwind runs, ice_init() has already cleared ICE_SERVICE_DIS and armed serv_tmr. ice_load() has also queued serv_task through ice_service_task_restart().
ice_deinit() only sets ICE_SERVICE_DIS, which does not wait for a running work item, and then ice_dealloc_vsis() frees pf->vsi. After that come ice_adapter_put() and ice_deinit_hw(), and only then the stop in ice_deinit_dev().
Commit 8a37f9e2ff40, named in the Fixes: tag, is also the commit that moved ice_deinit_dev() after ice_deinit_hw() in this unwind. Should ice_devlink_reinit_down() and the probe unwind also stop the service task before they tear down the PF? Neither path seems to change later in the series.
[Severity: Medium]
Does a single ice_service_task_stop() here prevent serv_task from being queued again before ice_remove_arfs(), ice_unload() and ice_deinit() run?
ice_service_task_schedule() tests ICE_SERVICE_DIS without a lock and only calls queue_work() afterwards:
if (!test_bit(ICE_SERVICE_DIS, pf->state) && !test_and_set_bit(ICE_SERVICE_SCHED, pf->state) && !test_bit(ICE_NEEDS_RESTART, pf->state)) queue_work(ice_wq, &pf->serv_task);
Also, ice_service_task() does not check ICE_SERVICE_DIS when it starts.
At this point the netdev is still registered and the misc IRQ is still live. That means ice_set_rx_mode(), ice_rx_flow_steer(), ice_misc_intr() and the VF fdir handlers can all still reach ice_service_task_schedule().
One possible interleaving:
CPU0 (ice_set_rx_mode) CPU1 (ice_remove)
set ICE_FLAG_FLTR_SYNCtest_bit(ICE_SERVICE_DIS) == 0
ice_service_task_stop()
test_and_set_bit(ICE_SERVICE_DIS)
timer_delete_sync()
cancel_work_sync() /* idle */
clear_bit(ICE_SERVICE_SCHED)
queue_work(ice_wq, &pf->serv_task)
ice_remove_arfs()
ice_unload() /* free_netdev() */
ice_deinit() /* ice_dealloc_vsis() */The worker would then run ice_sync_fltr_subtask(), ice_sync_arfs_fltrs() and the other subtasks against the state being freed. The second stop in ice_deinit_dev() only runs after the VSIs are already gone.
The window is only a few instructions wide. Would a check of ICE_SERVICE_DIS at the start of ice_service_task(), or quiescing these scheduling sources first, be needed to close it?
drivers/net/ethernet/intel/ice/ice_main.c static void ice_remove(struct pci_dev *pdev) · line 5414
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-1if (!ice_is_safe_mode (pf))ice_remove_arfs (pf);@@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)ice_deinit_hw (&pf->hw);ice_deinit_dev (pf); -ice_aq_cancel_waiting_tasks (pf);set_bit (ICE_DOWN , pf->state); }
[Severity: High]
The commit message says the stop in ice_deinit_dev() "stays and deletes a timer armed by the last run". The ordering inside ice_service_task_stop() has not changed, though:
ret = test_and_set_bit(ICE_SERVICE_DIS, pf->state); if (pf->serv_tmr.function) timer_delete_sync(&pf->serv_tmr); if (pf->serv_task.func) cancel_work_sync(&pf->serv_task);
A work item that is running during the stop can re-arm the timer after timer_delete_sync():
- ice_service_task() calls mod_timer(&pf->serv_tmr, jiffies) at its tail when a run was long or an *_EVENT_PENDING bit is set.
- ice_service_task_recovery_mode() always calls
mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100)).
Once that happens, ice_service_timer() keeps re-arming itself.
Some paths still stop only once. The first is the recovery-mode branch of ice_remove():
if (ice_is_recovery_mode(&pf->hw)) {
ice_service_task_stop(pf);
scoped_guard(devl, priv_to_devlink(pf)) {
ice_deinit_devlink(pf);
}
return;
}After this, devres frees the PF (the devlink priv), and the recovery-mode work re-arms every 100ms. Can serv_tmr then fire on freed memory, or, after rmmod, on unloaded module text?
The probe error unwind also calls ice_deinit_dev() only once before devres frees the PF.
In ice_devlink_reinit_down(), the single stop in ice_deinit_dev() is followed by ice_devlink_reinit_up()->ice_init_dev()-> ice_start_service_task(). That calls timer_setup(&pf->serv_tmr, ...) on a timer that may still be enqueued. Could this corrupt the timer wheel list once mod_timer() enqueues it again?
Would it be better to fix this inside ice_service_task_stop()? One option is a second timer_delete_sync() after cancel_work_sync(). Another is to skip the tail mod_timer() calls when ICE_SERVICE_DIS is set. Either would avoid relying on a double stop at the call site.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com
PATCH v5 2/4 ice: do not leave switchdev mode while representors exist
In reply to Petr Orosice_eswitch_mode_set() refuses a mode change only while VFs exist, but a subfunction port has a representor and a switchdev session too. devlink core usually refuses the change first, because of the devlink rate nodes the representors export, but ice exports none while DCB is active. A switch to legacy then destroys the representor xarray under the running session, the representors leak, and the uplink stays in its switchdev configuration.
Refuse the mode change while the representor xarray is not empty.
Found by AI code review. Reproduced on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) with the firmware LLDP agent off, without kernel changes:
dcb ets set dev $PF tc-tsa all:ets tc-bw 0:50 1:50 prio-tc 1:1 devlink dev eswitch set pci/$BDF mode switchdev devlink port add pci/$BDF flavour pcisf pfnum 0 sfnum 88 devlink dev eswitch set pci/$BDF mode legacy
The last command succeeded, the representor netdev stayed registered and promisc off no longer took effect on the PF. With this patch the command fails with "Remove all subfunction ports before changing eswitch mode". No kernel selftests cover this.
---
v5:
- New patch. Without it a switch to legacy can orphan a switchdev session, and patch 3 resyncs the uplink only when a session ends.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/intel/ice/ice_eswitch.c +7 -0
@@ -354,6 +354,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,return -EOPNOTSUPP ; } +/* subfunction ports have representors too */ +if (!xa_empty (&pf->eswitch.reprs)) { +NL_SET_ERR_MSG_MOD (extack, +"Remove all subfunction ports before changing eswitch mode" ); +return -EOPNOTSUPP ; + } +switch (mode) {case DEVLINK_ESWITCH_MODE_LEGACY : dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
Signature · 1 line
2.56.1
Re: [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist
Quoted 42 lines · Petr Oros
ice_eswitch_mode_set()refuses a mode change only while VFs exist, but a subfunction port has a representor and a switchdev session too. devlink core usually refuses the change first, because of the devlink rate nodes the representors export, but ice exports none while DCB is active. A switch to legacy then destroys the representor xarray under the running session, the representors leak, and the uplink stays in its switchdev configuration.Refuse the mode change while the representor xarray is not empty.
Found by AI code review. Reproduced on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) with the firmware LLDP agent off, without kernel changes:
dcb ets set dev $PF tc-tsa all:ets tc-bw 0:50 1:50 prio-tc 1:1 devlink dev eswitch set pci/$BDF mode switchdev devlink port add pci/$BDF flavour pcisf pfnum 0 sfnum 88 devlink dev eswitch set pci/$BDF mode legacy
The last command succeeded, the representor netdev stayed registered and promisc off no longer took effect on the PF. With this patch the command fails with "Remove all subfunction ports before changing eswitch mode". No kernel selftests cover this.
Fixes 977514fb0fa8 ("ice: create port representor for SF")Signed-off-by Petr Oros <[email protected]>---
v5:
- New patch. Without it a switch to legacy can orphan a switchdev session, and patch 3 resyncs the uplink only when a session ends.--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-0@@ -354,6 +354,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,return -EOPNOTSUPP ; }
drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 366
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +7
-0+/* subfunction ports have representors too */ +if (!xa_empty (&pf->eswitch.reprs)) { +NL_SET_ERR_MSG_MOD (extack, +"Remove all subfunction ports before changing eswitch mode" ); +return -EOPNOTSUPP ; + } +switch (mode) {case DEVLINK_ESWITCH_MODE_LEGACY : dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
[email protected]
AI reviewRe: [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist
In reply to Petr OrosThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The new xa_empty(&pf->eswitch.reprs) check in ice_eswitch_mode_set() is protected only by the PF devlink lock, which…
- [Low] The commit message understates what this patch fixes.
- [Low] In ice_eswitch_mode_set(), the new !xa_empty(&pf->eswitch.reprs) check (ice_eswitch.c:358) runs before…
- [Low] The new gate checks whether pf->eswitch.reprs is empty, not whether SF ports exist.
--
ice: do not leave switchdev mode while representors exist
This patch makes ice_eswitch_mode_set() refuse an eswitch mode change while the representor xarray is not empty. Before the patch, switching to legacy mode with DCB active could destroy the xarray under a running switchdev session that still had a subfunction port representor.
Quoted 4 lines
the representors export, but ice exports none while DCB is active. A switch to legacy then destroys the representor xarray under the running session, the representors leak, and the uplink stays in its switchdev configuration.
[Severity: Low]
Does "the representors leak" describe the whole consequence? Before this patch, the later SF port deletion looks like it ends in a use-after-free of dyn_port.
Once the switch to legacy has run xa_destroy(&pf->eswitch.reprs), a devlink port del on the SF port goes through ice_devlink_port_del()->ice_dealloc_dynamic_port(), which calls:
drivers/net/ethernet/intel/ice/ice_eswitch.c:ice_eswitch_detach_sf() {
struct ice_repr *repr = xa_load(&pf->eswitch.reprs, sf->repr_id);
if (!repr)
return;
...
}So ice_repr_rem_sf() never runs. That means neither unregister_netdev(repr->netdev) nor ice_devlink_destroy_sf_port()->devl_port_unregister() is called. ice_dealloc_dynamic_port() then does:
ice_eswitch_detach_sf(pf, dyn_port); xa_erase(&pf->dyn_ports, dyn_port->vsi->idx); ice_vsi_free(dyn_port->vsi); kfree(dyn_port);
The embedded dyn_port->devlink_port is still registered in devlink->ports. The representor netdev is also still registered, and it keeps pointers into the freed dyn_port: repr->sf, and the devlink port set through SET_NETDEV_DEVLINK_PORT(). Driver removal takes the same path through ice_remove()->ice_dealloc_all_dynamic_ports().
The code change closes this path. Could the commit message mention the use-after-free, so stable and CVE triage can weigh the fix correctly?
drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 358
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2
-0@@ -354,6 +354,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,return -EOPNOTSUPP ; } +/* subfunction ports have representors too */ +if (!xa_empty (&pf->eswitch.reprs)) {
[Severity: Medium]
Is the result of xa_empty(&pf->eswitch.reprs) stable under the lock held here? devlink core holds only the PF devlink lock around ice_eswitch_mode_set(). However, ice_eswitch_update_repr() changes the same xarray from ice_sf_dev_probe(), and that path holds only the SF's own devlink lock:
drivers/net/ethernet/intel/ice/ice_sf_eth.c:ice_sf_dev_probe() {
...
devlink = priv_to_devlink(priv);
devl_lock(devlink);
err = ice_vsi_cfg(vsi);
...
ice_eswitch_update_repr(&dyn_port->repr_id, vsi);
...
}drivers/net/ethernet/intel/ice/ice_eswitch.c:ice_eswitch_update_repr() {
...
if (repr->id != vsi->vsi_num) {
xa_erase(&pf->eswitch.reprs, repr->id);
repr->id = vsi->vsi_num;
if (xa_insert(&pf->eswitch.reprs, repr->id, repr, GFP_KERNEL))
...
}ice_sf_dev_remove() does not delete the hardware VSI. So if the ice.sf.N auxiliary device is unbound and then rebound through sysfs, ice_vsi_cfg() runs with ICE_VSI_FLAG_INIT and allocates a new VSI number. That takes the erase/insert branch above.
With a single SF representor and no VFs, can a concurrent eswitch mode change see the xarray empty between the erase and the insert?
CPU1 (SF rebind, SF devlink lock only)ice_eswitch_update_repr()
xa_erase(&pf->eswitch.reprs, old_id);
CPU2 (PF devlink lock held) ice_eswitch_mode_set(LEGACY)
!xa_empty(&pf->eswitch.reprs) is false, check passes xa_destroy(&pf->eswitch.reprs); pf->eswitch_mode = mode;
CPU1
xa_insert(&pf->eswitch.reprs, new_id, repr, GFP_KERNEL);
The result is legacy mode with a live SF representor, and pf->eswitch.is_running stays true because ice_eswitch_disable_switchdev() is never called. The uplink keeps its switchdev configuration until the SF port is deleted. This same check then refuses a switch back to switchdev.
Would checking pf->dyn_ports instead close this? Its writers, ice_alloc_dynamic_port() and ice_dealloc_dynamic_port(), run under the PF devlink lock, so they would be serialized with mode_set.
[Severity: Low]
A related case: if that xa_insert() fails, ice_eswitch_update_repr() only logs an error:
if (xa_insert(&pf->eswitch.reprs, repr->id, repr, GFP_KERNEL)) dev_err(ice_pf_to_dev(pf), "Failed to reload port representor %d", repr->id);
If that was the only SF representor, pf->eswitch.reprs is now empty. The SF devlink port is still in pf->dyn_ports, and pf->eswitch.is_running is still true.
Would ice_eswitch_mode_set(LEGACY) then pass both ice_has_vfs() and the new xa_empty() check? If so, it would run xa_destroy() and switch to legacy without calling ice_eswitch_disable_switchdev(), leaving the same orphaned session this patch is meant to prevent.
The dropped-entry handling in ice_eswitch_update_repr() predates this patch, but a check on pf->dyn_ports would also cover this case.
drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 364
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +5
-0+NL_SET_ERR_MSG_MOD (extack, +"Remove all subfunction ports before changing eswitch mode" ); +return -EOPNOTSUPP ; + } +switch (mode) {
[Severity: Low]
Should the requested mode be validated before the representor check? The devlink policy accepts DEVLINK_ATTR_ESWITCH_MODE values up to 2 (NLA_POLICY_MAX(NLA_U16, 2) in net/devlink/netlink_gen.c). So DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE reaches the driver, and ice rejects it only in the default branch:
default: NL_SET_ERR_MSG_MOD(extack, "Unknown eswitch mode"); return -EINVAL;
With the PF in switchdev mode and an SF port present, a switchdev_inactive request now fails with -EOPNOTSUPP and "Remove all subfunction ports before changing eswitch mode". If the SF ports are removed as the message says, the retry still fails, this time with -EINVAL.
The existing ice_has_vfs() check has the same ordering, but this patch adds a new path that reports the wrong reason. Would it be better to validate the mode first, or to apply the representor check only to supported transitions?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com
PATCH v5 3/4 ice: resync uplink filters after a switchdev session
In reply to Petr OrosA switchdev session leaves the uplink filters out of sync with its netdev. ice_eswitch_setup_env() removes the multicast promisc rules and the address filters, and ice_eswitch_release_env() removes the default VSI (DFLT) Rx rule that a promiscuous uplink needs. ice_set_rx_mode() ignores the uplink during the session and nothing syncs it when the session ends, so these are not installed again, and flag changes made meanwhile are lost.
Let the eswitch own the uplink promisc configuration during a session. While the new ICE_VSI_ESWITCH_UPLINK bit is set, ice_vsi_sync_fltr() leaves it alone. When the session ends, after is_running is cleared, ice_eswitch_resync_uplink() clears the bit and queues a full filter sync, which programs the uplink from the netdev flags. Also subscribe a promiscuous VSI to multicast when it already holds the DFLT rule, and enable VLAN pruning on every promisc off, because it can be off without our DFLT rule after a session or with LAG.
This does not restore the uplink VLAN filters that ice_eswitch_setup_env() removes, a separate problem that now also shows when promisc is cleared after a promiscuous session.
Found by AI code review, starting with the Sashiko review of v4, and reproduced on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without kernel changes:
ip link set $PF promisc on
devlink dev eswitch set pci/$BDF mode switchdev
echo 1 > /sys/class/net/$PF/device/sriov_numvfs
echo 0 > /sys/class/net/$PF/device/sriov_numvfs
after which unknown unicast no longer reaches the PF, and with this patch it does again. Also tested on that E810-C with promisc changed before, during and after sessions, allmulti across a session, and PF resets and driver removal during sessions. LAG and switchdev setup errors were not tested. No kernel selftests cover this.
---
v5:
- Reworked after the Sashiko review of the v4 pull. Instead of keeping the Rx DFLT rule on release, the eswitch now owns the uplink promisc configuration during a session, and the uplink filters are resynced from the netdev flags when the session ends.
- A new VSI state bit keeps filter syncs away from the uplink promisc configuration during a session. The sync queued at the end of a session relies on patch 1 when the PF goes away.
- A promiscuous VSI that already holds the DFLT rule is subscribed to multicast, and VLAN pruning is re-enabled on every promisc off.
- New title, was "ice: preserve uplink DFLT Rx rule on switchdev release". Moved before the multicast patch.
- Added Fixes tags for 1a1c40df2e80, 2571a3fa6251 and 776fe19953b0.
- Dropped the Reviewed-by and Tested-by tags because of the rework.
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/deef5756e534ef06c12d910c5305d3fd205d30a0.1781786935.git.poros@redhat.com/
--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 40 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 17 +++++++-- 3 files changed, 55 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -321,6 +321,7 @@ enum ice_vsi_state {ICE_VSI_MMAC_FLTR_CHANGED ,ICE_VSI_PROMISC_CHANGED ,ICE_VSI_REBUILD_PENDING , +ICE_VSI_ESWITCH_UPLINK ,/* eswitch owns the promisc config */ ICE_VSI_STATE_NBITS /* must be last */ };
drivers/net/ethernet/intel/ice/ice_eswitch.c +40 -0
@@ -10,6 +10,34 @@#include "devlink/devlink.h" #include "ice_tc_lib.h" +/** +* ice_eswitch_resync_uplink - hand the uplink filters back after switchdev +* @uplink_vsi: the uplink VSI +*/ +static void ice_eswitch_resync_uplink (struct ice_vsi *uplink_vsi) +{ +struct ice_pf *pf = uplink_vsi->back; + +while (test_and_set_bit (ICE_CFG_BUSY , uplink_vsi->state)) +usleep_range (1000 ,2000 ); + +/* VLAN changes during the session may have added these */ +ice_fltr_clear_vlan_vsi_promisc (&pf->hw, uplink_vsi, +ICE_MCAST_VLAN_PROMISC_BITS ); +ice_fltr_clear_vsi_promisc (&pf->hw, uplink_vsi->idx, +ICE_MCAST_PROMISC_BITS ,0 ); + uplink_vsi->current_netdev_flags &= ~IFF_ALLMULTI ; + +clear_bit (ICE_VSI_ESWITCH_UPLINK , uplink_vsi->state); +set_bit (ICE_VSI_PROMISC_CHANGED , uplink_vsi->state); +set_bit (ICE_VSI_UMAC_FLTR_CHANGED , uplink_vsi->state); +set_bit (ICE_VSI_MMAC_FLTR_CHANGED , uplink_vsi->state); +clear_bit_unlock (ICE_CFG_BUSY , uplink_vsi->state); + +set_bit (ICE_FLAG_FLTR_SYNC , pf->flags); +ice_service_task_schedule (pf); +} +/** * ice_eswitch_setup_env - configure eswitch HW filters * @pf: pointer to PF struct
@@ -28,6 +56,12 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)if (ice_down (uplink_vsi))return -ENODEV ; +/* the eswitch owns the uplink promisc config until the resync */ +while (test_and_set_bit (ICE_CFG_BUSY , uplink_vsi->state)) +usleep_range (1000 ,2000 ); +set_bit (ICE_VSI_ESWITCH_UPLINK , uplink_vsi->state); +clear_bit_unlock (ICE_CFG_BUSY , uplink_vsi->state); +ice_remove_vsi_fltr (&pf->hw, uplink_vsi->idx);ice_vsi_cfg_sw_lldp (uplink_vsi, true, false);
@@ -77,6 +111,8 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)if (if_running)ice_up (uplink_vsi); +ice_eswitch_resync_uplink (uplink_vsi); +return -ENODEV ; }
@@ -318,6 +354,7 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf) err_br_offloads:ice_eswitch_release_env (pf); +ice_eswitch_resync_uplink (uplink_vsi);return -ENODEV ; }
@@ -331,6 +368,9 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)ice_eswitch_release_env (pf); pf->eswitch.is_running = false; + +/* after is_running is cleared, so no rx mode change is lost */ +ice_eswitch_resync_uplink (pf->eswitch.uplink_vsi); }/**
drivers/net/ethernet/intel/ice/ice_main.c +14 -3
@@ -394,6 +394,10 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) } } err =0 ; +/* the eswitch owns the uplink promisc config during a session */ +if (test_bit (ICE_VSI_ESWITCH_UPLINK , vsi->state)) + goto exit; +/* check for changes in promiscuous modes */ if (changed_flags &IFF_ALLMULTI ) {if (vsi->current_netdev_flags &IFF_ALLMULTI ) {
@@ -438,6 +442,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) ICE_MCAST_PROMISC_BITS);if (err) goto out_promisc; + }else if (ice_is_vsi_dflt_vsi (vsi)) { +/* still the default VSI, so subscribe it */ + err =ice_set_promisc (vsi, +ICE_MCAST_PROMISC_BITS ); +if (err) + goto out_promisc; } }else {/* Clear Rx filter to remove traffic from wire */
@@ -450,11 +460,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)IFF_PROMISC ; goto out_promisc; } -if (vsi->netdev->features & -NETIF_F_HW_VLAN_CTAG_FILTER ) - vlan_ops->ena_rx_filtering (vsi); } +/* pruning can be off even without our DFLT rule */ +if (vsi->netdev->features &NETIF_F_HW_VLAN_CTAG_FILTER ) + vlan_ops->ena_rx_filtering (vsi); +/* disable allmulti here, but only if allmulti is not * still enabled for the netdev */
Signature · 1 line
2.56.1
Re: [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session
Quoted 36 lines · Petr Oros
A switchdev session leaves the uplink filters out of sync with its netdev.
ice_eswitch_setup_env()removes the multicast promisc rules and the address filters, andice_eswitch_release_env()removes the default VSI (DFLT) Rx rule that a promiscuous uplink needs.ice_set_rx_mode()ignores the uplink during the session and nothing syncs it when the session ends, so these are not installed again, and flag changes made meanwhile are lost.Let the eswitch own the uplink promisc configuration during a session. While the new
ICE_VSI_ESWITCH_UPLINKbit is set,ice_vsi_sync_fltr()leaves it alone. When the session ends, afteris_runningis cleared,ice_eswitch_resync_uplink()clears the bit and queues a full filter sync, which programs the uplink from the netdev flags. Also subscribe a promiscuous VSI to multicast when it already holds the DFLT rule, and enable VLAN pruning on every promisc off, because it can be off without our DFLT rule after a session or with LAG.This does not restore the uplink VLAN filters that
ice_eswitch_setup_env()removes, a separate problem that now also shows when promisc is cleared after a promiscuous session.Found by AI code review, starting with the Sashiko review of v4, and reproduced on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without kernel changes:
ip link set $PF promisc on
devlink dev eswitch set pci/$BDF mode switchdev echo 1 >/sys/class/net/$PF/device/sriov_numvfs echo 0 >/sys/class/net/$PF/device/sriov_numvfsafter which unknown unicast no longer reaches the PF, and with this patch it does again. Also tested on that E810-C with promisc changed before, during and after sessions, allmulti across a session, and PF resets and driver removal during sessions. LAG and switchdev setup errors were not tested. No kernel selftests cover this.
Quoted 5 lines
Fixes 1a1c40df2e80 ("ice: set and release switchdev environment")Fixes 2571a3fa6251 ("ice: Prohibit rx mode change in switchdev mode")Fixes 5c07be96d8b3 ("ice: Avoid setting default Rx VSI twice in switchdev setup")Fixes 776fe19953b0 ("ice: block default rule setting on LAG interface")Signed-off-by Petr Oros<[email protected]>
[email protected]
AI reviewRe: [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session
In reply to Petr OrosThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] ice: ice_vsi_sync_fltr() re-adds uplink MAC filters during switchdev --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] ice: ice_vsi_sync_fltr() re-adds uplink MAC filters during switchdev
--
commit edb8f55bf97ab7c6c15ad8258647b17f2ec38996
Author: Petr Oros <[email protected]>
ice: resync uplink filters after a switchdev session
This commit adds ICE_VSI_ESWITCH_UPLINK to keep ice_vsi_sync_fltr() from modifying the uplink promiscuous configuration during a switchdev session, and schedules a filter resync when the session ends.
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-0
[ ... ]
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +6
-0@@ -28,6 +56,12 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)if (ice_down (uplink_vsi))return -ENODEV ; +/* the eswitch owns the uplink promisc config until the resync */ +while (test_and_set_bit (ICE_CFG_BUSY , uplink_vsi->state)) +usleep_range (1000 ,2000 ); +set_bit (ICE_VSI_ESWITCH_UPLINK , uplink_vsi->state); +clear_bit_unlock (ICE_CFG_BUSY , uplink_vsi->state); +ice_remove_vsi_fltr (&pf->hw, uplink_vsi->idx);ice_vsi_cfg_sw_lldp (uplink_vsi, true, false);
[ ... ]
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-0
drivers/net/ethernet/intel/ice/ice_main.c static int ice_vsi_sync_fltr(struct ice_vsi *vsi) · line 403
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +4
-0@@ -394,6 +394,10 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) } } err =0 ; +/* the eswitch owns the uplink promisc config during a session */ +if (test_bit (ICE_VSI_ESWITCH_UPLINK , vsi->state)) + goto exit; +/* check for changes in promiscuous modes */ if (changed_flags &IFF_ALLMULTI ) {if (vsi->current_netdev_flags &IFF_ALLMULTI ) {
[Severity: High]
Does checking ICE_VSI_ESWITCH_UPLINK after the MAC filter sync block allow ice_vsi_sync_fltr() to re-install the uplink's unicast and multicast MAC filters during a switchdev session?
When ice_eswitch_enable_switchdev() calls ice_eswitch_setup_env() while the uplink netdev is up, pf->eswitch.is_running is still false. At the end of ice_eswitch_setup_env(), ice_up(uplink_vsi) calls ice_vsi_cfg_lan() -> ice_set_rx_mode(), which sees ice_is_switchdev_running() == false and schedules a filter sync with ICE_VSI_UMAC_FLTR_CHANGED and ICE_VSI_MMAC_FLTR_CHANGED set.
When ice_vsi_sync_fltr() runs for uplink_vsi, it executes __dev_uc_sync(), __dev_mc_sync() and ice_fltr_add_mac_list() before reaching the ICE_VSI_ESWITCH_UPLINK check, re-adding all the MAC filters that ice_eswitch_setup_env() just removed and unsynced. Because pf->eswitch.is_running is then set to true, later address removals on the uplink are ignored by ice_set_rx_mode(), leaving stale MAC rules in hardware for the rest of the session (with multicast MAC rules also overriding the lower-priority switchdev default Tx rule). It also updates vsi->current_netdev_flags = vsi->netdev->flags before the check, and in ice_eswitch_setup_env() releasing ICE_CFG_BUSY before ice_remove_vsi_fltr() and __dev_uc_unsync()/__dev_mc_unsync() lets an already-queued ice_vsi_sync_fltr() race with filter removal.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session
In reply to Petr OrosThank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · Low: 4
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The end-of-session uplink resync is not retried if its promisc step fails.
- [Medium] The patch adds two more open-coded `while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) usleep_range(1000,…
- [Medium] When a session ends, the uplink's primary unicast MAC filter is rebuilt for port_info->mac.perm_addr, not for netdev->dev_addr, and…
- [Low] The commit message does not say that this patch needs the earlier patch in the series, "ice: stop the service task before the PF is…
- [Low] In ice_vsi_sync_fltr(), the ICE_VSI_ESWITCH_UPLINK gate sits after the uc/mc MAC-list sync, and ice_eswitch_resync_uplink() leaves…
- [Low] A promiscuous VSI that already holds the DFLT Rx rule never has VLAN pruning turned off.
- [Low] The new comment in ice_eswitch_disable_switchdev(), "after is_running is cleared, so no rx mode change is lost", assumes…
--
ice: resync uplink filters after a switchdev session
This patch adds a new VSI state bit, ICE_VSI_ESWITCH_UPLINK. While it is set, the eswitch owns the uplink promisc configuration and ice_vsi_sync_fltr() leaves it alone. When the session ends, ice_eswitch_resync_uplink() clears the bit and queues a full filter sync, and the patch also changes how ice_vsi_sync_fltr() handles multicast subscription and VLAN pruning for promiscuous VSIs.
Quoted 15 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +7
-0@@ -10,6 +10,34 @@#include "devlink/devlink.h" #include "ice_tc_lib.h" +/** +* ice_eswitch_resync_uplink - hand the uplink filters back after switchdev +* @uplink_vsi: the uplink VSI +*/ +static void ice_eswitch_resync_uplink (struct ice_vsi *uplink_vsi) +{ +struct ice_pf *pf = uplink_vsi->back;
drivers/net/ethernet/intel/ice/ice_eswitch.c line 29
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +10
-0+ +while (test_and_set_bit (ICE_CFG_BUSY , uplink_vsi->state)) +usleep_range (1000 ,2000 ); + +/* VLAN changes during the session may have added these */ +ice_fltr_clear_vlan_vsi_promisc (&pf->hw, uplink_vsi, +ICE_MCAST_VLAN_PROMISC_BITS ); +ice_fltr_clear_vsi_promisc (&pf->hw, uplink_vsi->idx, +ICE_MCAST_PROMISC_BITS ,0 ); + uplink_vsi->current_netdev_flags &= ~IFF_ALLMULTI ;
[Severity: Medium]
Is a state bit the right tool to lock this? This patch adds two more open-coded ICE_CFG_BUSY sections, here and in ice_eswitch_setup_env():
while (test_and_set_bit(ICE_CFG_BUSY, uplink_vsi->state))
usleep_range(1000, 2000);
...
clear_bit_unlock(ICE_CFG_BUSY, uplink_vsi->state);These sections pass ownership of ICE_VSI_ESWITCH_UPLINK, and the current_netdev_flags read-modify-write above, back and forth with ice_vsi_sync_fltr(). Lockdep cannot see them, and the eswitch side sleep-polls on the bit while it holds the devlink instance lock.
The section they pair with in ice_vsi_sync_fltr() releases the bit with a plain clear_bit(), which has no release ordering:
exit:
clear_bit(ICE_CFG_BUSY, vsi->state); return err;
So the store "vsi->current_netdev_flags = vsi->netdev->flags" made inside ice_vsi_sync_fltr() may not be visible to the next holder. Could the current_netdev_flags &= ~IFF_ALLMULTI here then write back a stale value?
The last patch in the series drops that read-modify-write, but the ad-hoc lock sections are still there in the final state. Would a real mutex or spinlock fit better here?
drivers/net/ethernet/intel/ice/ice_eswitch.c line 35
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +6
-0+ +clear_bit (ICE_VSI_ESWITCH_UPLINK , uplink_vsi->state); +set_bit (ICE_VSI_PROMISC_CHANGED , uplink_vsi->state); +set_bit (ICE_VSI_UMAC_FLTR_CHANGED , uplink_vsi->state); +set_bit (ICE_VSI_MMAC_FLTR_CHANGED , uplink_vsi->state); +clear_bit_unlock (ICE_CFG_BUSY , uplink_vsi->state);
[Severity: Medium]
What happens if the promisc stage of the queued sync fails? This function queues one ice_vsi_sync_fltr() pass and relies on it to install the DFLT Rx rule and multicast promisc from the netdev flags.
ice_vsi_sync_fltr() clears UMAC/MMAC_FLTR_CHANGED at the top. If ice_set_dflt_vsi(), ice_clear_dflt_vsi() or ice_set_promisc()/ice_clear_promisc() then fails, it only re-arms PROMISC_CHANGED:
out_promisc:
set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state); goto exit;
ice_sync_fltr_subtask() then sets ICE_FLAG_FLTR_SYNC again. But the next run only syncs VSIs for which ice_vsi_fltr_changed() is true:
if (pf->vsi[v] && ice_vsi_fltr_changed(pf->vsi[v]) &&
ice_vsi_sync_fltr(pf->vsi[v])) {
/* come back and try again later */
set_bit(ICE_FLAG_FLTR_SYNC, pf->flags);ice_vsi_fltr_changed() only tests UMAC/MMAC_FLTR_CHANGED.
Wouldn't the uplink be skipped then? Its DFLT and multicast state would stay out of sync with netdev->flags until some unrelated rx mode or address change.
The final state of the series does the same through set_bit(ICE_VSI_PROMISC_CHANGED) in the DFLT and mc_err branches. The last patch adds the comment "retried by the next sync, with the allmulti change", and its commit message says a failed DFLT install is kept "before the retry". There doesn't seem to be an automatic retry, though. That same commit message shows ice_set_dflt_vsi() failing with -EIO once the switch lookup table is full, so this failure can happen in practice.
drivers/net/ethernet/intel/ice/ice_eswitch.c line 39
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +4
-0+ +set_bit (ICE_FLAG_FLTR_SYNC , pf->flags); +ice_service_task_schedule (pf); +}
[Severity: Low]
Should the commit message say that this patch depends on the earlier patch in the series? On driver removal this schedule runs inside ice_free_vfs():
ice_remove()
ice_free_vfs()
ice_eswitch_detach_vf()
ice_eswitch_detach()
ice_eswitch_disable_switchdev()
ice_eswitch_resync_uplink()
ice_service_task_schedule()
In this tree that is only safe because the earlier patch, "ice: stop the service task before the PF is unloaded", added ice_service_task_stop() right after ice_free_vfs(). Since 8a37f9e2ff40, the only other stop on the remove path is in ice_deinit_dev() at the very end of ice_remove().
Without that patch, wouldn't the queued ice_sync_fltr_subtask() walk pf->vsi[] and the uplink netdev while ice_unload()/ice_deinit()/ice_vsi_release_all() free them?
The dependency is only mentioned below the cut line ("relies on patch 1 when the PF goes away"), and that text is dropped on apply. The Fixes:
tags go back to 1a1c40df2e80, so stable could pick this patch up on its own. The earlier patch does carry Fixes: 8a37f9e2ff40, which helps.
[ ... ]
drivers/net/ethernet/intel/ice/ice_eswitch.c static int ice_eswitch_setup_env(struct ice_pf *pf) · line 117
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2
-0@@ -77,6 +111,8 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)if (if_running)ice_up (uplink_vsi); +ice_eswitch_resync_uplink (uplink_vsi); +return -ENODEV ; }
[Severity: Medium]
Does the resync restore the uplink's primary unicast filter for netdev->dev_addr?
ice_eswitch_setup_env() removes every ICE_SW_LKUP_MAC rule on the uplink with ice_remove_vsi_fltr(). That includes the dev_addr filter installed by ice_set_mac_address(). This error path and ice_eswitch_release_env() only add back the permanent address:
ice_fltr_add_mac_and_broadcast(uplink_vsi, uplink_vsi->port_info->mac.perm_addr, ICE_FWD_TO_VSI);
ice_set_mac_address() never updates port_info->mac.perm_addr. Only ice_aq_manage_mac_read() fills it, at init. The sync queued by ice_eswitch_resync_uplink() only walks dev->uc and dev->mc, and dev_addr is in neither list.
Suppose a locally administered MAC was set on the PF, with ip link set address or by bonding. After the session, wouldn't the switch forward only the factory MAC to the uplink? Unicast to the address the netdev actually uses would then be dropped while promisc is off.
The perm_addr restore predates this patch. Still, the commit message says setup_env removes "the address filters" and that "these are not installed again", and the resync leaves the primary address out.
[ ... ]
drivers/net/ethernet/intel/ice/ice_eswitch.c static void ice_eswitch_disable_switchdev(struct ice_pf *pf) · line 374
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +3
-0@@ -331,6 +368,9 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)ice_eswitch_release_env (pf); pf->eswitch.is_running = false; + +/* after is_running is cleared, so no rx mode change is lost */ +ice_eswitch_resync_uplink (pf->eswitch.uplink_vsi); }
[Severity: Low]
Does this ordering give the guarantee the comment describes?
pf->eswitch.is_running is cleared with a plain store. The caller holds only the devlink lock, not rtnl. ice_set_rx_mode() reads the flag with a plain load:
if (!vsi || ice_is_switchdev_running(vsi->back)) return;
On the rtnl side, __dev_change_flags() stores dev->flags and then reaches ice_set_rx_mode() via dev_set_rx_mode()->netif_addr_lock_bh()->__dev_set_rx_mode(). The acquire in spin_lock does not order the earlier dev->flags store before the later is_running load.
This looks like the store-buffering pattern:
CPU A (rtnl) CPU B (teardown)
W dev->flags W is_running = false
R is_running (true) test_and_set_bit(ICE_CFG_BUSY)
return early queue_work()
service task reads old netdev->flagsOn weakly ordered CPUs such as arm64 or ppc, couldn't a promisc or allmulti change made during teardown be lost, with nothing scheduling another sync?
Would smp_store_release()/smp_load_acquire() plus a full barrier work here? Or could the is_running early return in ice_set_rx_mode() be dropped now that the ICE_VSI_ESWITCH_UPLINK check exists?
drivers/net/ethernet/intel/ice/ice_main.c static int ice_vsi_sync_fltr(struct ice_vsi *vsi) · line 401
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_main.c +4
-0@@ -394,6 +394,10 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) } } err =0 ; +/* the eswitch owns the uplink promisc config during a session */ +if (test_bit (ICE_VSI_ESWITCH_UPLINK , vsi->state)) + goto exit; +/* check for changes in promiscuous modes */
[Severity: Low]
Should this check come before the uc/mc address list sync above it?
ice_eswitch_resync_uplink() leaves UMAC/MMAC_FLTR_CHANGED and ICE_FLAG_FLTR_SYNC pending, and nothing clears them when the next session starts. ice_reset_all_vfs() runs detach and attach for each VF back to back:
ice_eswitch_detach_vf()
ice_eswitch_disable_switchdev()
ice_eswitch_resync_uplink() <- sets UMAC/MMAC, FLTR_SYNCice_eswitch_attach_vf()
ice_eswitch_enable_switchdev()
ice_eswitch_setup_env() <- sets ICE_VSI_ESWITCH_UPLINK,
ice_remove_vsi_fltr(),
__dev_uc_unsync()/__dev_mc_unsync()The stale sync then runs inside the new session. ice_vsi_fltr_changed() is true, and __dev_uc_sync()/__dev_mc_sync() rebuild tmp_sync_list from every address. ice_fltr_add_mac_list() then installs them as FWD_TO_VSI rules on the uplink before this goto exit is reached.
Doesn't that leave per-address forwarding rules on the uplink during the session, after setup_env meant to remove them?
The same thing already happens when the uplink is admin-up, because setup_env's ice_up()->ice_vsi_cfg_lan()->ice_set_rx_mode() runs while is_running is still false. The stale resync adds a trigger that also fires when the uplink is admin-down.
drivers/net/ethernet/intel/ice/ice_main.c static int ice_vsi_sync_fltr(struct ice_vsi *vsi) · line 451
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_main.c +6
-0@@ -438,6 +442,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) ICE_MCAST_PROMISC_BITS);if (err) goto out_promisc; + }else if (ice_is_vsi_dflt_vsi (vsi)) { +/* still the default VSI, so subscribe it */ + err =ice_set_promisc (vsi, +ICE_MCAST_PROMISC_BITS ); +if (err) + goto out_promisc; }
[Severity: Low]
This subscribes an already-default VSI to multicast. Should it also turn off VLAN pruning, as the ice_set_dflt_vsi() branch above does?
The commit message says DFLT ownership and pruning can get out of step, and fixes the promisc-off direction. The opposite case, DFLT held with pruning on, looks reachable at the end of a session. ice_eswitch_release_env() enables pruning first, then removes the DFLT Rx rule and ignores the result:
vlan_ops->ena_rx_filtering(uplink_vsi); ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, false, ICE_FLTR_TX); ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, false, ICE_FLTR_RX);
The err_override_local_lb path in ice_eswitch_setup_env() does the same.
If that removal fails, the resync sees ice_is_dflt_vsi_in_use() return true for a promiscuous netdev. It then takes this branch and skips dis_rx_filtering().
Wouldn't tagged frames for VLANs without a filter be pruned even though the netdev is promiscuous? After a session that is every non-zero VLAN, because setup_env wiped the VLAN filter table.
The last patch in the series replaces this branch with ice_vsi_wants_mc_promisc(). The final promisc-on path still only calls dis_rx_filtering() when it installs the DFLT rule itself.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com
PATCH v5 4/4 ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
In reply to Petr OrosAn allmulticast or promiscuous PF VSI with VLANs is subscribed to multicast with an ICE_SW_LKUP_PROMISC_VLAN rule pair for every VID, and each rule takes an entry of the switch lookup table (FLU), which has 32K entries for all PFs of the device. A port of a vlan_filtering bridge is allmulticast, so a wide trunk (vid 2-4094) over several such ports overruns the table. Firmware then rejects Add Switch Rules with ENOSPC, the trunk of the last port is only partly installed, and the default VSI (DFLT) Rx rule fails to install when a port turns promiscuous:
ice 0000:5c:00.1: Failed to set VSI 14 as the default forwarding
VSI, error -5
ice 0000:5c:00.1 ens1f1: Error -5 setting default VSI 14 Rx rule
Subscribe PF VSIs with the VLAN agnostic pair (ICE_SW_LKUP_PROMISC, vid
0) only. Drop the per-VID handling from ice_vlan_rx_add_vid() and ice_vlan_rx_kill_vid(), and stop clearing the multicast rules in ice_eswitch_resync_uplink(), whose queued sync now reconciles them. The pair matches multicast on every VLAN. VLAN pruning still limits what it delivers to the VLANs of the VSI, and with pruning off, as for the DFLT holder, it delivers on every VLAN. The subscription now follows IFF_PROMISC and IFF_ALLMULTI in one place, so clearing allmulti no longer unsubscribes a promiscuous VSI unless another VSI holds the DFLT rule, and a failed DFLT install does not remove it before the retry. ice_set_promisc() adds the Rx and the Tx rule one at a time, so a rule left by an earlier failure does not keep the other one from being added.
A trusted VF that holds the DFLT rule no longer gets through it the multicast on VLANs the PF is not a member of, because the promisc recipe has a higher priority than the default one. It keeps what its own multicast promisc rules match.
The overrun was observed on a machine in real use, and the allmulti problem was found by the Sashiko review of v4. The overrun reproduces on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without kernel changes:
for p in $P0 $P2 $P3; do
ip link add br-$p type bridge vlan_filtering 1 ip link set br-$p up
ip link set $p master br-$p
bridge vlan add vid 2-4094 dev $p
done
ip link set br-$P0 promisc on
With the per-VID pairs a trunked port took 12292 FLU entries, the third bridge vlan add failed part way and the promisc on logged the errors above. With this patch a trunked port takes 4104 entries, all three trunks fit with 20387 of the 32768 entries free, and the DFLT rule installs. The FLU numbers come from a test-only debugfs file that issues Get Resource Allocation (AQ 0x0204). Also tested with multicast to joined and unjoined groups on member and non-member VLANs, with promisc and allmulti changed in every order, with VLANs added and removed while allmulticast, with a trusted promiscuous VF, and with the DFLT install made to fail by a test-only change. No kernel selftests cover this.
---
v5:
- Reworked after the Sashiko review of the v4 pull. PF VSIs now always use the VLAN agnostic multicast pair, and the per-VID multicast rules and their handling in ice_vlan_rx_add_vid() and ice_vlan_rx_kill_vid() are gone.
- The multicast subscription is reconciled from IFF_PROMISC and IFF_ALLMULTI in one place, so clearing allmulti keeps the subscription of a promiscuous VSI unless another VSI holds the DFLT rule.
- ice_set_promisc() adds the Rx and the Tx rule separately.
- New title, was "ice: skip per-VLAN promisc rules when default VSI Rx rule is set".
- Added the Fixes tag for 43fbca02c2dd.
- Dropped the Reviewed-by and Tested-by tags because of the rework.
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/89efbea9831175e6f57e9fe8557f7a0e48e050b7.1781786935.git.poros@redhat.com/
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 8 - drivers/net/ethernet/intel/ice/ice_main.c | 232 ++++++------------- 2 files changed, 77 insertions(+), 163 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +0 -8
@@ -20,14 +20,6 @@ static void ice_eswitch_resync_uplink(struct ice_vsi *uplink_vsi)while (test_and_set_bit (ICE_CFG_BUSY , uplink_vsi->state))usleep_range (1000 ,2000 ); - -/* VLAN changes during the session may have added these */ -ice_fltr_clear_vlan_vsi_promisc (&pf->hw, uplink_vsi, -ICE_MCAST_VLAN_PROMISC_BITS ); -ice_fltr_clear_vsi_promisc (&pf->hw, uplink_vsi->idx, -ICE_MCAST_PROMISC_BITS ,0 ); - uplink_vsi->current_netdev_flags &= ~IFF_ALLMULTI ; -clear_bit (ICE_VSI_ESWITCH_UPLINK , uplink_vsi->state);set_bit (ICE_VSI_PROMISC_CHANGED , uplink_vsi->state);set_bit (ICE_VSI_UMAC_FLTR_CHANGED , uplink_vsi->state);
drivers/net/ethernet/intel/ice/ice_main.c +77 -155
300 lines not on this page · raw message
Signature · 1 line
2.56.1
Re: [PATCH net v5 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
Quoted 72 lines · Petr Oros
An allmulticast or promiscuous PF VSI with VLANs is subscribed to multicast with an
ICE_SW_LKUP_PROMISC_VLANrule pair for every VID, and each rule takes an entry of the switch lookup table (FLU), which has 32K entries for all PFs of the device. A port of avlan_filteringbridge is allmulticast, so a wide trunk (vid 2-4094) over several such ports overruns the table. Firmware then rejects Add Switch Rules with ENOSPC, the trunk of the last port is only partly installed, and the default VSI (DFLT) Rx rule fails to install when a port turns promiscuous:ice 0000:5c:00.1: Failed to set VSI 14 as the default forwarding
VSI, error -5
ice 0000:5c:00.1 ens1f1: Error -5 setting default VSI 14 Rx ruleSubscribe PF VSIs with the VLAN agnostic pair (
ICE_SW_LKUP_PROMISC, vid
0) only. Drop the per-VID handling fromice_vlan_rx_add_vid()andice_vlan_rx_kill_vid(), and stop clearing the multicast rules inice_eswitch_resync_uplink(), whose queued sync now reconciles them. The pair matches multicast on every VLAN. VLAN pruning still limits what it delivers to the VLANs of the VSI, and with pruning off, as for the DFLT holder, it delivers on every VLAN. The subscription now followsIFF_PROMISCandIFF_ALLMULTIin one place, so clearing allmulti no longer unsubscribes a promiscuous VSI unless another VSI holds the DFLT rule, and a failed DFLT install does not remove it before the retry.ice_set_promisc()adds the Rx and the Tx rule one at a time, so a rule left by an earlier failure does not keep the other one from being added.A trusted VF that holds the DFLT rule no longer gets through it the multicast on VLANs the PF is not a member of, because the promisc recipe has a higher priority than the default one. It keeps what its own multicast promisc rules match.
The overrun was observed on a machine in real use, and the allmulti problem was found by the Sashiko review of v4. The overrun reproduces on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without kernel changes:
for p in $P0 $P2 $P3; do
ip link add br-$p type bridgevlan_filtering1 ip link set br-$p up
ip link set $p master br-$p
bridge vlan add vid 2-4094 dev $p
done
ip link set br-$P0 promisc onWith the per-VID pairs a trunked port took 12292 FLU entries, the third bridge vlan add failed part way and the promisc on logged the errors above. With this patch a trunked port takes 4104 entries, all three trunks fit with 20387 of the 32768 entries free, and the DFLT rule installs. The FLU numbers come from a test-only debugfs file that issues Get Resource Allocation (AQ
0x0204). Also tested with multicast to joined and unjoined groups on member and non-member VLANs, with promisc and allmulti changed in every order, with VLANs added and removed while allmulticast, with a trusted promiscuous VF, and with the DFLT install made to fail by a test-only change. No kernel selftests cover this.Fixes 1273f89578f2 ("ice: Fix broken IFF_ALLMULTI handling")Fixes 43fbca02c2dd ("ice: fix lost multicast packets in promisc mode")Signed-off-by Petr Oros<[email protected]>---
v5:
- Reworked after the Sashiko review of the v4 pull. PF VSIs now always use the VLAN agnostic multicast pair, and the per-VID multicast rules and their handling inice_vlan_rx_add_vid()andice_vlan_rx_kill_vid()are gone.
- The multicast subscription is reconciled fromIFF_PROMISCandIFF_ALLMULTIin one place, so clearing allmulti keeps the subscription of a promiscuous VSI unless another VSI holds the DFLT rule.
-ice_set_promisc()adds the Rx and the Tx rule separately.
- New title, was "ice: skip per-VLAN promisc rules when default VSI Rx rule is set".
- Added the Fixes tag for43fbca02c2dd.
- Dropped the Reviewed-by and Tested-by tags because of the rework.
Quoted 4 lines
v4:https://lore.kernel.org/all/[email protected]/ v3:https://lore.kernel.org/all/[email protected]/ v2:https://lore.kernel.org/all/[email protected]/ v1:https://lore.kernel.org/ all/89efbea9831175e6f57e9fe8557f7a0e48e050b7.1781786935.git.poros@redhat.com/
[email protected]
AI reviewRe: [PATCH net v5 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
In reply to Petr OrosThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] In ice_vsi_sync_fltr() (drivers/net/ethernet/intel/ice/ice_main.c), the error paths rewritten…
--
ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
On PF VSIs, this patch replaces the per-VID ICE_SW_LKUP_PROMISC_VLAN multicast promisc rule pairs with one VLAN agnostic ICE_SW_LKUP_PROMISC pair, so the switch lookup table no longer runs out. It removes the per-VID handling from ice_vlan_rx_add_vid() and ice_vlan_rx_kill_vid(). The multicast subscription is now reconciled from IFF_PROMISC and IFF_ALLMULTI in one place in ice_vsi_sync_fltr().
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-0
[ ... ]
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -399,91 +408,65 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) goto exit;/* check for changes in promiscuous modes */
[ ... ]
Quoted 15 lines
drivers/net/ethernet/intel/ice/ice_main.c +15
-0+ promisc_changed =test_and_clear_bit (ICE_VSI_PROMISC_CHANGED , + vsi->state); +if ((changed_flags &IFF_PROMISC ) || promisc_forced_on) + promisc_changed = true; + +if (promisc_changed && (vsi->current_netdev_flags &IFF_PROMISC )) { +/* Apply Rx filter rule to get traffic from wire */ +if (!ice_is_dflt_vsi_in_use (vsi->port_info)) { + err =ice_set_dflt_vsi (vsi); +if (err && err != -EEXIST ) { +netdev_err (netdev,"Error %d setting default VSI %i Rx rule\n" , + err, vsi->vsi_num); + vsi->current_netdev_flags &= ~IFF_PROMISC ; +set_bit (ICE_VSI_PROMISC_CHANGED , vsi->state); + dflt_err = true;
[ ... ]
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_main.c +11
-0+/* promiscuous mode implies allmulticast */ +if (promisc_changed || (changed_flags &IFF_ALLMULTI )) { +int mc_err =0 ; + +/* a failed DFLT install leaves the netdev promiscuous */ +if (ice_vsi_wants_mc_promisc (vsi)) + mc_err =ice_set_promisc (vsi,ICE_MCAST_PROMISC_BITS ); +else if (!dflt_err) + mc_err =ice_clear_promisc (vsi,ICE_MCAST_PROMISC_BITS ); +if (mc_err) { + netdev_err(netdev, "Error %d syncing multicast promiscuous on VSI %i\n",
drivers/net/ethernet/intel/ice/ice_main.c static int ice_vsi_sync_fltr(struct ice_vsi *vsi) · line 469
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +7
-0+ mc_err, vsi->vsi_num); +/* retried by the next sync, with the allmulti change */ + vsi->current_netdev_flags ^= + changed_flags &IFF_ALLMULTI ; +set_bit (ICE_VSI_PROMISC_CHANGED , vsi->state); +if (!err) + err = mc_err; } } goto exit;
[Severity: Medium]
Does this retry actually happen? Both the comment above and the commit message ("a failed DFLT install does not remove it before the retry") expect a later sync.
Three error paths are involved: the failed DFLT install (dflt_err), the failed DFLT clear and this mc_err path. Each one only sets ICE_VSI_PROMISC_CHANGED, returns an error and leaves through exit.
ice_sync_fltr_subtask() calls ice_vsi_sync_fltr() only when ice_vsi_fltr_changed() is true:
ice_sync_fltr_subtask() {
...
ice_for_each_vsi(pf, v)
if (pf->vsi[v] && ice_vsi_fltr_changed(pf->vsi[v]) &&
ice_vsi_sync_fltr(pf->vsi[v])) {
/* come back and try again later */
set_bit(ICE_FLAG_FLTR_SYNC, pf->flags);
break;
}
}ice_vsi_fltr_changed() looks only at the UMAC and MMAC bits:
return test_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state) || test_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state);
ice_vsi_sync_fltr() clears both bits near its start. Only the out label sets them again, and these paths skip it. So ICE_FLAG_FLTR_SYNC is set again after the error, but on the next service task pass the VSI is skipped and the flag is cleared.
The admin queue can fail transiently, for example in the FW ENOSPC -> -EIO case from the commit message. Could the VSI then stay with IFF_PROMISC set but no DFLT Rx rule? Could it also stay with IFF_ALLMULTI or IFF_PROMISC set and missing or stale multicast promisc rules?
Removing VLANs to free FLU entries would not trigger a resync, because ice_vlan_rx_kill_vid() sets no sync bits. The state seems to last until an unrelated ice_set_rx_mode() call or an eswitch resync.
The old out_promisc label had the same gating, but this patch adds new retry state and depends on it.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com