From c74b43c80789f5e437dfe4cc491157b45a7f222e Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 9 Apr 2020 17:24:07 -0400 Subject: buffers: configurable buffer fault injector When configured at compile time via the cmake VPP_BUFFER_FAULT_INJECTOR option, the buffer allocator will appear to fail a certain fraction of the time. By default, the allocator succeeds 80% of the time. Detailed command line configuration options are available, but only when the image has been compiled with cmake option described above: vlib { buffer-alloc-success-rate [0.0 ... 1.0] buffer-alloc-success-seed } Modify vlib_buffer_pool_create(...) so 0 is always an invalid buffer index. Debug images: add checks for bad buffer index enqueues, and also verify that f->n_vectors doesn't accidentally map one or more instances of the frame poison pattern 0xfefefefe. Type: improvement Signed-off-by: Dave Barach Change-Id: Iab939858014463d1e664682805013d334d6fcbe5 --- src/vlib/buffer_node.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/vlib/buffer_node.h') diff --git a/src/vlib/buffer_node.h b/src/vlib/buffer_node.h index bd82b1037a9..0fa18d6dde2 100644 --- a/src/vlib/buffer_node.h +++ b/src/vlib/buffer_node.h @@ -69,6 +69,8 @@ #define vlib_validate_buffer_enqueue_x2(vm,node,next_index,to_next,n_left_to_next,bi0,bi1,next0,next1) \ do { \ + ASSERT (bi0 != 0); \ + ASSERT (bi1 != 0); \ int enqueue_code = (next0 != next_index) + 2*(next1 != next_index); \ \ if (PREDICT_FALSE (enqueue_code != 0)) \ @@ -137,6 +139,10 @@ do { \ #define vlib_validate_buffer_enqueue_x4(vm,node,next_index,to_next,n_left_to_next,bi0,bi1,bi2,bi3,next0,next1,next2,next3) \ do { \ + ASSERT (bi0 != 0); \ + ASSERT (bi1 != 0); \ + ASSERT (bi2 != 0); \ + ASSERT (bi3 != 0); \ /* After the fact: check the [speculative] enqueue to "next" */ \ u32 fix_speculation = (next_index ^ next0) | (next_index ^ next1) \ | (next_index ^ next2) | (next_index ^ next3); \ @@ -217,6 +223,7 @@ do { \ */ #define vlib_validate_buffer_enqueue_x1(vm,node,next_index,to_next,n_left_to_next,bi0,next0) \ do { \ + ASSERT (bi0 != 0); \ if (PREDICT_FALSE (next0 != next_index)) \ { \ vlib_put_next_frame (vm, node, next_index, n_left_to_next + 1); \ -- cgit 1.2.3-korg