Skip to contentSkip to conversation

ice: Fix VF-VF direction matching in drop rule in switchdev

PATCH In review Marcin Szycik 3 participants 3 messages Oct 25, 2023 – Nov 4, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Fix VF-VF direction matching in drop rule in switchdev

When adding a drop rule on a VF, rule direction is not being set, which results in it always being set to ingress (ICE_ESWITCH_FLTR_INGRESS equals 0). Because of this, drop rules added on port representors don't match any packets.

To fix it, set rule direction in drop action to egress when netdev is a port representor, otherwise set it to ingress.

Fixes 0960a27bd479 ("ice: Add direction metadata")
---
 drivers/net/ethernet/intel/ice/ice_tc_lib.c | 24 ++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_tc_lib.c +23 -1
index 0e75fc6b3c06..dd03cb69ad26 100644
@@ -670,6 +670,25 @@ static int ice_tc_setup_redirect_action(struct net_device *filter_dev,
 	return 0;
 }
 
+static int
+ice_tc_setup_drop_action(struct net_device *filter_dev,
+			 struct ice_tc_flower_fltr *fltr)
+{
+	fltr->action.fltr_act = ICE_DROP_PACKET;
+
+	if (ice_is_port_repr_netdev(filter_dev)) {
+		fltr->direction = ICE_ESWITCH_FLTR_EGRESS;
+	} else if (ice_tc_is_dev_uplink(filter_dev)) {
+		fltr->direction = ICE_ESWITCH_FLTR_INGRESS;
+	} else {
+		NL_SET_ERR_MSG_MOD(fltr->extack,
+				   "Unsupported netdevice in switchdev mode");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int ice_eswitch_tc_parse_action(struct net_device *filter_dev,
 				       struct ice_tc_flower_fltr *fltr,
 				       struct flow_action_entry *act)
@@ -678,7 +697,10 @@ static int ice_eswitch_tc_parse_action(struct net_device *filter_dev,
 
 	switch (act->id) {
 	case FLOW_ACTION_DROP:
-		fltr->action.fltr_act = ICE_DROP_PACKET;
+		err = ice_tc_setup_drop_action(filter_dev, fltr);
+		if (err)
+			return err;
+
 		break;
 
 	case FLOW_ACTION_REDIRECT:
Signature · 1 line
2.31.1
Tested-by on v1 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Wednesday, October 25, 2023 8:17 PM
To: [email protected]
Cc: [email protected]; Marcin Szycik <[email protected]>; Michal Swiatkowski <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net] ice: Fix VF-VF direction matching in drop rule in switchdev

When adding a drop rule on a VF, rule direction is not being set, which results in it always being set to ingress (ICE_ESWITCH_FLTR_INGRESS equals 0). Because of this, drop rules added on port representors don't match any packets.

To fix it, set rule direction in drop action to egress when netdev is a port representor, otherwise set it to ingress.

Quoted 7 lines
Fixes 0960a27bd479 ("ice: Add direction metadata")
---
 drivers/net/ethernet/intel/ice/ice_tc_lib.c | 24 ++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Marcin Szycik
Quoted 11 lines · Marcin Szycik

When adding a drop rule on a VF, rule direction is not being set, which results in it always being set to ingress (ICE_ESWITCH_FLTR_INGRESS equals 0). Because of this, drop rules added on port representors don't match any packets.

To fix it, set rule direction in drop action to egress when netdev is a port representor, otherwise set it to ingress.

Fixes 0960a27bd479 ("ice: Add direction metadata")