Re: [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist
From: netdev-bot+sashiko
Date: Thu Dec 03 2026 - 03:02:18 EST
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