net: sparx5: flower: check for unsupported control flags
authorAsbjørn Sloth Tønnesen <ast@fiberby.net>
Wed, 24 Apr 2024 12:16:25 +0000 (12:16 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 26 Apr 2024 02:35:08 +0000 (19:35 -0700)
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: Daniel Machon <daniel.machon@microchip.com>
Tested-by: Daniel Machon <daniel.machon@microchip.com>
Link: https://lore.kernel.org/r/20240424121632.459022-5-ast@fiberby.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c

index 22f6c778afb0f3bc15e094aa41ceee2efa79e475..8d67d9f24c76bf3d8584caa67effda336500866e 100644 (file)
@@ -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;