aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-11-13 16:34:13 -0500
committerFlorin Coras <florin.coras@gmail.com>2018-11-14 15:54:01 +0000
commit178cf493d009995b28fdf220f04c98860ff79a9b (patch)
tree097c1be82b8f6fa9bc04b9b1e193158e2e4997eb /src/vnet/ip
parent6917b94f2146aa51195a6a2a1ccd8416a1d74bf3 (diff)
Remove c-11 memcpy checks from perf-critical code
Change-Id: Id4f37f5d4a03160572954a416efa1ef9b3d79ad1 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip.c7
-rw-r--r--src/vnet/ip/ip4_forward.c24
-rw-r--r--src/vnet/ip/ip4_options.c2
-rw-r--r--src/vnet/ip/ip4_packet.h3
-rw-r--r--src/vnet/ip/ip4_reassembly.c4
-rw-r--r--src/vnet/ip/ip6.h8
-rw-r--r--src/vnet/ip/ip6_forward.c28
-rw-r--r--src/vnet/ip/ip6_hop_by_hop.c6
-rw-r--r--src/vnet/ip/ip6_reassembly.c4
-rw-r--r--src/vnet/ip/ip6_to_ip4.h2
-rw-r--r--src/vnet/ip/ip_frag.c8
-rw-r--r--src/vnet/ip/punt.c4
-rw-r--r--src/vnet/ip/rd_cp.c2
13 files changed, 52 insertions, 50 deletions
diff --git a/src/vnet/ip/ip.c b/src/vnet/ip/ip.c
index 144bbcc405d..cab0cd0315a 100644
--- a/src/vnet/ip/ip.c
+++ b/src/vnet/ip/ip.c
@@ -70,7 +70,7 @@ ip_is_local (u32 fib_index, ip46_address_t * ip46_address, u8 is_ip4)
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 @@ ip_copy (ip46_address_t * dst, ip46_address_t * src, u8 is_ip4)
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 @@ ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
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 9911eb71b99..e011e5134d8 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -1072,9 +1072,9 @@ ip4_forward_next_trace (vlib_main_t * vm,
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 @@ ip4_forward_next_trace (vlib_main_t * vm,
(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 @@ ip4_forward_next_trace (vlib_main_t * vm,
(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 @@ ip4_arp_inline (vlib_main_t * vm,
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 @@ ip4_probe_neighbor (vlib_main_t * vm, ip4_address_t * dst, u32 sw_if_index,
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 c008b9bde8c..1b5a7878512 100644
--- a/src/vnet/ip/ip4_options.c
+++ b/src/vnet/ip/ip4_options.c
@@ -94,7 +94,7 @@ VLIB_NODE_FN (ip4_options_node) (vlib_main_t * vm,
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 fa86229a073..2ce6763f8d7 100644
--- a/src/vnet/ip/ip4_packet.h
+++ b/src/vnet/ip/ip4_packet.h
@@ -67,7 +67,8 @@ always_inline void
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 42231d0e30d..bd33026db85 100644
--- a/src/vnet/ip/ip4_reassembly.c
+++ b/src/vnet/ip/ip4_reassembly.c
@@ -1125,8 +1125,8 @@ ip4_reass_set (u32 timeout_ms, u32 max_reassemblies,
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 e807886cd2a..aef24454413 100644
--- a/src/vnet/ip/ip6.h
+++ b/src/vnet/ip/ip6.h
@@ -616,10 +616,10 @@ vlib_buffer_push_ip6 (vlib_main_t * vm, vlib_buffer_t * b,
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 be0037e5edd..5a176435510 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -883,9 +883,9 @@ ip6_forward_next_trace (vlib_main_t * vm,
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 @@ ip6_forward_next_trace (vlib_main_t * vm,
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 @@ ip6_forward_next_trace (vlib_main_t * vm,
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 @@ ip6_probe_neighbor (vlib_main_t * vm, ip6_address_t * dst, u32 sw_if_index,
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 @@ ip6_hop_by_hop (vlib_main_t * vm,
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 @@ ip6_hop_by_hop (vlib_main_t * vm,
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 @@ ip6_hop_by_hop (vlib_main_t * vm,
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 fbaf0007f19..38cdbfffeaa 100644
--- a/src/vnet/ip/ip6_hop_by_hop.c
+++ b/src/vnet/ip/ip6_hop_by_hop.c
@@ -321,8 +321,8 @@ ip6_add_hop_by_hop_node_fn (vlib_main_t * vm,
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 @@ ip6_add_hop_by_hop_node_fn (vlib_main_t * vm,
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 7f6c5ca4af7..de9fbe52a75 100644
--- a/src/vnet/ip/ip6_reassembly.c
+++ b/src/vnet/ip/ip6_reassembly.c
@@ -1165,8 +1165,8 @@ ip6_reass_set (u32 timeout_ms, u32 max_reassemblies,
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 f25c9e408f0..d13a0c1f104 100644
--- a/src/vnet/ip/ip6_to_ip4.h
+++ b/src/vnet/ip/ip6_to_ip4.h
@@ -373,7 +373,7 @@ icmp6_to_icmp (vlib_buffer_t * p, ip6_to_ip4_set_fn_t fn, void *ctx,
//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 8de4dfc5d58..6efb8834c4b 100644
--- a/src/vnet/ip/ip_frag.c
+++ b/src/vnet/ip/ip_frag.c
@@ -165,7 +165,7 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
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 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
/* 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 @@ ip6_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
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 @@ ip6_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
/* 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 a6d6c08818b..d8c7d81a23a 100644
--- a/src/vnet/ip/punt.c
+++ b/src/vnet/ip/punt.c
@@ -368,7 +368,7 @@ udp46_punt_socket_inline (vlib_main_t * vm,
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 @@ udp46_punt_socket_inline (vlib_main_t * vm,
}
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 164b3045775..1a6122fc9d3 100644
--- a/src/vnet/ip/rd_cp.c
+++ b/src/vnet/ip/rd_cp.c
@@ -227,7 +227,7 @@ get_interface_mac_address (u32 sw_if_index, u8 mac[])
return 1;
}
- clib_memcpy (mac, eth_if->address, 6);
+ clib_memcpy_fast (mac, eth_if->address, 6);
return 0;
}