app/testpmd: fix ether header size calculation

Message ID 20190408101236.18076-1-pbhagavatula@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix ether header size calculation |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Pavan Nikhilesh Bhagavatula April 8, 2019, 10:13 a.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Fix ether header size calculation in Tx only mode.

Coverity issue: 337684
Fixes: 01b645dcff7f ("app/testpmd: move txonly prepare in separate function")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 app/test-pmd/txonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Bruce Richardson April 8, 2019, 11:57 a.m. UTC | #1
On Mon, Apr 08, 2019 at 10:13:04AM +0000, Pavan Nikhilesh Bhagavatula wrote:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Fix ether header size calculation in Tx only mode.
> 
> Coverity issue: 337684
> Fixes: 01b645dcff7f ("app/testpmd: move txonly prepare in separate function")
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  app/test-pmd/txonly.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
> index 66e63788a..a9c27be3e 100644
> --- a/app/test-pmd/txonly.c
> +++ b/app/test-pmd/txonly.c
> @@ -189,7 +189,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
>  	/*
>  	 * Copy headers in first packet segment(s).
>  	 */
> -	copy_buf_to_pkt(eth_hdr, sizeof(eth_hdr), pkt, 0);
> +	copy_buf_to_pkt(eth_hdr, sizeof(struct ether_hdr), pkt, 0);

Would a simpler fix not be to change "sizeof(eth_hdr)" to
"sizeof(*eth_hdr)"? It would keep the logical connection between the
destination and destination size, and make future refactoring easier.

/Bruce
  
Pavan Nikhilesh Bhagavatula April 8, 2019, 12:28 p.m. UTC | #2
>-----Original Message-----
>From: Bruce Richardson <bruce.richardson@intel.com>
>Sent: Monday, April 8, 2019 5:28 PM
>To: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
>Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; thomas@monjalon.net;
>dev@dpdk.org
>Subject: [EXT] Re: [dpdk-dev] [PATCH] app/testpmd: fix ether header size
>calculation
>
>External Email
>
>----------------------------------------------------------------------
>On Mon, Apr 08, 2019 at 10:13:04AM +0000, Pavan Nikhilesh Bhagavatula wrote:
>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>
>> Fix ether header size calculation in Tx only mode.
>>
>> Coverity issue: 337684
>> Fixes: 01b645dcff7f ("app/testpmd: move txonly prepare in separate
>> function")
>>
>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> ---
>>  app/test-pmd/txonly.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index
>> 66e63788a..a9c27be3e 100644
>> --- a/app/test-pmd/txonly.c
>> +++ b/app/test-pmd/txonly.c
>> @@ -189,7 +189,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct
>rte_mempool *mbp,
>>  	/*
>>  	 * Copy headers in first packet segment(s).
>>  	 */
>> -	copy_buf_to_pkt(eth_hdr, sizeof(eth_hdr), pkt, 0);
>> +	copy_buf_to_pkt(eth_hdr, sizeof(struct ether_hdr), pkt, 0);
>
>Would a simpler fix not be to change "sizeof(eth_hdr)" to "sizeof(*eth_hdr)"? It
>would keep the logical connection between the destination and destination size,
>and make future refactoring easier.
>
Ack, will send v2. 
>/Bruce
  

Patch

diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 66e63788a..a9c27be3e 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -189,7 +189,7 @@  pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
 	/*
 	 * Copy headers in first packet segment(s).
 	 */
-	copy_buf_to_pkt(eth_hdr, sizeof(eth_hdr), pkt, 0);
+	copy_buf_to_pkt(eth_hdr, sizeof(struct ether_hdr), pkt, 0);
 	copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt,
 			sizeof(struct ether_hdr));
 	if (txonly_multi_flow) {