From: Linkui Xiao <redacted>
ice_eswitch_br_set_pvid() puts the VF VSI into port VLAN mode with
ice_vf_vsi_enable_port_vlan() before it programs the port VLAN itself.
Both error paths below that point return the error code straight away,
so nothing is undone when set_port_vlan() or add_vlan() fails.
The stale port VLAN is the more visible half of the problem.
set_port_vlan() turns on Rx VLAN pruning in the VSI context and relies
on the add_vlan() call right after it to install the matching prune
filter, so a failing add_vlan() leaves the VF VSI pruning away every
packet it receives, while port->pvid stays 0 and the bridge is told the
VLAN was not offloaded.
The VLAN ops table is never restored either.
ice_vf_vsi_disable_port_vlan() is only ever called from
ice_eswitch_br_clear_pvid(), which is reached from
ice_eswitch_br_vlan_cleanup() only when port->pvid matches the VLAN
being removed. Neither the failed VLAN, which was never inserted into
port->vlans, nor a port->pvid value ever got that far, so the VSI keeps
the port VLAN flavour of its inner and outer vlan_ops until the VF VSI
is rebuilt:
dis_rx_filtering() turns into a no-op and, in Double VLAN Mode, the
inner add_vlan() and del_vlan() stop doing anything.
Unwind both steps the way ice_eswitch_br_clear_pvid() does: clear the
port VLAN from the VSI context when it was already programmed, then
hand the VLAN ops back to ice_port_vlan_off().
Fixes: 2946204b3fa8 ("ice: implement bridge port vlan")
Cc: stable@vger.kernel.org
Signed-off-by: Linkui Xiao <redacted>
---
drivers/net/ethernet/intel/ice/ice_eswitch_br.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
index 1d8a6b95ccda..53ce98ba7007 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
@@ -679,16 +679,23 @@ ice_eswitch_br_set_pvid(struct ice_esw_br_port *port,
vlan_ops = ice_get_compat_vsi_vlan_ops(port->vsi);
err = vlan_ops->set_port_vlan(port->vsi, &port_vlan);
if (err)
- return err;
+ goto err_disable_port_vlan;
err = vlan_ops->add_vlan(port->vsi, &port_vlan);
if (err)
- return err;
+ goto err_clear_port_vlan;
ice_eswitch_br_port_vlans_flush(port);
port->pvid = vlan->vid;
return 0;
+
+err_clear_port_vlan:
+ vlan_ops->clear_port_vlan(port->vsi);
+err_disable_port_vlan:
+ ice_vf_vsi_disable_port_vlan(port->vsi);
+
+ return err;
}
static struct ice_esw_br_vlan *
--
2.25.1