aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/dhcp
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-04-08 08:14:57 -0400
committerFlorin Coras <florin.coras@gmail.com>2020-04-08 16:29:44 +0000
commit954c707972bf7efcd227e26d9679544813a78115 (patch)
tree99e3ff617ceaef9c94f5cb33176ac14d248a316b /src/plugins/dhcp
parent8d0d8d2fcccd77e462f30b21f7f8810db312ee62 (diff)
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
Diffstat (limited to 'src/plugins/dhcp')
-rw-r--r--src/plugins/dhcp/dhcp4_proxy_error.def2
-rw-r--r--src/plugins/dhcp/dhcp4_proxy_node.c7
-rw-r--r--src/plugins/dhcp/dhcp6_ia_na_client_dp.c3
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_dp.c3
-rw-r--r--src/plugins/dhcp/dhcp6_proxy_error.def1
-rw-r--r--src/plugins/dhcp/dhcp6_proxy_node.c7
6 files changed, 22 insertions, 1 deletions
diff --git a/src/plugins/dhcp/dhcp4_proxy_error.def b/src/plugins/dhcp/dhcp4_proxy_error.def
index 83f11830ab6..bd814e34ff8 100644
--- a/src/plugins/dhcp/dhcp4_proxy_error.def
+++ b/src/plugins/dhcp/dhcp4_proxy_error.def
@@ -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 (PKT_TOO_BIG, "DHCP packets which are too big.")
dhcp_proxy_error (FOR_US, "DHCP packets for local client.")
-
+dhcp_proxy_error (ALLOC_FAIL, "DHCP buffer allocation failures.")
diff --git a/src/plugins/dhcp/dhcp4_proxy_node.c b/src/plugins/dhcp/dhcp4_proxy_node.c
index 53c95c09f12..28c3e624aa1 100644
--- a/src/plugins/dhcp/dhcp4_proxy_node.c
+++ b/src/plugins/dhcp/dhcp4_proxy_node.c
@@ -364,6 +364,13 @@ dhcp_proxy_to_server_input (vlib_main_t * vm,
u32 ci0;
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);
ci0 = vlib_get_buffer_index (vm, c0);
server = &proxy->dhcp_servers[ii];
diff --git a/src/plugins/dhcp/dhcp6_ia_na_client_dp.c b/src/plugins/dhcp/dhcp6_ia_na_client_dp.c
index 3cf2fb1b349..c240beb3eb3 100644
--- a/src/plugins/dhcp/dhcp6_ia_na_client_dp.c
+++ b/src/plugins/dhcp/dhcp6_ia_na_client_dp.c
@@ -258,6 +258,9 @@ check_send_client_message (vlib_main_t * vm,
next_index = ip6_rewrite_mcast_node.index;
c0 = vlib_buffer_copy (vm, p0);
+ if (c0 == NULL)
+ return client_state->keep_sending_client_message;
+
ci0 = vlib_get_buffer_index (vm, c0);
ip = (ip6_header_t *) vlib_buffer_get_current (c0);
diff --git a/src/plugins/dhcp/dhcp6_pd_client_dp.c b/src/plugins/dhcp/dhcp6_pd_client_dp.c
index 980c83c7bbe..b43e5a4754d 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_dp.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_dp.c
@@ -264,6 +264,9 @@ check_pd_send_client_message (vlib_main_t * vm,
next_index = ip6_rewrite_mcast_node.index;
c0 = vlib_buffer_copy (vm, p0);
+ if (c0 == NULL)
+ return client_state->keep_sending_client_message;
+
ci0 = vlib_get_buffer_index (vm, c0);
ip = (ip6_header_t *) vlib_buffer_get_current (c0);
diff --git a/src/plugins/dhcp/dhcp6_proxy_error.def b/src/plugins/dhcp/dhcp6_proxy_error.def
index 55fa731766c..5a85c423c5f 100644
--- a/src/plugins/dhcp/dhcp6_proxy_error.def
+++ b/src/plugins/dhcp/dhcp6_proxy_error.def
@@ -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 (PKT_TOO_BIG, "DHCPv6 packets which are too big.")
dhcpv6_proxy_error (WRONG_INTERFACE_ID_OPTION, "DHCPv6 reply to invalid interface.")
+dhcpv6_proxy_error (ALLOC_FAIL, "DHCPv6 buffer allocation failures.")
diff --git a/src/plugins/dhcp/dhcp6_proxy_node.c b/src/plugins/dhcp/dhcp6_proxy_node.c
index 272c379b6a3..95e5c9272f5 100644
--- a/src/plugins/dhcp/dhcp6_proxy_node.c
+++ b/src/plugins/dhcp/dhcp6_proxy_node.c
@@ -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];