diff mbox series

[net-next,2/2] net: sparx5: flower: check for unsupported control flags

Message ID 20240423102728.228765-2-ast@fiberby.net (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] net: lan966x: cleanup lan966x_tc_flower_handler_control_usage() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/apply fail Patch does not apply to net-next-1

Commit Message

Asbjørn Sloth Tønnesen April 23, 2024, 10:27 a.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/microchip/sparx5/sparx5_tc_flower.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Daniel Machon April 23, 2024, 11:16 a.m. UTC | #1
> 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/microchip/sparx5/sparx5_tc_flower.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
> index d846edd77a01..f81d89f8f620 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
> @@ -197,6 +197,11 @@ sparx5_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
>                 }
>         }
> 
> +       if (!flow_rule_is_supp_control_flags(FLOW_DIS_IS_FRAGMENT |
> +                                            FLOW_DIS_FIRST_FRAG,
> +                                            mt.mask->flags, extack))
> +               return -EOPNOTSUPP;
> +
>         st->used_keys |= BIT_ULL(FLOW_DISSECTOR_KEY_CONTROL);
> 
>         return err;
> --
> 2.43.0

As mentioned in patch #1, use supp_flags here. Otherwise looks
good.

/Daniel
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
index d846edd77a01..f81d89f8f620 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
@@ -197,6 +197,11 @@  sparx5_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
 		}
 	}
 
+	if (!flow_rule_is_supp_control_flags(FLOW_DIS_IS_FRAGMENT |
+					     FLOW_DIS_FIRST_FRAG,
+					     mt.mask->flags, extack))
+		return -EOPNOTSUPP;
+
 	st->used_keys |= BIT_ULL(FLOW_DISSECTOR_KEY_CONTROL);
 
 	return err;