summaryrefslogtreecommitdiffstats
path: root/src/vcl
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/vcl
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/vcl')
-rw-r--r--src/vcl/ldp.c45
-rw-r--r--src/vcl/vcl_bapi.c10
-rw-r--r--src/vcl/vppcom.c79
3 files changed, 69 insertions, 65 deletions
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c
index 96a7c36acef..e806dff7959 100644
--- a/src/vcl/ldp.c
+++ b/src/vcl/ldp.c
@@ -850,8 +850,8 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
clib_bitmap_validate (ldp->sid_rd_bitmap, minbits);
clib_bitmap_validate (ldp->libc_rd_bitmap, minbits);
clib_bitmap_validate (ldp->rd_bitmap, minbits);
- clib_memcpy (ldp->rd_bitmap, readfds,
- vec_len (ldp->rd_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (ldp->rd_bitmap, readfds,
+ vec_len (ldp->rd_bitmap) * sizeof (clib_bitmap_t));
FD_ZERO (readfds);
/* *INDENT-OFF* */
@@ -884,8 +884,8 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
clib_bitmap_validate (ldp->sid_wr_bitmap, minbits);
clib_bitmap_validate (ldp->libc_wr_bitmap, minbits);
clib_bitmap_validate (ldp->wr_bitmap, minbits);
- clib_memcpy (ldp->wr_bitmap, writefds,
- vec_len (ldp->wr_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (ldp->wr_bitmap, writefds,
+ vec_len (ldp->wr_bitmap) * sizeof (clib_bitmap_t));
FD_ZERO (writefds);
/* *INDENT-OFF* */
@@ -918,8 +918,8 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
clib_bitmap_validate (ldp->sid_ex_bitmap, minbits);
clib_bitmap_validate (ldp->libc_ex_bitmap, minbits);
clib_bitmap_validate (ldp->ex_bitmap, minbits);
- clib_memcpy (ldp->ex_bitmap, exceptfds,
- vec_len (ldp->ex_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (ldp->ex_bitmap, exceptfds,
+ vec_len (ldp->ex_bitmap) * sizeof (clib_bitmap_t));
FD_ZERO (exceptfds);
/* *INDENT-OFF* */
@@ -964,17 +964,17 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
func_str = "vppcom_select";
if (readfds)
- clib_memcpy (ldp->rd_bitmap, ldp->sid_rd_bitmap,
- vec_len (ldp->rd_bitmap) *
- sizeof (clib_bitmap_t));
+ clib_memcpy_fast (ldp->rd_bitmap, ldp->sid_rd_bitmap,
+ vec_len (ldp->rd_bitmap) *
+ sizeof (clib_bitmap_t));
if (writefds)
- clib_memcpy (ldp->wr_bitmap, ldp->sid_wr_bitmap,
- vec_len (ldp->wr_bitmap) *
- sizeof (clib_bitmap_t));
+ clib_memcpy_fast (ldp->wr_bitmap, ldp->sid_wr_bitmap,
+ vec_len (ldp->wr_bitmap) *
+ sizeof (clib_bitmap_t));
if (exceptfds)
- clib_memcpy (ldp->ex_bitmap, ldp->sid_ex_bitmap,
- vec_len (ldp->ex_bitmap) *
- sizeof (clib_bitmap_t));
+ clib_memcpy_fast (ldp->ex_bitmap, ldp->sid_ex_bitmap,
+ vec_len (ldp->ex_bitmap) *
+ sizeof (clib_bitmap_t));
rv = vppcom_select (sid_bits,
readfds ? ldp->rd_bitmap : NULL,
@@ -1049,14 +1049,17 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
func_str = "libc_pselect";
if (readfds)
- clib_memcpy (readfds, ldp->libc_rd_bitmap,
- vec_len (ldp->rd_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (readfds, ldp->libc_rd_bitmap,
+ vec_len (ldp->rd_bitmap) *
+ sizeof (clib_bitmap_t));
if (writefds)
- clib_memcpy (writefds, ldp->libc_wr_bitmap,
- vec_len (ldp->wr_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (writefds, ldp->libc_wr_bitmap,
+ vec_len (ldp->wr_bitmap) *
+ sizeof (clib_bitmap_t));
if (exceptfds)
- clib_memcpy (exceptfds, ldp->libc_ex_bitmap,
- vec_len (ldp->ex_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (exceptfds, ldp->libc_ex_bitmap,
+ vec_len (ldp->ex_bitmap) *
+ sizeof (clib_bitmap_t));
tspec.tv_sec = tspec.tv_nsec = 0;
rv = libc_pselect (libc_bits,
readfds ? readfds : NULL,
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index 7d02c4fc793..ea8f2ce5651 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -401,7 +401,7 @@ vppcom_app_send_attach (void)
if (nsid_len)
{
bmp->namespace_id_len = nsid_len;
- clib_memcpy (bmp->namespace_id, vcm->cfg.namespace_id, nsid_len);
+ clib_memcpy_fast (bmp->namespace_id, vcm->cfg.namespace_id, nsid_len);
bmp->options[APP_OPTIONS_NAMESPACE_SECRET] = vcm->cfg.namespace_secret;
}
vl_msg_api_send_shmem (vcm->vl_input_queue, (u8 *) & bmp);
@@ -453,10 +453,10 @@ vppcom_send_connect_sock (vcl_session_t * session)
cmp->context = session->session_index;
cmp->wrk_index = vcl_get_worker_index ();
cmp->is_ip4 = session->transport.is_ip4;
- clib_memcpy (cmp->ip, &session->transport.rmt_ip, sizeof (cmp->ip));
+ clib_memcpy_fast (cmp->ip, &session->transport.rmt_ip, sizeof (cmp->ip));
cmp->port = session->transport.rmt_port;
cmp->proto = session->session_type;
- clib_memcpy (cmp->options, session->options, sizeof (cmp->options));
+ clib_memcpy_fast (cmp->options, session->options, sizeof (cmp->options));
vl_msg_api_send_shmem (vcm->vl_input_queue, (u8 *) & cmp);
}
@@ -490,10 +490,10 @@ vppcom_send_bind_sock (vcl_session_t * session)
bmp->context = session->session_index;
bmp->wrk_index = vcl_get_worker_index ();
bmp->is_ip4 = session->transport.is_ip4;
- clib_memcpy (bmp->ip, &session->transport.lcl_ip, sizeof (bmp->ip));
+ clib_memcpy_fast (bmp->ip, &session->transport.lcl_ip, sizeof (bmp->ip));
bmp->port = session->transport.lcl_port;
bmp->proto = session->session_type;
- clib_memcpy (bmp->options, session->options, sizeof (bmp->options));
+ clib_memcpy_fast (bmp->options, session->options, sizeof (bmp->options));
vl_msg_api_send_shmem (vcm->vl_input_queue, (u8 *) & bmp);
}
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 46b1c106d20..99547377523 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -311,7 +311,8 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
session->session_state = STATE_ACCEPT;
session->transport.rmt_port = mp->port;
session->transport.is_ip4 = mp->is_ip4;
- clib_memcpy (&session->transport.rmt_ip, mp->ip, sizeof (ip46_address_t));
+ clib_memcpy_fast (&session->transport.rmt_ip, mp->ip,
+ sizeof (ip46_address_t));
vcl_session_table_add_vpp_handle (wrk, mp->handle, session->session_index);
session->transport.lcl_port = listen_session->transport.lcl_port;
@@ -389,8 +390,8 @@ vcl_session_connected_handler (vcl_worker_t * wrk,
session->tx_fifo = tx_fifo;
session->vpp_handle = mp->handle;
session->transport.is_ip4 = mp->is_ip4;
- clib_memcpy (&session->transport.lcl_ip, mp->lcl_ip,
- sizeof (session->transport.lcl_ip));
+ clib_memcpy_fast (&session->transport.lcl_ip, mp->lcl_ip,
+ sizeof (session->transport.lcl_ip));
session->transport.lcl_port = mp->lcl_port;
session->session_state = STATE_CONNECT;
@@ -454,8 +455,8 @@ vcl_session_bound_handler (vcl_worker_t * wrk, session_bound_msg_t * mp)
session->vpp_handle = mp->handle;
session->transport.is_ip4 = mp->lcl_is_ip4;
- clib_memcpy (&session->transport.lcl_ip, mp->lcl_ip,
- sizeof (ip46_address_t));
+ clib_memcpy_fast (&session->transport.lcl_ip, mp->lcl_ip,
+ sizeof (ip46_address_t));
session->transport.lcl_port = mp->lcl_port;
vcl_session_table_add_listener (wrk, mp->handle, sid);
session->session_state = STATE_LISTEN;
@@ -942,11 +943,11 @@ vppcom_session_bind (uint32_t session_handle, vppcom_endpt_t * ep)
session->transport.is_ip4 = ep->is_ip4;
if (ep->is_ip4)
- clib_memcpy (&session->transport.lcl_ip.ip4, ep->ip,
- sizeof (ip4_address_t));
+ clib_memcpy_fast (&session->transport.lcl_ip.ip4, ep->ip,
+ sizeof (ip4_address_t));
else
- clib_memcpy (&session->transport.lcl_ip.ip6, ep->ip,
- sizeof (ip6_address_t));
+ clib_memcpy_fast (&session->transport.lcl_ip.ip6, ep->ip,
+ sizeof (ip6_address_t));
session->transport.lcl_port = ep->port;
VDBG (0, "VCL<%d>: sid %u: binding to local %s address %U port %u, "
@@ -1091,7 +1092,7 @@ vppcom_session_accept (uint32_t listen_session_handle, vppcom_endpt_t * ep,
svm_msg_q_free_msg (wrk->app_event_queue, &msg);
continue;
}
- clib_memcpy (&accepted_msg, e->data, sizeof (accepted_msg));
+ clib_memcpy_fast (&accepted_msg, e->data, sizeof (accepted_msg));
svm_msg_q_free_msg (wrk->app_event_queue, &msg);
break;
}
@@ -1118,11 +1119,11 @@ handle:
ep->is_ip4 = client_session->transport.is_ip4;
ep->port = client_session->transport.rmt_port;
if (client_session->transport.is_ip4)
- clib_memcpy (ep->ip, &client_session->transport.rmt_ip.ip4,
- sizeof (ip4_address_t));
+ clib_memcpy_fast (ep->ip, &client_session->transport.rmt_ip.ip4,
+ sizeof (ip4_address_t));
else
- clib_memcpy (ep->ip, &client_session->transport.rmt_ip.ip6,
- sizeof (ip6_address_t));
+ clib_memcpy_fast (ep->ip, &client_session->transport.rmt_ip.ip6,
+ sizeof (ip6_address_t));
}
if (accepted_msg.server_event_queue_address)
@@ -1191,11 +1192,11 @@ vppcom_session_connect (uint32_t session_handle, vppcom_endpt_t * server_ep)
session->transport.is_ip4 = server_ep->is_ip4;
if (session->transport.is_ip4)
- clib_memcpy (&session->transport.rmt_ip.ip4, server_ep->ip,
- sizeof (ip4_address_t));
+ clib_memcpy_fast (&session->transport.rmt_ip.ip4, server_ep->ip,
+ sizeof (ip4_address_t));
else
- clib_memcpy (&session->transport.rmt_ip.ip6, server_ep->ip,
- sizeof (ip6_address_t));
+ clib_memcpy_fast (&session->transport.rmt_ip.ip6, server_ep->ip,
+ sizeof (ip6_address_t));
session->transport.rmt_port = server_ep->port;
VDBG (0, "VCL<%d>: vpp handle 0x%llx, sid %u: connecting to server %s %U "
@@ -1481,11 +1482,11 @@ int
vppcom_data_segment_copy (void *buf, vppcom_data_segments_t ds, u32 max_bytes)
{
u32 first_copy = clib_min (ds[0].len, max_bytes);
- clib_memcpy (buf, ds[0].data, first_copy);
+ clib_memcpy_fast (buf, ds[0].data, first_copy);
if (first_copy < max_bytes)
{
- clib_memcpy (buf + first_copy, ds[1].data,
- clib_min (ds[1].len, max_bytes - first_copy));
+ clib_memcpy_fast (buf + first_copy, ds[1].data,
+ clib_min (ds[1].len, max_bytes - first_copy));
}
return 0;
}
@@ -1908,23 +1909,23 @@ vppcom_select (unsigned long n_bits, unsigned long *read_map,
if (n_bits && read_map)
{
clib_bitmap_validate (wrk->rd_bitmap, minbits);
- clib_memcpy (wrk->rd_bitmap, read_map,
- vec_len (wrk->rd_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (wrk->rd_bitmap, read_map,
+ vec_len (wrk->rd_bitmap) * sizeof (clib_bitmap_t));
memset (read_map, 0, vec_len (wrk->rd_bitmap) * sizeof (clib_bitmap_t));
}
if (n_bits && write_map)
{
clib_bitmap_validate (wrk->wr_bitmap, minbits);
- clib_memcpy (wrk->wr_bitmap, write_map,
- vec_len (wrk->wr_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (wrk->wr_bitmap, write_map,
+ vec_len (wrk->wr_bitmap) * sizeof (clib_bitmap_t));
memset (write_map, 0,
vec_len (wrk->wr_bitmap) * sizeof (clib_bitmap_t));
}
if (n_bits && except_map)
{
clib_bitmap_validate (wrk->ex_bitmap, minbits);
- clib_memcpy (wrk->ex_bitmap, except_map,
- vec_len (wrk->ex_bitmap) * sizeof (clib_bitmap_t));
+ clib_memcpy_fast (wrk->ex_bitmap, except_map,
+ vec_len (wrk->ex_bitmap) * sizeof (clib_bitmap_t));
memset (except_map, 0,
vec_len (wrk->ex_bitmap) * sizeof (clib_bitmap_t));
}
@@ -2646,11 +2647,11 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
ep->is_ip4 = session->transport.is_ip4;
ep->port = session->transport.rmt_port;
if (session->transport.is_ip4)
- clib_memcpy (ep->ip, &session->transport.rmt_ip.ip4,
- sizeof (ip4_address_t));
+ clib_memcpy_fast (ep->ip, &session->transport.rmt_ip.ip4,
+ sizeof (ip4_address_t));
else
- clib_memcpy (ep->ip, &session->transport.rmt_ip.ip6,
- sizeof (ip6_address_t));
+ clib_memcpy_fast (ep->ip, &session->transport.rmt_ip.ip6,
+ sizeof (ip6_address_t));
*buflen = sizeof (*ep);
VDBG (1, "VCL<%d>: VPPCOM_ATTR_GET_PEER_ADDR: sid %u, is_ip4 = %u, "
"addr = %U, port %u", getpid (),
@@ -2670,11 +2671,11 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
ep->is_ip4 = session->transport.is_ip4;
ep->port = session->transport.lcl_port;
if (session->transport.is_ip4)
- clib_memcpy (ep->ip, &session->transport.lcl_ip.ip4,
- sizeof (ip4_address_t));
+ clib_memcpy_fast (ep->ip, &session->transport.lcl_ip.ip4,
+ sizeof (ip4_address_t));
else
- clib_memcpy (ep->ip, &session->transport.lcl_ip.ip6,
- sizeof (ip6_address_t));
+ clib_memcpy_fast (ep->ip, &session->transport.lcl_ip.ip6,
+ sizeof (ip6_address_t));
*buflen = sizeof (*ep);
VDBG (1, "VCL<%d>: VPPCOM_ATTR_GET_LCL_ADDR: sid %u, is_ip4 = %u,"
" addr = %U port %d", getpid (),
@@ -3146,11 +3147,11 @@ vppcom_session_recvfrom (uint32_t session_handle, void *buffer,
if (ep)
{
if (session->transport.is_ip4)
- clib_memcpy (ep->ip, &session->transport.rmt_ip.ip4,
- sizeof (ip4_address_t));
+ clib_memcpy_fast (ep->ip, &session->transport.rmt_ip.ip4,
+ sizeof (ip4_address_t));
else
- clib_memcpy (ep->ip, &session->transport.rmt_ip.ip6,
- sizeof (ip6_address_t));
+ clib_memcpy_fast (ep->ip, &session->transport.rmt_ip.ip6,
+ sizeof (ip6_address_t));
}
return rv;