[10/13] crypto/cnxk: acquire lock while updating antireplay

Message ID 20221020111453.1982947-4-ktejasree@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series fixes and improvements to cnxk crypto PMD |

Commit Message

Tejasree Kondoj Oct. 20, 2022, 11:14 a.m. UTC
  From: Vidya Sagar Velumuri <vvelumuri@marvell.com>

Acquire locks in antireplay logic to avoid race condition

Signed-off-by: Vidya Sagar Velumuri <vvelumuri@marvell.com>
---
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 2a5c00eadd..04c004bc7a 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -500,6 +500,7 @@  ipsec_antireplay_check(struct cn9k_sec_session *sess, uint32_t win_sz,
 	if (unlikely(seq == 0))
 		return IPSEC_ANTI_REPLAY_FAILED;
 
+	rte_spinlock_lock(&sess->ar.lock);
 	ret = cnxk_on_anti_replay_check(seq, &sess->ar, win_sz);
 	if (esn && !ret) {
 		esn_low = rte_be_to_cpu_32(common_sa->seq_t.tl);
@@ -510,6 +511,7 @@  ipsec_antireplay_check(struct cn9k_sec_session *sess, uint32_t win_sz,
 			common_sa->seq_t.th = rte_cpu_to_be_32(seqh);
 		}
 	}
+	rte_spinlock_unlock(&sess->ar.lock);
 
 	return ret;
 }