From e2568b5d0a5e34f02adda788e51ed0147644bec9 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Fri, 10 Apr 2020 10:18:35 -0400 Subject: 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 (cherry picked from commit c25ef58965871ea5d2b40904df9506803f69e47e) Change-Id: I6cd4f289c4fadc3f36c3203b53546e9a788ef99b --- src/plugins/ioam/encap/ip6_ioam_trace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/ioam/encap/ip6_ioam_trace.c b/src/plugins/ioam/encap/ip6_ioam_trace.c index 53fb63ea6fd..23448575798 100644 --- a/src/plugins/ioam/encap/ip6_ioam_trace.c +++ b/src/plugins/ioam/encap/ip6_ioam_trace.c @@ -222,14 +222,16 @@ ip6_hbh_ioam_loopback_handler (vlib_buffer_t * b, ip6_header_t * ip, ioam_trace_option_t *opt; udp_ping_t *udp; + b0 = vlib_buffer_copy (hm->vlib_main, b); + if (b0 == NULL) + return; + + buf_index = vlib_get_buffer_index (hm->vlib_main, b0); next_node = vlib_get_node_by_name (hm->vlib_main, (u8 *) "ip6-lookup"); nf = vlib_get_frame_to_node (hm->vlib_main, next_node->index); nf->n_vectors = 0; to_next = vlib_frame_vector_args (nf); - b0 = vlib_buffer_copy (hm->vlib_main, b); - buf_index = vlib_get_buffer_index (hm->vlib_main, b0); - vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0; -- cgit 1.2.3-korg