When the uplink PF is promiscuous, ice_vsi_sync_fltr() installs an
ICE_SW_LKUP_DFLT catch-all Rx rule on the uplink VSI. Entering switchdev
re-affirms it through the idempotent ice_set_dflt_vsi(), but
ice_eswitch_release_env() removed both the Rx and Tx DFLT rules
unconditionally on teardown. That clobbered a promisc-owned Rx rule: it
disappeared while IFF_PROMISC was still set and the sync path was not
retriggered, leaving the uplink without the catch-all the netdev
requested.

Skip the Rx DFLT removal when the uplink is promiscuous, both in
ice_eswitch_release_env() and the err_def_tx unwind of
ice_eswitch_setup_env(); the Tx leg, owned by switchdev, is still removed.
Test the live netdev->flags, the same value ena_rx_filtering() ->
ice_cfg_vlan_pruning() above already keys on, so the preserved rule and
the pruning state stay consistent, including for a promisc change made
while switchdev ran (which never reached the gated filter sync).

Fixes: 5c07be96d8b3 ("ice: Avoid setting default Rx VSI twice in switchdev 
setup")
Reviewed-by: Marcin Szycik <[email protected]>
Reviewed-by: Aleksandr Loktionov <[email protected]>
Signed-off-by: Petr Oros <[email protected]>
---
v4:
- No code change, added Marcin's and Aleksandr's Reviewed-by.

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.po...@redhat.com/
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index c30e27bbfe6e25..07e2016fb9481f 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -66,8 +66,10 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
        ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, false,
                         ICE_FLTR_TX);
 err_def_tx:
-       ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, false,
-                        ICE_FLTR_RX);
+       /* keep the Rx DFLT rule if the uplink is promiscuous (see release_env) 
*/
+       if (!(uplink_vsi->netdev->flags & IFF_PROMISC))
+               ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx,
+                                false, ICE_FLTR_RX);
 err_def_rx:
        ice_vsi_del_vlan_zero(uplink_vsi);
 err_vlan_zero:
@@ -276,8 +278,16 @@ static void ice_eswitch_release_env(struct ice_pf *pf)
        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);
+
+       /* Keep the Rx DFLT rule if the uplink is promiscuous; it must outlive
+        * the session. Test the live netdev->flags, the same value
+        * ena_rx_filtering() -> ice_cfg_vlan_pruning() above keys its decision
+        * on, so the preserved DFLT rule and the pruning state stay consistent.
+        */
+       if (!(uplink_vsi->netdev->flags & IFF_PROMISC))
+               ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx,
+                                false, ICE_FLTR_RX);
+
        ice_fltr_add_mac_and_broadcast(uplink_vsi,
                                       uplink_vsi->port_info->mac.perm_addr,
                                       ICE_FWD_TO_VSI);
-- 
2.54.0

Reply via email to