misc: check return values from vlib_buffer_copy(...)
[vpp.git] / src / plugins / ioam / encap / ip6_ioam_trace.c
index 299ee88..2344857 100644 (file)
@@ -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;
 
@@ -254,13 +256,11 @@ int
 ip6_hbh_ioam_trace_data_list_handler (vlib_buffer_t * b, ip6_header_t * ip,
                                      ip6_hop_by_hop_option_t * opt)
 {
-  ip6_main_t *im = &ip6_main;
-  ip_lookup_main_t *lm = &im->lookup_main;
   ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main;
   u8 elt_index = 0;
   ioam_trace_option_t *trace = (ioam_trace_option_t *) opt;
   u32 adj_index = vnet_buffer (b)->ip.adj_index[VLIB_TX];
-  ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index);
+  ip_adjacency_t *adj = adj_get (adj_index);
   time_u64_t time_u64;
   u32 *elt;
   int rv = 0;
@@ -411,7 +411,7 @@ VLIB_CLI_COMMAND (ip6_show_ioam_trace_cmd, static) = {
 /* *INDENT-OFF* */
 VLIB_PLUGIN_REGISTER () = {
     .version = VPP_BUILD_VER,
-    .description = "Inbound OAM",
+    .description = "Inbound Operations, Administration, and Maintenance (OAM)",
 };
 /* *INDENT-ON* */
 
@@ -419,20 +419,10 @@ static clib_error_t *
 ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm)
 {
   ip6_hop_by_hop_ioam_trace_main_t *hm = &ip6_hop_by_hop_ioam_trace_main;
-  clib_error_t *error;
-
-  if ((error = vlib_call_init_function (vm, ip_main_init)))
-    return (error);
-
-  if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
-    return error;
-
-  if ((error = vlib_call_init_function (vm, ip6_hop_by_hop_ioam_init)))
-    return (error);
 
   hm->vlib_main = vm;
   hm->vnet_main = vnet_get_main ();
-  memset (hm->counters, 0, sizeof (hm->counters));
+  clib_memset (hm->counters, 0, sizeof (hm->counters));
 
 
   if (ip6_hbh_register_option
@@ -454,6 +444,14 @@ ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm)
   return (0);
 }
 
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_trace_init) =
+{
+  .runs_after = VLIB_INITS ("ip_main_init", "ip6_lookup_init",
+                            "ip6_hop_by_hop_ioam_init"),
+};
+/* *INDENT-ON* */
+
 int
 ip6_trace_profile_cleanup (void)
 {
@@ -492,9 +490,6 @@ ip6_trace_profile_setup (void)
   return (0);
 }
 
-
-VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_trace_init);
-
 /*
  * fd.io coding-style-patch-verification: ON
  *