Commit a16fa289 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

flow_offload: restrict driver to pass one allowed bit to flow_action_hw_stats_types_check()

The intention of this helper was to allow driver to specify one type
that it supports, so not only "any" value would pass. So make the API
more strict and allow driver to pass only 1 bit that is going
to be checked.
Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42d5fe5f
...@@ -2879,7 +2879,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, ...@@ -2879,7 +2879,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
return -EINVAL; return -EINVAL;
if (!flow_action_hw_stats_types_check(flow_action, extack, if (!flow_action_hw_stats_types_check(flow_action, extack,
FLOW_ACTION_HW_STATS_TYPE_DELAYED)) FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT))
return -EOPNOTSUPP; return -EOPNOTSUPP;
attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG; attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
...@@ -3374,7 +3374,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, ...@@ -3374,7 +3374,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
return -EINVAL; return -EINVAL;
if (!flow_action_hw_stats_types_check(flow_action, extack, if (!flow_action_hw_stats_types_check(flow_action, extack,
FLOW_ACTION_HW_STATS_TYPE_DELAYED)) FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT))
return -EOPNOTSUPP; return -EOPNOTSUPP;
flow_action_for_each(i, act, flow_action) { flow_action_for_each(i, act, flow_action) {
......
...@@ -300,9 +300,10 @@ flow_action_first_entry_get(const struct flow_action *action) ...@@ -300,9 +300,10 @@ flow_action_first_entry_get(const struct flow_action *action)
} }
static inline bool static inline bool
flow_action_hw_stats_types_check(const struct flow_action *action, __flow_action_hw_stats_types_check(const struct flow_action *action,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
u8 allowed_hw_stats_type) bool check_allow_bit,
enum flow_action_hw_stats_type_bit allow_bit)
{ {
const struct flow_action_entry *action_entry; const struct flow_action_entry *action_entry;
...@@ -311,23 +312,32 @@ flow_action_hw_stats_types_check(const struct flow_action *action, ...@@ -311,23 +312,32 @@ flow_action_hw_stats_types_check(const struct flow_action *action,
if (!flow_action_mixed_hw_stats_types_check(action, extack)) if (!flow_action_mixed_hw_stats_types_check(action, extack))
return false; return false;
action_entry = flow_action_first_entry_get(action); action_entry = flow_action_first_entry_get(action);
if (allowed_hw_stats_type == 0 && if (!check_allow_bit &&
action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_ANY) { action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_ANY) {
NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\""); NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
return false; return false;
} else if (allowed_hw_stats_type != 0 && } else if (check_allow_bit &&
!(action_entry->hw_stats_type & allowed_hw_stats_type)) { !(action_entry->hw_stats_type & BIT(allow_bit))) {
NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type"); NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");
return false; return false;
} }
return true; return true;
} }
static inline bool
flow_action_hw_stats_types_check(const struct flow_action *action,
struct netlink_ext_ack *extack,
enum flow_action_hw_stats_type_bit allow_bit)
{
return __flow_action_hw_stats_types_check(action, extack,
true, allow_bit);
}
static inline bool static inline bool
flow_action_basic_hw_stats_types_check(const struct flow_action *action, flow_action_basic_hw_stats_types_check(const struct flow_action *action,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
return flow_action_hw_stats_types_check(action, extack, 0); return __flow_action_hw_stats_types_check(action, extack, false, 0);
} }
struct flow_rule { struct flow_rule {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment