app/testpmd: fix flow flush with invalid port

Message ID 20201014083005.64428-1-junyux.jiang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series app/testpmd: fix flow flush with invalid port |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Junyu Jiang Oct. 14, 2020, 8:30 a.m. UTC
  There is no error info displayed when running flow flush
command with invalid port. This patch fixed the issue.

Fixes: 2a449871a12d ("app/testpmd: align behaviour of multi-port detach")
Cc: stable@dpdk.org

Signed-off-by: Junyu Jiang <junyux.jiang@intel.com>
---
 app/test-pmd/config.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Comments

Suanming Mou Oct. 14, 2020, 10:16 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Junyu Jiang
> Sent: Wednesday, October 14, 2020 4:30 PM
> To: dev@dpdk.org
> Cc: Beilei Xing <beilei.xing@intel.com>; Wenzhuo Lu <wenzhuo.lu@intel.com>;
> Junyu Jiang <junyux.jiang@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] app/testpmd: fix flow flush with invalid port
> 
> There is no error info displayed when running flow flush command with invalid
> port. This patch fixed the issue.
> 
> Fixes: 2a449871a12d ("app/testpmd: align behaviour of multi-port detach")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Junyu Jiang <junyux.jiang@intel.com>
> ---
>  app/test-pmd/config.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> fe31a9d52..cc4527386 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1775,16 +1775,17 @@ port_flow_flush(portid_t port_id)
>  	struct rte_port *port = &ports[port_id];
>  	int ret = 0;
> 
> +	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
> +		port_id == (portid_t)RTE_PORT_ALL)
> +		return -EINVAL;
> +

Also better to move the port initialize after this check to make the code clean?
Reviewed-by: Suanming Mou <suanmingm@nvidia.com>

>  	if (port->flow_list == NULL)
>  		return ret;
> 
>  	/* Poisoning to make sure PMDs update it in case of error. */
>  	memset(&error, 0x44, sizeof(error));
>  	if (rte_flow_flush(port_id, &error)) {
> -		ret = port_flow_complain(&error);
> -		if (port_id_is_invalid(port_id, DISABLED_WARN) ||
> -		    port_id == (portid_t)RTE_PORT_ALL)
> -			return ret;
> +		port_flow_complain(&error);
>  	}
> 
>  	while (port->flow_list) {
> --
> 2.17.1
  
Ferruh Yigit Oct. 15, 2020, 10:14 p.m. UTC | #2
On 10/14/2020 11:16 AM, Suanming Mou wrote:
> Hi,
> 
>> -----Original Message-----
>> From: dev <dev-bounces@dpdk.org> On Behalf Of Junyu Jiang
>> Sent: Wednesday, October 14, 2020 4:30 PM
>> To: dev@dpdk.org
>> Cc: Beilei Xing <beilei.xing@intel.com>; Wenzhuo Lu <wenzhuo.lu@intel.com>;
>> Junyu Jiang <junyux.jiang@intel.com>; stable@dpdk.org
>> Subject: [dpdk-dev] [PATCH] app/testpmd: fix flow flush with invalid port
>>
>> There is no error info displayed when running flow flush command with invalid
>> port. This patch fixed the issue.
>>
>> Fixes: 2a449871a12d ("app/testpmd: align behaviour of multi-port detach")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Junyu Jiang <junyux.jiang@intel.com>
>> ---
>>   app/test-pmd/config.c | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>> fe31a9d52..cc4527386 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -1775,16 +1775,17 @@ port_flow_flush(portid_t port_id)
>>   	struct rte_port *port = &ports[port_id];
>>   	int ret = 0;
>>
>> +	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
>> +		port_id == (portid_t)RTE_PORT_ALL)
>> +		return -EINVAL;
>> +
> 
> Also better to move the port initialize after this check to make the code clean?
 >

+1
  
Junyu Jiang Oct. 16, 2020, 1:27 a.m. UTC | #3
Hi,

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Friday, October 16, 2020 6:14 AM
> To: Suanming Mou <suanmingm@nvidia.com>; Jiang, JunyuX
> <junyux.jiang@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] app/testpmd: fix flow flush with invalid port
> 
> On 10/14/2020 11:16 AM, Suanming Mou wrote:
> > Hi,
> >
> >> -----Original Message-----
> >> From: dev <dev-bounces@dpdk.org> On Behalf Of Junyu Jiang
> >> Sent: Wednesday, October 14, 2020 4:30 PM
> >> To: dev@dpdk.org
> >> Cc: Beilei Xing <beilei.xing@intel.com>; Wenzhuo Lu
> >> <wenzhuo.lu@intel.com>; Junyu Jiang <junyux.jiang@intel.com>;
> >> stable@dpdk.org
> >> Subject: [dpdk-dev] [PATCH] app/testpmd: fix flow flush with invalid
> >> port
> >>
> >> There is no error info displayed when running flow flush command with
> >> invalid port. This patch fixed the issue.
> >>
> >> Fixes: 2a449871a12d ("app/testpmd: align behaviour of multi-port
> >> detach")
> >> Cc: stable@dpdk.org
> >>
> >> Signed-off-by: Junyu Jiang <junyux.jiang@intel.com>
> >> ---
> >>   app/test-pmd/config.c | 9 +++++----
> >>   1 file changed, 5 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> >> fe31a9d52..cc4527386 100644
> >> --- a/app/test-pmd/config.c
> >> +++ b/app/test-pmd/config.c
> >> @@ -1775,16 +1775,17 @@ port_flow_flush(portid_t port_id)
> >>   	struct rte_port *port = &ports[port_id];
> >>   	int ret = 0;
> >>
> >> +	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
> >> +		port_id == (portid_t)RTE_PORT_ALL)
> >> +		return -EINVAL;
> >> +
> >
> > Also better to move the port initialize after this check to make the code
> clean?
>  >
> 
> +1
I will fix in V2.
Thanks.
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index fe31a9d52..cc4527386 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1775,16 +1775,17 @@  port_flow_flush(portid_t port_id)
 	struct rte_port *port = &ports[port_id];
 	int ret = 0;
 
+	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+		port_id == (portid_t)RTE_PORT_ALL)
+		return -EINVAL;
+
 	if (port->flow_list == NULL)
 		return ret;
 
 	/* Poisoning to make sure PMDs update it in case of error. */
 	memset(&error, 0x44, sizeof(error));
 	if (rte_flow_flush(port_id, &error)) {
-		ret = port_flow_complain(&error);
-		if (port_id_is_invalid(port_id, DISABLED_WARN) ||
-		    port_id == (portid_t)RTE_PORT_ALL)
-			return ret;
+		port_flow_complain(&error);
 	}
 
 	while (port->flow_list) {