Skip to contentSkip to conversation

net: lan966x: flower: validate control flags

PATCH Applied Asbjørn Sloth Tønnesen 4 participants 7 messages Apr 24, 2024 – Apr 26, 2024

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

v2 cover net: lan966x: flower: validate control flags

This series adds flower control flags validation to the lan966x driver, and changes it from assuming that it handles all control flags, to instead reject rules if they have masked any unknown/unsupported control flags.

---
Changelog:

v2:
* Split first patch into 2 (requested by Jiri)
* Added cover letter (requested by Simon)

v1: https://lore.kernel.org/netdev/[email protected]/

Asbjørn Sloth Tønnesen (3):
net: lan966x: flower: add extack to
lan966x_tc_flower_handler_control_usage()
net: lan966x: flower: rename goto in
lan966x_tc_flower_handler_control_usage()
net: lan966x: flower: check for unsupported control flags

 .../ethernet/microchip/lan966x/lan966x_tc_flower.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 net: lan966x: flower: add extack to lan966x_tc_flower_handler_control_usage()

Define extack locally, to reduce line lengths and aid future users.

Only compile-tested.

---
 drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c +2 -1
index d696cf9dbd19..a63b83fa2823 100644
@@ -45,6 +45,7 @@ static bool lan966x_tc_is_known_etype(struct vcap_tc_flower_parse_usage *st,
 static int
 lan966x_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
 {
+	struct netlink_ext_ack *extack = st->fco->common.extack;
 	struct flow_match_control match;
 	int err = 0;
 
@@ -80,7 +81,7 @@ lan966x_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
 	return err;
 
 out:
-	NL_SET_ERR_MSG_MOD(st->fco->common.extack, "ip_frag parse error");
+	NL_SET_ERR_MSG_MOD(extack, "ip_frag parse error");
 	return err;
 }
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/3 net: lan966x: flower: rename goto in lan966x_tc_flower_handler_control_usage()

In reply to Asbjørn Sloth Tønnesen

Rename goto label, as the error message is specific to the fragment flags.

Only compile-tested.

---
 drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c +3 -3
index a63b83fa2823..8baec0cd8d95 100644
@@ -60,7 +60,7 @@ lan966x_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
 						    VCAP_KF_L3_FRAGMENT,
 						    VCAP_BIT_0);
 		if (err)
-			goto out;
+			goto bad_frag_out;
 	}
 
 	if (match.mask->flags & FLOW_DIS_FIRST_FRAG) {
@@ -73,14 +73,14 @@ lan966x_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
 						    VCAP_KF_L3_FRAG_OFS_GT0,
 						    VCAP_BIT_1);
 		if (err)
-			goto out;
+			goto bad_frag_out;
 	}
 
 	st->used_keys |= BIT_ULL(FLOW_DISSECTOR_KEY_CONTROL);
 
 	return err;
 
-out:
+bad_frag_out:
 	NL_SET_ERR_MSG_MOD(extack, "ip_frag parse error");
 	return err;
 }
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/3 net: lan966x: flower: check for unsupported control flags

In reply to Asbjørn Sloth Tønnesen

Use flow_rule_is_supp_control_flags() to reject filters with unsupported control flags.

In case any unsupported control flags are masked, flow_rule_is_supp_control_flags() sets a NL extended error message, and we return -EOPNOTSUPP.

Only compile-tested.

---
 drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c +5 -0
index 8baec0cd8d95..43913d6204e1 100644
@@ -76,6 +76,11 @@ lan966x_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
 			goto bad_frag_out;
 	}
 
+	if (!flow_rule_is_supp_control_flags(FLOW_DIS_IS_FRAGMENT |
+					     FLOW_DIS_FIRST_FRAG,
+					     match.mask->flags, extack))
+		return -EOPNOTSUPP;
+
 	st->used_keys |= BIT_ULL(FLOW_DISSECTOR_KEY_CONTROL);
 
 	return err;
Signature · 1 line
2.43.0
Reviewed-by on the v2 series
#4 lore raw
In reply to Asbjørn Sloth Tønnesen
Quoted 11 lines · Wed, Apr 24, 2024 at 02:53:37PM CEST, [email protected] wrote:

This series adds flower control flags validation to the lan966x driver, and changes it from assuming that it handles all control flags, to instead reject rules if they have masked any unknown/unsupported control flags.

---
Changelog:

v2:
* Split first patch into 2 (requested by Jiri)
* Added cover letter (requested by Simon)

set-

maintainer Reviewed-by on the v2 series
#5 lore raw
In reply to Asbjørn Sloth Tønnesen
Quoted 5 lines · Asbjørn Sloth Tønnesen

This series adds flower control flags validation to the lan966x driver, and changes it from assuming that it handles all control flags, to instead reject rules if they have masked any unknown/unsupported control flags.

For the entire series:

Quoted 23 lines

---
Changelog:

v2:
* Split first patch into 2 (requested by Jiri)
* Added cover letter (requested by Simon)

v1: https://lore.kernel.org/netdev/[email protected]/

Asbjørn Sloth Tønnesen (3):
net: lan966x: flower: add extack to
lan966x_tc_flower_handler_control_usage()
net: lan966x: flower: rename goto in
lan966x_tc_flower_handler_control_usage()
net: lan966x: flower: check for unsupported control flags

 .../ethernet/microchip/lan966x/lan966x_tc_flower.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

--
2.43.0

Signature · 1 line
/Horatiu
#6 lore raw
In reply to Asbjørn Sloth Tønnesen
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 24 Apr 2024 12:53:37 +0000 you wrote:

This series adds flower control flags validation to the lan966x driver, and changes it from assuming that it handles all control flags, to instead reject rules if they have masked any unknown/unsupported control flags.

---
Changelog:

[...]

Here is the summary with links:
- [net-next,v2,1/3] net: lan966x: flower: add extack to lan966x_tc_flower_handler_control_usage()

    https://git.kernel.org/netdev/net-next/c/505ccf890c21
  - [net-next,v2,2/3] net: lan966x: flower: rename goto in lan966x_tc_flower_handler_control_usage()
    https://git.kernel.org/netdev/net-next/c/12b8e129c409
  - [net-next,v2,3/3] net: lan966x: flower: check for unsupported control flags
    https://git.kernel.org/netdev/net-next/c/8c65e27b42fc

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html