Thanks! Merged!
Maxim.
On 11/18/2014 06:27 PM, Robbie King (robking) wrote:
Oops! Good catch. I looked and I don't see any other
manifestations.
Reviewed-by: Robert King <[email protected]>
Robbie.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jerin Jacob
Sent: Friday, November 14, 2014 6:31 AM
To: [email protected]
Subject: [lng-odp] [PATCH] ipsec: Fix ctx->state update race
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:
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp