[V2] app/testpmd: fix parameters order when calling rte_ether_addr_copy()

Message ID PH0PR11MB51595AE8B05206E9E7A67CF4A6949@PH0PR11MB5159.namprd11.prod.outlook.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series [V2] app/testpmd: fix parameters order when calling rte_ether_addr_copy() |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Xu, Wei1 Nov. 11, 2021, 2:29 a.m. UTC
  Running in 'csum' mode, the 'from' and 'to' parameters are not
in the correct order when calling rte_ether_addr_copy() which
means the 'src/dst' mac addresses in the mbuf will be overwriten.

As a result, the packets will not be recognized and received
by the receiver(s).

Test CLI:
./app/dpdk-testpmd -n 1 -l 1-2 -a 09:00.0 -- -i --forward-mode=csum

Fixes: 10f4620(app/testpmd: modify mac in csum forwarding)

v2:
	- fixed indentation and long line warnings.

Signed-off-by: Wei Xu <wei1.xu@intel.com>
---
 app/test-pmd/csumonly.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Ferruh Yigit Nov. 15, 2021, 7 p.m. UTC | #1
On 11/11/2021 2:29 AM, Xu, Wei1 wrote:
> Running in 'csum' mode, the 'from' and 'to' parameters are not
> in the correct order when calling rte_ether_addr_copy() which
> means the 'src/dst' mac addresses in the mbuf will be overwriten.
> 

Hi Wei,

Original code looks good. What are you trying to fix exactly?

API order is, 'rte_ether_addr_copy(from, to)'.

I assume your expectation is packet to keep original src & dst MAC address,
but it is not working that way, dest addrs is written by user configured
'peer address'.

With your change for each packet, packet mac address written to testpmd
configuration, which doesn't make sense.

> As a result, the packets will not be recognized and received
> by the receiver(s).
> 
> Test CLI:
> ./app/dpdk-testpmd -n 1 -l 1-2 -a 09:00.0 -- -i --forward-mode=csum
> 
> Fixes: 10f4620(app/testpmd: modify mac in csum forwarding)
> 
> v2:
> 	- fixed indentation and long line warnings.
> 
> Signed-off-by: Wei Xu <wei1.xu@intel.com>
> ---
>   app/test-pmd/csumonly.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> index 8526d9158a..08484fcda2 100644
> --- a/app/test-pmd/csumonly.c
> +++ b/app/test-pmd/csumonly.c
> @@ -872,10 +872,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
>   		 * and inner headers */
>   
>   		eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
> -		rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr],
> -				&eth_hdr->dst_addr);
> -		rte_ether_addr_copy(&ports[fs->tx_port].eth_addr,
> -				&eth_hdr->src_addr);
> +		rte_ether_addr_copy(&eth_hdr->dst_addr,
> +				&peer_eth_addrs[fs->peer_addr]);
> +		rte_ether_addr_copy(&eth_hdr->src_addr,
> +				&ports[fs->tx_port].eth_addr);
>   		parse_ethernet(eth_hdr, &info);
>   		l3_hdr = (char *)eth_hdr + info.l2_len;
>   
>
  
Xu, Wei1 Nov. 22, 2021, 4 a.m. UTC | #2
Hi Ferruh,
Thanks for your explaining. 

It it by design, maybe a check and only rewrite the mac addresses when they are explicitly set?

Thanks,
Wei

-----Original Message-----
From: Yigit, Ferruh <ferruh.yigit@intel.com> 
Sent: Tuesday, November 16, 2021 3:00 AM
To: Xu, Wei1 <wei1.xu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>; dev@dpdk.org
Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
Subject: Re: [PATCH V2] app/testpmd: fix parameters order when calling rte_ether_addr_copy()

On 11/11/2021 2:29 AM, Xu, Wei1 wrote:
> Running in 'csum' mode, the 'from' and 'to' parameters are not in the 
> correct order when calling rte_ether_addr_copy() which means the 
> 'src/dst' mac addresses in the mbuf will be overwriten.
> 

Hi Wei,

Original code looks good. What are you trying to fix exactly?

API order is, 'rte_ether_addr_copy(from, to)'.

I assume your expectation is packet to keep original src & dst MAC address, but it is not working that way, dest addrs is written by user configured 'peer address'.

With your change for each packet, packet mac address written to testpmd configuration, which doesn't make sense.

> As a result, the packets will not be recognized and received by the 
> receiver(s).
> 
> Test CLI:
> ./app/dpdk-testpmd -n 1 -l 1-2 -a 09:00.0 -- -i --forward-mode=csum
> 
> Fixes: 10f4620(app/testpmd: modify mac in csum forwarding)
> 
> v2:
> 	- fixed indentation and long line warnings.
> 
> Signed-off-by: Wei Xu <wei1.xu@intel.com>
> ---
>   app/test-pmd/csumonly.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 
> 8526d9158a..08484fcda2 100644
> --- a/app/test-pmd/csumonly.c
> +++ b/app/test-pmd/csumonly.c
> @@ -872,10 +872,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
>   		 * and inner headers */
>   
>   		eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
> -		rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr],
> -				&eth_hdr->dst_addr);
> -		rte_ether_addr_copy(&ports[fs->tx_port].eth_addr,
> -				&eth_hdr->src_addr);
> +		rte_ether_addr_copy(&eth_hdr->dst_addr,
> +				&peer_eth_addrs[fs->peer_addr]);
> +		rte_ether_addr_copy(&eth_hdr->src_addr,
> +				&ports[fs->tx_port].eth_addr);
>   		parse_ethernet(eth_hdr, &info);
>   		l3_hdr = (char *)eth_hdr + info.l2_len;
>   
>
  
Ferruh Yigit Nov. 22, 2021, 9:10 a.m. UTC | #3
On 11/22/2021 4:00 AM, Xu, Wei1 wrote:
> Hi Ferruh,
> Thanks for your explaining.
> 
> It it by design, maybe a check and only rewrite the mac addresses when they are explicitly set?
> 

What are you trying to fix/achieve exactly?

> Thanks,
> Wei
> 
> -----Original Message-----
> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> Sent: Tuesday, November 16, 2021 3:00 AM
> To: Xu, Wei1 <wei1.xu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>; dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: Re: [PATCH V2] app/testpmd: fix parameters order when calling rte_ether_addr_copy()
> 
> On 11/11/2021 2:29 AM, Xu, Wei1 wrote:
>> Running in 'csum' mode, the 'from' and 'to' parameters are not in the
>> correct order when calling rte_ether_addr_copy() which means the
>> 'src/dst' mac addresses in the mbuf will be overwriten.
>>
> 
> Hi Wei,
> 
> Original code looks good. What are you trying to fix exactly?
> 
> API order is, 'rte_ether_addr_copy(from, to)'.
> 
> I assume your expectation is packet to keep original src & dst MAC address, but it is not working that way, dest addrs is written by user configured 'peer address'.
> 
> With your change for each packet, packet mac address written to testpmd configuration, which doesn't make sense.
> 
>> As a result, the packets will not be recognized and received by the
>> receiver(s).
>>
>> Test CLI:
>> ./app/dpdk-testpmd -n 1 -l 1-2 -a 09:00.0 -- -i --forward-mode=csum
>>
>> Fixes: 10f4620(app/testpmd: modify mac in csum forwarding)
>>
>> v2:
>> 	- fixed indentation and long line warnings.
>>
>> Signed-off-by: Wei Xu <wei1.xu@intel.com>
>> ---
>>    app/test-pmd/csumonly.c | 8 ++++----
>>    1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index
>> 8526d9158a..08484fcda2 100644
>> --- a/app/test-pmd/csumonly.c
>> +++ b/app/test-pmd/csumonly.c
>> @@ -872,10 +872,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
>>    		 * and inner headers */
>>    
>>    		eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
>> -		rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr],
>> -				&eth_hdr->dst_addr);
>> -		rte_ether_addr_copy(&ports[fs->tx_port].eth_addr,
>> -				&eth_hdr->src_addr);
>> +		rte_ether_addr_copy(&eth_hdr->dst_addr,
>> +				&peer_eth_addrs[fs->peer_addr]);
>> +		rte_ether_addr_copy(&eth_hdr->src_addr,
>> +				&ports[fs->tx_port].eth_addr);
>>    		parse_ethernet(eth_hdr, &info);
>>    		l3_hdr = (char *)eth_hdr + info.l2_len;
>>    
>>
>
  

Patch

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 8526d9158a..08484fcda2 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -872,10 +872,10 @@  pkt_burst_checksum_forward(struct fwd_stream *fs)
 		 * and inner headers */
 
 		eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-		rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr],
-				&eth_hdr->dst_addr);
-		rte_ether_addr_copy(&ports[fs->tx_port].eth_addr,
-				&eth_hdr->src_addr);
+		rte_ether_addr_copy(&eth_hdr->dst_addr,
+				&peer_eth_addrs[fs->peer_addr]);
+		rte_ether_addr_copy(&eth_hdr->src_addr,
+				&ports[fs->tx_port].eth_addr);
 		parse_ethernet(eth_hdr, &info);
 		l3_hdr = (char *)eth_hdr + info.l2_len;