From e700df8eb4f640762d5eced6623bbc2473ad0095 Mon Sep 17 00:00:00 2001 From: Miklos Tirpak Date: Wed, 13 Jan 2021 10:00:38 +0100 Subject: vlib: fix counter_will_expand prediction vlib_validate_combined_counter_will_expand() was calling _vec_resize_will_expand() with wrong arguments, which resulted in false return value. Apart from the initial call, it never indicated a vector resize. The callers relying on this function did not perform a barrier sync because of the wrong prediction even if the vector got extended by a subsequent vlib_validate_combined_counter() call. The fix introduces a new, simplified macro that is easier to call. vec_resize_will_expand() accepts the same arguments as vec_resize(). Type: fix Signed-off-by: Miklos Tirpak Change-Id: Ib2c2c8afd3e665e0e3d6ae62ff5cfa287acf670f --- src/vlib/counter.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/vlib/counter.c') diff --git a/src/vlib/counter.c b/src/vlib/counter.c index adf667f4051..81c81aea02f 100644 --- a/src/vlib/counter.c +++ b/src/vlib/counter.c @@ -140,12 +140,9 @@ int /* Trivially OK, and proves that index >= vec_len(...) */ if (index < vec_len (cm->counters[i])) continue; - if (_vec_resize_will_expand - (cm->counters[i], - index - vec_len (cm->counters[i]) /* length_increment */ , - sizeof (cm->counters[i]) /* data_bytes */ , - 0 /* header_bytes */ , - CLIB_CACHE_LINE_BYTES /* data_alignment */ )) + if (vec_resize_will_expand (cm->counters[i], + index - vec_len (cm->counters[i]) + + 1 /* length_increment */)) { vlib_stats_pop_heap (cm, oldheap, index, 3 /*STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED */ ); -- cgit 1.2.3-korg