aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/l2
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/l2
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/l2')
-rw-r--r--src/vnet/l2/l2_efp_filter.c18
-rw-r--r--src/vnet/l2/l2_fib.c15
-rw-r--r--src/vnet/l2/l2_flood.c8
-rw-r--r--src/vnet/l2/l2_fwd.c20
-rw-r--r--src/vnet/l2/l2_input.c20
-rw-r--r--src/vnet/l2/l2_input_vtr.c18
-rw-r--r--src/vnet/l2/l2_learn.c20
-rw-r--r--src/vnet/l2/l2_output.c6
-rw-r--r--src/vnet/l2/l2_vtr.c18
9 files changed, 73 insertions, 70 deletions
diff --git a/src/vnet/l2/l2_efp_filter.c b/src/vnet/l2/l2_efp_filter.c
index 59f9f515d47..f10c5eaf7f9 100644
--- a/src/vnet/l2/l2_efp_filter.c
+++ b/src/vnet/l2/l2_efp_filter.c
@@ -340,9 +340,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm,
l2_efp_filter_trace_t *t =
vlib_add_trace (vm, node, b0, sizeof (*t));
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
- clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw));
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -350,9 +350,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm,
l2_efp_filter_trace_t *t =
vlib_add_trace (vm, node, b1, sizeof (*t));
t->sw_if_index = sw_if_index1;
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
- clib_memcpy (t->raw, &h1->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h1->src_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h1->type, sizeof (t->raw));
}
}
@@ -441,9 +441,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm,
l2_efp_filter_trace_t *t =
vlib_add_trace (vm, node, b0, sizeof (*t));
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
- clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw));
}
/* verify speculative enqueue, maybe switch current next frame */
diff --git a/src/vnet/l2/l2_fib.c b/src/vnet/l2/l2_fib.c
index 48be42e8ce9..fc518fe9dbf 100644
--- a/src/vnet/l2/l2_fib.c
+++ b/src/vnet/l2/l2_fib.c
@@ -83,7 +83,7 @@ incr_mac_address (u8 * mac)
tmp += 1 << 16; /* skip unused (least significant) octets */
tmp = clib_host_to_net_u64 (tmp);
- clib_memcpy (mac, &tmp, 6);
+ clib_memcpy_fast (mac, &tmp, 6);
}
/** Format sw_if_index. If the value is ~0, use the text "N/A" */
@@ -584,7 +584,7 @@ l2fib_test_command_fn (vlib_main_t * vm,
return clib_error_return (0,
"noop: pick at least one of (add,del,check)");
- clib_memcpy (save_mac, mac, 6);
+ clib_memcpy_fast (save_mac, mac, 6);
if (is_add)
{
@@ -601,7 +601,7 @@ l2fib_test_command_fn (vlib_main_t * vm,
BVT (clib_bihash_kv) kv;
l2fib_main_t *mp = &l2fib_main;
- clib_memcpy (mac, save_mac, 6);
+ clib_memcpy_fast (mac, save_mac, 6);
for (i = 0; i < count; i++)
{
@@ -617,7 +617,7 @@ l2fib_test_command_fn (vlib_main_t * vm,
if (is_del)
{
- clib_memcpy (mac, save_mac, 6);
+ clib_memcpy_fast (mac, save_mac, 6);
for (i = 0; i < count; i++)
{
@@ -1071,8 +1071,8 @@ l2fib_scan (vlib_main_t * vm, f64 start_time, u8 event_only)
if (l2fib_entry_result_is_set_LRN_EVT (&result))
{
/* copy mac entry to event msg */
- clib_memcpy (mp->mac[evt_idx].mac_addr, key.fields.mac,
- 6);
+ clib_memcpy_fast (mp->mac[evt_idx].mac_addr,
+ key.fields.mac, 6);
mp->mac[evt_idx].action =
l2fib_entry_result_is_set_LRN_MOV (&result) ?
MAC_EVENT_ACTION_MOVE : MAC_EVENT_ACTION_ADD;
@@ -1116,7 +1116,8 @@ l2fib_scan (vlib_main_t * vm, f64 start_time, u8 event_only)
if (client)
{
/* copy mac entry to event msg */
- clib_memcpy (mp->mac[evt_idx].mac_addr, key.fields.mac, 6);
+ clib_memcpy_fast (mp->mac[evt_idx].mac_addr, key.fields.mac,
+ 6);
mp->mac[evt_idx].action = MAC_EVENT_ACTION_DELETE;
mp->mac[evt_idx].sw_if_index =
htonl (result.fields.sw_if_index);
diff --git a/src/vnet/l2/l2_flood.c b/src/vnet/l2/l2_flood.c
index aeac8ff10d8..3198d323d60 100644
--- a/src/vnet/l2/l2_flood.c
+++ b/src/vnet/l2/l2_flood.c
@@ -256,8 +256,8 @@ l2flood_node_fn (vlib_main_t * vm,
h0 = vlib_buffer_get_current (c0);
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (c0)->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
/* Do normal L2 forwarding */
@@ -307,8 +307,8 @@ l2flood_node_fn (vlib_main_t * vm,
h0 = vlib_buffer_get_current (c0);
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (c0)->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
diff --git a/src/vnet/l2/l2_fwd.c b/src/vnet/l2/l2_fwd.c
index 9fb7b7d355a..dfc1a74a38c 100644
--- a/src/vnet/l2/l2_fwd.c
+++ b/src/vnet/l2/l2_fwd.c
@@ -324,8 +324,8 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
t->result = result0;
}
if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
@@ -333,8 +333,8 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
t->sw_if_index = sw_if_index1;
t->bd_index = vnet_buffer (b[1])->l2.bd_index;
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->src, h1->src_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address, 6);
t->result = result1;
}
if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
@@ -342,8 +342,8 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
t->sw_if_index = sw_if_index2;
t->bd_index = vnet_buffer (b[2])->l2.bd_index;
- clib_memcpy (t->src, h2->src_address, 6);
- clib_memcpy (t->dst, h2->dst_address, 6);
+ clib_memcpy_fast (t->src, h2->src_address, 6);
+ clib_memcpy_fast (t->dst, h2->dst_address, 6);
t->result = result2;
}
if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
@@ -351,8 +351,8 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t));
t->sw_if_index = sw_if_index3;
t->bd_index = vnet_buffer (b[3])->l2.bd_index;
- clib_memcpy (t->src, h3->src_address, 6);
- clib_memcpy (t->dst, h3->dst_address, 6);
+ clib_memcpy_fast (t->src, h3->src_address, 6);
+ clib_memcpy_fast (t->dst, h3->dst_address, 6);
t->result = result3;
}
}
@@ -387,8 +387,8 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
t->result = result0;
}
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index 28b8697a7e4..b66a7446d66 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -366,8 +366,8 @@ l2input_node_inline (vlib_main_t * vm,
l2input_trace_t *t =
vlib_add_trace (vm, node, b0, sizeof (*t));
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -375,8 +375,8 @@ l2input_node_inline (vlib_main_t * vm,
l2input_trace_t *t =
vlib_add_trace (vm, node, b1, sizeof (*t));
t->sw_if_index = sw_if_index1;
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->src, h1->src_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address, 6);
}
if (b2->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -384,8 +384,8 @@ l2input_node_inline (vlib_main_t * vm,
l2input_trace_t *t =
vlib_add_trace (vm, node, b2, sizeof (*t));
t->sw_if_index = sw_if_index2;
- clib_memcpy (t->src, h2->src_address, 6);
- clib_memcpy (t->dst, h2->dst_address, 6);
+ clib_memcpy_fast (t->src, h2->src_address, 6);
+ clib_memcpy_fast (t->dst, h2->dst_address, 6);
}
if (b3->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -393,8 +393,8 @@ l2input_node_inline (vlib_main_t * vm,
l2input_trace_t *t =
vlib_add_trace (vm, node, b3, sizeof (*t));
t->sw_if_index = sw_if_index3;
- clib_memcpy (t->src, h3->src_address, 6);
- clib_memcpy (t->dst, h3->dst_address, 6);
+ clib_memcpy_fast (t->src, h3->src_address, 6);
+ clib_memcpy_fast (t->dst, h3->dst_address, 6);
}
}
@@ -434,8 +434,8 @@ l2input_node_inline (vlib_main_t * vm,
l2input_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
classify_and_dispatch (msm, b0, &next0);
diff --git a/src/vnet/l2/l2_input_vtr.c b/src/vnet/l2/l2_input_vtr.c
index 9470752f0e0..25b3bd03e65 100644
--- a/src/vnet/l2/l2_input_vtr.c
+++ b/src/vnet/l2/l2_input_vtr.c
@@ -222,9 +222,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
vlib_add_trace (vm, node, b0, sizeof (*t));
ethernet_header_t *h0 = vlib_buffer_get_current (b0);
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
- clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw));
}
if (b1->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -232,9 +232,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
vlib_add_trace (vm, node, b1, sizeof (*t));
ethernet_header_t *h1 = vlib_buffer_get_current (b1);
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
- clib_memcpy (t->raw, &h1->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h1->src_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h1->type, sizeof (t->raw));
}
}
@@ -301,9 +301,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
vlib_add_trace (vm, node, b0, sizeof (*t));
ethernet_header_t *h0 = vlib_buffer_get_current (b0);
t->sw_if_index = sw_if_index0;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
- clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw));
}
/* verify speculative enqueue, maybe switch current next frame */
diff --git a/src/vnet/l2/l2_learn.c b/src/vnet/l2/l2_learn.c
index c6ecef33b0f..e47365751c7 100644
--- a/src/vnet/l2/l2_learn.c
+++ b/src/vnet/l2/l2_learn.c
@@ -306,8 +306,8 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -315,8 +315,8 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_add_trace (vm, node, b[1], sizeof (*t));
t->sw_if_index = sw_if_index1;
t->bd_index = vnet_buffer (b[1])->l2.bd_index;
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->src, h1->src_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address, 6);
}
if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -324,8 +324,8 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_add_trace (vm, node, b[2], sizeof (*t));
t->sw_if_index = sw_if_index2;
t->bd_index = vnet_buffer (b[2])->l2.bd_index;
- clib_memcpy (t->src, h2->src_address, 6);
- clib_memcpy (t->dst, h2->dst_address, 6);
+ clib_memcpy_fast (t->src, h2->src_address, 6);
+ clib_memcpy_fast (t->dst, h2->dst_address, 6);
}
if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -333,8 +333,8 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_add_trace (vm, node, b[3], sizeof (*t));
t->sw_if_index = sw_if_index3;
t->bd_index = vnet_buffer (b[3])->l2.bd_index;
- clib_memcpy (t->src, h3->src_address, 6);
- clib_memcpy (t->dst, h3->dst_address, 6);
+ clib_memcpy_fast (t->src, h3->src_address, 6);
+ clib_memcpy_fast (t->dst, h3->dst_address, 6);
}
}
@@ -391,8 +391,8 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2learn_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
/* process 1 pkt */
diff --git a/src/vnet/l2/l2_output.c b/src/vnet/l2/l2_output.c
index 27b838f4378..e15f0ac45b2 100644
--- a/src/vnet/l2/l2_output.c
+++ b/src/vnet/l2/l2_output.c
@@ -426,9 +426,9 @@ VLIB_NODE_FN (l2output_node) (vlib_main_t * vm,
vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
h = vlib_buffer_get_current (b[0]);
- clib_memcpy (t->src, h->src_address, 6);
- clib_memcpy (t->dst, h->dst_address, 6);
- clib_memcpy (t->raw, &h->type, sizeof (t->raw));
+ clib_memcpy_fast (t->src, h->src_address, 6);
+ clib_memcpy_fast (t->dst, h->dst_address, 6);
+ clib_memcpy_fast (t->raw, &h->type, sizeof (t->raw));
}
/* next */
n_left--;
diff --git a/src/vnet/l2/l2_vtr.c b/src/vnet/l2/l2_vtr.c
index 7096891381d..aa3d5c45bee 100644
--- a/src/vnet/l2/l2_vtr.c
+++ b/src/vnet/l2/l2_vtr.c
@@ -91,10 +91,10 @@ l2pbb_configure (vlib_main_t * vlib_main,
}
else if (vtr_op == L2_VTR_PUSH_2)
{
- clib_memcpy (in_config->macs_tags.b_dst_address, b_dmac,
- sizeof (in_config->macs_tags.b_dst_address));
- clib_memcpy (in_config->macs_tags.b_src_address, b_smac,
- sizeof (in_config->macs_tags.b_src_address));
+ clib_memcpy_fast (in_config->macs_tags.b_dst_address, b_dmac,
+ sizeof (in_config->macs_tags.b_dst_address));
+ clib_memcpy_fast (in_config->macs_tags.b_src_address, b_smac,
+ sizeof (in_config->macs_tags.b_src_address));
in_config->macs_tags.b_type =
clib_net_to_host_u16 (ETHERNET_TYPE_DOT1AD);
in_config->macs_tags.priority_dei_id =
@@ -726,10 +726,12 @@ l2pbb_get (vlib_main_t * vlib_main, vnet_main_t * vnet_main, u32 sw_if_index,
else if (in_config->push_bytes)
*vtr_op = L2_VTR_PUSH_2;
- clib_memcpy (&eth_hdr->dst_address, in_config->macs_tags.b_dst_address,
- sizeof (eth_hdr->dst_address));
- clib_memcpy (&eth_hdr->src_address, in_config->macs_tags.b_src_address,
- sizeof (eth_hdr->src_address));
+ clib_memcpy_fast (&eth_hdr->dst_address,
+ in_config->macs_tags.b_dst_address,
+ sizeof (eth_hdr->dst_address));
+ clib_memcpy_fast (&eth_hdr->src_address,
+ in_config->macs_tags.b_src_address,
+ sizeof (eth_hdr->src_address));
*b_vlanid =
clib_host_to_net_u16 (in_config->macs_tags.priority_dei_id) & 0xFFF;