Remove c-11 memcpy checks from perf-critical code
Change-Id: Id4f37f5d4a03160572954a416efa1ef9b3d79ad1
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/vnet/ip/ip.c b/src/vnet/ip/ip.c
index 144bbcc..cab0cd0 100644
--- a/src/vnet/ip/ip.c
+++ b/src/vnet/ip/ip.c
@@ -70,7 +70,7 @@
prefix.fp_proto = FIB_PROTOCOL_IP6;
}
- clib_memcpy (&prefix.fp_addr, ip46_address, sizeof (ip46_address_t));
+ clib_memcpy_fast (&prefix.fp_addr, ip46_address, sizeof (ip46_address_t));
fei = fib_table_lookup (fib_index, &prefix);
flags = fib_entry_get_flags (fei);
@@ -83,7 +83,7 @@
if (is_ip4)
dst->ip4.as_u32 = src->ip4.as_u32;
else
- clib_memcpy (&dst->ip6, &src->ip6, sizeof (ip6_address_t));
+ clib_memcpy_fast (&dst->ip6, &src->ip6, sizeof (ip6_address_t));
}
void
@@ -92,7 +92,8 @@
if (is_ip4)
dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
else
- clib_memcpy (&dst->ip6, (ip6_address_t *) src, sizeof (ip6_address_t));
+ clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
+ sizeof (ip6_address_t));
}
u8
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index 9911eb7..e011e51 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -1072,9 +1072,9 @@
vec_elt (im->fib_index_by_sw_if_index,
vnet_buffer (b0)->sw_if_index[VLIB_RX]);
- clib_memcpy (t0->packet_data,
- vlib_buffer_get_current (b0),
- sizeof (t0->packet_data));
+ clib_memcpy_fast (t0->packet_data,
+ vlib_buffer_get_current (b0),
+ sizeof (t0->packet_data));
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -1086,8 +1086,8 @@
(u32) ~ 0) ? vnet_buffer (b1)->sw_if_index[VLIB_TX] :
vec_elt (im->fib_index_by_sw_if_index,
vnet_buffer (b1)->sw_if_index[VLIB_RX]);
- clib_memcpy (t1->packet_data, vlib_buffer_get_current (b1),
- sizeof (t1->packet_data));
+ clib_memcpy_fast (t1->packet_data, vlib_buffer_get_current (b1),
+ sizeof (t1->packet_data));
}
from += 2;
n_left -= 2;
@@ -1113,8 +1113,8 @@
(u32) ~ 0) ? vnet_buffer (b0)->sw_if_index[VLIB_TX] :
vec_elt (im->fib_index_by_sw_if_index,
vnet_buffer (b0)->sw_if_index[VLIB_RX]);
- clib_memcpy (t0->packet_data, vlib_buffer_get_current (b0),
- sizeof (t0->packet_data));
+ clib_memcpy_fast (t0->packet_data, vlib_buffer_get_current (b0),
+ sizeof (t0->packet_data));
}
from += 1;
n_left -= 1;
@@ -1852,9 +1852,9 @@
hw_if0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
/* Src ethernet address in ARP header. */
- clib_memcpy (h0->ip4_over_ethernet[0].ethernet,
- hw_if0->hw_address,
- sizeof (h0->ip4_over_ethernet[0].ethernet));
+ clib_memcpy_fast (h0->ip4_over_ethernet[0].ethernet,
+ hw_if0->hw_address,
+ sizeof (h0->ip4_over_ethernet[0].ethernet));
if (is_glean)
{
/* The interface's source address is stashed in the Glean Adj */
@@ -2027,8 +2027,8 @@
sw_if_index);
}
- clib_memcpy (h->ip4_over_ethernet[0].ethernet, hi->hw_address,
- sizeof (h->ip4_over_ethernet[0].ethernet));
+ clib_memcpy_fast (h->ip4_over_ethernet[0].ethernet, hi->hw_address,
+ sizeof (h->ip4_over_ethernet[0].ethernet));
h->ip4_over_ethernet[0].ip4 = src[0];
h->ip4_over_ethernet[1].ip4 = dst[0];
diff --git a/src/vnet/ip/ip4_options.c b/src/vnet/ip/ip4_options.c
index c008b9b..1b5a787 100644
--- a/src/vnet/ip/ip4_options.c
+++ b/src/vnet/ip/ip4_options.c
@@ -94,7 +94,7 @@
ip4_options_trace_t *t =
vlib_add_trace (vm, node, b, sizeof (*t));
- clib_memcpy (t->option, options, 4);
+ clib_memcpy_fast (t->option, options, 4);
}
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi, next);
diff --git a/src/vnet/ip/ip4_packet.h b/src/vnet/ip/ip4_packet.h
index fa86229..2ce6763 100644
--- a/src/vnet/ip/ip4_packet.h
+++ b/src/vnet/ip/ip4_packet.h
@@ -67,7 +67,8 @@
ip4_addr_fib_init (ip4_address_fib_t * addr_fib,
const ip4_address_t * address, u32 fib_index)
{
- clib_memcpy (&addr_fib->ip4_addr, address, sizeof (addr_fib->ip4_addr));
+ clib_memcpy_fast (&addr_fib->ip4_addr, address,
+ sizeof (addr_fib->ip4_addr));
addr_fib->fib_index = fib_index;
}
diff --git a/src/vnet/ip/ip4_reassembly.c b/src/vnet/ip/ip4_reassembly.c
index 42231d0..bd33026 100644
--- a/src/vnet/ip/ip4_reassembly.c
+++ b/src/vnet/ip/ip4_reassembly.c
@@ -1125,8 +1125,8 @@
else
{
clib_bihash_free_16_8 (&ip4_reass_main.hash);
- clib_memcpy (&ip4_reass_main.hash, &new_hash,
- sizeof (ip4_reass_main.hash));
+ clib_memcpy_fast (&ip4_reass_main.hash, &new_hash,
+ sizeof (ip4_reass_main.hash));
}
}
return 0;
diff --git a/src/vnet/ip/ip6.h b/src/vnet/ip/ip6.h
index e807886..aef2445 100644
--- a/src/vnet/ip/ip6.h
+++ b/src/vnet/ip/ip6.h
@@ -616,10 +616,10 @@
ip6h->hop_limit = 0xff;
ip6h->protocol = proto;
- clib_memcpy (ip6h->src_address.as_u8, src->as_u8,
- sizeof (ip6h->src_address));
- clib_memcpy (ip6h->dst_address.as_u8, dst->as_u8,
- sizeof (ip6h->src_address));
+ clib_memcpy_fast (ip6h->src_address.as_u8, src->as_u8,
+ sizeof (ip6h->src_address));
+ clib_memcpy_fast (ip6h->dst_address.as_u8, dst->as_u8,
+ sizeof (ip6h->src_address));
b->flags |= VNET_BUFFER_F_IS_IP6;
return ip6h;
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index be0037e..5a17643 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -883,9 +883,9 @@
vec_elt (im->fib_index_by_sw_if_index,
vnet_buffer (b0)->sw_if_index[VLIB_RX]);
- clib_memcpy (t0->packet_data,
- vlib_buffer_get_current (b0),
- sizeof (t0->packet_data));
+ clib_memcpy_fast (t0->packet_data,
+ vlib_buffer_get_current (b0),
+ sizeof (t0->packet_data));
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -898,9 +898,9 @@
vec_elt (im->fib_index_by_sw_if_index,
vnet_buffer (b1)->sw_if_index[VLIB_RX]);
- clib_memcpy (t1->packet_data,
- vlib_buffer_get_current (b1),
- sizeof (t1->packet_data));
+ clib_memcpy_fast (t1->packet_data,
+ vlib_buffer_get_current (b1),
+ sizeof (t1->packet_data));
}
from += 2;
n_left -= 2;
@@ -927,9 +927,9 @@
vec_elt (im->fib_index_by_sw_if_index,
vnet_buffer (b0)->sw_if_index[VLIB_RX]);
- clib_memcpy (t0->packet_data,
- vlib_buffer_get_current (b0),
- sizeof (t0->packet_data));
+ clib_memcpy_fast (t0->packet_data,
+ vlib_buffer_get_current (b0),
+ sizeof (t0->packet_data));
}
from += 1;
n_left -= 1;
@@ -1530,8 +1530,8 @@
sw_if_index);
}
- clib_memcpy (h->link_layer_option.ethernet_address, hi->hw_address,
- vec_len (hi->hw_address));
+ clib_memcpy_fast (h->link_layer_option.ethernet_address, hi->hw_address,
+ vec_len (hi->hw_address));
h->neighbor.icmp.checksum =
ip6_tcp_udp_icmp_compute_checksum (vm, 0, &h->ip, &bogus_length);
@@ -2415,7 +2415,7 @@
ARRAY_LEN (t->option_data) ? trace_len :
ARRAY_LEN (t->option_data);
t->trace_len = trace_len;
- clib_memcpy (t->option_data, hbh0, trace_len);
+ clib_memcpy_fast (t->option_data, hbh0, trace_len);
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -2429,7 +2429,7 @@
ARRAY_LEN (t->option_data) ? trace_len :
ARRAY_LEN (t->option_data);
t->trace_len = trace_len;
- clib_memcpy (t->option_data, hbh1, trace_len);
+ clib_memcpy_fast (t->option_data, hbh1, trace_len);
}
}
@@ -2510,7 +2510,7 @@
ARRAY_LEN (t->option_data) ? trace_len :
ARRAY_LEN (t->option_data);
t->trace_len = trace_len;
- clib_memcpy (t->option_data, hbh0, trace_len);
+ clib_memcpy_fast (t->option_data, hbh0, trace_len);
}
b0->error = error_node->errors[error0];
diff --git a/src/vnet/ip/ip6_hop_by_hop.c b/src/vnet/ip/ip6_hop_by_hop.c
index fbaf000..38cdbff 100644
--- a/src/vnet/ip/ip6_hop_by_hop.c
+++ b/src/vnet/ip/ip6_hop_by_hop.c
@@ -321,8 +321,8 @@
hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1);
hbh1 = (ip6_hop_by_hop_header_t *) (ip1 + 1);
/* $$$ tune, rewrite_length is a multiple of 8 */
- clib_memcpy (hbh0, rewrite, rewrite_length);
- clib_memcpy (hbh1, rewrite, rewrite_length);
+ clib_memcpy_fast (hbh0, rewrite, rewrite_length);
+ clib_memcpy_fast (hbh1, rewrite, rewrite_length);
/* Patch the protocol chain, insert the h-b-h (type 0) header */
hbh0->protocol = ip0->protocol;
hbh1->protocol = ip1->protocol;
@@ -399,7 +399,7 @@
hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1);
/* $$$ tune, rewrite_length is a multiple of 8 */
- clib_memcpy (hbh0, rewrite, rewrite_length);
+ clib_memcpy_fast (hbh0, rewrite, rewrite_length);
/* Patch the protocol chain, insert the h-b-h (type 0) header */
hbh0->protocol = ip0->protocol;
ip0->protocol = 0;
diff --git a/src/vnet/ip/ip6_reassembly.c b/src/vnet/ip/ip6_reassembly.c
index 7f6c5ca..de9fbe5 100644
--- a/src/vnet/ip/ip6_reassembly.c
+++ b/src/vnet/ip/ip6_reassembly.c
@@ -1165,8 +1165,8 @@
else
{
clib_bihash_free_48_8 (&ip6_reass_main.hash);
- clib_memcpy (&ip6_reass_main.hash, &new_hash,
- sizeof (ip6_reass_main.hash));
+ clib_memcpy_fast (&ip6_reass_main.hash, &new_hash,
+ sizeof (ip6_reass_main.hash));
}
}
return 0;
diff --git a/src/vnet/ip/ip6_to_ip4.h b/src/vnet/ip/ip6_to_ip4.h
index f25c9e4..d13a0c1 100644
--- a/src/vnet/ip/ip6_to_ip4.h
+++ b/src/vnet/ip/ip6_to_ip4.h
@@ -373,7 +373,7 @@
//Move up icmp header
ip4 = (ip4_header_t *) u8_ptr_add (inner_l4, -2 * sizeof (*ip4) - 8);
- clib_memcpy (u8_ptr_add (inner_l4, -sizeof (*ip4) - 8), icmp, 8);
+ clib_memcpy_fast (u8_ptr_add (inner_l4, -sizeof (*ip4) - 8), icmp, 8);
icmp = (icmp46_header_t *) u8_ptr_add (inner_l4, -sizeof (*ip4) - 8);
}
else
diff --git a/src/vnet/ip/ip_frag.c b/src/vnet/ip/ip_frag.c
index 8de4dfc..6efb883 100644
--- a/src/vnet/ip/ip_frag.c
+++ b/src/vnet/ip/ip_frag.c
@@ -165,7 +165,7 @@
frag_set_sw_if_index (to_b, org_from_b);
/* Copy ip4 header */
- clib_memcpy (to_b->data, org_from_packet, sizeof (ip4_header_t));
+ clib_memcpy_fast (to_b->data, org_from_packet, sizeof (ip4_header_t));
to_ip4 = vlib_buffer_get_current (to_b);
to_data = (void *) (to_ip4 + 1);
@@ -178,7 +178,7 @@
/* Figure out how many bytes we can safely copy */
bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ?
left_in_to_buffer : left_in_from_buffer;
- clib_memcpy (to_data + to_ptr, from_data + ptr, bytes_to_copy);
+ clib_memcpy_fast (to_data + to_ptr, from_data + ptr, bytes_to_copy);
left_in_to_buffer -= bytes_to_copy;
ptr += bytes_to_copy;
left_in_from_buffer -= bytes_to_copy;
@@ -441,7 +441,7 @@
frag_set_sw_if_index (to_b, org_from_b);
/* Copy ip6 header */
- clib_memcpy (to_b->data, ip6, sizeof (ip6_header_t));
+ clib_memcpy_fast (to_b->data, ip6, sizeof (ip6_header_t));
to_ip6 = vlib_buffer_get_current (to_b);
to_frag_hdr = (ip6_frag_hdr_t *) (to_ip6 + 1);
to_data = (void *) (to_frag_hdr + 1);
@@ -455,7 +455,7 @@
/* Figure out how many bytes we can safely copy */
bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ?
left_in_to_buffer : left_in_from_buffer;
- clib_memcpy (to_data + to_ptr, from_data + ptr, bytes_to_copy);
+ clib_memcpy_fast (to_data + to_ptr, from_data + ptr, bytes_to_copy);
left_in_to_buffer -= bytes_to_copy;
ptr += bytes_to_copy;
left_in_from_buffer -= bytes_to_copy;
diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c
index a6d6c08..d8c7d81 100644
--- a/src/vnet/ip/punt.c
+++ b/src/vnet/ip/punt.c
@@ -368,7 +368,7 @@
c = punt_client_get (is_ip4, port);
udp_punt_trace_t *t;
t = vlib_add_trace (vm, node, b, sizeof (t[0]));
- clib_memcpy (&t->client, c, sizeof (t->client));
+ clib_memcpy_fast (&t->client, c, sizeof (t->client));
}
/* Re-set iovecs if present. */
@@ -401,7 +401,7 @@
}
udp_punt_trace_t *t;
t = vlib_add_trace (vm, node, b, sizeof (t[0]));
- clib_memcpy (&t->client, c, sizeof (t->client));
+ clib_memcpy_fast (&t->client, c, sizeof (t->client));
t->is_midchain = 1;
}
diff --git a/src/vnet/ip/rd_cp.c b/src/vnet/ip/rd_cp.c
index 164b304..1a6122f 100644
--- a/src/vnet/ip/rd_cp.c
+++ b/src/vnet/ip/rd_cp.c
@@ -227,7 +227,7 @@
return 1;
}
- clib_memcpy (mac, eth_if->address, 6);
+ clib_memcpy_fast (mac, eth_if->address, 6);
return 0;
}