diff options
-rw-r--r-- | src/vlib/buffer.h | 11 | ||||
-rw-r--r-- | src/vnet/bier/bier_lookup.c | 2 | ||||
-rw-r--r-- | src/vnet/dpo/replicate_dpo.c | 3 | ||||
-rw-r--r-- | src/vnet/l2/l2_flood.c | 4 |
4 files changed, 15 insertions, 5 deletions
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h index f9750ecf3e1..99f40e840a5 100644 --- a/src/vlib/buffer.h +++ b/src/vlib/buffer.h @@ -51,6 +51,14 @@ #define VLIB_BUFFER_DATA_SIZE (2048) #define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE +/* Minimum buffer chain segment size. Does not apply to last buffer in chain. + Dataplane code can safely asume that specified amount of data is not split + into 2 chained buffers */ +#define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE (128) + +/* Amount of head buffer data copied to each replica head buffer */ +#define VLIB_BUFFER_CLONE_HEAD_SIZE (256) + typedef u8 vlib_buffer_free_list_index_t; /** \file @@ -224,6 +232,9 @@ vlib_buffer_advance (vlib_buffer_t * b, word l) ASSERT (b->current_length >= l); b->current_data += l; b->current_length -= l; + + ASSERT ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0 || + b->current_length >= VLIB_BUFFER_MIN_CHAIN_SEG_SIZE); } /** \brief Check if there is enough space in buffer to advance diff --git a/src/vnet/bier/bier_lookup.c b/src/vnet/bier/bier_lookup.c index d4500823f13..51011c98008 100644 --- a/src/vnet/bier/bier_lookup.c +++ b/src/vnet/bier/bier_lookup.c @@ -223,7 +223,7 @@ bier_lookup (vlib_main_t * vm, num_cloned = vlib_buffer_clone(vm, bi0, blm->blm_clones[thread_index], n_clones, - n_bytes + 8); + VLIB_BUFFER_CLONE_HEAD_SIZE); if (num_cloned != vec_len(blm->blm_fmasks[thread_index])) { diff --git a/src/vnet/dpo/replicate_dpo.c b/src/vnet/dpo/replicate_dpo.c index c9d86f39832..39b17f103c9 100644 --- a/src/vnet/dpo/replicate_dpo.c +++ b/src/vnet/dpo/replicate_dpo.c @@ -673,7 +673,8 @@ replicate_inline (vlib_main_t * vm, vec_validate (rm->clones[thread_index], rep0->rep_n_buckets - 1); num_cloned = vlib_buffer_clone (vm, bi0, rm->clones[thread_index], - rep0->rep_n_buckets, 128); + rep0->rep_n_buckets, + VLIB_BUFFER_CLONE_HEAD_SIZE); if (num_cloned != rep0->rep_n_buckets) { diff --git a/src/vnet/l2/l2_flood.c b/src/vnet/l2/l2_flood.c index 8908c4312d3..aeac8ff10d8 100644 --- a/src/vnet/l2/l2_flood.c +++ b/src/vnet/l2/l2_flood.c @@ -223,9 +223,7 @@ l2flood_node_fn (vlib_main_t * vm, n_cloned = vlib_buffer_clone (vm, bi0, msm->clones[thread_index], n_clones, - (vnet_buffer (b0)->l2.l2_len + - sizeof (udp_header_t) + - 2 * sizeof (ip6_header_t))); + VLIB_BUFFER_CLONE_HEAD_SIZE); if (PREDICT_FALSE (n_cloned != n_clones)) { |