aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-31 18:50:04 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-01-31 22:25:44 +0000
commitf646d74392490cf162a615badb92f62b573c694d (patch)
treecace20119d60ae83ef289dd15bada88bafe8bdd6
parent0ede47aa452faceed85965ddb727c305059b856a (diff)
buffers: vallidate that buffer is allocated during buffer pool put
Change-Id: I8044b34a37fe1994a8dfa1ca89929f3642c72e8d Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/plugins/dpdk/buffer.c2
-rw-r--r--src/vlib/buffer_funcs.h13
2 files changed, 6 insertions, 9 deletions
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index 7f6c118a4a5..1894df42805 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -222,7 +222,7 @@ CLIB_MULTIARCH_FN (dpdk_ops_vpp_enqueue) (struct rte_mempool * mp,
{
vlib_get_buffer_indices_with_offset (vm, (void **) obj_table, bufs,
n, sizeof (struct rte_mbuf));
- vlib_buffer_pool_put (vm, buffer_pool_index, bufs, batch_size);
+ vlib_buffer_pool_put (vm, buffer_pool_index, bufs, n);
}
return 0;
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;
}