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 (cherry picked from commit 954c707972bf7efcd227e26d9679544813a78115)
This commit is contained in:
Dave Barach
committed by
Dave Wallace
parent
8c6efc0610
commit
d55f62f788
@ -30,4 +30,4 @@ dhcp_proxy_error (BAD_YIADDR, "DHCP packets with bad your_ip_address fields")
|
|||||||
dhcp_proxy_error (BAD_SVR_FIB_OR_ADDRESS, "DHCP packets not from DHCP server or server FIB.")
|
dhcp_proxy_error (BAD_SVR_FIB_OR_ADDRESS, "DHCP packets not from DHCP server or server FIB.")
|
||||||
dhcp_proxy_error (PKT_TOO_BIG, "DHCP packets which are too big.")
|
dhcp_proxy_error (PKT_TOO_BIG, "DHCP packets which are too big.")
|
||||||
dhcp_proxy_error (FOR_US, "DHCP packets for local client.")
|
dhcp_proxy_error (FOR_US, "DHCP packets for local client.")
|
||||||
|
dhcp_proxy_error (ALLOC_FAIL, "DHCP buffer allocation failures.")
|
||||||
|
@ -364,6 +364,13 @@ dhcp_proxy_to_server_input (vlib_main_t * vm,
|
|||||||
u32 ci0;
|
u32 ci0;
|
||||||
|
|
||||||
c0 = vlib_buffer_copy (vm, b0);
|
c0 = vlib_buffer_copy (vm, b0);
|
||||||
|
if (c0 == NULL)
|
||||||
|
{
|
||||||
|
vlib_node_increment_counter
|
||||||
|
(vm, dhcp_proxy_to_server_node.index,
|
||||||
|
DHCP_PROXY_ERROR_ALLOC_FAIL, 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (c0);
|
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (c0);
|
||||||
ci0 = vlib_get_buffer_index (vm, c0);
|
ci0 = vlib_get_buffer_index (vm, c0);
|
||||||
server = &proxy->dhcp_servers[ii];
|
server = &proxy->dhcp_servers[ii];
|
||||||
|
@ -258,6 +258,9 @@ check_send_client_message (vlib_main_t * vm,
|
|||||||
next_index = ip6_rewrite_mcast_node.index;
|
next_index = ip6_rewrite_mcast_node.index;
|
||||||
|
|
||||||
c0 = vlib_buffer_copy (vm, p0);
|
c0 = vlib_buffer_copy (vm, p0);
|
||||||
|
if (c0 == NULL)
|
||||||
|
return client_state->keep_sending_client_message;
|
||||||
|
|
||||||
ci0 = vlib_get_buffer_index (vm, c0);
|
ci0 = vlib_get_buffer_index (vm, c0);
|
||||||
|
|
||||||
ip = (ip6_header_t *) vlib_buffer_get_current (c0);
|
ip = (ip6_header_t *) vlib_buffer_get_current (c0);
|
||||||
|
@ -264,6 +264,9 @@ check_pd_send_client_message (vlib_main_t * vm,
|
|||||||
next_index = ip6_rewrite_mcast_node.index;
|
next_index = ip6_rewrite_mcast_node.index;
|
||||||
|
|
||||||
c0 = vlib_buffer_copy (vm, p0);
|
c0 = vlib_buffer_copy (vm, p0);
|
||||||
|
if (c0 == NULL)
|
||||||
|
return client_state->keep_sending_client_message;
|
||||||
|
|
||||||
ci0 = vlib_get_buffer_index (vm, c0);
|
ci0 = vlib_get_buffer_index (vm, c0);
|
||||||
|
|
||||||
ip = (ip6_header_t *) vlib_buffer_get_current (c0);
|
ip = (ip6_header_t *) vlib_buffer_get_current (c0);
|
||||||
|
@ -27,3 +27,4 @@ dhcpv6_proxy_error (NO_RELAY_MESSAGE_OPTION, "DHCPv6 reply packets without relay
|
|||||||
dhcpv6_proxy_error (BAD_SVR_FIB_OR_ADDRESS, "DHCPv6 packets not from DHCPv6 server or server FIB.")
|
dhcpv6_proxy_error (BAD_SVR_FIB_OR_ADDRESS, "DHCPv6 packets not from DHCPv6 server or server FIB.")
|
||||||
dhcpv6_proxy_error (PKT_TOO_BIG, "DHCPv6 packets which are too big.")
|
dhcpv6_proxy_error (PKT_TOO_BIG, "DHCPv6 packets which are too big.")
|
||||||
dhcpv6_proxy_error (WRONG_INTERFACE_ID_OPTION, "DHCPv6 reply to invalid interface.")
|
dhcpv6_proxy_error (WRONG_INTERFACE_ID_OPTION, "DHCPv6 reply to invalid interface.")
|
||||||
|
dhcpv6_proxy_error (ALLOC_FAIL, "DHCPv6 buffer allocation failures.")
|
||||||
|
@ -437,6 +437,13 @@ dhcpv6_proxy_to_server_input (vlib_main_t * vm,
|
|||||||
u32 ci0;
|
u32 ci0;
|
||||||
|
|
||||||
c0 = vlib_buffer_copy (vm, b0);
|
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);
|
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (c0);
|
||||||
ci0 = vlib_get_buffer_index (vm, c0);
|
ci0 = vlib_get_buffer_index (vm, c0);
|
||||||
server = &proxy->dhcp_servers[ii];
|
server = &proxy->dhcp_servers[ii];
|
||||||
|
@ -222,14 +222,16 @@ ip6_hbh_ioam_loopback_handler (vlib_buffer_t * b, ip6_header_t * ip,
|
|||||||
ioam_trace_option_t *opt;
|
ioam_trace_option_t *opt;
|
||||||
udp_ping_t *udp;
|
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");
|
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 = vlib_get_frame_to_node (hm->vlib_main, next_node->index);
|
||||||
nf->n_vectors = 0;
|
nf->n_vectors = 0;
|
||||||
to_next = vlib_frame_vector_args (nf);
|
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_RX] = 0;
|
||||||
vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
|
vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
|
||||||
|
|
||||||
|
@ -1219,6 +1219,9 @@ check_send_rs (vlib_main_t * vm, ip6_ra_t * radv_info, f64 current_time,
|
|||||||
next_index = ip6_rewrite_mcast_node.index;
|
next_index = ip6_rewrite_mcast_node.index;
|
||||||
|
|
||||||
c0 = vlib_buffer_copy (vm, p0);
|
c0 = vlib_buffer_copy (vm, p0);
|
||||||
|
if (c0 == NULL)
|
||||||
|
return radv_info->keep_sending_rs;
|
||||||
|
|
||||||
ci0 = vlib_get_buffer_index (vm, c0);
|
ci0 = vlib_get_buffer_index (vm, c0);
|
||||||
|
|
||||||
f = vlib_get_frame_to_node (vm, next_index);
|
f = vlib_get_frame_to_node (vm, next_index);
|
||||||
|
Reference in New Issue
Block a user