aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2023-10-05 15:33:40 -0700
committerDave Wallace <dwallacelf@gmail.com>2023-12-01 16:36:09 +0000
commit6c2464d0327f6d3fcaae67d209ae99e1c3069592 (patch)
tree5b9a10c26401c42469bc53dae1483e62f7b0e7fa
parent6d83dddeb142b9e44bb1e0e8f266629706c4fdc3 (diff)
memif: contention between memif_disconnect and memif RX/TX threads
memif_disconect may be called without barrier sync. It removes stuff in mq without protection which may cause troubles for memif RX/TX worker threads. The fix is to protect mq removal in memif_disconnect. Type: fix Change-Id: I368c466d1f13df98980dfa87e8442fbcd822a428 Signed-off-by: Steven Luong <sluong@cisco.com> (cherry picked from commit 34c721fb47155135bf2173ca7b9a31aaacfde190)
-rw-r--r--src/plugins/memif/memif.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 37028d8223e..22f3e3dcdf1 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -100,6 +100,8 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
memif_region_t *mr;
memif_queue_t *mq;
int i;
+ vlib_main_t *vm = vlib_get_main ();
+ int with_barrier = 0;
if (mif == 0)
return;
@@ -141,6 +143,12 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
clib_mem_free (mif->sock);
}
+ if (vlib_worker_thread_barrier_held () == 0)
+ {
+ with_barrier = 1;
+ vlib_worker_thread_barrier_sync (vm);
+ }
+
/* *INDENT-OFF* */
vec_foreach_index (i, mif->rx_queues)
{
@@ -198,6 +206,9 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
vec_free (mif->remote_name);
vec_free (mif->remote_if_name);
clib_fifo_free (mif->msg_queue);
+
+ if (with_barrier)
+ vlib_worker_thread_barrier_release (vm);
}
static clib_error_t *