]> git.droids-corp.org - dpdk.git/commitdiff
net/iavf: fix flow access
authorJeff Guo <jia.guo@intel.com>
Fri, 22 May 2020 02:11:51 +0000 (22:11 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 22 May 2020 15:10:15 +0000 (17:10 +0200)
Add invalid flow checking func in iavf generic flow to avoid the error
of "Cannot access memory at address 0xXXXXXX" occur.

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.

Fixes: 5ea614254332 ("net/iavf: fix VF reset for RSS")
Fixes: ff2d0c345c3b ("net/iavf: support generic flow API")
Signed-off-by: Jeff Guo <jia.guo@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Tested-by: Yuan Peng <yuan.peng@intel.com>
drivers/net/iavf/iavf_generic_flow.c
drivers/net/iavf/iavf_hash.c

index c0c67d0c7876766a24d1cf676848d069dbc43eba..b6c26c4fdc0fb1b4cff4f5fc282c41e3a481dda3 100644 (file)
@@ -935,6 +935,22 @@ free_flow:
        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;
        }
 
index 56ab170d80d6631fe88d911a1ab43d99135d6e26..af528863b0fd5a32125eff5b0ae117a44ded376f 100644 (file)
@@ -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);
 }