aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2018-05-15 11:43:56 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-05-25 17:07:42 +0000
commitc65770deebf63d34cc09c6aa3af7c86b3affb4b8 (patch)
tree762c09083d338c98834f9c6e233186df7e7e4391 /src/vnet/ip
parent56318932367ecb3fa65243033f1f8978c32fd4a4 (diff)
Fix possible null pointer dereference
Replace clib_warning with vlib_log_warn Change-Id: I6d0b8d97048b75f4418609264af0c14e19fad79b Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/rd_cp.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/vnet/ip/rd_cp.c b/src/vnet/ip/rd_cp.c
index 21e45519da1..164b3045775 100644
--- a/src/vnet/ip/rd_cp.c
+++ b/src/vnet/ip/rd_cp.c
@@ -71,6 +71,9 @@ typedef struct
svm_queue_t *vl_input_queue;
u32 my_client_index;
+ /* logging */
+ vlib_log_class_t log_class;
+
/* convenience */
vlib_main_t *vlib_main;
vnet_main_t *vnet_main;
@@ -210,7 +213,7 @@ get_interface_mac_address (u32 sw_if_index, u8 mac[])
if (!vnet_sw_interface_is_api_valid (rm->vnet_main, sw_if_index))
{
- clib_warning ("Invalid sw_if_index");
+ vlib_log_warn (rm->log_class, "Invalid sw_if_index");
return 1;
}
@@ -218,6 +221,12 @@ get_interface_mac_address (u32 sw_if_index, u8 mac[])
if (si->type == VNET_SW_INTERFACE_TYPE_HARDWARE)
eth_if = ethernet_get_interface (&ethernet_main, si->hw_if_index);
+ if (!eth_if)
+ {
+ vlib_log_warn (rm->log_class, "Failed to get hardware interface");
+ return 1;
+ }
+
clib_memcpy (mac, eth_if->address, 6);
return 0;
@@ -316,7 +325,7 @@ ip6_ra_report_handler (void *data)
if (get_interface_mac_address (sw_if_index, mac) != 0)
{
- clib_warning ("Error getting MAC address");
+ vlib_log_warn (rm->log_class, "Error getting MAC address");
return clib_error_return (0, "Error getting MAC address");
}
@@ -501,7 +510,7 @@ set_address_autoconfig (u32 sw_if_index, u8 enable, u8 install_default_routes)
if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
{
- clib_warning ("Invalid sw_if_index");
+ vlib_log_warn (rm->log_class, "Invalid sw_if_index");
return 1;
}
@@ -652,6 +661,8 @@ rd_cp_init (vlib_main_t * vm)
rm->api_main = am;
rm->node_index = rd_cp_process_node.index;
+ rm->log_class = vlib_log_register_class ("rd_cp", 0);
+
#define _(N,n) \
vl_msg_api_set_handlers(VL_API_##N, #n, \
vl_api_##n##_t_handler, \