Currently, for a sessionless op, the session taken from the mempool contains some values previously set by a testcase that does use a session. This is due to the session object not being reset before going back into the mempool.
This caused issues when multiple sessionless testcases ran, as the previously set objects were being used for the first few testcases, but subsequent testcases used empty objects, as they were being correctly reset by the sessionless testcases. To fix this, the session objects are now reset before being returned to the mempool for session testcases. In addition, rather than pulling the session object directly from the mempool for sessionless testcases, the session_create() function is now used, which sets the required values, such as nb_drivers. Fixes: c75542ae4200 ("crypto/ipsec_mb: introduce IPsec_mb framework") Fixes: b3bbd9e5f265 ("cryptodev: support device independent sessions") Cc: roy.fan.zh...@intel.com Cc: slawomirx.mrozow...@intel.com Signed-off-by: Ciara Power <ciara.po...@intel.com> Acked-by: Fan Zhang <roy.fan.zh...@intel.com> Acked-by: Pablo de Lara <pablo.de.lara.gua...@intel.com> --- v3: - Modified fix to reset sessions, and ensure values are then set for sessionless testcases. V2 fix just ensured the same values in session objects were reused, as they were not being reset, which was incorrect. --- drivers/crypto/ipsec_mb/ipsec_mb_private.h | 12 ++++++++---- lib/cryptodev/rte_cryptodev.c | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_private.h b/drivers/crypto/ipsec_mb/ipsec_mb_private.h index 472b672f08..420701a818 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_private.h +++ b/drivers/crypto/ipsec_mb/ipsec_mb_private.h @@ -415,7 +415,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) uint32_t driver_id = ipsec_mb_get_driver_id(qp->pmd_type); struct rte_crypto_sym_op *sym_op = op->sym; uint8_t sess_type = op->sess_type; - void *_sess; + struct rte_cryptodev_sym_session *_sess; void *_sess_private_data = NULL; struct ipsec_mb_internals *pmd_data = &ipsec_mb_pmds[qp->pmd_type]; @@ -426,8 +426,12 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) driver_id); break; case RTE_CRYPTO_OP_SESSIONLESS: - if (!qp->sess_mp || - rte_mempool_get(qp->sess_mp, (void **)&_sess)) + if (!qp->sess_mp) + return NULL; + + _sess = rte_cryptodev_sym_session_create(qp->sess_mp); + + if (!_sess) return NULL; if (!qp->sess_mp_priv || @@ -443,7 +447,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) sess = NULL; } - sym_op->session = (struct rte_cryptodev_sym_session *)_sess; + sym_op->session = _sess; set_sym_session_private_data(sym_op->session, driver_id, _sess_private_data); break; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 9e76a1c72d..ac0c508e76 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -2187,6 +2187,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) /* Return session to mempool */ sess_mp = rte_mempool_from_obj(sess); + memset(sess, 0, rte_cryptodev_sym_get_existing_header_session_size(sess)); rte_mempool_put(sess_mp, sess); rte_cryptodev_trace_sym_session_free(sess); -- 2.25.1