* [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded
2026-12-02 7:16 [PATCH net v7 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
@ 2026-12-02 7:16 ` Petr Oros
2026-12-03 8:01 ` netdev-bot+sashiko
2026-12-02 7:16 ` [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist Petr Oros
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Petr Oros @ 2026-12-02 7:16 UTC (permalink / raw)
To: netdev
Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
intel-wired-lan, linux-kernel
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,
and make that stop final. The new ice_service_task_shutdown() also
disables the work and shuts the timer down, so a caller that passed the
ICE_SERVICE_DIS test before the stop can no longer queue the work, and
a run in progress can no longer arm the timer after its delete. The
recovery mode branch of ice_remove() gets the same final stop. The stop
in ice_deinit_dev() stays for its other callers. 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.
This only hardens the removal path. ice_devlink_reinit_down() and the
error paths of ice_probe() and ice_devlink_reinit_up() also tear the PF
down before they stop the service task, all three are older than that
commit and are not changed here.
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.
Fixes: 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
Signed-off-by: Petr Oros <poros@redhat.com>
---
v7:
- The stop after ice_free_vfs() is final now, it also disables the work
and shuts the timer down, so the work can no longer be queued after
the stop and the timer can no longer be armed. The recovery mode
branch of ice_remove() gets the same final stop.
- The message no longer says the stop in ice_deinit_dev() deletes a
timer, the shutdown already did, and it names the error path of
ice_devlink_reinit_up() among the paths that are not changed here.
- Dropped the Reviewed-by tags because the code changed.
v6: https://lore.kernel.org/all/20261130132107.1177185-2-poros@redhat.com/
v5: https://lore.kernel.org/all/20261127085714.1207361-2-poros@redhat.com/
---
drivers/net/ethernet/intel/ice/ice_main.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 47c6798c97e8f1..b05eda1bf50ae7 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1707,6 +1707,22 @@ static int ice_service_task_stop(struct ice_pf *pf)
return ret;
}
+/**
+ * ice_service_task_shutdown - stop the service task for PF removal
+ * @pf: board private structure
+ *
+ * A caller that passed the ICE_SERVICE_DIS test before the stop can
+ * still queue the work after it, and a run in progress can arm the
+ * timer after its delete. The PF is going away, so make both
+ * permanently dead, nothing restarts them.
+ */
+static void ice_service_task_shutdown(struct ice_pf *pf)
+{
+ ice_service_task_stop(pf);
+ disable_work_sync(&pf->serv_task);
+ timer_shutdown_sync(&pf->serv_tmr);
+}
+
/**
* ice_service_task_restart - restart service task and schedule works
* @pf: board private structure
@@ -5375,7 +5391,7 @@ static void ice_remove(struct pci_dev *pdev)
}
if (ice_is_recovery_mode(&pf->hw)) {
- ice_service_task_stop(pf);
+ ice_service_task_shutdown(pf);
scoped_guard(devl, priv_to_devlink(pf)) {
ice_deinit_devlink(pf);
}
@@ -5387,6 +5403,9 @@ static void ice_remove(struct pci_dev *pdev)
ice_free_vfs(pf);
}
+ ice_service_task_shutdown(pf);
+ ice_aq_cancel_waiting_tasks(pf);
+
if (!ice_is_safe_mode(pf))
ice_remove_arfs(pf);
@@ -5407,7 +5426,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);
}
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded
2026-12-02 7:16 ` [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded Petr Oros
@ 2026-12-03 8:01 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 8:01 UTC (permalink / raw)
To: poros
Cc: netdev, anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev,
davem, edumazet, kuba, pabeni, aleksandr.loktionov, horms,
michal.swiatkowski, grzegorz.nitka, pmenzel, wojciech.drewek,
marcin.szycik, martyna.szapar-mudlaw, ivecera, alice.michael,
jacob.e.keller, jbrandeb, patryk.holda, sx.rinitha, aaron.ma,
intel-wired-lan, linux-kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The patch fixes a second, older bug in the recovery mode branch
of ice_remove() (drivers/net/ethernet/intel/ice/ice_main.c), but the…
- [Low] ice: clear_bit(ICE_SERVICE_SCHED) before disable_work_sync() in
shutdown
--
ice: stop the service task before the PF is unloaded
This patch moves the service task stop and the AdminQ waiter cancel in
ice_remove() back to right after ice_free_vfs(). It adds
ice_service_task_shutdown(), which also calls disable_work_sync() and
timer_shutdown_sync() so nothing can re-arm the work or the timer. The
recovery mode branch of ice_remove() now uses the same final stop.
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 47c6798c97e8f..b05eda1bf50ae 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
[ ... ]
> @@ -5375,7 +5391,7 @@ static void ice_remove(struct pci_dev *pdev)
> }
>
> if (ice_is_recovery_mode(&pf->hw)) {
> - ice_service_task_stop(pf);
> + ice_service_task_shutdown(pf);
> scoped_guard(devl, priv_to_devlink(pf)) {
> ice_deinit_devlink(pf);
> }
[Severity: Low]
This change looks right, but it seems to fix a second, older bug that
the Fixes tag doesn't cover. Should this also carry a Fixes tag for
1de25c6b984d ("ice: support FW Recovery Mode")?
The recovery mode branch of ice_remove() comes from 1de25c6b984d, and
8a37f9e2ff40 never changed it. Before this patch the branch called
ice_service_task_stop() once and returned. That function runs
timer_delete_sync() first and cancel_work_sync() second.
If ice_service_task_recovery_mode() is running at that moment, it
re-arms the timer unconditionally after the delete:
ice_service_task_recovery_mode() {
...
ice_service_task_complete(pf);
mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100));
}
cancel_work_sync() only waits for that run to finish. After that,
ice_service_timer() keeps re-arming itself no matter what
ICE_SERVICE_DIS says:
ice_service_timer() {
...
mod_timer(&pf->serv_tmr, round_jiffies(pf->serv_tmr_period + jiffies));
ice_service_task_schedule(pf);
}
So the timer can still fire after the PF has been freed and the module
has been unloaded.
The commit message only says "The recovery mode branch of ice_remove()
gets the same final stop". Trees that have 1de25c6b984d but not
8a37f9e2ff40 would not see that this fix applies to them. Could the
message also say that this path is fixed, and add the extra tag?
Fixes: 1de25c6b984d ("ice: support FW Recovery Mode")
[ ... ]
> @@ -1707,6 +1707,22 @@ static int ice_service_task_stop(struct ice_pf *pf)
> return ret;
> }
>
> +/**
> + * ice_service_task_shutdown - stop the service task for PF removal
> + * @pf: board private structure
> + *
> + * A caller that passed the ICE_SERVICE_DIS test before the stop can
> + * still queue the work after it, and a run in progress can arm the
> + * timer after its delete. The PF is going away, so make both
> + * permanently dead, nothing restarts them.
> + */
> +static void ice_service_task_shutdown(struct ice_pf *pf)
> +{
> + ice_service_task_stop(pf);
> + disable_work_sync(&pf->serv_task);
> + timer_shutdown_sync(&pf->serv_tmr);
> +}
> +
> /**
> * ice_service_task_restart - restart service task and schedule works
> * @pf: board private structure
[Severity: Low]
ice_service_task_shutdown() starts with ice_service_task_stop(), and
that clears ICE_SERVICE_SCHED right after cancel_work_sync(), before
disable_work_sync() has run. That leaves the window this helper is
meant to close still open for the SCHED bit.
ice_service_task_schedule() tests the bits and queues the work in
separate steps:
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);
So this interleaving looks possible:
1. CPU0 in ice_service_task_schedule() passes the ICE_SERVICE_DIS
test and sets ICE_SERVICE_SCHED.
2. CPU1 in ice_remove() runs ice_service_task_stop(), which sets
ICE_SERVICE_DIS, finds nothing queued in cancel_work_sync() and
clears ICE_SERVICE_SCHED.
3. CPU0 calls queue_work(), so pf->serv_task is now pending while
ICE_SERVICE_SCHED is clear.
4. A worker starts running it before CPU1 reaches
disable_work_sync(), which then waits for that run to finish.
ice_service_task() and ice_service_task_recovery_mode() both finish
through ice_service_task_complete(), which then hits:
WARN_ON(!test_bit(ICE_SERVICE_SCHED, pf->state));
If CPU0 instead does its test_and_set_bit() after the clear, the work
is cancelled by disable_work_sync() and ICE_SERVICE_SCHED is left set
on a PF that is going away.
Neither case is a use-after-free, since disable_work_sync() still
drains the run before the VSIs are freed, but rmmod can splat a
warning. Would it be cleaner to open code the final stop so the bit
is cleared last: set ICE_SERVICE_DIS, timer_shutdown_sync(),
disable_work_sync(), and only then clear_bit(ICE_SERVICE_SCHED)? Once
the timer is shut down, a run that calls mod_timer() on its way out
is a no-op, and once the work is disabled nothing can queue it again.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202071642.2527605-1-poros%40redhat.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist
2026-12-02 7:16 [PATCH net v7 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
2026-12-02 7:16 ` [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded Petr Oros
@ 2026-12-02 7:16 ` Petr Oros
2026-12-03 8:01 ` netdev-bot+sashiko
2026-12-02 7:16 ` [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session Petr Oros
2026-12-02 7:16 ` [PATCH net v7 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs Petr Oros
3 siblings, 1 reply; 9+ messages in thread
From: Petr Oros @ 2026-12-02 7:16 UTC (permalink / raw)
To: netdev
Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
intel-wired-lan, linux-kernel
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 and the uplink stays in its switchdev configuration. Deleting
the SF port afterwards frees its devlink port while it stays
registered, so a later devlink port dump reads freed memory.
Refuse the switch to legacy while subfunction ports exist. Check
pf->dyn_ports, which only changes under the devlink instance lock held
here, while ice_sf_dev_probe() can change the representor xarray
without it.
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. Deleting the SF
port then returned 0 and the next devlink port list read its freed
devlink port, KASAN reported a slab use after free in
devlink_nl_port_fill(). With this patch the mode switch fails with
"Remove all subfunction ports before changing eswitch mode", after
the SF port is deleted it succeeds, and promisc off takes effect
again. No kernel selftests cover this.
Fixes: 977514fb0fa8 ("ice: create port representor for SF")
Signed-off-by: Petr Oros <poros@redhat.com>
---
v6:
- Check pf->dyn_ports instead of the representor xarray, which
ice_sf_dev_probe() can change without the devlink lock of the PF.
- Refuse only the switch to legacy, so an unknown mode gets "Unknown
eswitch mode" again.
- The message says what deleting the SF port does after such a switch
and names the use after free that the devlink port dump then hits.
- New title, was "ice: do not leave switchdev mode while representors
exist".
- Dropped Ivan's Reviewed-by because the check changed.
All after the Sashiko review of v5.
v6: https://lore.kernel.org/all/20261130132107.1177185-3-poros@redhat.com/
v5: https://lore.kernel.org/all/20261127085714.1207361-3-poros@redhat.com/
---
drivers/net/ethernet/intel/ice/ice_eswitch.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 6e7bba4738989b..44ef1fcfc6e4a5 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -356,6 +356,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
switch (mode) {
case DEVLINK_ESWITCH_MODE_LEGACY:
+ /* subfunction ports have representors too */
+ if (!xa_empty(&pf->dyn_ports)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Remove all subfunction ports before changing eswitch mode");
+ return -EOPNOTSUPP;
+ }
+
dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
pf->hw.pf_id);
xa_destroy(&pf->eswitch.reprs);
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist
2026-12-02 7:16 ` [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist Petr Oros
@ 2026-12-03 8:01 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 8:01 UTC (permalink / raw)
To: poros
Cc: netdev, anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev,
davem, edumazet, kuba, pabeni, aleksandr.loktionov, horms,
michal.swiatkowski, grzegorz.nitka, pmenzel, wojciech.drewek,
marcin.szycik, martyna.szapar-mudlaw, ivecera, alice.michael,
jacob.e.keller, jbrandeb, patryk.holda, sx.rinitha, aaron.ma,
intel-wired-lan, linux-kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] When SF ports still exist, the new refusal in
ice_eswitch_mode_set() (drivers/net/ethernet/intel/ice/ice_eswitch.c)…
--
ice: do not leave switchdev mode while subfunction ports exist
This patch makes ice_eswitch_mode_set() refuse a switch to legacy mode
while subfunction ports exist, by checking pf->dyn_ports. Without the
check, devlink core can let the change through when DCB is active and no
rate nodes are exported. The representor xarray is then destroyed under
a running switchdev session, which later leads to a use after free in
devlink_nl_port_fill().
> diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> index 6e7bba4738989..44ef1fcfc6e4a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> @@ -356,6 +356,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
>
> switch (mode) {
> case DEVLINK_ESWITCH_MODE_LEGACY:
> + /* subfunction ports have representors too */
> + if (!xa_empty(&pf->dyn_ports)) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Remove all subfunction ports before changing eswitch mode");
> + return -EOPNOTSUPP;
^^^^^^^^^^^
[Severity: Low]
Should this be -EBUSY rather than -EOPNOTSUPP? The condition is temporary
and goes away once the SF ports are deleted.
The same user sequence (eswitch switchdev, port add pcisf, eswitch legacy)
can also be refused one level up, in devlink_nl_eswitch_set_doit() in
net/devlink/dev.c. That check runs before the driver callback:
err = devlink_rates_check(devlink, devlink_rate_is_node,
info->extack);
if (err)
return err;
mode = nla_get_u16(info->attrs[DEVLINK_ATTR_ESWITCH_MODE]);
err = ops->eswitch_mode_set(devlink, mode, info->extack);
When rate nodes exist, devlink_rates_check() returns -EBUSY with "Rate
node(s) exists.".
ice only exports rate nodes when DCB and ADQ are off, because
ice_repr_set_tx_topology() returns early if ice_is_dcb_active(pf). As a
result, user space gets -EBUSY from devlink core with DCB off, and
-EOPNOTSUPP from the driver with DCB on, for the same operation.
-EOPNOTSUPP usually means the operation is not supported, not that it is
blocked until other objects are removed. Could tools that branch on the
errno treat a retryable condition as a missing feature?
The existing ice_has_vfs() check just above in the same function also
returns -EOPNOTSUPP for a similar temporary condition. So the patch
follows local driver style, and that mismatch with devlink core already
existed.
> + }
> +
> dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
> pf->hw.pf_id);
> xa_destroy(&pf->eswitch.reprs);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202071642.2527605-1-poros%40redhat.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session
2026-12-02 7:16 [PATCH net v7 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
2026-12-02 7:16 ` [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded Petr Oros
2026-12-02 7:16 ` [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist Petr Oros
@ 2026-12-02 7:16 ` Petr Oros
2026-12-03 8:01 ` netdev-bot+sashiko
2026-12-02 7:16 ` [PATCH net v7 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs Petr Oros
3 siblings, 1 reply; 9+ messages in thread
From: Petr Oros @ 2026-12-02 7:16 UTC (permalink / raw)
To: netdev
Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
intel-wired-lan, linux-kernel
A switchdev session leaves the uplink filters out of sync with its
netdev. ice_eswitch_setup_env() removes the multicast promisc rules, 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 rules
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 the promisc configuration of the uplink alone. Its address list
filters are still installed again during a session that starts with
the uplink up, an older behavior this patch does not change. 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. As before this patch, nothing retries a failed
promisc step on its own. A full barrier in ice_set_rx_mode() orders the
flag change of its caller before the is_running test, so a change made
while the session ends is not lost. The is_running accesses use
READ_ONCE() and WRITE_ONCE(), they are read locklessly in the Tx path.
ice_vsi_sync_fltr() releases ICE_CFG_BUSY with clear_bit_unlock() now,
like the new sections, so the stores it makes in its section are
ordered before the next one takes the bit.
ice_eswitch_setup_env() drops a filter sync that is still pending, so a
session that a reset creates again does not run the sync queued when
the old one ended. 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.
When the driver is removed during a session, the session ends in
ice_remove(), and the sync queued there needs "ice: stop the service
task before the PF is unloaded".
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. It does not change
the unicast filter that ice_eswitch_release_env() adds back either,
which is for the permanent MAC address even if the PF uses another one.
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.
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 <poros@redhat.com>
---
v7:
- The is_running accesses use READ_ONCE() and WRITE_ONCE(), and
ice_vsi_sync_fltr() releases ICE_CFG_BUSY with clear_bit_unlock(),
like the new sections.
v6:
- ice_eswitch_setup_env() drops a pending filter sync, so a session that
a reset creates again does not run the sync queued at the end of the
old one.
- Full barrier in ice_set_rx_mode() before the is_running test.
- The message no longer counts the address filters among what a session
leaves uninstalled, it says that the address list filters of a session
that starts with the uplink up are still installed again and that
nothing retries a failed promisc step on its own, and it names the
dependency on patch 1 and the permanent MAC address filter.
- Dropped Ivan's Reviewed-by because of the code changes.
All after the Sashiko reviews of v5.
v6: https://lore.kernel.org/all/20261130132107.1177185-4-poros@redhat.com/
v5: https://lore.kernel.org/all/20261127085714.1207361-4-poros@redhat.com/
v4: https://lore.kernel.org/all/20260708125755.706263-3-poros@redhat.com/
v3: https://lore.kernel.org/all/20260701133601.2118382-3-poros@redhat.com/
v2: https://lore.kernel.org/all/20260622113428.2565255-3-poros@redhat.com/
v1: https://lore.kernel.org/all/deef5756e534ef06c12d910c5305d3fd205d30a0.1781786935.git.poros@redhat.com/
---
drivers/net/ethernet/intel/ice/ice.h | 3 +-
drivers/net/ethernet/intel/ice/ice_eswitch.c | 49 +++++++++++++++++++-
drivers/net/ethernet/intel/ice/ice_main.c | 28 +++++++++--
3 files changed, 72 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 432da05c48c08a..39e261f216b561 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -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 */
};
@@ -931,7 +932,7 @@ static inline struct ice_vsi *ice_find_vsi(struct ice_pf *pf, u16 vsi_num)
*/
static inline bool ice_is_switchdev_running(struct ice_pf *pf)
{
- return pf->eswitch.is_running;
+ return READ_ONCE(pf->eswitch.is_running);
}
#define ICE_FD_STAT_CTR_BLOCK_COUNT 256
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 44ef1fcfc6e4a5..e91f126bc8a67d 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -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,15 @@ 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);
+ /* drop a pending sync, the address lists are unsynced below */
+ clear_bit(ICE_VSI_UMAC_FLTR_CHANGED, uplink_vsi->state);
+ clear_bit(ICE_VSI_MMAC_FLTR_CHANGED, 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 +114,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;
}
@@ -312,12 +351,13 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
netif_keep_dst(uplink_vsi->netdev);
- pf->eswitch.is_running = true;
+ WRITE_ONCE(pf->eswitch.is_running, true);
return 0;
err_br_offloads:
ice_eswitch_release_env(pf);
+ ice_eswitch_resync_uplink(uplink_vsi);
return -ENODEV;
}
@@ -330,7 +370,12 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
ice_eswitch_br_offloads_deinit(pf);
ice_eswitch_release_env(pf);
- pf->eswitch.is_running = false;
+ WRITE_ONCE(pf->eswitch.is_running, false);
+
+ /* after is_running is cleared, so no rx mode change is lost, its
+ * test_and_set_bit() pairs with smp_mb() in ice_set_rx_mode()
+ */
+ ice_eswitch_resync_uplink(pf->eswitch.uplink_vsi);
}
/**
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index b05eda1bf50ae7..3230ee88fafcba 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -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
*/
@@ -478,7 +489,7 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state);
set_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state);
exit:
- clear_bit(ICE_CFG_BUSY, vsi->state);
+ clear_bit_unlock(ICE_CFG_BUSY, vsi->state);
return err;
}
@@ -6054,7 +6065,14 @@ static void ice_set_rx_mode(struct net_device *netdev)
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi;
- if (!vsi || ice_is_switchdev_running(vsi->back))
+ if (!vsi)
+ return;
+
+ /* order the flag change of the caller before the is_running test,
+ * pairs with test_and_set_bit() in ice_eswitch_resync_uplink()
+ */
+ smp_mb();
+ if (ice_is_switchdev_running(vsi->back))
return;
/* Set the flags to synchronize filters
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session
2026-12-02 7:16 ` [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session Petr Oros
@ 2026-12-03 8:01 ` netdev-bot+sashiko
2026-12-03 9:51 ` Petr Oros
0 siblings, 1 reply; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 8:01 UTC (permalink / raw)
To: poros
Cc: netdev, anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev,
davem, edumazet, kuba, pabeni, aleksandr.loktionov, horms,
michal.swiatkowski, grzegorz.nitka, pmenzel, wojciech.drewek,
marcin.szycik, martyna.szapar-mudlaw, ivecera, alice.michael,
jacob.e.keller, jbrandeb, patryk.holda, sx.rinitha, aaron.ma,
intel-wired-lan, linux-kernel
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] The patch adds two new critical sections in
drivers/net/ethernet/intel/ice/ice_eswitch.c that use the ICE_CFG_BUSY…
--
ice: resync uplink filters after a switchdev session
This patch adds an ICE_VSI_ESWITCH_UPLINK bit so the eswitch owns the
uplink promisc configuration during a switchdev session. When the session
ends, it queues a full filter sync so the uplink is programmed again from
the netdev flags. It also adds a barrier in ice_set_rx_mode() and changes
how ice_vsi_sync_fltr() handles multicast promisc and VLAN pruning.
> diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> index 44ef1fcfc6e4a..e91f126bc8a67 100644
> --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> @@ -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);
> +
[ ... ]
> + 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,15 @@ 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);
> + /* drop a pending sync, the address lists are unsynced below */
> + clear_bit(ICE_VSI_UMAC_FLTR_CHANGED, uplink_vsi->state);
> + clear_bit(ICE_VSI_MMAC_FLTR_CHANGED, uplink_vsi->state);
> + clear_bit_unlock(ICE_CFG_BUSY, uplink_vsi->state);
> +
[Severity: Medium]
Both new sections, in ice_eswitch_resync_uplink() and
ice_eswitch_setup_env(), use ICE_CFG_BUSY in uplink_vsi->state as a
sleeping lock. They take it with a test_and_set_bit()/usleep_range() poll
loop and drop it with clear_bit_unlock().
Could a real lock be used here instead of a hand-built bit lock?
The new ownership handoff depends entirely on this bit for mutual
exclusion. That covers publishing ICE_VSI_ESWITCH_UPLINK, dropping the
pending UMAC/MMAC syncs and the resync when the session ends. Lockdep
can't see the bit, it has no owner tracking or fairness, and the
acquire/release ordering has to be built by hand.
The ordering is already hard to keep consistent. This version had to
switch ice_vsi_sync_fltr() to clear_bit_unlock(), but other holders of the
same bit still release it with a plain clear_bit():
drivers/net/ethernet/intel/ice/ice_main.c:ice_vlan_rx_add_vid() {
...
finish:
clear_bit(ICE_CFG_BUSY, vsi->state);
...
}
ice_vlan_rx_kill_vid() does the same.
There doesn't appear to be a concrete deadlock among the current holders:
ice_vsi_sync_fltr() from the service task, the VLAN ndos under rtnl, and
the devlink path here. But lockdep would not catch a future lock ordering
problem in these sections.
Would a per-VSI mutex around the filter and promisc state give the same
exclusion, with proper acquire/release semantics? These sections are still
there in the last patch of the series.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202071642.2527605-1-poros%40redhat.com
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session
2026-12-03 8:01 ` netdev-bot+sashiko
@ 2026-12-03 9:51 ` Petr Oros
0 siblings, 0 replies; 9+ messages in thread
From: Petr Oros @ 2026-12-03 9:51 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, intel-wired-lan, linux-kernel, Tony Nguyen,
Przemek Kitszel, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Aleksandr Loktionov, Simon Horman,
Michal Swiatkowski, Grzegorz Nitka, Paul Menzel, Wojciech Drewek,
Marcin Szycik, Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael,
Jacob Keller, Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma
On Wed, Dec 03, 2026 at 08:01:57AM +0000, Sashiko wrote:
> Would a per-VSI mutex around the filter and promisc state give the same
> exclusion, with proper acquire/release semantics?
No, it would give none. The state the two new sections touch is the state
ice_vsi_sync_fltr(), ice_vlan_rx_add_vid() and ice_vlan_rx_kill_vid()
already touch under ICE_CFG_BUSY in vsi->state. A fresh mutex taken only
by the eswitch paths would not exclude any of them and the handoff would
stop working, so all of them would have to be converted at once.
ICE_CFG_BUSY also cannot just become a mutex. ice_reset_subtask(),
ice_watchdog_subtask() and ice_update_vsi_stats() only test_bit() it to
decide whether to skip a pass, so it would first have to be split into a
lock and a separate "reconfiguration in flight" flag, across vsi->state
and pf->state both.
That is a driver wide cleanup, and this is a fix for net with four Fixes
tags reaching back to 1a1c40df2e80 ("ice: set and release switchdev
environment") from 2021, headed for stable. The review found no concrete
deadlock among the current holders, so there is nothing incorrect here to
fix, and using the serialization the driver already has is what keeps the
backport small.
> This version had to switch ice_vsi_sync_fltr() to clear_bit_unlock(),
> but other holders of the same bit still release it with a plain
> clear_bit():
Fair, and pre-existing. Both VLAN ndos write current_netdev_flags and
reprogram promisc rules in their section and release with plain
clear_bit(), which is already weak against ice_vsi_sync_fltr() without
this series. v7 tightened the one release the handoff depends on and left
the rest alone on purpose. I will send the ndos, and the full conversion
if people want it, for net-next.
Thanks,
Petr
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v7 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
2026-12-02 7:16 [PATCH net v7 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
` (2 preceding siblings ...)
2026-12-02 7:16 ` [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session Petr Oros
@ 2026-12-02 7:16 ` Petr Oros
3 siblings, 0 replies; 9+ messages in thread
From: Petr Oros @ 2026-12-02 7:16 UTC (permalink / raw)
To: netdev
Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
intel-wired-lan, linux-kernel
An 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. As before this
patch, nothing retries a failed promisc step on its own. The service
task skips a VSI that has only ICE_VSI_PROMISC_CHANGED set, so the retry
comes with the next filter sync that an rx mode change or the end of a
switchdev session starts. 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. Also tested with a trusted VF in
allmulticast over its VLANs while the PF was allmulticast, which still
receives all of its multicast. No kernel selftests cover this.
Fixes: 1273f89578f2 ("ice: Fix broken IFF_ALLMULTI handling")
Fixes: 43fbca02c2dd ("ice: fix lost multicast packets in promisc mode")
Reviewed-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Petr Oros <poros@redhat.com>
---
v6:
- No code changes. The message says that nothing retries a failed
promisc step on its own and what starts the retry (Sashiko review of
v5).
v6: https://lore.kernel.org/all/20261130132107.1177185-5-poros@redhat.com/
v5: https://lore.kernel.org/all/20261127085714.1207361-5-poros@redhat.com/
v4: https://lore.kernel.org/all/20260708125755.706263-2-poros@redhat.com/
v3: https://lore.kernel.org/all/20260701133601.2118382-2-poros@redhat.com/
v2: https://lore.kernel.org/all/20260622113428.2565255-2-poros@redhat.com/
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(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index e91f126bc8a67d..36b5612d51f31f 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -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);
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 3230ee88fafcba..6816f260b004d0 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -269,21 +269,18 @@ static bool ice_vsi_fltr_changed(struct ice_vsi *vsi)
*/
static int ice_set_promisc(struct ice_vsi *vsi, u8 promisc_m)
{
- int status;
+ unsigned long bits = promisc_m;
+ int status, bit;
if (vsi->type != ICE_VSI_PF)
return 0;
- if (ice_vsi_has_non_zero_vlans(vsi)) {
- promisc_m |= (ICE_PROMISC_VLAN_RX | ICE_PROMISC_VLAN_TX);
- status = ice_fltr_set_vlan_vsi_promisc(&vsi->back->hw, vsi,
- promisc_m);
- } else {
+ for_each_set_bit(bit, &bits, BITS_PER_BYTE) {
status = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
- promisc_m, 0);
+ BIT(bit), 0);
+ if (status && status != -EEXIST)
+ return status;
}
- if (status && status != -EEXIST)
- return status;
netdev_dbg(vsi->netdev, "set promisc filter bits for VSI %i: 0x%x\n",
vsi->vsi_num, promisc_m);
@@ -303,20 +300,30 @@ static int ice_clear_promisc(struct ice_vsi *vsi, u8 promisc_m)
if (vsi->type != ICE_VSI_PF)
return 0;
- if (ice_vsi_has_non_zero_vlans(vsi)) {
- promisc_m |= (ICE_PROMISC_VLAN_RX | ICE_PROMISC_VLAN_TX);
- status = ice_fltr_clear_vlan_vsi_promisc(&vsi->back->hw, vsi,
- promisc_m);
- } else {
- status = ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
- promisc_m, 0);
- }
+ status = ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
+ promisc_m, 0);
netdev_dbg(vsi->netdev, "clear promisc filter bits for VSI %i: 0x%x\n",
vsi->vsi_num, promisc_m);
return status;
}
+/**
+ * ice_vsi_wants_mc_promisc - check if the VSI needs the multicast promisc rules
+ * @vsi: the VSI
+ *
+ * Return: true if the VSI needs the multicast promisc rules.
+ */
+static bool ice_vsi_wants_mc_promisc(struct ice_vsi *vsi)
+{
+ if (vsi->current_netdev_flags & IFF_ALLMULTI)
+ return true;
+ if (!(vsi->current_netdev_flags & IFF_PROMISC))
+ return false;
+ return ice_is_vsi_dflt_vsi(vsi) ||
+ !ice_is_dflt_vsi_in_use(vsi->port_info);
+}
+
/**
* ice_vsi_sync_fltr - Update the VSI filter list to the HW
* @vsi: ptr to the VSI
@@ -332,6 +339,8 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
struct ice_pf *pf = vsi->back;
struct ice_hw *hw = &pf->hw;
u32 changed_flags = 0;
+ bool dflt_err = false;
+ bool promisc_changed;
int err;
if (!vsi->netdev)
@@ -399,91 +408,65 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
goto exit;
/* check for changes in promiscuous modes */
- if (changed_flags & IFF_ALLMULTI) {
- if (vsi->current_netdev_flags & IFF_ALLMULTI) {
- err = ice_set_promisc(vsi, ICE_MCAST_PROMISC_BITS);
- if (err) {
- vsi->current_netdev_flags &= ~IFF_ALLMULTI;
- goto out_promisc;
- }
- } else {
- /* !(vsi->current_netdev_flags & IFF_ALLMULTI) */
- err = ice_clear_promisc(vsi, ICE_MCAST_PROMISC_BITS);
- if (err) {
- vsi->current_netdev_flags |= IFF_ALLMULTI;
- goto out_promisc;
- }
- }
- }
-
- if (((changed_flags & IFF_PROMISC) || promisc_forced_on) ||
- test_bit(ICE_VSI_PROMISC_CHANGED, vsi->state)) {
- clear_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
- if (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;
- goto out_promisc;
- }
+ 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;
+ } else {
err = 0;
vlan_ops->dis_rx_filtering(vsi);
-
- /* promiscuous mode implies allmulticast so
- * that VSIs that are in promiscuous mode are
- * subscribed to multicast packets coming to
- * the port
- */
- err = ice_set_promisc(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 */
- if (ice_is_vsi_dflt_vsi(vsi)) {
- err = ice_clear_dflt_vsi(vsi);
- if (err) {
- netdev_err(netdev, "Error %d clearing default VSI %i Rx rule\n",
- err, vsi->vsi_num);
- vsi->current_netdev_flags |=
- IFF_PROMISC;
- goto out_promisc;
- }
+ }
+ } else if (promisc_changed) {
+ /* Clear Rx filter to remove traffic from wire */
+ if (ice_is_vsi_dflt_vsi(vsi)) {
+ err = ice_clear_dflt_vsi(vsi);
+ if (err) {
+ netdev_err(netdev, "Error %d clearing default VSI %i Rx rule\n",
+ err, vsi->vsi_num);
+ vsi->current_netdev_flags |= IFF_PROMISC;
+ set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
}
+ }
- /* 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
- */
- if (!(vsi->current_netdev_flags & IFF_ALLMULTI)) {
- err = ice_clear_promisc(vsi,
- ICE_MCAST_PROMISC_BITS);
- if (err) {
- netdev_err(netdev, "Error %d clearing multicast promiscuous on VSI %i\n",
- err, vsi->vsi_num);
- }
- }
+ /* pruning can be off even without our DFLT rule */
+ if (!(vsi->current_netdev_flags & IFF_PROMISC) &&
+ vsi->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
+ vlan_ops->ena_rx_filtering(vsi);
+ }
+
+ /* 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",
+ 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;
-
-out_promisc:
- set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
- goto exit;
out:
/* if something went wrong then set the changed flag so we try again */
set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state);
@@ -3702,17 +3685,6 @@ int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
while (test_and_set_bit(ICE_CFG_BUSY, vsi->state))
usleep_range(1000, 2000);
- /* Add multicast promisc rule for the VLAN ID to be added if
- * all-multicast is currently enabled.
- */
- if (vsi->current_netdev_flags & IFF_ALLMULTI) {
- ret = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_VLAN_PROMISC_BITS,
- vid);
- if (ret && ret != -EEXIST)
- goto finish;
- }
-
vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
/* Add a switch rule for this VLAN ID so its corresponding VLAN tagged
@@ -3720,22 +3692,7 @@ int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
*/
vlan = ICE_VLAN(be16_to_cpu(proto), vid, 0);
ret = vlan_ops->add_vlan(vsi, &vlan);
- if (ret)
- goto finish;
-
- /* If all-multicast is currently enabled and this VLAN ID is only one
- * besides VLAN-0 we have to update look-up type of multicast promisc
- * rule for VLAN-0 from ICE_SW_LKUP_PROMISC to ICE_SW_LKUP_PROMISC_VLAN.
- */
- if ((vsi->current_netdev_flags & IFF_ALLMULTI) &&
- ice_vsi_num_non_zero_vlans(vsi) == 1) {
- ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_PROMISC_BITS, 0);
- ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_VLAN_PROMISC_BITS, 0);
- }
-finish:
clear_bit(ICE_CFG_BUSY, vsi->state);
return ret;
@@ -3764,46 +3721,11 @@ int ice_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
while (test_and_set_bit(ICE_CFG_BUSY, vsi->state))
usleep_range(1000, 2000);
- ret = ice_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_VLAN_PROMISC_BITS, vid);
- if (ret) {
- netdev_err(netdev, "Error clearing multicast promiscuous mode on VSI %i\n",
- vsi->vsi_num);
- vsi->current_netdev_flags |= IFF_ALLMULTI;
- }
-
vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
- /* Make sure VLAN delete is successful before updating VLAN
- * information
- */
vlan = ICE_VLAN(be16_to_cpu(proto), vid, 0);
ret = vlan_ops->del_vlan(vsi, &vlan);
- if (ret)
- goto finish;
-
- /* Remove multicast promisc rule for the removed VLAN ID if
- * all-multicast is enabled.
- */
- if (vsi->current_netdev_flags & IFF_ALLMULTI)
- ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_VLAN_PROMISC_BITS, vid);
-
- if (!ice_vsi_has_non_zero_vlans(vsi)) {
- /* Update look-up type of multicast promisc rule for VLAN 0
- * from ICE_SW_LKUP_PROMISC_VLAN to ICE_SW_LKUP_PROMISC when
- * all-multicast is enabled and VLAN 0 is the only VLAN rule.
- */
- if (vsi->current_netdev_flags & IFF_ALLMULTI) {
- ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_VLAN_PROMISC_BITS,
- 0);
- ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
- ICE_MCAST_PROMISC_BITS, 0);
- }
- }
-finish:
clear_bit(ICE_CFG_BUSY, vsi->state);
return ret;
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread