Re: [lng-odp] [PATCH] ipsec: Fix ctx-state update race
Robbie, Taras anybody else, can you please add sign-off to that patch? Thanks, Maxim. On 11/14/2014 02:31 PM, Jerin Jacob wrote: 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 jerin.ja...@caviumnetworks.com --- 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, params, 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 lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
Re: [lng-odp] [PATCH] ipsec: Fix ctx-state update race
Oops! Good catch. I looked and I don't see any other manifestations. Reviewed-by: Robert King robk...@cisco.com Robbie. -Original Message- From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Jerin Jacob Sent: Friday, November 14, 2014 6:31 AM To: lng-odp@lists.linaro.org 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 jerin.ja...@caviumnetworks.com --- 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, params, 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 lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp ___ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
[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 jerin.ja...@caviumnetworks.com --- 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, params, 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 lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp