bier: fix vector size confusing ASan
[vpp.git] / src / vnet / bier / bier_lookup.c
index 51011c9..f7a21a1 100644 (file)
@@ -22,7 +22,7 @@
 #include <vnet/bier/bier_fmask.h>
 
 /**
- * Struct maintining the per-worker thread data for BIER lookups
+ * Struct maintaining the per-worker thread data for BIER lookups
  */
 typedef struct bier_lookup_main_t_
 {
@@ -44,7 +44,7 @@ static char * bier_lookup_error_strings[] = {
 };
 
 /*
- * Keep these values sematically the same as BIER lookup
+ * Keep these values semantically the same as BIER lookup
  */
 #define foreach_bier_lookup_next                \
     _(DROP, "bier-drop")                        \
@@ -67,7 +67,7 @@ typedef enum {
 vlib_node_registration_t bier_lookup_node;
 
 /**
- * @brief Packet trace recoed for a BIER lookup
+ * @brief Packet trace record for a BIER lookup
  */
 typedef struct bier_lookup_trace_t_
 {
@@ -147,10 +147,9 @@ bier_lookup (vlib_main_t * vm,
             memcpy(bbs.bbs_buckets, bh0->bh_bit_string, bbs.bbs_len);
 
             /*
-             * reset the fmask and clone storage vectors
+             * reset the fmask storage vector
              */
             vec_reset_length (blm->blm_fmasks[thread_index]);
-            vec_reset_length (blm->blm_clones[thread_index]);
 
             /*
              * Loop through the buckets in the header
@@ -220,13 +219,16 @@ bier_lookup (vlib_main_t * vm,
 
             if (PREDICT_TRUE(0 != n_clones))
             {
+                vec_set_len(blm->blm_clones[thread_index], n_clones);
                 num_cloned = vlib_buffer_clone(vm, bi0,
                                                blm->blm_clones[thread_index],
                                                n_clones,
                                               VLIB_BUFFER_CLONE_HEAD_SIZE);
 
-                if (num_cloned != vec_len(blm->blm_fmasks[thread_index]))
+
+                if (num_cloned != n_clones)
                 {
+                    vec_set_len(blm->blm_clones[thread_index], num_cloned);
                     vlib_node_increment_counter
                         (vm, node->node_index,
                          BIER_LOOKUP_ERROR_BUFFER_ALLOCATION_FAILURE, 1);
@@ -250,9 +252,6 @@ bier_lookup (vlib_main_t * vm,
                     {
                         bier_lookup_trace_t *tr;
 
-                        if (c0 != b0)
-                            vlib_buffer_copy_trace_flag (vm, b0, ci0);
-
                         tr = vlib_add_trace (vm, node, c0, sizeof (*tr));
                         tr->bt_index = bti0;
                         tr->bfm_index = blm->blm_fmasks[thread_index][clone];