diff options
-rw-r--r-- | src/vnet/bier/bier_lookup.c | 7 | ||||
-rw-r--r-- | src/vnet/l2/l2_flood.c | 3 | ||||
-rw-r--r-- | src/vppinfra/vec_bootstrap.h | 19 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/vnet/bier/bier_lookup.c b/src/vnet/bier/bier_lookup.c index a9fab9c80f1..9361845c992 100644 --- a/src/vnet/bier/bier_lookup.c +++ b/src/vnet/bier/bier_lookup.c @@ -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 @@ -225,7 +224,9 @@ bier_lookup (vlib_main_t * vm, n_clones, VLIB_BUFFER_CLONE_HEAD_SIZE); - if (num_cloned != vec_len(blm->blm_fmasks[thread_index])) + vec_set_len(blm->blm_clones[thread_index], num_cloned); + + if (num_cloned != n_clones) { vlib_node_increment_counter (vm, node->node_index, diff --git a/src/vnet/l2/l2_flood.c b/src/vnet/l2/l2_flood.c index 8d34233b520..10e087767e4 100644 --- a/src/vnet/l2/l2_flood.c +++ b/src/vnet/l2/l2_flood.c @@ -213,7 +213,6 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm, else if (n_clones > 1) { vec_validate (msm->clones[thread_index], n_clones); - vec_reset_length (msm->clones[thread_index]); /* * the header offset needs to be large enough to incorporate @@ -226,6 +225,8 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm, n_clones, VLIB_BUFFER_CLONE_HEAD_SIZE); + vec_set_len (msm->clones[thread_index], n_cloned); + if (PREDICT_FALSE (n_cloned != n_clones)) { b0->error = node->errors[L2FLOOD_ERROR_REPL_FAIL]; diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h index fec0df08143..7fb016fe8d2 100644 --- a/src/vppinfra/vec_bootstrap.h +++ b/src/vppinfra/vec_bootstrap.h @@ -142,12 +142,6 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align) #define vec_len(v) ((v) ? _vec_len(v) : 0) -/** \brief Reset vector length to zero - NULL-pointer tolerant -*/ - -#define vec_reset_length(v) do { if (v) _vec_len (v) = 0; } while (0) - /** \brief Number of data bytes in vector. */ #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) @@ -165,6 +159,19 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align) /** \brief Total number of elements that can fit into vector. */ #define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0])) +/** \brief Set vector length to a user-defined value */ +#define vec_set_len(v, l) do { \ + ASSERT(v); \ + ASSERT((l) <= vec_max_len(v)); \ + _vec_len(v) = (l); \ +} while (0) + +/** \brief Reset vector length to zero + NULL-pointer tolerant +*/ + +#define vec_reset_length(v) do { if (v) vec_set_len (v, 0); } while (0) + /** \brief End (last data address) of vector. */ #define vec_end(v) ((v) + vec_len (v)) |