diff options
author | Damjan Marion <damarion@cisco.com> | 2019-01-31 18:50:04 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-01-31 22:25:44 +0000 |
commit | f646d74392490cf162a615badb92f62b573c694d (patch) | |
tree | cace20119d60ae83ef289dd15bada88bafe8bdd6 /src/vlib/buffer_funcs.h | |
parent | 0ede47aa452faceed85965ddb727c305059b856a (diff) |
buffers: vallidate that buffer is allocated during buffer pool put
Change-Id: I8044b34a37fe1994a8dfa1ca89929f3642c72e8d
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/buffer_funcs.h')
-rw-r--r-- | src/vlib/buffer_funcs.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index 37ddcd4a206..09ffd06428f 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -635,7 +635,7 @@ vlib_buffer_alloc_to_ring_from_pool (vlib_main_t * vm, u32 * ring, u32 start, return n_alloc; } -static void +static_always_inline void vlib_buffer_pool_put (vlib_main_t * vm, u8 buffer_pool_index, u32 * buffers, u32 n_buffers) { @@ -643,6 +643,10 @@ vlib_buffer_pool_put (vlib_main_t * vm, u8 buffer_pool_index, vlib_buffer_pool_thread_t *bpt = vec_elt_at_index (bp->threads, vm->thread_index); + if (CLIB_DEBUG > 0) + vlib_buffer_validate_alloc_free (vm, buffers, n_buffers, + VLIB_BUFFER_KNOWN_ALLOCATED); + vec_add_aligned (bpt->cached_buffers, buffers, n_buffers, CLIB_CACHE_LINE_BYTES); @@ -733,10 +737,6 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, vlib_buffer_copy_template (b[3], &bt); n_queue += 4; - if (CLIB_DEBUG > 0) - vlib_buffer_validate_alloc_free (vm, buffers, 4, - VLIB_BUFFER_KNOWN_ALLOCATED); - vlib_buffer_validate (vm, b[0]); vlib_buffer_validate (vm, b[1]); vlib_buffer_validate (vm, b[2]); @@ -786,9 +786,6 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, if (clib_atomic_sub_fetch (&b[0]->ref_count, 1) == 0) { - if (CLIB_DEBUG > 0) - vlib_buffer_validate_alloc_free (vm, &bi, 1, - VLIB_BUFFER_KNOWN_ALLOCATED); vlib_buffer_copy_template (b[0], &bt); queue[n_queue++] = bi; } |