vlib_buffer_is_known (vlib_main_t * vm, u32 buffer_index)
{
vlib_buffer_main_t *bm = vm->buffer_main;
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
uword *p = hash_get (bm->buffer_known_hash, buffer_index);
return p ? p[0] : VLIB_BUFFER_UNKNOWN;
vlib_buffer_known_state_t state)
{
vlib_buffer_main_t *bm = vm->buffer_main;
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
hash_set (bm->buffer_known_hash, buffer_index, state);
}
{
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;
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 */
{
if (n_alloc > 0)
vlib_buffer_free (vm, new_buffers, n_alloc);
- vec_free (new_buffers);
return 0;
}
d->flags = s->flags & flag_mask;
}
- vec_free (new_buffers);
return fd;
}
/* Make sure buffer template is sane. */
ASSERT (fl->index == fl->buffer_init_template.free_list_index);
+ clib_memcpy (STRUCT_MARK_PTR (dst, template_start),
+ STRUCT_MARK_PTR (src, template_start),
+ STRUCT_OFFSET_OF (vlib_buffer_t, template_end) -
+ STRUCT_OFFSET_OF (vlib_buffer_t, template_start));
+
+ /* Not in the first 16 octets. */
+ dst->n_add_refs = src->n_add_refs;
+
/* Make sure it really worked. */
-#define _(f) dst->f = src->f
+#define _(f) ASSERT (dst->f == src->f);
_(current_data);
_(current_length);
_(flags);
_(free_list_index);
#undef _
- dst->total_length_not_including_first_buffer = 0;
+ ASSERT (dst->total_length_not_including_first_buffer == 0);
ASSERT (dst->n_add_refs == 0);
}
/* Make sure buffer template is sane. */
ASSERT (fl->index == fl->buffer_init_template.free_list_index);
+ clib_memcpy (STRUCT_MARK_PTR (dst0, template_start),
+ STRUCT_MARK_PTR (src, template_start),
+ STRUCT_OFFSET_OF (vlib_buffer_t, template_end) -
+ STRUCT_OFFSET_OF (vlib_buffer_t, template_start));
+
+ clib_memcpy (STRUCT_MARK_PTR (dst1, template_start),
+ STRUCT_MARK_PTR (src, template_start),
+ STRUCT_OFFSET_OF (vlib_buffer_t, template_end) -
+ STRUCT_OFFSET_OF (vlib_buffer_t, template_start));
+
+ /* Not in the first 16 octets. */
+ dst0->n_add_refs = src->n_add_refs;
+ dst1->n_add_refs = src->n_add_refs;
+
/* Make sure it really worked. */
-#define _(f) dst0->f = src->f; dst1->f = src->f
+#define _(f) ASSERT (dst0->f == src->f); ASSERT( dst1->f == src->f)
_(current_data);
_(current_length);
_(flags);
_(free_list_index);
#undef _
- dst0->total_length_not_including_first_buffer = 0;
- dst1->total_length_not_including_first_buffer = 0;
+
+ ASSERT (dst0->total_length_not_including_first_buffer == 0);
+ ASSERT (dst1->total_length_not_including_first_buffer == 0);
ASSERT (dst0->n_add_refs == 0);
ASSERT (dst1->n_add_refs == 0);
}