app/testpmd: fix flow list command
PATCH 1/1 app/testpmd: fix flow list command
This patch fixes the 'flow list <port id>' command which caused a segfault when passing the action or item 'type' field instead of the action or item struct pointer in the call to rte_flow_conv.
--- app/test-pmd/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c +2 -2
@@ -1354,7 +1354,7 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n])while (item->type !=RTE_FLOW_ITEM_TYPE_END ) {if (rte_flow_conv (RTE_FLOW_CONV_OP_ITEM_NAME_PTR , &name,sizeof (name), - (void *)(uintptr_t )item->type, + (void *)(uintptr_t )item,NULL ) <=0 ) name ="[UNKNOWN]" ;if (item->type !=RTE_FLOW_ITEM_TYPE_VOID )
@@ -1365,7 +1365,7 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n])while (action->type !=RTE_FLOW_ACTION_TYPE_END ) {if (rte_flow_conv (RTE_FLOW_CONV_OP_ACTION_NAME_PTR , &name,sizeof (name), - (void *)(uintptr_t )action->type, + (void *)(uintptr_t )action,NULL ) <=0 ) name ="[UNKNOWN]" ;if (action->type !=RTE_FLOW_ACTION_TYPE_VOID )
Signature · 1 line
2.16.2
Hi John
Quoted 7 lines · John Daley
This patch fixes the 'flow list <port id>' command which caused a segfault when passing the action or item 'type' field instead of the action or item struct pointer in the call to
rte_flow_conv.Fixes 7d94dcedf7ce ("app/testpmd: rely on flow API conversion function")Signed-off-by John Daley <[email protected]>
That bug was introduced by a broken fix, it wasn't present in the original patch, please see yesterday's discussion [1].
RTE_FLOW_CONV_OP_(ITEM|ACTION)_NAME[_PTR] operations are documented as using an integer type (enum rte_flow_item_type) cast as (void *) for src because they convert item/action *types* to corresponding strings, i.e. no need to allocate temporary items/actions just to retrieve their names. I thought it would be more versatile and efficient that way.
[1] "ethdev: fix flow API item/action name conversion"
https://mails.dpdk.org/archives/dev/2018-October/115054.html
Quoted 9 lines
--- app/test-pmd/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)app/test-pmd/config.c +0
-0
app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) · line 1357
Quoted 5 lines
app/test-pmd/config.c +1
-1@@ -1354,7 +1354,7 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n])while (item->type !=RTE_FLOW_ITEM_TYPE_END ) { if (rte_flow_conv(RTE_FLOW_CONV_OP_ITEM_NAME_PTR, &name, sizeof(name), - (void *)(uintptr_t)item->type, + (void *)(uintptr_t)item,
Also, while it does work because type is the first field, it should have read "&item->type" for correctness. Anyway this patch shouldn't be needed assuming the broken fix is reverted.
app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) · line 1368
Quoted 9 lines
app/test-pmd/config.c +1
-1NULL) <= 0) name ="[UNKNOWN]" ;if (item->type !=RTE_FLOW_ITEM_TYPE_VOID )@@ -1365,7 +1365,7 @@ port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n])while (action->type !=RTE_FLOW_ACTION_TYPE_END ) { if (rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), - (void *)(uintptr_t)action->type, + (void *)(uintptr_t)action,
Ditto.
Quoted 6 lines
app/test-pmd/config.c +0
-0NULL) <= 0) name ="[UNKNOWN]" ;if (action->type !=RTE_FLOW_ACTION_TYPE_VOID )Signature · 1 line
2.16.2
Thanks.
Signature · 2 lines
Adrien Mazarguil 6WIND
Hi Adrien,
You are correct, the bug is not where we thought it is, moreover the fix breaks
the CLI and should be rejected.
We investigated more and found that the bug is in the port_flow_query routine Which passes an incorrect argument to rte_flow_conv as follows:
ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), action, &error); While it should pass onlt the action type as follows: ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), (void *)(uintptr_t)action->type, &error); As done in port_flow_list routine (which works) if (rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), (void *)(uintptr_t)action->type, NULL) <= 0)
And according to the parameters description of rte_flow_conv_name (called by rte_flow_conv):
* @param[in] src
* Depending on @p is_action, source pattern item or action type cast as a
* pointer.
Modifying port_flow_query accordingly solves the issue. I will issue a new patch tonight.
Moti
Quoted 84 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Adrien Mazarguil
Sent: Wednesday, October 10, 2018 11:38 AM
To: John Daley <[email protected]>
Cc: [email protected]; Ferruh Yigit <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: fix flow list commandHi John
Quoted 8 lines · John Daley
This patch fixes the 'flow list <port id>' command which caused a segfault when passing the action or item 'type' field instead of the action or item struct pointer in the call to
rte_flow_conv.Fixes 7d94dcedf7ce ("app/testpmd: rely on flow API conversionfunction")
Signed-off-by John Daley <[email protected]>That bug was introduced by a broken fix, it wasn't present in the original patch, please see yesterday's discussion [1].
RTE_FLOW_CONV_OP_(ITEM|ACTION)_NAME[_PTR] operations are
documented as using an integer type (enumrte_flow_item_type) cast as (void *) for src because they convert item/action *types* to corresponding strings, i.e. no need to allocate temporary items/actions just to retrieve their names. I thought it would be more versatile and efficient that way.[1] "ethdev: fix flow API item/action name conversion"
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fma
ils.dpdk.org%2Farchives%2Fdev%2F2018- October%2F115054.html&data=02%7C01%7Cmotih%40mellanox.com%7 C76b627327b134664eabe08d62e8bba68%7Ca652971c7d2e4d9ba6a4d149256f 461b%7C0%7C0%7C636747575020110564&sdata=nRUfdIhoS%2F2Rm76y osDvBlttJlvcGJDB1egot8pql%2FY%3D&reserved=0app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const
Quoted 9 lines
--- app/test-pmd/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-0
86c205806..2ce40f3e1100644app/test-pmd/config.c +0
-0@@ -1354,7 +1354,7 @@ port_flow_list(portid_t port_id, uint32_t n, const
uint32_tgroup[n])app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const · line 1355
Quoted 2 lines
app/test-pmd/config.c +0
-0while (item->type !=RTE_FLOW_ITEM_TYPE_END ) { if(rte_flow_conv(RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) · line 1357
Quoted 3 lines
app/test-pmd/config.c +1
-1&name,sizeof (name), - (void *)(uintptr_t)item->type, + (void *)(uintptr_t)item,Also, while it does work because type is the first field, it should have read "
&item->type" for correctness. Anyway this patch shouldn't be needed assuming the broken fix is reverted.app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n])
Quoted 3 lines
app/test-pmd/config.c +0
-0NULL) <= 0) name ="[UNKNOWN]" ; if (item->type != RTE_FLOW_ITEM_TYPE_VOID) @@-1365,7 +1365,7 @@
app/test-pmd/config.c
Quoted 3 lines
port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n])app/test-pmd/config.c +0
-0while (action->type !=RTE_FLOW_ACTION_TYPE_END ) { if(rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
app/test-pmd/config.c port_flow_list(portid_t port_id, uint32_t n, const uint32_t group[n]) · line 1368
Quoted 3 lines
app/test-pmd/config.c +1
-1&name,sizeof (name), - (void *)(uintptr_t)action->type, + (void *)(uintptr_t)action,Ditto.
Quoted 6 lines
app/test-pmd/config.c +0
-1NULL) <= 0) name ="[UNKNOWN]" ;if (action->type !=RTE_FLOW_ACTION_TYPE_VOID ) --2.16.2
Thanks.
--
Adrien Mazarguil
6WIND
Quoted 16 lines · Mordechay Haimovsky
Hi Adrien,
You are correct, the bug is not where we thought it is, moreover the fix breaks
the CLI and should be rejected.
We investigated more and found that the bug is in theport_flow_queryroutine Which passes an incorrect argument torte_flow_convas follows:ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), action, &error); While it should pass onlt the action type as follows: ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), (void *)(uintptr_t)action->type, &error); As done in port_flow_list routine (which works) if (rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, &name, sizeof(name), (void *)(uintptr_t)action->type, NULL) <= 0)
Quoted 7 lines
And according to the parameters description of
rte_flow_conv_name(called byrte_flow_conv):
* @param[in] src
* Depending on @pis_action, source pattern item or action type cast as a
* pointer.Modifying
port_flow_queryaccordingly solves the issue. I will issue a new patch tonight.
Indeed, I confirm this is the right bug to address (and seems like I did not validate rte_flow_query() properly.) Thanks for taking care of it!
Signature · 2 lines
Adrien Mazarguil 6WIND