test/event_crypto: fix event crypto metadata write

Message ID fe10a92bf84637cfbc1d207b9e16657148220f1c.1632756287.git.sthotton@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series test/event_crypto: fix event crypto metadata write |

Checks

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

Commit Message

Shijith Thotton Sept. 27, 2021, 3:29 p.m. UTC
  Using memcpy to update event crypto metadata fields (request/response)
will result in one overwriting the other. To avoid this, fields of each
structure should be updated one by one.

Fixes: 3c2c535ecfc0 ("test: add event crypto adapter auto-test")

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test/test_event_crypto_adapter.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
  

Comments

Gujjar, Abhinandan S Oct. 3, 2021, 9:46 a.m. UTC | #1
Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>

> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Monday, September 27, 2021 8:59 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Shijith Thotton <sthotton@marvell.com>;
> jerinj@marvell.com; anoobj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Subject: [PATCH] test/event_crypto: fix event crypto metadata write
> 
> Using memcpy to update event crypto metadata fields (request/response)
> will result in one overwriting the other. To avoid this, fields of each structure
> should be updated one by one.
> 
> Fixes: 3c2c535ecfc0 ("test: add event crypto adapter auto-test")
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
>  app/test/test_event_crypto_adapter.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/app/test/test_event_crypto_adapter.c
> b/app/test/test_event_crypto_adapter.c
> index 279aa3abf5..3d7e9fb93c 100644
> --- a/app/test/test_event_crypto_adapter.c
> +++ b/app/test/test_event_crypto_adapter.c
> @@ -212,10 +212,10 @@ test_op_forward_mode(uint8_t session_less)
> 
>  		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
>  			/* Fill in private user data information */
> -			rte_memcpy(&m_data.response_info,
> &response_info,
> -				sizeof(response_info));
> -			rte_memcpy(&m_data.request_info, &request_info,
> -				sizeof(request_info));
> +			m_data.request_info.cdev_id =
> request_info.cdev_id;
> +			m_data.request_info.queue_pair_id =
> +				request_info.queue_pair_id;
> +			m_data.response_info.event =
> response_info.event;
>  			rte_cryptodev_sym_session_set_user_data(sess,
>  						&m_data, sizeof(m_data));
>  		}
> @@ -231,10 +231,9 @@ test_op_forward_mode(uint8_t session_less)
>  		uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
>  		op->private_data_offset = len;
>  		/* Fill in private data information */
> -		rte_memcpy(&m_data.response_info, &response_info,
> -			   sizeof(response_info));
> -		rte_memcpy(&m_data.request_info, &request_info,
> -			   sizeof(request_info));
> +		m_data.request_info.cdev_id = request_info.cdev_id;
> +		m_data.request_info.queue_pair_id =
> request_info.queue_pair_id;
> +		m_data.response_info.event = response_info.event;
>  		rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
>  	}
> 
> @@ -405,8 +404,7 @@ test_op_new_mode(uint8_t session_less)
> 
>  		if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
>  			/* Fill in private user data information */
> -			rte_memcpy(&m_data.response_info,
> &response_info,
> -				   sizeof(m_data));
> +			m_data.response_info.event =
> response_info.event;
>  			rte_cryptodev_sym_session_set_user_data(sess,
>  						&m_data, sizeof(m_data));
>  		}
> @@ -425,8 +423,7 @@ test_op_new_mode(uint8_t session_less)
>  		uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
>  		op->private_data_offset = len;
>  		/* Fill in private data information */
> -		rte_memcpy(&m_data.response_info, &response_info,
> -			   sizeof(m_data));
> +		m_data.response_info.event = response_info.event;
>  		rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
>  	}
> 
> --
> 2.25.1
  
Akhil Goyal Oct. 5, 2021, 3:15 p.m. UTC | #2
> Acked-by: Abhinandan Gujjar <Abhinandan.gujjar@intel.com>
> 
Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c
index 279aa3abf5..3d7e9fb93c 100644
--- a/app/test/test_event_crypto_adapter.c
+++ b/app/test/test_event_crypto_adapter.c
@@ -212,10 +212,10 @@  test_op_forward_mode(uint8_t session_less)
 
 		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
 			/* Fill in private user data information */
-			rte_memcpy(&m_data.response_info, &response_info,
-				sizeof(response_info));
-			rte_memcpy(&m_data.request_info, &request_info,
-				sizeof(request_info));
+			m_data.request_info.cdev_id = request_info.cdev_id;
+			m_data.request_info.queue_pair_id =
+				request_info.queue_pair_id;
+			m_data.response_info.event = response_info.event;
 			rte_cryptodev_sym_session_set_user_data(sess,
 						&m_data, sizeof(m_data));
 		}
@@ -231,10 +231,9 @@  test_op_forward_mode(uint8_t session_less)
 		uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
 		op->private_data_offset = len;
 		/* Fill in private data information */
-		rte_memcpy(&m_data.response_info, &response_info,
-			   sizeof(response_info));
-		rte_memcpy(&m_data.request_info, &request_info,
-			   sizeof(request_info));
+		m_data.request_info.cdev_id = request_info.cdev_id;
+		m_data.request_info.queue_pair_id = request_info.queue_pair_id;
+		m_data.response_info.event = response_info.event;
 		rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
 	}
 
@@ -405,8 +404,7 @@  test_op_new_mode(uint8_t session_less)
 
 		if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
 			/* Fill in private user data information */
-			rte_memcpy(&m_data.response_info, &response_info,
-				   sizeof(m_data));
+			m_data.response_info.event = response_info.event;
 			rte_cryptodev_sym_session_set_user_data(sess,
 						&m_data, sizeof(m_data));
 		}
@@ -425,8 +423,7 @@  test_op_new_mode(uint8_t session_less)
 		uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
 		op->private_data_offset = len;
 		/* Fill in private data information */
-		rte_memcpy(&m_data.response_info, &response_info,
-			   sizeof(m_data));
+		m_data.response_info.event = response_info.event;
 		rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
 	}