summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
331ce43)
Fix mixing enum types enum rte_table_action_policer
and enum rte_mtr_policer_action for dereference of
policer action.
Coverity issue 323483, 323511
Fixes:
7e30e444c3e4 ("net/softnic: support flow meter action")
Fixes:
8a917ef88db7 ("net/softnic: update policer actions")
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
/* RTE_TABLE_ACTION_METER */
rule_action->mtr.mtr[0].meter_profile_id = meter_profile_id;
rule_action->mtr.mtr[0].policer[e_RTE_METER_GREEN] =
/* RTE_TABLE_ACTION_METER */
rule_action->mtr.mtr[0].meter_profile_id = meter_profile_id;
rule_action->mtr.mtr[0].policer[e_RTE_METER_GREEN] =
- (enum rte_table_action_policer)m->params.action[RTE_MTR_GREEN];
+ softnic_table_action_policer(m->params.action[RTE_MTR_GREEN]);
rule_action->mtr.mtr[0].policer[e_RTE_METER_YELLOW] =
rule_action->mtr.mtr[0].policer[e_RTE_METER_YELLOW] =
- (enum rte_table_action_policer)m->params.action[RTE_MTR_YELLOW];
+ softnic_table_action_policer(m->params.action[RTE_MTR_YELLOW]);
rule_action->mtr.mtr[0].policer[e_RTE_METER_RED] =
rule_action->mtr.mtr[0].policer[e_RTE_METER_RED] =
- (enum rte_table_action_policer)m->params.action[RTE_MTR_RED];
+ softnic_table_action_policer(m->params.action[RTE_MTR_RED]);
rule_action->mtr.tc_mask = 1;
rule_action->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
break;
rule_action->mtr.tc_mask = 1;
rule_action->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
break;
const char *name,
struct softnic_table_action_profile_params *params);
const char *name,
struct softnic_table_action_profile_params *params);
+enum rte_table_action_policer
+softnic_table_action_policer(enum rte_mtr_policer_action action);
+
+enum rte_table_action_policer
+softnic_table_action_policer(enum rte_mtr_policer_action action)
+{
+ switch (action) {
+ case MTR_POLICER_ACTION_COLOR_GREEN:
+ return RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
+
+ /* FALLTHROUGH */
+ case MTR_POLICER_ACTION_COLOR_YELLOW:
+ return RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
+
+ /* FALLTHROUGH */
+ case MTR_POLICER_ACTION_COLOR_RED:
+ return RTE_TABLE_ACTION_POLICER_COLOR_RED;
+
+ /* FALLTHROUGH */
+ default:
+ return RTE_TABLE_ACTION_POLICER_DROP;
+ }
+}
+
static int
meter_profile_check(struct rte_eth_dev *dev,
uint32_t meter_profile_id,
static int
meter_profile_check(struct rte_eth_dev *dev,
uint32_t meter_profile_id,
for (i = 0; i < RTE_MTR_COLORS; i++)
if (action_mask & (1 << i))
action.mtr.mtr[0].policer[i] =
for (i = 0; i < RTE_MTR_COLORS; i++)
if (action_mask & (1 << i))
action.mtr.mtr[0].policer[i] =
- (enum rte_table_action_policer)actions[i];
+ softnic_table_action_policer(actions[i]);
/* Re-add the rule */
status = softnic_pipeline_table_rule_add(p,
/* Re-add the rule */
status = softnic_pipeline_table_rule_add(p,