First commit SR MPLS
[vpp.git] / src / plugins / ioam / ip6 / ioam_cache.h
index aa88d58..e668ad7 100644 (file)
@@ -20,7 +20,7 @@
 #include <vnet/ip/ip_packet.h>
 #include <vnet/ip/ip4_packet.h>
 #include <vnet/ip/ip6_packet.h>
-#include <vnet/sr/sr.h>
+#include <vnet/srv6/sr.h>
 
 #include <vppinfra/pool.h>
 #include <vppinfra/hash.h>
@@ -203,8 +203,8 @@ typedef struct
 
 ioam_cache_main_t ioam_cache_main;
 
-vlib_node_registration_t ioam_cache_node;
-vlib_node_registration_t ioam_cache_ts_node;
+extern vlib_node_registration_t ioam_cache_node;
+extern vlib_node_registration_t ioam_cache_ts_node;
 
 /*  Compute flow hash.  We'll use it to select which Sponge to use for this
  *  flow.  And other things.
@@ -436,9 +436,9 @@ ioam_cache_sr_rewrite_template_create (void)
 
   /* This nodes address and the original dest will be
    * filled when the packet is processed */
-  vec_add2 (segments, this_seg, 2);
-  memset (this_seg, 0xfe, 2 * sizeof (ip6_address_t));
-  cm->sr_rewrite_template = ip6_compute_rewrite_string_insert (segments);
+  vec_add2 (segments, this_seg, 1);
+  memset (this_seg, 0xfe, sizeof (ip6_address_t));
+  cm->sr_rewrite_template = ip6_sr_compute_rewrite_string_insert (segments);
   vec_free (segments);
 }
 
@@ -484,16 +484,21 @@ format_ioam_cache_entry (u8 * s, va_list * args)
 {
   ioam_cache_entry_t *e = va_arg (*args, ioam_cache_entry_t *);
   ioam_cache_main_t *cm = &ioam_cache_main;
+  int rewrite_len = vec_len (e->ioam_rewrite_string);
 
   s = format (s, "%d: %U:%d to  %U:%d seq_no %lu\n",
              (e - cm->ioam_rewrite_pool),
              format_ip6_address, &e->src_address,
              e->src_port,
              format_ip6_address, &e->dst_address, e->dst_port, e->seq_no);
-  s = format (s, "  %U",
-             format_ip6_hop_by_hop_ext_hdr,
-             (ip6_hop_by_hop_header_t *) e->ioam_rewrite_string,
-             vec_len (e->ioam_rewrite_string) - 1);
+
+  if (rewrite_len)
+    {
+      s = format (s, "  %U",
+                 format_ip6_hop_by_hop_ext_hdr,
+                 (ip6_hop_by_hop_header_t *) e->ioam_rewrite_string,
+                 rewrite_len - 1);
+    }
   return s;
 }
 
@@ -795,7 +800,10 @@ format_ioam_cache_ts_entry (u8 * s, va_list * args)
   vlib_main_t *vm = cm->vlib_main;
   clib_time_t *ct = &vm->clib_time;
 
-  if (e && e->hbh)
+  if (!e)
+    goto end;
+
+  if (e->hbh)
     {
       e2e =
        ip6_ioam_find_hbh_option (e->hbh,
@@ -826,6 +834,8 @@ format_ioam_cache_ts_entry (u8 * s, va_list * args)
                 vm->cpu_time_main_loop_start) * ct->seconds_per_clock,
                e->response_received);
     }
+
+end:
   return s;
 }