From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1E47FA0093; Thu, 21 May 2020 16:12:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CB9371D6CA; Thu, 21 May 2020 16:12:46 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 99CD62E81 for ; Thu, 21 May 2020 16:12:45 +0200 (CEST) IronPort-SDR: X247mLiePvR1pNhtZzz6M4bZyMCsfaOSpYgfzy/YS7U3EZNHUvDmmhkjNFaQv33IFMZb19JCQ9 WeISOY/lK8wg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2020 07:12:44 -0700 IronPort-SDR: 5vpF6dju3NE4qg9zitEPoU8yQJAtV2TitX+P2+zke6s4F3iwQCMD4A3liQkDC9hrhWTZVQ0Yfy 1Ql0cryj/KGg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,417,1583222400"; d="scan'208";a="300311396" Received: from npg-dpdk-cvl-jeffguo-01.sh.intel.com ([10.67.111.128]) by fmsmga002.fm.intel.com with ESMTP; 21 May 2020 07:12:42 -0700 From: Jeff Guo To: beilei.xing@intel.com, qi.z.zhang@intel.com, jingjing.wu@intel.com, qiming.yang@intel.com Cc: xiaolong.ye@intel.com, dev@dpdk.org, jia.guo@intel.com Date: Thu, 21 May 2020 22:11:51 -0400 Message-Id: <20200522021151.55835-1-jia.guo@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] net/iavf: fix invalid flow access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When hash init, the default rss rules would be added, while hash uninit, the default rss rules should be deleted. Add the missing part in the hash uninit process. Also add invalid flow checking func in iavf generic flow to avoid the error of "Cannot access memory at address 0xXXXXXX" occur. Fixes: 5ea614254332 ("net/iavf: fix VF reset for RSS") Fixes: ff2d0c345c3b ("net/iavf: support generic flow API") Signed-off-by: Jeff Guo --- drivers/net/iavf/iavf_generic_flow.c | 24 ++++++++++++++++++++---- drivers/net/iavf/iavf_hash.c | 12 ++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/net/iavf/iavf_generic_flow.c b/drivers/net/iavf/iavf_generic_flow.c index c0c67d0c7..b6c26c4fd 100644 --- a/drivers/net/iavf/iavf_generic_flow.c +++ b/drivers/net/iavf/iavf_generic_flow.c @@ -935,6 +935,22 @@ iavf_flow_create(struct rte_eth_dev *dev, return flow; } +static bool +iavf_flow_is_valid(struct rte_flow *flow) +{ + struct iavf_flow_engine *engine; + void *temp; + + if (flow && flow->engine) { + TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) { + if (engine == flow->engine) + return true; + } + } + + return false; +} + static int iavf_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, @@ -945,10 +961,10 @@ iavf_flow_destroy(struct rte_eth_dev *dev, struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); int ret = 0; - if (!flow || !flow->engine || !flow->engine->destroy) { + if (!iavf_flow_is_valid(flow) || !flow->engine->destroy) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, - NULL, "Invalid flow"); + NULL, "Invalid flow destroy"); return -rte_errno; } @@ -1002,10 +1018,10 @@ iavf_flow_query(struct rte_eth_dev *dev, IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct rte_flow_query_count *count = data; - if (!flow || !flow->engine || !flow->engine->query_count) { + if (!iavf_flow_is_valid(flow) || !flow->engine->query_count) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, - NULL, "Invalid flow"); + NULL, "Invalid flow query"); return -rte_errno; } diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index 56ab170d8..af528863b 100644 --- a/drivers/net/iavf/iavf_hash.c +++ b/drivers/net/iavf/iavf_hash.c @@ -887,7 +887,7 @@ static struct iavf_flow_parser iavf_hash_parser = { }; static int -iavf_hash_default_set(struct iavf_adapter *ad) +iavf_hash_default_set(struct iavf_adapter *ad, bool add) { struct virtchnl_rss_cfg *rss_cfg; uint16_t i; @@ -902,9 +902,10 @@ iavf_hash_default_set(struct iavf_adapter *ad) rss_cfg->proto_hdrs = *iavf_hash_default_hdrs[i]; rss_cfg->rss_algorithm = VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC; - ret = iavf_add_del_rss_cfg(ad, rss_cfg, true); + ret = iavf_add_del_rss_cfg(ad, rss_cfg, add); if (ret) { - PMD_DRV_LOG(ERR, "fail to add RSS configure"); + PMD_DRV_LOG(ERR, "fail to %s RSS configure", + add ? "add" : "delete"); rte_free(rss_cfg); return ret; } @@ -941,7 +942,7 @@ iavf_hash_init(struct iavf_adapter *ad) return ret; } - ret = iavf_hash_default_set(ad); + ret = iavf_hash_default_set(ad, true); if (ret) { PMD_DRV_LOG(ERR, "fail to set default RSS"); iavf_unregister_parser(parser, ad); @@ -1222,6 +1223,9 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *ad, static void iavf_hash_uninit(struct iavf_adapter *ad) { + if (iavf_hash_default_set(ad, false)) + PMD_DRV_LOG(ERR, "fail to delete default RSS"); + iavf_unregister_parser(&iavf_hash_parser, ad); } -- 2.20.1