From 3a63fc5470caffda434064a439ffdbe8518963f9 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 7 Jan 2019 09:15:47 -0500 Subject: Handle buffer alloc failure in vlib_buffer_add_data It's not OK to crash due to a transient buffer allocation failure. Return 1 if the requested operation failed, otherwise 0. Buffer index parameter change to a value-result, so the caller can differentiate between partial and complete allocation failure: callers which request an initial allocation (inbound bi = ~0) need to check the (out) value to decide whether or not to call vlib_buffer_free(...). Change-Id: I03029d7f2714c17dca4630dfd95a1eb578b68384 Signed-off-by: Dave Barach --- src/vlib/buffer_funcs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/vlib/buffer_funcs.h') diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index 54fc1f61598..b561a91c394 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -672,9 +672,9 @@ vlib_buffer_free_list_buffer_size (vlib_main_t * vm, } /* Append given data to end of buffer, possibly allocating new buffers. */ -u32 vlib_buffer_add_data (vlib_main_t * vm, +int vlib_buffer_add_data (vlib_main_t * vm, vlib_buffer_free_list_index_t free_list_index, - u32 buffer_index, void *data, u32 n_data_bytes); + u32 * buffer_index, void *data, u32 n_data_bytes); /* duplicate all buffers in chain */ always_inline vlib_buffer_t * -- cgit 1.2.3-korg