From a5bfe6cd0e0b1e413bbb2decfcdb97c65b79cbce Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Wed, 12 Jan 2022 15:22:23 +0500 Subject: ip: add barrier sync, ip4_ply_pool expand case ply_create() is not thread safe when the ip4_ply_pool expands. Type: fix Signed-off-by: Vladislav Grishenko Change-Id: Ie11cc8b1ba587d5e9239a60f4e288492da61368e --- src/vnet/ip/ip4_mtrie.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/vnet/ip/ip4_mtrie.c b/src/vnet/ip/ip4_mtrie.c index e61b4aa577b..00855f7db43 100644 --- a/src/vnet/ip/ip4_mtrie.c +++ b/src/vnet/ip/ip4_mtrie.c @@ -115,12 +115,24 @@ static ip4_mtrie_leaf_t ply_create (ip4_mtrie_leaf_t init_leaf, u32 leaf_prefix_len, u32 ply_base_len) { ip4_mtrie_8_ply_t *p; - /* Get cache aligned ply. */ + ip4_mtrie_leaf_t l; + u8 need_barrier_sync = pool_get_will_expand (ip4_ply_pool); + vlib_main_t *vm = vlib_get_main (); + ASSERT (vm->thread_index == 0); + if (need_barrier_sync) + vlib_worker_thread_barrier_sync (vm); + + /* Get cache aligned ply. */ pool_get_aligned (ip4_ply_pool, p, CLIB_CACHE_LINE_BYTES); ply_8_init (p, init_leaf, leaf_prefix_len, ply_base_len); - return ip4_mtrie_leaf_set_next_ply_index (p - ip4_ply_pool); + l = ip4_mtrie_leaf_set_next_ply_index (p - ip4_ply_pool); + + if (need_barrier_sync) + vlib_worker_thread_barrier_release (vm); + + return l; } always_inline ip4_mtrie_8_ply_t * -- cgit 1.2.3-korg