From: Nikhil Agarwal <[email protected]>

If the packet sumbitted for cyprto operation returns back to
other thread before pre crypto thread has completed
processing, ctx will has old state hence packet will be
re-submitted for crypto operation.
To fix this issue, update the ctx state before packet
submission.

Signed-off-by: Nikhil Agarwal <[email protected]>
---
 example/ipsec/odp_ipsec.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 4928985..8b4f1a8 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -701,6 +701,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
 
        /* Issue crypto request */
        *skip = FALSE;
+       ctx->state = PKT_STATE_IPSEC_IN_FINISH;
        if (odp_crypto_operation(&params,
                                 &posted,
                                 result)) {
@@ -1127,13 +1128,11 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
 
                        case PKT_STATE_IPSEC_IN_CLASSIFY:
 
+                               ctx->state = PKT_STATE_ROUTE_LOOKUP;
                                rc = do_ipsec_in_classify(pkt,
                                                          ctx,
                                                          &skip,
                                                          &result);
-                               ctx->state = (skip) ?
-                                       PKT_STATE_ROUTE_LOOKUP :
-                                       PKT_STATE_IPSEC_IN_FINISH;
                                break;
 
                        case PKT_STATE_IPSEC_IN_FINISH:
@@ -1163,8 +1162,8 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
 
                        case PKT_STATE_IPSEC_OUT_SEQ:
 
-                               rc = do_ipsec_out_seq(pkt, ctx, &result);
                                ctx->state = PKT_STATE_IPSEC_OUT_FINISH;
+                               rc = do_ipsec_out_seq(pkt, ctx, &result);
                                break;
 
                        case PKT_STATE_IPSEC_OUT_FINISH:
-- 
1.7.9.5

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to