summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
authorStanislav Zaikin <zstaseg@gmail.com>2021-09-28 18:31:32 +0200
committerNeale Ranns <neale@graphiant.com>2021-09-29 07:29:07 +0000
commit754cffbe1635feb261536c96e0b0f32ae876f2ef (patch)
treed43ab27ab1277a0b5a95ca624a78259763a7fbbc /src/vnet/fib
parent36217e3ca8a1ca2e7a341b6b44ffc25e6497191c (diff)
fib: add barrier lock for fib_urpf_list_pool and fib_entry_pool
Pools fib_urpf_list_pool and fib_entry_pool can grow while ip6_urpf_loose_check/fib_entry_get_flags_for_source are being executed. That may result as a crash in mt environment. Type: fix Change-Id: I44ca2cb70255e7aaf2e1f7a7d2eecd25cbdd0aaa Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_entry.c11
-rw-r--r--src/vnet/fib/fib_urpf_list.c11
2 files changed, 22 insertions, 0 deletions
diff --git a/src/vnet/fib/fib_entry.c b/src/vnet/fib/fib_entry.c
index 119a7ac5e77..dfa0cb285b4 100644
--- a/src/vnet/fib/fib_entry.c
+++ b/src/vnet/fib/fib_entry.c
@@ -599,8 +599,19 @@ fib_entry_alloc (u32 fib_index,
{
fib_entry_t *fib_entry;
fib_prefix_t *fep;
+ u8 need_barrier_sync = 0;
+ vlib_main_t *vm = vlib_get_main();
+ ASSERT (vm->thread_index == 0);
+
+ pool_get_will_expand (fib_entry_pool, need_barrier_sync );
+ if (need_barrier_sync)
+ vlib_worker_thread_barrier_sync (vm);
pool_get(fib_entry_pool, fib_entry);
+
+ if (need_barrier_sync)
+ vlib_worker_thread_barrier_release (vm);
+
clib_memset(fib_entry, 0, sizeof(*fib_entry));
fib_node_init(&fib_entry->fe_node,
diff --git a/src/vnet/fib/fib_urpf_list.c b/src/vnet/fib/fib_urpf_list.c
index 4f751a63627..f9790b59031 100644
--- a/src/vnet/fib/fib_urpf_list.c
+++ b/src/vnet/fib/fib_urpf_list.c
@@ -55,8 +55,19 @@ index_t
fib_urpf_list_alloc_and_lock (void)
{
fib_urpf_list_t *urpf;
+ u8 need_barrier_sync = 0;
+ vlib_main_t *vm = vlib_get_main();
+ ASSERT (vm->thread_index == 0);
+
+ pool_get_will_expand (fib_urpf_list_pool, need_barrier_sync );
+ if (need_barrier_sync)
+ vlib_worker_thread_barrier_sync (vm);
pool_get(fib_urpf_list_pool, urpf);
+
+ if (need_barrier_sync)
+ vlib_worker_thread_barrier_release (vm);
+
clib_memset(urpf, 0, sizeof(*urpf));
urpf->furpf_locks++;