summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-03-16 15:21:35 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-16 20:28:13 +0000
commit0d65d11053395bde7bd8c36439e9025e50ea8028 (patch)
treee893ef41493550da42dcb6486b8c1c33a4b934b3 /src/vlib
parentc03742346f0f3f08b83b0d2944bf72e19ea26191 (diff)
Fix a long-latent bi=0 bug in vlib_buffer_add_data
Change vlib_buffer_add_data() so it interprets ~0 to mean please allocate a new buffer, instead of 0. Fixed a couple of calls to pass ~0 instead of 0. Zero has always been a valid buffer index, we never happened to actually use it until recent buffer allocator changes. The presenting symptom: ASSERT failure when running "make TEST=test_mpls test-debug" Change-Id: Ic909913c1d464b3434d6d47e0c58f978806854d5 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/buffer.c2
-rw-r--r--src/vlib/buffer_serialize.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 6caca72cf03..3f90f5a0860 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -817,7 +817,7 @@ vlib_buffer_add_data (vlib_main_t * vm,
void *d;
bi = buffer_index;
- if (bi == 0
+ if (bi == ~0
&& 1 != vlib_buffer_alloc_from_free_list (vm, &bi, 1, free_list_index))
goto out_of_buffers;
diff --git a/src/vlib/buffer_serialize.c b/src/vlib/buffer_serialize.c
index 96a5f0a0da8..48dcce3be90 100644
--- a/src/vlib/buffer_serialize.c
+++ b/src/vlib/buffer_serialize.c
@@ -216,7 +216,7 @@ serialize_close_vlib_buffer (serialize_main_t * m)
{
sm->last_buffer
= vlib_buffer_add_data (sm->vlib_main, sm->tx.free_list_index,
- sm->last_buffer == ~0 ? 0 : sm->last_buffer,
+ sm->last_buffer,
s->overflow_buffer,
vec_len (s->overflow_buffer));
_vec_len (s->overflow_buffer) = 0;