diff options
author | Jiri Pirko <jiri@resnulli.us> | 2020-03-10 18:49:09 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-03-11 02:04:19 +0300 |
commit | a16fa289843d5d4dd7c4d8eb3b2deb15a9d2180e (patch) | |
tree | 8db1b7e7a3bbd559c06c7e996eab3dd23d7ff1dc /include/net | |
parent | 42d5fe5f9c19a3c6a74186190936df91dcab4aa4 (diff) | |
download | linux-a16fa289843d5d4dd7c4d8eb3b2deb15a9d2180e.tar.xz |
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: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/flow_offload.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 6849cb5d4883..d1b1e4aa310a 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -300,9 +300,10 @@ flow_action_first_entry_get(const struct flow_action *action) } static inline bool -flow_action_hw_stats_types_check(const struct flow_action *action, - struct netlink_ext_ack *extack, - u8 allowed_hw_stats_type) +__flow_action_hw_stats_types_check(const struct flow_action *action, + struct netlink_ext_ack *extack, + bool check_allow_bit, + enum flow_action_hw_stats_type_bit allow_bit) { const struct flow_action_entry *action_entry; @@ -311,12 +312,12 @@ flow_action_hw_stats_types_check(const struct flow_action *action, if (!flow_action_mixed_hw_stats_types_check(action, extack)) return false; 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) { NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\""); return false; - } else if (allowed_hw_stats_type != 0 && - !(action_entry->hw_stats_type & allowed_hw_stats_type)) { + } else if (check_allow_bit && + !(action_entry->hw_stats_type & BIT(allow_bit))) { NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type"); return false; } @@ -324,10 +325,19 @@ flow_action_hw_stats_types_check(const struct flow_action *action, } 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 flow_action_basic_hw_stats_types_check(const struct flow_action *action, 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 { |