From a474d09a9e0a0e527bad88d32c3655fe1e5046db Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Thu, 26 Aug 2021 16:43:13 +0200 Subject: [PATCH] Fix crash when vlib_buffer_copy() fails - also sent upstream in https://gerrit.fd.io/r/c/vpp/+/33606 --- lcpng_if_node.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/lcpng_if_node.c b/lcpng_if_node.c index f2b1e56..69ba0d4 100644 --- a/lcpng_if_node.c +++ b/lcpng_if_node.c @@ -675,10 +675,14 @@ VLIB_NODE_FN (lcp_arp_phy_node) c0 = vlib_buffer_copy (vm, b0); vlib_buffer_advance (b0, len0); - /* Send to the host */ - vnet_buffer (c0)->sw_if_index[VLIB_TX] = - lip0->lip_host_sw_if_index; - reply_copies[n_copies++] = vlib_get_buffer_index (vm, c0); + if (c0) + { + /* Send to the host */ + vnet_buffer (c0)->sw_if_index[VLIB_TX] = + lip0->lip_host_sw_if_index; + reply_copies[n_copies++] = + vlib_get_buffer_index (vm, c0); + } } } if (arp1->opcode == clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_reply)) @@ -703,10 +707,14 @@ VLIB_NODE_FN (lcp_arp_phy_node) c1 = vlib_buffer_copy (vm, b1); vlib_buffer_advance (b1, len1); - /* Send to the host */ - vnet_buffer (c1)->sw_if_index[VLIB_TX] = - lip1->lip_host_sw_if_index; - reply_copies[n_copies++] = vlib_get_buffer_index (vm, c1); + if (c1) + { + /* Send to the host */ + vnet_buffer (c1)->sw_if_index[VLIB_TX] = + lip1->lip_host_sw_if_index; + reply_copies[n_copies++] = + vlib_get_buffer_index (vm, c1); + } } } @@ -775,10 +783,14 @@ VLIB_NODE_FN (lcp_arp_phy_node) c0 = vlib_buffer_copy (vm, b0); vlib_buffer_advance (b0, len0); - /* Send to the host */ - vnet_buffer (c0)->sw_if_index[VLIB_TX] = - lip0->lip_host_sw_if_index; - reply_copies[n_copies++] = vlib_get_buffer_index (vm, c0); + if (c0) + { + /* Send to the host */ + vnet_buffer (c0)->sw_if_index[VLIB_TX] = + lip0->lip_host_sw_if_index; + reply_copies[n_copies++] = + vlib_get_buffer_index (vm, c0); + } } }