aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-03-15 01:28:31 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-03-15 16:19:11 +0000
commit9d676afbb779da5186cb3869925ef6d7d3d04db1 (patch)
tree299d7c1d9a1fbf04d4aa08ec279fcf7e0d952d8f /src
parent0856b97b494ea54f3daa6e0c31a2f882bf23a551 (diff)
No vector allocation during buffer copy
Change-Id: I7e8556af833ca0e00fadc96dcd2077ff1104541b Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/buffer_funcs.h5
-rw-r--r--src/vnet/fib/mpls_fib.h4
2 files changed, 2 insertions, 7 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index f346676baee..394c336ac49 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -476,7 +476,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
{
vlib_buffer_t *s, *d, *fd;
uword n_alloc, n_buffers = 1;
- u32 *new_buffers = 0;
u32 flag_mask = VLIB_BUFFER_NEXT_PRESENT | VLIB_BUFFER_TOTAL_LENGTH_VALID;
int i;
@@ -486,8 +485,8 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
n_buffers++;
s = vlib_get_buffer (vm, s->next_buffer);
}
+ u32 new_buffers[n_buffers];
- vec_validate (new_buffers, n_buffers - 1);
n_alloc = vlib_buffer_alloc (vm, new_buffers, n_buffers);
/* No guarantee that we'll get all the buffers we asked for */
@@ -495,7 +494,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
{
if (n_alloc > 0)
vlib_buffer_free (vm, new_buffers, n_alloc);
- vec_free (new_buffers);
return 0;
}
@@ -526,7 +524,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
d->flags = s->flags & flag_mask;
}
- vec_free (new_buffers);
return fd;
}
diff --git a/src/vnet/fib/mpls_fib.h b/src/vnet/fib/mpls_fib.h
index e2ef9253a9d..779decaa7ef 100644
--- a/src/vnet/fib/mpls_fib.h
+++ b/src/vnet/fib/mpls_fib.h
@@ -28,9 +28,7 @@
static inline mpls_fib_t*
mpls_fib_get (fib_node_index_t index)
{
- if (!pool_is_free_index(mpls_main.fibs, index))
- return (&(pool_elt_at_index(mpls_main.fibs, index)->mpls));
- return (NULL);
+ return (&(pool_elt_at_index(mpls_main.fibs, index)->mpls));
}
extern u32 mpls_fib_table_find_or_create_and_lock(u32 table_id);