misc: check return values from vlib_buffer_copy(...)

vlib_buffer_copy(...) returns NULL if the system is temporarily out of
buffers.

This is NOT correct. Please don't be this person:

   c0 = vlib_buffer_copy (vm, p0);
   ci0 = vlib_get_buffer_index (vm, c0);

Type: fix

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ic25ef58965871ea5d2b40904df9506803f69e47e
This commit is contained in:
Dave Barach
2020-04-08 08:14:57 -04:00
committed by Florin Coras
parent 8d0d8d2fcc
commit 954c707972
8 changed files with 30 additions and 4 deletions

View File

@ -437,6 +437,13 @@ dhcpv6_proxy_to_server_input (vlib_main_t * vm,
u32 ci0;
c0 = vlib_buffer_copy (vm, b0);
if (c0 == NULL)
{
vlib_node_increment_counter
(vm, dhcpv6_proxy_to_server_node.index,
DHCPV6_PROXY_ERROR_ALLOC_FAIL, 1);
continue;
}
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (c0);
ci0 = vlib_get_buffer_index (vm, c0);
server = &proxy->dhcp_servers[ii];