In existing code, ctx->state of packet which received from ORDERED queue has been updated after sending the packet to ATOMIC queue. This creates a race between "updating ctx->state from core x(ORDERED)" and "reading stale ctx->state from core y(ATOMIC)" In order to avoid the race, core x(ORDERED) should update the ctx->state value before sending to ATOMIC queue.
Signed-off-by: Jerin Jacob <[email protected]> --- example/ipsec/odp_ipsec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index da6c48e..37ad34d 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -932,9 +932,7 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt, ctx->ipsec.esp_seq = &entry->state.esp_seq; memcpy(&ctx->ipsec.params, ¶ms, sizeof(params)); - /* Send packet to the atmoic queue to assign sequence numbers */ *skip = FALSE; - odp_queue_enq(seqnumq, odp_packet_to_buffer(pkt)); return PKT_POSTED; } @@ -1108,9 +1106,12 @@ void *pktio_thread(void *arg ODP_UNUSED) case PKT_STATE_IPSEC_OUT_CLASSIFY: rc = do_ipsec_out_classify(pkt, ctx, &skip); - ctx->state = (skip) ? - PKT_STATE_TRANSMIT : - PKT_STATE_IPSEC_OUT_SEQ; + if (odp_unlikely(skip)) { + ctx->state = PKT_STATE_TRANSMIT; + } else { + ctx->state = PKT_STATE_IPSEC_OUT_SEQ; + odp_queue_enq(seqnumq, buf); + } break; case PKT_STATE_IPSEC_OUT_SEQ: -- 1.9.3 _______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
