Skip to content

Commit

Permalink
test/event_crypto: fix event crypto metadata write
Browse files Browse the repository at this point in the history
[ upstream commit 67c8bae ]

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: 3c2c535 ("test: add event crypto adapter auto-test")

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
  • Loading branch information
Shijith Thotton authored and cpaelzer committed Nov 30, 2021
1 parent 6882449 commit 03cbc1d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions app/test/test_event_crypto_adapter.c
Expand Up @@ -208,10 +208,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));
}
Expand All @@ -227,10 +227,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));
}

Expand Down Expand Up @@ -401,8 +400,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));
}
Expand All @@ -421,8 +419,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));
}

Expand Down

0 comments on commit 03cbc1d

Please sign in to comment.