testpmd: fix init mpls struct

Message ID 1580401099-103931-1-git-send-email-orika@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series testpmd: fix init mpls struct |

Checks

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

Commit Message

Ori Kam Jan. 30, 2020, 4:18 p.m. UTC
  When adding mpls item we copy the structure, in some cases
the item is not initialized.

This commit solves this by initializing the struct.

Coverity issue: 325734
Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation")
Cc: stable@dpdk.org

Signed-off-by: Ori Kam <orika@mellanox.com>
---
 app/test-pmd/cmdline_flow.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit Jan. 31, 2020, 11:01 a.m. UTC | #1
On 1/30/2020 4:18 PM, Ori Kam wrote:
> When adding mpls item we copy the structure, in some cases
> the item is not initialized.
> 
> This commit solves this by initializing the struct.
> 
> Coverity issue: 325734
> Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ori Kam <orika@mellanox.com>
> ---
>  app/test-pmd/cmdline_flow.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index e99e24c..42d90f5 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -4576,7 +4576,9 @@ static int comp_set_raw_index(struct context *, const struct token *,
>  	struct rte_flow_item_gre gre = {
>  		.protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
>  	};
> -	struct rte_flow_item_mpls mpls;
> +	struct rte_flow_item_mpls mpls = {
> +		.ttl = 0

I wasn't aware that this is valid 'c' syntax, no ',' at the end.

Anyway, I guess this patch has been superseded by following, right?
https://patches.dpdk.org/patch/65383/
"app/testpmd: fix uninitialized members of mpls"

> +	};
>  	uint8_t *header;
>  	int ret;
>  
>
  
Ori Kam Feb. 2, 2020, 8:05 a.m. UTC | #2
Hi Ferruh,

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Friday, January 31, 2020 1:01 PM
> To: Ori Kam <orika@mellanox.com>; Wenzhuo Lu <wenzhuo.lu@intel.com>;
> Jingjing Wu <jingjing.wu@intel.com>; Bernard Iremonger
> <bernard.iremonger@intel.com>
> Cc: dev@dpdk.org; Slava Ovsiienko <viacheslavo@mellanox.com>;
> stable@dpdk.org
> Subject: Re: [PATCH] testpmd: fix init mpls struct
> 
> On 1/30/2020 4:18 PM, Ori Kam wrote:
> > When adding mpls item we copy the structure, in some cases
> > the item is not initialized.
> >
> > This commit solves this by initializing the struct.
> >
> > Coverity issue: 325734
> > Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Ori Kam <orika@mellanox.com>
> > ---
> >  app/test-pmd/cmdline_flow.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> > index e99e24c..42d90f5 100644
> > --- a/app/test-pmd/cmdline_flow.c
> > +++ b/app/test-pmd/cmdline_flow.c
> > @@ -4576,7 +4576,9 @@ static int comp_set_raw_index(struct context *,
> const struct token *,
> >  	struct rte_flow_item_gre gre = {
> >  		.protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
> >  	};
> > -	struct rte_flow_item_mpls mpls;
> > +	struct rte_flow_item_mpls mpls = {
> > +		.ttl = 0
> 
> I wasn't aware that this is valid 'c' syntax, no ',' at the end.
> 
> Anyway, I guess this patch has been superseded by following, right?
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatches.d
> pdk.org%2Fpatch%2F65383%2F&amp;data=02%7C01%7Corika%40mellanox.co
> m%7C413906e79d3942d283f108d7a63ce6d7%7Ca652971c7d2e4d9ba6a4d149
> 256f461b%7C0%7C0%7C637160652819605813&amp;sdata=MxJo%2BJ2t4TlvT%
> 2BM0SzkPzAX9m8IJUtGIfUiVa3AzXaY%3D&amp;reserved=0
> "app/testpmd: fix uninitialized members of mpls"
> 

Yes you are correct.
Sorry for incorrect versions,
I will send the relevant patch with version 2.

> > +	};
> >  	uint8_t *header;
> >  	int ret;
> >
> >
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e99e24c..42d90f5 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -4576,7 +4576,9 @@  static int comp_set_raw_index(struct context *, const struct token *,
 	struct rte_flow_item_gre gre = {
 		.protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
 	};
-	struct rte_flow_item_mpls mpls;
+	struct rte_flow_item_mpls mpls = {
+		.ttl = 0
+	};
 	uint8_t *header;
 	int ret;