From aa736145b5c7aac1683f6c6de60f9ee934843535 Mon Sep 17 00:00:00 2001 From: Wei Zhao Date: Fri, 26 Jan 2018 16:46:51 +0800 Subject: [PATCH] net/i40e: fix flow RSS return error This patch fixes issues reported by Coverity check. Function parse_rss_action and i40e_config_rss_filter might return at wrong time which will cause error for RSS configuration and parser. Hash function variable with 32 bits width might also cause error when it needs more than 32 bits, so change this variable to 64 bits. Coverity issue: 257020, 257024, 257037 Fixes: ecad87d22383 ("net/i40e: move RSS to flow API") Signed-off-by: Wei Zhao Acked-by: Qi Zhang --- drivers/net/i40e/i40e_ethdev.c | 2 +- drivers/net/i40e/i40e_flow.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 33cdf0cd57..7e3d1a84a7 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11713,7 +11713,7 @@ i40e_config_rss_filter(struct i40e_pf *pf, sizeof(uint32_t); } - return i40e_hw_rss_hash_set(pf, &rss_conf); + i40e_hw_rss_hash_set(pf, &rss_conf); rte_memcpy(rss_info, conf, sizeof(struct i40e_rte_flow_rss_conf)); diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 34661c8a70..8bf1304d45 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -4177,6 +4177,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, struct i40e_rte_flow_rss_conf *rss_info = &pf->rss_info; uint16_t i, j, n, tmp; uint32_t index = 0; + uint64_t hf_bit = 1; NEXT_ITEM_OF_ACTION(act, actions, index); rss = act->conf; @@ -4195,7 +4196,7 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, if (action_flag) { for (n = 0; n < 64; n++) { - if (rss->rss_conf->rss_hf & (1 << n)) { + if (rss->rss_conf->rss_hf & (hf_bit << n)) { conf_info->region[0].hw_flowtype[0] = n; conf_info->region[0].flowtype_num = 1; conf_info->queue_region_number = 1; @@ -4289,9 +4290,11 @@ i40e_flow_parse_rss_action(struct rte_eth_dev *dev, } rss_config->queue_region_conf = TRUE; - return 0; } + if (rss_config->queue_region_conf) + return 0; + if (!rss || !rss->num) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, -- 2.20.1