patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH] net/ice: fix wild pointer
@ 2019-11-05  3:38 Wang ShougangX
       [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
  2019-11-07  3:19 ` [dpdk-stable] [dpdk-dev] [PATCH] " Ye Xiaolong
  0 siblings, 2 replies; 10+ messages in thread
From: Wang ShougangX @ 2019-11-05  3:38 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, yahui.cao, Wang ShougangX, stable

To avoid wild pointer, pointers should be set to NULL after free them.

Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 736ccd54e..d2c754f07 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
 		rte_free(fdir_info->hash_map);
 	if (fdir_info->hash_table)
 		rte_hash_free(fdir_info->hash_table);
+
+	fdir_info->hash_map = NULL;
+	fdir_info->hash_table = NULL;
 }
 
 /*
@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
 
 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
-	     ptype++)
+	     ptype++) {
 		rte_free(hw->fdir_prof[ptype]);
+		hw->fdir_prof[ptype] = NULL;
+	}
 
 	rte_free(hw->fdir_prof);
+	hw->fdir_prof = NULL;
 }
 
 /* Remove a profile for some filter type */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR
       [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
@ 2019-11-07  2:22   ` Wang ShougangX
  2019-11-11  8:09     ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Wang ShougangX @ 2019-11-07  2:22 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, Wang ShougangX, stable

To avoid memzone reserve failure and memory leak, following
resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.

Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_ethdev.h      |  1 +
 drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index de67e5934..0a39ca6ff 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -325,6 +325,7 @@ struct ice_fdir_info {
 	struct ice_rx_queue *rxq;
 	void *prg_pkt;                 /* memory for fdir program packet */
 	uint64_t dma_addr;             /* physic address of packet memory*/
+	const struct rte_memzone *mz;
 	struct ice_fdir_filter_conf conf;
 
 	struct ice_fdir_filter_conf **hash_map;
diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 736ccd54e..31705c164 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -140,6 +140,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;
 static const struct rte_memzone *
 ice_memzone_reserve(const char *name, uint32_t len, int socket_id)
 {
+	const struct rte_memzone *mz;
+
+	mz = rte_memzone_lookup(name);
+	if (mz)
+		return mz;
+
 	return rte_memzone_reserve_aligned(name, len, socket_id,
 					   RTE_MEMZONE_IOVA_CONTIG,
 					   ICE_RING_BASE_ALIGN);
@@ -493,19 +499,23 @@ ice_fdir_setup(struct ice_pf *pf)
 	}
 	pf->fdir.prg_pkt = mz->addr;
 	pf->fdir.dma_addr = mz->iova;
+	pf->fdir.mz = mz;
 
 	err = ice_fdir_prof_alloc(hw);
 	if (err) {
 		PMD_DRV_LOG(ERR, "Cannot allocate memory for "
 			    "flow director profile.");
 		err = -ENOMEM;
-		goto fail_mem;
+		goto fail_prof;
 	}
 
 	PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.",
 		    vsi->base_queue);
 	return ICE_SUCCESS;
 
+fail_prof:
+	rte_memzone_free(pf->fdir.mz);
+	pf->fdir.mz = NULL;
 fail_mem:
 	ice_rx_queue_release(pf->fdir.rxq);
 	pf->fdir.rxq = NULL;
@@ -619,6 +629,13 @@ ice_fdir_teardown(struct ice_pf *pf)
 	ice_fdir_prof_free(hw);
 	ice_release_vsi(vsi);
 	pf->fdir.fdir_vsi = NULL;
+
+	if (pf->fdir.mz) {
+		err = rte_memzone_free(pf->fdir.mz);
+		pf->fdir.mz = NULL;
+		if (err)
+			PMD_DRV_LOG(ERR, "Failed to free memezone.");
+	}
 }
 
 static int
-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH v2 2/4] net/ice: fix removal of FDIR profile
       [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR Wang ShougangX
@ 2019-11-07  2:22   ` Wang ShougangX
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 4/4] net/ice: fix wild pointer Wang ShougangX
  3 siblings, 0 replies; 10+ messages in thread
From: Wang ShougangX @ 2019-11-07  2:22 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, Wang ShougangX, stable

The removal of FDIR profile should start from ICE_FLTR_PTYPE_NONF_IPV4_UDP.

Fixes: 109e8e06249e ("net/ice: configure HW flow director rule")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 31705c164..87634e4de 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -583,7 +583,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf)
 {
 	enum ice_fltr_ptype ptype;
 
-	for (ptype = ICE_FLTR_PTYPE_NONF_NONE;
+	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
 	     ptype++) {
 		ice_fdir_prof_rm(pf, ptype, false);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH v2 3/4] net/ice: fix FDIR counter resource release
       [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR Wang ShougangX
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
@ 2019-11-07  2:22   ` Wang ShougangX
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 4/4] net/ice: fix wild pointer Wang ShougangX
  3 siblings, 0 replies; 10+ messages in thread
From: Wang ShougangX @ 2019-11-07  2:22 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, Wang ShougangX, stable

All the counter resources should be cleaned up when teardown.

Fixes: 0f880c3df192 ("net/ice: add flow director counter resource init/release")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 87634e4de..94a6e96df 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -265,6 +265,9 @@ ice_fdir_counter_release(struct ice_pf *pf)
 	for (i = 0; i < container->index_free; i++)
 		rte_free(container->pools[i]);
 
+	TAILQ_INIT(&container->pool_list);
+	container->index_free = 0;
+
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH v2 4/4] net/ice: fix wild pointer
       [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
                     ` (2 preceding siblings ...)
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
@ 2019-11-07  2:22   ` Wang ShougangX
  3 siblings, 0 replies; 10+ messages in thread
From: Wang ShougangX @ 2019-11-07  2:22 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, Wang ShougangX, stable

To avoid wild pointer, pointers should be set to NULL after free them.

Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
Fixes: 0f880c3df192 ("net/ice: add flow director counter resource init/release")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 94a6e96df..e6e925b4e 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -165,6 +165,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)
 		if (!hw->fdir_prof)
 			return -ENOMEM;
 	}
+
+	/* To avoid wild pointer, unused field pointer should be NULL */
+	hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE] = NULL;
+
 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
 	     ptype++) {
@@ -180,9 +184,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw)
 fail_mem:
 	for (fltr_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     fltr_ptype < ptype;
-	     fltr_ptype++)
+	     fltr_ptype++) {
 		rte_free(hw->fdir_prof[fltr_ptype]);
+		hw->fdir_prof[fltr_ptype] = NULL;
+	}
+
 	rte_free(hw->fdir_prof);
+	hw->fdir_prof = NULL;
 	return -ENOMEM;
 }
 
@@ -262,8 +270,10 @@ ice_fdir_counter_release(struct ice_pf *pf)
 				&fdir_info->counter;
 	uint8_t i;
 
-	for (i = 0; i < container->index_free; i++)
+	for (i = 0; i < container->index_free; i++) {
 		rte_free(container->pools[i]);
+		container->pools[i] = NULL;
+	}
 
 	TAILQ_INIT(&container->pool_list);
 	container->index_free = 0;
@@ -412,6 +422,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
 		rte_free(fdir_info->hash_map);
 	if (fdir_info->hash_table)
 		rte_hash_free(fdir_info->hash_table);
+
+	fdir_info->hash_map = NULL;
+	fdir_info->hash_table = NULL;
 }
 
 /*
@@ -538,10 +551,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
 
 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
-	     ptype++)
+	     ptype++) {
 		rte_free(hw->fdir_prof[ptype]);
+		hw->fdir_prof[ptype] = NULL;
+	}
 
 	rte_free(hw->fdir_prof);
+	hw->fdir_prof = NULL;
 }
 
 /* Remove a profile for some filter type */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/ice: fix wild pointer
  2019-11-05  3:38 [dpdk-stable] [PATCH] net/ice: fix wild pointer Wang ShougangX
       [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
@ 2019-11-07  3:19 ` " Ye Xiaolong
  2019-11-07  3:30   ` Ye Xiaolong
  1 sibling, 1 reply; 10+ messages in thread
From: Ye Xiaolong @ 2019-11-07  3:19 UTC (permalink / raw)
  To: Wang ShougangX; +Cc: dev, qiming.yang, beilei.xing, yahui.cao, stable

On 11/05, Wang ShougangX wrote:
>To avoid wild pointer, pointers should be set to NULL after free them.
>
>Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
>Cc: stable@dpdk.org
>
>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
>---
> drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
>index 736ccd54e..d2c754f07 100644
>--- a/drivers/net/ice/ice_fdir_filter.c
>+++ b/drivers/net/ice/ice_fdir_filter.c
>@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
> 		rte_free(fdir_info->hash_map);
> 	if (fdir_info->hash_table)
> 		rte_hash_free(fdir_info->hash_table);
>+
>+	fdir_info->hash_map = NULL;
>+	fdir_info->hash_table = NULL;
> }
> 
> /*
>@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
> 
> 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
> 	     ptype < ICE_FLTR_PTYPE_MAX;
>-	     ptype++)
>+	     ptype++) {
> 		rte_free(hw->fdir_prof[ptype]);
>+		hw->fdir_prof[ptype] = NULL;
>+	}
> 
> 	rte_free(hw->fdir_prof);
>+	hw->fdir_prof = NULL;
> }
> 
> /* Remove a profile for some filter type */
>-- 
>2.17.1
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

Applied to dpdk-next-net-intel. Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/ice: fix wild pointer
  2019-11-07  3:19 ` [dpdk-stable] [dpdk-dev] [PATCH] " Ye Xiaolong
@ 2019-11-07  3:30   ` Ye Xiaolong
  2019-11-07  5:44     ` Wang, ShougangX
  0 siblings, 1 reply; 10+ messages in thread
From: Ye Xiaolong @ 2019-11-07  3:30 UTC (permalink / raw)
  To: Wang ShougangX; +Cc: dev, qiming.yang, beilei.xing, yahui.cao, stable

On 11/07, Ye Xiaolong wrote:
>On 11/05, Wang ShougangX wrote:
>>To avoid wild pointer, pointers should be set to NULL after free them.
>>
>>Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
>>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
>>Cc: stable@dpdk.org
>>
>>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
>>---
>> drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
>>index 736ccd54e..d2c754f07 100644
>>--- a/drivers/net/ice/ice_fdir_filter.c
>>+++ b/drivers/net/ice/ice_fdir_filter.c
>>@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
>> 		rte_free(fdir_info->hash_map);
>> 	if (fdir_info->hash_table)
>> 		rte_hash_free(fdir_info->hash_table);
>>+
>>+	fdir_info->hash_map = NULL;
>>+	fdir_info->hash_table = NULL;
>> }
>> 
>> /*
>>@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
>> 
>> 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
>> 	     ptype < ICE_FLTR_PTYPE_MAX;
>>-	     ptype++)
>>+	     ptype++) {
>> 		rte_free(hw->fdir_prof[ptype]);
>>+		hw->fdir_prof[ptype] = NULL;
>>+	}
>> 
>> 	rte_free(hw->fdir_prof);
>>+	hw->fdir_prof = NULL;
>> }
>> 
>> /* Remove a profile for some filter type */
>>-- 
>>2.17.1
>>
>
>Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
>
>Applied to dpdk-next-net-intel. Thanks.

Please ignore this mail, I'm still waiting for your new patchset.

Thanks,
Xiaolong

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/ice: fix wild pointer
  2019-11-07  3:30   ` Ye Xiaolong
@ 2019-11-07  5:44     ` Wang, ShougangX
  0 siblings, 0 replies; 10+ messages in thread
From: Wang, ShougangX @ 2019-11-07  5:44 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Yang, Qiming, Xing, Beilei, Cao, Yahui, stable


> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Thursday, November 7, 2019 11:30 AM
> To: Wang, ShougangX <shougangx.wang@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Cao, Yahui <yahui.cao@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/ice: fix wild pointer
> 
> On 11/07, Ye Xiaolong wrote:
> >On 11/05, Wang ShougangX wrote:
> >>To avoid wild pointer, pointers should be set to NULL after free them.
> >>
> >>Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
> >>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
> >>Cc: stable@dpdk.org
> >>
> >>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> >>---
> >> drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
> >> 1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> >>index 736ccd54e..d2c754f07 100644
> >>--- a/drivers/net/ice/ice_fdir_filter.c
> >>+++ b/drivers/net/ice/ice_fdir_filter.c
> >>@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
> >> 		rte_free(fdir_info->hash_map);
> >> 	if (fdir_info->hash_table)
> >> 		rte_hash_free(fdir_info->hash_table);
> >>+
> >>+	fdir_info->hash_map = NULL;
> >>+	fdir_info->hash_table = NULL;
> >> }
> >>
> >> /*
> >>@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
> >>
> >> 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
> >> 	     ptype < ICE_FLTR_PTYPE_MAX;
> >>-	     ptype++)
> >>+	     ptype++) {
> >> 		rte_free(hw->fdir_prof[ptype]);
> >>+		hw->fdir_prof[ptype] = NULL;
> >>+	}
> >>
> >> 	rte_free(hw->fdir_prof);
> >>+	hw->fdir_prof = NULL;
> >> }
> >>
> >> /* Remove a profile for some filter type */
> >>--
> >>2.17.1
> >>
> >
> >Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
> >
> >Applied to dpdk-next-net-intel. Thanks.
> 
> Please ignore this mail, I'm still waiting for your new patchset.
> 
OK, I will make a patchset.

> Thanks,
> Xiaolong

Thanks.
Shougang

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR
  2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR Wang ShougangX
@ 2019-11-11  8:09     ` " Ye Xiaolong
  2019-11-11  8:39       ` Wang, ShougangX
  0 siblings, 1 reply; 10+ messages in thread
From: Ye Xiaolong @ 2019-11-11  8:09 UTC (permalink / raw)
  To: Wang ShougangX; +Cc: dev, qiming.yang, beilei.xing, stable

On 11/07, Wang ShougangX wrote:
>To avoid memzone reserve failure and memory leak, following
>resources management should be added.
>- Check if the FDIR Memzone already exists before reserving.

In what scenario it will reserve FDIR memzone twice?

>- Free FDIR memzone when teardown and other failure scenarios.
>
>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
>Cc: stable@dpdk.org

No need to cc stable since commit  84dc7a95a2d3 is in this release.

>
>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
>---
> drivers/net/ice/ice_ethdev.h      |  1 +
> drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++-
> 2 files changed, 19 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
>index de67e5934..0a39ca6ff 100644
>--- a/drivers/net/ice/ice_ethdev.h
>+++ b/drivers/net/ice/ice_ethdev.h
>@@ -325,6 +325,7 @@ struct ice_fdir_info {
> 	struct ice_rx_queue *rxq;
> 	void *prg_pkt;                 /* memory for fdir program packet */
> 	uint64_t dma_addr;             /* physic address of packet memory*/
>+	const struct rte_memzone *mz;
> 	struct ice_fdir_filter_conf conf;
> 
> 	struct ice_fdir_filter_conf **hash_map;
>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
>index 736ccd54e..31705c164 100644
>--- a/drivers/net/ice/ice_fdir_filter.c
>+++ b/drivers/net/ice/ice_fdir_filter.c
>@@ -140,6 +140,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;
> static const struct rte_memzone *
> ice_memzone_reserve(const char *name, uint32_t len, int socket_id)
> {
>+	const struct rte_memzone *mz;
>+
>+	mz = rte_memzone_lookup(name);
>+	if (mz)
>+		return mz;
>+
> 	return rte_memzone_reserve_aligned(name, len, socket_id,
> 					   RTE_MEMZONE_IOVA_CONTIG,
> 					   ICE_RING_BASE_ALIGN);
>@@ -493,19 +499,23 @@ ice_fdir_setup(struct ice_pf *pf)
> 	}
> 	pf->fdir.prg_pkt = mz->addr;
> 	pf->fdir.dma_addr = mz->iova;
>+	pf->fdir.mz = mz;
> 
> 	err = ice_fdir_prof_alloc(hw);
> 	if (err) {
> 		PMD_DRV_LOG(ERR, "Cannot allocate memory for "
> 			    "flow director profile.");
> 		err = -ENOMEM;
>-		goto fail_mem;
>+		goto fail_prof;
> 	}
> 
> 	PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.",
> 		    vsi->base_queue);
> 	return ICE_SUCCESS;
> 
>+fail_prof:
>+	rte_memzone_free(pf->fdir.mz);
>+	pf->fdir.mz = NULL;
> fail_mem:
> 	ice_rx_queue_release(pf->fdir.rxq);
> 	pf->fdir.rxq = NULL;
>@@ -619,6 +629,13 @@ ice_fdir_teardown(struct ice_pf *pf)
> 	ice_fdir_prof_free(hw);
> 	ice_release_vsi(vsi);
> 	pf->fdir.fdir_vsi = NULL;
>+
>+	if (pf->fdir.mz) {
>+		err = rte_memzone_free(pf->fdir.mz);
>+		pf->fdir.mz = NULL;
>+		if (err)
>+			PMD_DRV_LOG(ERR, "Failed to free memezone.");

Be more specific about the error, like "Failed to free memzone for flow director."



Thanks,
Xiaolong

>+	}
> }
> 
> static int
>-- 
>2.17.1
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR
  2019-11-11  8:09     ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
@ 2019-11-11  8:39       ` Wang, ShougangX
  0 siblings, 0 replies; 10+ messages in thread
From: Wang, ShougangX @ 2019-11-11  8:39 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Yang, Qiming, Xing, Beilei, stable

Hi, Xiaolong

> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Monday, November 11, 2019 4:10 PM
> To: Wang, ShougangX <shougangx.wang@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and
> release in FDIR
> 
> On 11/07, Wang ShougangX wrote:
> >To avoid memzone reserve failure and memory leak, following resources
> >management should be added.
> >- Check if the FDIR Memzone already exists before reserving.
> 
> In what scenario it will reserve FDIR memzone twice?

Currently, there is no scenario.
It is a failsafe method, just like i40e_memzone_reserve().

> 
> >- Free FDIR memzone when teardown and other failure scenarios.
> >
> >Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
> >Cc: stable@dpdk.org
> 
> No need to cc stable since commit  84dc7a95a2d3 is in this release.

Got it.

> 
> >
> >Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> >---
> > drivers/net/ice/ice_ethdev.h      |  1 +
> > drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++-
> > 2 files changed, 19 insertions(+), 1 deletion(-)
> >
> >diff --git a/drivers/net/ice/ice_ethdev.h
> >b/drivers/net/ice/ice_ethdev.h index de67e5934..0a39ca6ff 100644
> >--- a/drivers/net/ice/ice_ethdev.h
> >+++ b/drivers/net/ice/ice_ethdev.h
> >@@ -325,6 +325,7 @@ struct ice_fdir_info {
> > 	struct ice_rx_queue *rxq;
> > 	void *prg_pkt;                 /* memory for fdir program packet */
> > 	uint64_t dma_addr;             /* physic address of packet memory*/
> >+	const struct rte_memzone *mz;
> > 	struct ice_fdir_filter_conf conf;
> >
> > 	struct ice_fdir_filter_conf **hash_map; diff --git
> >a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> >index 736ccd54e..31705c164 100644
> >--- a/drivers/net/ice/ice_fdir_filter.c
> >+++ b/drivers/net/ice/ice_fdir_filter.c
> >@@ -140,6 +140,12 @@ static struct ice_flow_parser
> >ice_fdir_parser_comms;  static const struct rte_memzone *
> >ice_memzone_reserve(const char *name, uint32_t len, int socket_id)  {
> >+	const struct rte_memzone *mz;
> >+
> >+	mz = rte_memzone_lookup(name);
> >+	if (mz)
> >+		return mz;
> >+
> > 	return rte_memzone_reserve_aligned(name, len, socket_id,
> > 					   RTE_MEMZONE_IOVA_CONTIG,
> > 					   ICE_RING_BASE_ALIGN);
> >@@ -493,19 +499,23 @@ ice_fdir_setup(struct ice_pf *pf)
> > 	}
> > 	pf->fdir.prg_pkt = mz->addr;
> > 	pf->fdir.dma_addr = mz->iova;
> >+	pf->fdir.mz = mz;
> >
> > 	err = ice_fdir_prof_alloc(hw);
> > 	if (err) {
> > 		PMD_DRV_LOG(ERR, "Cannot allocate memory for "
> > 			    "flow director profile.");
> > 		err = -ENOMEM;
> >-		goto fail_mem;
> >+		goto fail_prof;
> > 	}
> >
> > 	PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming
> queue %u.",
> > 		    vsi->base_queue);
> > 	return ICE_SUCCESS;
> >
> >+fail_prof:
> >+	rte_memzone_free(pf->fdir.mz);
> >+	pf->fdir.mz = NULL;
> > fail_mem:
> > 	ice_rx_queue_release(pf->fdir.rxq);
> > 	pf->fdir.rxq = NULL;
> >@@ -619,6 +629,13 @@ ice_fdir_teardown(struct ice_pf *pf)
> > 	ice_fdir_prof_free(hw);
> > 	ice_release_vsi(vsi);
> > 	pf->fdir.fdir_vsi = NULL;
> >+
> >+	if (pf->fdir.mz) {
> >+		err = rte_memzone_free(pf->fdir.mz);
> >+		pf->fdir.mz = NULL;
> >+		if (err)
> >+			PMD_DRV_LOG(ERR, "Failed to free memezone.");
> 
> Be more specific about the error, like "Failed to free memzone for flow
> director."

Got it.

> 
> 
> 
> Thanks,
> Xiaolong
> 
> >+	}
> > }
> >
> > static int
> >--
> >2.17.1
> >

Thanks.
Shougang

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, back to index

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05  3:38 [dpdk-stable] [PATCH] net/ice: fix wild pointer Wang ShougangX
     [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR Wang ShougangX
2019-11-11  8:09     ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
2019-11-11  8:39       ` Wang, ShougangX
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-07  3:19 ` [dpdk-stable] [dpdk-dev] [PATCH] " Ye Xiaolong
2019-11-07  3:30   ` Ye Xiaolong
2019-11-07  5:44     ` Wang, ShougangX

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox