buffers: don't init metadata, as it is already initialized
Change-Id: Ia083050389853c25b069f0f8286d50d3f4aef527
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index 37966ba..626bea2 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -210,7 +210,6 @@
return 0;
clib_memset (&bt, 0, sizeof (vlib_buffer_t));
- vlib_buffer_init_for_free_list (&bt, fl);
bt.buffer_pool_index = privp->buffer_pool_index;
_vec_len (d->mbuf_alloc_list) = n_alloc;
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index df1a823..93f0205 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -273,11 +273,8 @@
CLIB_CACHE_LINE_BYTES);
for (i = 0; i < tm->n_vlib_mains; i++)
{
- vlib_buffer_free_list_t *fl;
dpdk_per_thread_data_t *ptd = vec_elt_at_index (dm->per_thread_data, i);
- fl = vlib_buffer_get_free_list (vm,
- VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (&ptd->buffer_template, fl);
+ clib_memset (&ptd->buffer_template, 0, sizeof (vlib_buffer_t));
ptd->buffer_template.flags = dm->buffer_flags_template;
vnet_buffer (&ptd->buffer_template)->sw_if_index[VLIB_TX] = (u32) ~ 0;
}
diff --git a/src/plugins/flowprobe/node.c b/src/plugins/flowprobe/node.c
index 2cd754b..8dfc47c 100644
--- a/src/plugins/flowprobe/node.c
+++ b/src/plugins/flowprobe/node.c
@@ -631,7 +631,6 @@
flow_report_main_t *frm = &flow_report_main;
vlib_buffer_t *b0;
u32 bi0;
- vlib_buffer_free_list_t *fl;
u32 my_cpu_number = vm->thread_index;
/* Find or allocate a buffer */
@@ -650,9 +649,6 @@
/* Initialize the buffer */
b0 = fm->context[which].buffers_per_worker[my_cpu_number] =
vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
b0->current_data = 0;
diff --git a/src/plugins/igmp/igmp_pkt.c b/src/plugins/igmp/igmp_pkt.c
index 81b8ecb..e93dd9c 100644
--- a/src/plugins/igmp/igmp_pkt.c
+++ b/src/plugins/igmp/igmp_pkt.c
@@ -27,7 +27,6 @@
static vlib_buffer_t *
igmp_pkt_get_buffer (igmp_pkt_build_t * bk)
{
- vlib_buffer_free_list_t *fl;
vlib_main_t *vm;
vlib_buffer_t *b;
u32 bi;
@@ -38,8 +37,6 @@
return (NULL);
b = vlib_get_buffer (vm, bi);
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
diff --git a/src/plugins/nat/nat_ipfix_logging.c b/src/plugins/nat/nat_ipfix_logging.c
index 042239f..8bee8e4 100644
--- a/src/plugins/nat/nat_ipfix_logging.c
+++ b/src/plugins/nat/nat_ipfix_logging.c
@@ -620,7 +620,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 proto = ~0;
if (!silm->enabled)
@@ -645,9 +644,6 @@
}
b0 = silm->nat44_session_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -723,7 +719,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 nat_event = NAT_ADDRESSES_EXHAUTED;
if (!silm->enabled)
@@ -746,9 +741,6 @@
}
b0 = silm->addr_exhausted_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -809,7 +801,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_ENTRIES_PER_USER;
@@ -833,9 +824,6 @@
}
b0 = silm->max_entries_per_user_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -902,7 +890,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_SESSION_ENTRIES;
@@ -926,9 +913,6 @@
}
b0 = silm->max_sessions_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -992,7 +976,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_BIB_ENTRIES;
@@ -1016,9 +999,6 @@
}
b0 = silm->max_bibs_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -1082,7 +1062,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_FRAGMENTS_PENDING_REASSEMBLY;
@@ -1106,9 +1085,6 @@
}
b0 = silm->max_frags_ip4_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -1175,7 +1151,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_FRAGMENTS_PENDING_REASSEMBLY;
@@ -1199,9 +1174,6 @@
}
b0 = silm->max_frags_ip6_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -1270,7 +1242,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
if (!silm->enabled)
return;
@@ -1292,9 +1263,6 @@
}
b0 = silm->nat64_bib_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
@@ -1374,7 +1342,6 @@
u32 offset;
vlib_main_t *vm = frm->vlib_main;
u64 now;
- vlib_buffer_free_list_t *fl;
if (!silm->enabled)
return;
@@ -1396,9 +1363,6 @@
}
b0 = silm->nat64_ses_buffer = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
}
diff --git a/src/plugins/nsim/nsim_input.c b/src/plugins/nsim/nsim_input.c
index 2e328a5..44c9f53 100644
--- a/src/plugins/nsim/nsim_input.c
+++ b/src/plugins/nsim/nsim_input.c
@@ -81,7 +81,6 @@
uword n_rx_packets = 0;
vlib_buffer_t *b0;
u32 bi0, next0;
- vlib_buffer_free_list_t *fl;
u32 *to_next;
u32 next_index;
u32 n_left_to_next;
@@ -100,7 +99,6 @@
* We use per-thread buffer caches, so we need the freelist to
* initialize them...
*/
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
next_index = node->cached_next_index;
while (wp->cursize)
@@ -149,7 +147,6 @@
b0 = vlib_get_buffer (vm, bi0);
/* Initialize the buffer */
- vlib_buffer_init_for_free_list (b0, fl);
b0->current_data = 0;
b0->current_length = ep->current_length;
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 547c264..419d7e2 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -531,7 +531,6 @@
vlib_buffer_set_known_state (vm, bi[0], VLIB_BUFFER_KNOWN_FREE);
clib_memset (b, 0, sizeof (vlib_buffer_t));
- vlib_buffer_init_for_free_list (b, fl);
if (fl->buffer_init_function)
fl->buffer_init_function (vm, fl, bi, 1);
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index 9095bd3..199dad0 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -967,43 +967,6 @@
vec_free (t->packet_data);
}
-/* Set a buffer quickly into "uninitialized" state. We want this to
- be extremely cheap and arrange for all fields that need to be
- initialized to be in the first 128 bits of the buffer. */
-always_inline void
-vlib_buffer_init_for_free_list (vlib_buffer_t * dst,
- vlib_buffer_free_list_t * fl)
-{
- vlib_buffer_t *src = &fl->buffer_init_template;
-
- /* Make sure vlib_buffer_t is cacheline aligned and sized */
- ASSERT (STRUCT_OFFSET_OF (vlib_buffer_t, cacheline0) == 0);
- ASSERT (STRUCT_OFFSET_OF (vlib_buffer_t, cacheline1) ==
- CLIB_CACHE_LINE_BYTES);
- ASSERT (STRUCT_OFFSET_OF (vlib_buffer_t, cacheline2) ==
- CLIB_CACHE_LINE_BYTES * 2);
-
- /* Make sure buffer template is sane. */
- vlib_buffer_copy_template (dst, src);
-
- /* Not in the first 16 octets. */
- dst->n_add_refs = src->n_add_refs;
-
- /* Make sure it really worked. */
-#define _(f) ASSERT (dst->f == src->f);
- _(current_data);
- _(current_length);
- _(flags);
-#undef _
- /* ASSERT (dst->total_length_not_including_first_buffer == 0); */
- /* total_length_not_including_first_buffer is not in the template anymore
- * so it may actually not zeroed for some buffers. One option is to
- * uncomment the line lower (comes at a cost), the other, is to just not
- * care */
- /* dst->total_length_not_including_first_buffer = 0; */
- ASSERT (dst->n_add_refs == 0);
-}
-
static_always_inline vlib_buffer_pool_t *
vlib_buffer_pool_get (vlib_main_t * vm, u8 buffer_pool_index)
{
@@ -1020,7 +983,7 @@
vlib_buffer_t *b;
b = vlib_get_buffer (vm, buffer_index);
if (PREDICT_TRUE (do_init))
- vlib_buffer_init_for_free_list (b, f);
+ clib_memset (b, 0, STRUCT_OFFSET_OF (vlib_buffer_t, template_end));
vec_add1_aligned (f->buffers, buffer_index, CLIB_CACHE_LINE_BYTES);
if (vec_len (f->buffers) > 4 * VLIB_FRAME_SIZE)
diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c
index ea58413..0cc7d72 100644
--- a/src/vnet/bfd/bfd_main.c
+++ b/src/vnet/bfd/bfd_main.c
@@ -908,7 +908,6 @@
}
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
ASSERT (b->current_data == 0);
- clib_memset (vnet_buffer (b), 0, sizeof (*vnet_buffer (b)));
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
bfd_echo_pkt_t *pkt = vlib_buffer_get_current (b);
clib_memset (pkt, 0, sizeof (*pkt));
@@ -982,7 +981,6 @@
}
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
ASSERT (b->current_data == 0);
- clib_memset (vnet_buffer (b), 0, sizeof (*vnet_buffer (b)));
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
bfd_init_control_frame (bm, bs, b);
switch (bs->poll_state)
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c
index d35c6de..041e584 100644
--- a/src/vnet/bfd/bfd_udp.c
+++ b/src/vnet/bfd/bfd_udp.c
@@ -1239,7 +1239,6 @@
{
b0->current_data = 0;
b0->current_length = 0;
- clib_memset (vnet_buffer (b0), 0, sizeof (*vnet_buffer (b0)));
bfd_init_final_control_frame (vm, b0, bfd_udp_main.bfd_main, bs,
0);
if (is_ipv6)
diff --git a/src/vnet/dhcp/dhcp6_proxy_node.c b/src/vnet/dhcp/dhcp6_proxy_node.c
index ea06c18..92e011b 100644
--- a/src/vnet/dhcp/dhcp6_proxy_node.c
+++ b/src/vnet/dhcp/dhcp6_proxy_node.c
@@ -179,7 +179,6 @@
dhcpv6_client_mac_t *cmac; // client mac
ethernet_header_t *e_h0;
u8 client_src_mac[6];
- vlib_buffer_free_list_t *fl;
dhcp_vss_t *vss;
u8 is_solicit = 0;
@@ -315,11 +314,9 @@
copy_ip6_address (&r1->link_addr, ia0);
link_address_set:
- fl = vlib_buffer_get_free_list
- (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
if ((b0->current_length + sizeof (*id1) + sizeof (*vss1) +
- sizeof (*cmac)) > fl->n_data_bytes)
+ sizeof (*cmac)) > VLIB_BUFFER_DATA_SIZE)
{
error0 = DHCPV6_PROXY_ERROR_PKT_TOO_BIG;
next0 = DHCPV6_PROXY_TO_SERVER_INPUT_NEXT_DROP;
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index d501832..b4b6888 100755
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -2307,7 +2307,6 @@
{
u32 bi0;
vlib_buffer_t *p0;
- vlib_buffer_free_list_t *fl;
icmp6_router_solicitation_header_t *rh;
u16 payload_length;
int bogus_length;
@@ -2322,8 +2321,6 @@
}
p0 = vlib_get_buffer (vm, bi0);
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (p0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (p0);
p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
diff --git a/src/vnet/ip/ip_frag.c b/src/vnet/ip/ip_frag.c
index de09987..de29776 100644
--- a/src/vnet/ip/ip_frag.c
+++ b/src/vnet/ip/ip_frag.c
@@ -78,9 +78,6 @@
return 0;
vlib_buffer_t *b = vlib_get_buffer (vm, *bi);
- vlib_buffer_free_list_t *fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
vlib_buffer_copy_trace_flag (vm, org_b, *bi);
diff --git a/src/vnet/ip/ping.c b/src/vnet/ip/ping.c
index 92a92e5..890285f 100755
--- a/src/vnet/ip/ping.c
+++ b/src/vnet/ip/ping.c
@@ -745,15 +745,12 @@
u32 bi0 = 0;
int n_buf0 = 0;
vlib_buffer_t *b0;
- vlib_buffer_free_list_t *fl;
n_buf0 = vlib_buffer_alloc (vm, &bi0, 1);
if (n_buf0 < 1)
ERROR_OUT (SEND_PING_ALLOC_FAIL);
b0 = vlib_get_buffer (vm, bi0);
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
/*
diff --git a/src/vnet/ipfix-export/flow_report.c b/src/vnet/ipfix-export/flow_report.c
index c9370a7..da91a7c 100644
--- a/src/vnet/ipfix-export/flow_report.c
+++ b/src/vnet/ipfix-export/flow_report.c
@@ -86,7 +86,6 @@
udp_header_t *udp;
vlib_main_t *vm = frm->vlib_main;
flow_report_stream_t *stream;
- vlib_buffer_free_list_t *fl;
ASSERT (buffer_indexp);
@@ -120,11 +119,9 @@
b0 = vlib_get_buffer (vm, bi0);
/* Initialize the buffer */
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
- ASSERT (vec_len (fr->rewrite) < VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES);
+ ASSERT (vec_len (fr->rewrite) < VLIB_BUFFER_DATA_SIZE);
clib_memcpy_fast (b0->data, fr->rewrite, vec_len (fr->rewrite));
b0->current_data = 0;
diff --git a/src/vnet/ipfix-export/ipfix_doc.md b/src/vnet/ipfix-export/ipfix_doc.md
index 95db15c..5feea0e 100644
--- a/src/vnet/ipfix-export/ipfix_doc.md
+++ b/src/vnet/ipfix-export/ipfix_doc.md
@@ -284,7 +284,6 @@
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_buffer_free_list_t *fl;
b0 = mlm->buffers_by_thread[thread_index];
@@ -300,9 +299,6 @@
}
b0 = vlib_get_buffer (vm, bi0);
- fl =
- vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b0, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
offset = 0;
mlm->buffers_by_thread[thread_index] = b0;
diff --git a/src/vnet/syslog/syslog.c b/src/vnet/syslog/syslog.c
index 1cffe03..462c5de 100644
--- a/src/vnet/syslog/syslog.c
+++ b/src/vnet/syslog/syslog.c
@@ -163,7 +163,6 @@
u32 bi, msg_len, *to_next;
u8 *tmp;
vlib_buffer_t *b;
- vlib_buffer_free_list_t *fl;
vlib_frame_t *f;
int i;
@@ -171,9 +170,6 @@
return -1;
b = vlib_get_buffer (vm, bi);
- clib_memset (vnet_buffer (b), 0, sizeof (*vnet_buffer (b)));
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- vlib_buffer_init_for_free_list (b, fl);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
/* one message per UDP datagram RFC5426 3.1. */