diff mbox series

[net-next] net/mlx5e: flower: check for unsupported control flags

Message ID 20240417135110.99900-1-ast@fiberby.net (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net/mlx5e: flower: check for unsupported control flags | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 926 this patch: 926
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: linux-rdma@vger.kernel.org
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-18--00-00 (tests: 961)

Commit Message

Asbjørn Sloth Tønnesen April 17, 2024, 1:51 p.m. UTC
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.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Horman April 19, 2024, 12:24 p.m. UTC | #1
On Wed, Apr 17, 2024 at 01:51:09PM +0000, Asbjørn Sloth Tønnesen wrote:
> 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.
> 
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>

Reviewed-by: Simon Horman <horms@kernel.org>
Jianbo Liu April 22, 2024, 6:58 a.m. UTC | #2
On Wed, 2024-04-17 at 13:51 +0000, Asbjørn Sloth Tønnesen wrote:
> 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.
> 
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index aeb32cb27182..5019280cfcdd 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -2819,6 +2819,11 @@ static int __parse_cls_flower(struct
> mlx5e_priv *priv,
>                         else
>                                 *match_level = MLX5_MATCH_L3;
>                 }
> +
> +               if
> (!flow_rule_is_supp_control_flags(FLOW_DIS_IS_FRAGMENT |
> +                                                   
> FLOW_DIS_FIRST_FRAG,

We reject FLOW_DIS_FIRST_FRAG at several lines above. I think you can
remove those lines and add FLOW_DIS_IS_FRAGMENT as the only supported
flag here.

Thanks!
Jianbo

> +                                                    match.mask-
> >flags, extack))
> +                       return -EOPNOTSUPP;
>         }
>  
>         if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
Asbjørn Sloth Tønnesen April 22, 2024, 8:31 a.m. UTC | #3
Hi Jianbo,

Thank you for the review.

On 4/22/24 6:58 AM, Jianbo Liu wrote:
> On Wed, 2024-04-17 at 13:51 +0000, Asbjørn Sloth Tønnesen wrote:
>> 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.
>>
>> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
>> ---
>>   drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> index aeb32cb27182..5019280cfcdd 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> @@ -2819,6 +2819,11 @@ static int __parse_cls_flower(struct
>> mlx5e_priv *priv,
>>                          else
>>                                  *match_level = MLX5_MATCH_L3;
>>                  }
>> +
>> +               if
>> (!flow_rule_is_supp_control_flags(FLOW_DIS_IS_FRAGMENT |
>> +
>> FLOW_DIS_FIRST_FRAG,
> 
> We reject FLOW_DIS_FIRST_FRAG at several lines above. I think you can
> remove those lines and add FLOW_DIS_IS_FRAGMENT as the only supported
> flag here.

Sure, I can do that. I originally kept it, since the error message was
more user-friendly.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index aeb32cb27182..5019280cfcdd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2819,6 +2819,11 @@  static int __parse_cls_flower(struct mlx5e_priv *priv,
 			else
 				*match_level = MLX5_MATCH_L3;
 		}
+
+		if (!flow_rule_is_supp_control_flags(FLOW_DIS_IS_FRAGMENT |
+						     FLOW_DIS_FIRST_FRAG,
+						     match.mask->flags, extack))
+			return -EOPNOTSUPP;
 	}
 
 	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {