l2: merge two clib_memcpy_fast into one
Merge two memcpy into one by swapping src and dst address in
l2fwd_trace_t.
Type: improvement
Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
Change-Id: I71c5ecad0b453a434b1cb292ef03d88a760255c8
diff --git a/src/vnet/l2/l2_fwd.c b/src/vnet/l2/l2_fwd.c
index 93e69db..f440778 100644
--- a/src/vnet/l2/l2_fwd.c
+++ b/src/vnet/l2/l2_fwd.c
@@ -61,8 +61,8 @@
typedef struct
{
/* per-pkt trace data */
- u8 src[6];
u8 dst[6];
+ u8 src[6];
u32 sw_if_index;
u16 bd_index;
l2fib_entry_result_t result;
@@ -324,8 +324,9 @@
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_fast (t->src, h0->src_address, 6);
- clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address,
+ sizeof (h0->dst_address) +
+ sizeof (h0->src_address));
t->result = result0;
}
if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
@@ -333,8 +334,9 @@
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_fast (t->src, h1->src_address, 6);
- clib_memcpy_fast (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address,
+ sizeof (h1->dst_address) +
+ sizeof (h1->src_address));
t->result = result1;
}
if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
@@ -342,8 +344,9 @@
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_fast (t->src, h2->src_address, 6);
- clib_memcpy_fast (t->dst, h2->dst_address, 6);
+ clib_memcpy_fast (t->dst, h2->dst_address,
+ sizeof (h2->dst_address) +
+ sizeof (h2->src_address));
t->result = result2;
}
if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
@@ -351,8 +354,9 @@
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_fast (t->src, h3->src_address, 6);
- clib_memcpy_fast (t->dst, h3->dst_address, 6);
+ clib_memcpy_fast (t->dst, h3->dst_address,
+ sizeof (h3->dst_address) +
+ sizeof (h3->src_address));
t->result = result3;
}
}
@@ -387,8 +391,9 @@
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_fast (t->src, h0->src_address, 6);
- clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address,
+ sizeof (h0->dst_address) +
+ sizeof (h0->src_address));
t->result = result0;
}