aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorNikhil Agarwal <nikhil.agarwal@freescale.com>2015-07-15 17:23:42 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-07-17 18:09:36 +0300
commite7dee785fe79652630d096ac890c4766c9a4ac33 (patch)
tree48fcfa112f057453e2dcf69b78cc183f2ab6fadb /example
parent3f12ab51b8c0020bdc7ac64102349bf8f62ab652 (diff)
example: ipsec: Fix context state race condition in
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 <nikhil.agarwal@freescale.com> Reviewed-by: Steve Kordus <skordus@cisco.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r--example/ipsec/odp_ipsec.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 089015f..134245c 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:
@@ -1164,8 +1163,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: