diff options
author | Dave Barach <dave@barachs.net> | 2020-04-09 17:24:07 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-04-13 15:54:31 +0000 |
commit | c74b43c80789f5e437dfe4cc491157b45a7f222e (patch) | |
tree | 0d149b8147d8225b5a872e709c6845476575fd1f /src/vlib/main.c | |
parent | c54162981cdd41d65ed283df36955007552ddffe (diff) |
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 <nnnn> }
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 <dave@barachs.net>
Change-Id: Iab939858014463d1e664682805013d334d6fcbe5
Diffstat (limited to 'src/vlib/main.c')
-rw-r--r-- | src/vlib/main.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c index f723d106120..fb3eb108736 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -190,6 +190,31 @@ vlib_get_frame_to_node (vlib_main_t * vm, u32 to_node_index) return vlib_get_frame (vm, f); } +static inline void +vlib_validate_frame_indices (vlib_frame_t * f) +{ + if (CLIB_DEBUG > 0) + { + int i; + u32 *from = vlib_frame_vector_args (f); + + /* Check for bad buffer index values */ + for (i = 0; i < f->n_vectors; i++) + { + if (from[i] == 0) + { + clib_warning ("BUG: buffer index 0 at index %d", i); + ASSERT (0); + } + else if (from[i] == 0xfefefefe) + { + clib_warning ("BUG: frame poison pattern at index %d", i); + ASSERT (0); + } + } + } +} + void vlib_put_frame_to_node (vlib_main_t * vm, u32 to_node_index, vlib_frame_t * f) { @@ -199,6 +224,8 @@ vlib_put_frame_to_node (vlib_main_t * vm, u32 to_node_index, vlib_frame_t * f) if (f->n_vectors == 0) return; + vlib_validate_frame_indices (f); + to_node = vlib_get_node (vm, to_node_index); vec_add2 (vm->node_main.pending_frames, p, 1); @@ -432,6 +459,9 @@ vlib_put_next_frame_validate (vlib_main_t * vm, f = vlib_get_frame (vm, nf->frame); ASSERT (n_vectors_left <= VLIB_FRAME_SIZE); + + vlib_validate_frame_indices (f); + n_after = VLIB_FRAME_SIZE - n_vectors_left; n_before = f->n_vectors; @@ -1986,6 +2016,20 @@ vlib_main_configure (vlib_main_t * vm, unformat_input_t * input) ; else if (unformat (input, "elog-post-mortem-dump")) vm->elog_post_mortem_dump = 1; + else if (unformat (input, "buffer-alloc-success-rate %f", + &vm->buffer_alloc_success_rate)) + { + if (VLIB_BUFFER_ALLOC_FAULT_INJECTOR == 0) + return clib_error_return + (0, "Buffer fault injection not configured"); + } + else if (unformat (input, "buffer-alloc-success-seed %u", + &vm->buffer_alloc_success_seed)) + { + if (VLIB_BUFFER_ALLOC_FAULT_INJECTOR == 0) + return clib_error_return + (0, "Buffer fault injection not configured"); + } else return unformat_parse_error (input); } @@ -2147,6 +2191,13 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input) vec_validate (vm->processing_rpc_requests, 0); _vec_len (vm->processing_rpc_requests) = 0; + /* Default params for the buffer allocator fault injector, if configured */ + if (VLIB_BUFFER_ALLOC_FAULT_INJECTOR > 0) + { + vm->buffer_alloc_success_seed = 0xdeaddabe; + vm->buffer_alloc_success_rate = 0.80; + } + if ((error = vlib_call_all_config_functions (vm, input, 0 /* is_early */ ))) goto done; |