aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-04 22:40:45 +0200
committerDamjan Marion <dmarion@me.com>2022-04-04 23:17:13 +0000
commit8bea589cfe0fca1a6f560e16ca66a4cf199041a2 (patch)
treecf2767f8f5f31344468b65e14baa3f1a4c85fb91 /src/plugins
parenta2b358b1faf6e762e1d29a931d83c7735ac9a77d (diff)
vppinfra: make _vec_len() read-only
Use of _vec_len() to set vector length breaks address sanitizer. Users should use vec_set_len(), vec_inc_len(), vec_dec_len () instead. Type: improvement Change-Id: I441ae948771eb21c23a61f3ff9163bdad74a2cb8 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/acl/acl.c2
-rw-r--r--src/plugins/acl/acl_test.c24
-rw-r--r--src/plugins/acl/hash_lookup.c4
-rw-r--r--src/plugins/acl/sess_mgmt_node.c7
-rw-r--r--src/plugins/builtinurl/builtins.c2
-rw-r--r--src/plugins/cdp/cdp_input.c39
-rw-r--r--src/plugins/cdp/cdp_periodic.c4
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp.c2
-rw-r--r--src/plugins/dns/dns.c8
-rw-r--r--src/plugins/dns/request_node.c2
-rw-r--r--src/plugins/dpdk/device/cli.c6
-rw-r--r--src/plugins/dpdk/device/dpdk_priv.h4
-rw-r--r--src/plugins/dpdk/device/init.c4
-rw-r--r--src/plugins/gtpu/gtpu.c4
-rw-r--r--src/plugins/hs_apps/echo_client.c2
-rw-r--r--src/plugins/hs_apps/http_cli.c4
-rw-r--r--src/plugins/http/http.c2
-rw-r--r--src/plugins/http_static/builtinurl/json_urls.c2
-rw-r--r--src/plugins/http_static/static_server.c2
-rw-r--r--src/plugins/ikev2/ikev2_crypto.c6
-rw-r--r--src/plugins/ioam/export-common/ioam_export.h2
-rw-r--r--src/plugins/l2tp/l2tp.c2
-rw-r--r--src/plugins/lacp/input.c6
-rw-r--r--src/plugins/lb/lb.c2
-rw-r--r--src/plugins/lisp/lisp-cp/control.c2
-rw-r--r--src/plugins/lisp/lisp-gpe/interface.c2
-rw-r--r--src/plugins/lldp/lldp_input.c4
-rw-r--r--src/plugins/lldp/lldp_node.c2
-rw-r--r--src/plugins/memif/device.c4
-rw-r--r--src/plugins/memif/memif.c2
-rw-r--r--src/plugins/memif/memif_api.c2
-rw-r--r--src/plugins/nsh/nsh_api.c2
-rw-r--r--src/plugins/pppoe/pppoe.c2
-rw-r--r--src/plugins/snort/enqueue.c2
-rw-r--r--src/plugins/unittest/bihash_test.c2
-rw-r--r--src/plugins/unittest/bitmap_test.c2
-rw-r--r--src/plugins/unittest/fib_test.c4
-rw-r--r--src/plugins/unittest/svm_fifo_test.c2
-rw-r--r--src/plugins/vmxnet3/vmxnet3_api.c4
39 files changed, 88 insertions, 92 deletions
diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c
index 01a1e87a29b..a7b81049761 100644
--- a/src/plugins/acl/acl.c
+++ b/src/plugins/acl/acl.c
@@ -3736,7 +3736,7 @@ acl_init (vlib_main_t * vm)
vec_validate (pw->expired,
ACL_N_TIMEOUTS *
am->fa_max_deleted_sessions_per_interval);
- _vec_len (pw->expired) = 0;
+ vec_set_len (pw->expired, 0);
vec_validate_init_empty (pw->fa_conn_list_head, ACL_N_TIMEOUTS - 1,
FA_SESSION_BOGUS_INDEX);
vec_validate_init_empty (pw->fa_conn_list_tail, ACL_N_TIMEOUTS - 1,
diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c
index 44abf30923d..7514a8e2e85 100644
--- a/src/plugins/acl/acl_test.c
+++ b/src/plugins/acl/acl_test.c
@@ -493,10 +493,10 @@ static int api_acl_add_replace (vat_main_t * vam)
if (vec_len(tag) >= sizeof(mp->tag))
{
tag[sizeof(mp->tag)-1] = 0;
- _vec_len(tag) = sizeof(mp->tag);
- }
- clib_memcpy(mp->tag, tag, vec_len(tag));
- vec_free(tag);
+ vec_set_len (tag, sizeof (mp->tag));
+ }
+ clib_memcpy (mp->tag, tag, vec_len (tag));
+ vec_free (tag);
}
mp->acl_index = ntohl(acl_index);
mp->count = htonl(n_rules);
@@ -1333,10 +1333,10 @@ static int api_macip_acl_add (vat_main_t * vam)
if (vec_len(tag) >= sizeof(mp->tag))
{
tag[sizeof(mp->tag)-1] = 0;
- _vec_len(tag) = sizeof(mp->tag);
- }
- clib_memcpy(mp->tag, tag, vec_len(tag));
- vec_free(tag);
+ vec_set_len (tag, sizeof (mp->tag));
+ }
+ clib_memcpy (mp->tag, tag, vec_len (tag));
+ vec_free (tag);
}
mp->count = htonl(n_rules);
@@ -1475,10 +1475,10 @@ static int api_macip_acl_add_replace (vat_main_t * vam)
if (vec_len(tag) >= sizeof(mp->tag))
{
tag[sizeof(mp->tag)-1] = 0;
- _vec_len(tag) = sizeof(mp->tag);
- }
- clib_memcpy(mp->tag, tag, vec_len(tag));
- vec_free(tag);
+ vec_set_len (tag, sizeof (mp->tag));
+ }
+ clib_memcpy (mp->tag, tag, vec_len (tag));
+ vec_free (tag);
}
mp->acl_index = ntohl(acl_index);
diff --git a/src/plugins/acl/hash_lookup.c b/src/plugins/acl/hash_lookup.c
index 85b54b3e8ac..c137b15a080 100644
--- a/src/plugins/acl/hash_lookup.c
+++ b/src/plugins/acl/hash_lookup.c
@@ -682,7 +682,7 @@ hash_acl_apply(acl_main_t *am, u32 lc_index, int acl_index, u32 acl_position)
if (vec_len(ha->rules) > 0) {
int old_vec_len = vec_len(*applied_hash_aces);
vec_validate((*applied_hash_aces), old_vec_len + vec_len(ha->rules) - 1);
- _vec_len((*applied_hash_aces)) = old_vec_len;
+ vec_set_len ((*applied_hash_aces), old_vec_len);
}
/* add the rules from the ACL to the hash table for lookup and append to the vector*/
@@ -903,7 +903,7 @@ hash_acl_unapply(acl_main_t *am, u32 lc_index, int acl_index)
move_applied_ace_hash_entry(am, lc_index, applied_hash_aces, tail_offset + i, base_offset + i);
}
/* trim the end of the vector */
- _vec_len((*applied_hash_aces)) -= vec_len(ha->rules);
+ vec_dec_len ((*applied_hash_aces), vec_len (ha->rules));
remake_hash_applied_mask_info_vec(am, applied_hash_aces, lc_index);
diff --git a/src/plugins/acl/sess_mgmt_node.c b/src/plugins/acl/sess_mgmt_node.c
index f9a3064cbb1..d0ec5936896 100644
--- a/src/plugins/acl/sess_mgmt_node.c
+++ b/src/plugins/acl/sess_mgmt_node.c
@@ -188,8 +188,7 @@ acl_fa_check_idle_sessions (acl_main_t * am, u16 thread_index, u64 now)
}
}
if (pw->wip_session_change_requests)
- _vec_len (pw->wip_session_change_requests) = 0;
-
+ vec_set_len (pw->wip_session_change_requests, 0);
{
u8 tt = 0;
@@ -309,7 +308,7 @@ acl_fa_check_idle_sessions (acl_main_t * am, u16 thread_index, u64 now)
total_expired = vec_len (pw->expired);
/* zero out the vector which we have acted on */
if (pw->expired)
- _vec_len (pw->expired) = 0;
+ vec_set_len (pw->expired, 0);
/* if we were advancing and reached the end
* (no more sessions to recycle), reset the fast-forward timestamp */
@@ -788,7 +787,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
send_interrupts_to_workers (vm, am);
if (event_data)
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
/*
* If the interrupts were not processed yet, ensure we wait a bit,
diff --git a/src/plugins/builtinurl/builtins.c b/src/plugins/builtinurl/builtins.c
index 14b68ce4a58..24323cd596e 100644
--- a/src/plugins/builtinurl/builtins.c
+++ b/src/plugins/builtinurl/builtins.c
@@ -54,7 +54,7 @@ trim_path_from_request (u8 * s, char *path)
* like a c-string.
*/
*cp = 0;
- _vec_len (s) = cp - s;
+ vec_set_len (s, cp - s);
break;
}
cp++;
diff --git a/src/plugins/cdp/cdp_input.c b/src/plugins/cdp/cdp_input.c
index 76a3d70a292..c6198d81de1 100644
--- a/src/plugins/cdp/cdp_input.c
+++ b/src/plugins/cdp/cdp_input.c
@@ -167,25 +167,24 @@ _(version,DEBUG_TLV_DUMP) \
_(platform,DEBUG_TLV_DUMP) \
_(port_id,DEBUG_TLV_DUMP)
-#define _(z,dbg) \
-static \
-cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n, \
- cdp_tlv_t *t) \
-{ \
- int i; \
- if (dbg) \
- fformat(stdout, "%U\n", format_text_tlv, t); \
- \
- if (n->z) \
- _vec_len(n->z) = 0; \
- \
- for (i = 0; i < (t->l - sizeof (*t)); i++) \
- vec_add1(n->z, t->v[i]); \
- \
- vec_add1(n->z, 0); \
- \
- return CDP_ERROR_NONE; \
-}
+#define _(z, dbg) \
+ static cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n, \
+ cdp_tlv_t *t) \
+ { \
+ int i; \
+ if (dbg) \
+ fformat (stdout, "%U\n", format_text_tlv, t); \
+ \
+ if (n->z) \
+ vec_set_len (n->z, 0); \
+ \
+ for (i = 0; i < (t->l - sizeof (*t)); i++) \
+ vec_add1 (n->z, t->v[i]); \
+ \
+ vec_add1 (n->z, 0); \
+ \
+ return CDP_ERROR_NONE; \
+ }
foreach_text_to_struct_tlv
#undef _
@@ -354,7 +353,7 @@ cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
*/
if (n->last_rx_pkt)
- _vec_len (n->last_rx_pkt) = 0;
+ vec_set_len (n->last_rx_pkt, 0);
/* cdp disabled on this interface, we're done */
if (n->disabled)
diff --git a/src/plugins/cdp/cdp_periodic.c b/src/plugins/cdp/cdp_periodic.c
index c73d86be316..295cf8fcfb1 100644
--- a/src/plugins/cdp/cdp_periodic.c
+++ b/src/plugins/cdp/cdp_periodic.c
@@ -394,9 +394,9 @@ cdp_periodic (vlib_main_t * vm)
delete_neighbor (cm, n, 1);
}
if (delete_list)
- _vec_len (delete_list) = 0;
+ vec_set_len (delete_list, 0);
if (n_list)
- _vec_len (n_list) = 0;
+ vec_set_len (n_list, 0);
}
static clib_error_t *
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.c b/src/plugins/dhcp/dhcp6_pd_client_cp.c
index f6d30fa0c7d..b1784bd9420 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp.c
@@ -992,7 +992,7 @@ dhcp6_cp_ip6_address_add_del (u32 sw_if_index, const u8 * prefix_group,
return VNET_API_ERROR_DUPLICATE_IF_ADDRESS;
cp_ip6_address_add_del_now (address_info, 0 /* del */ );
*address_info = apm->addresses[n - 1];
- _vec_len (apm->addresses) = n - 1;
+ vec_set_len (apm->addresses, n - 1);
return 0;
}
}
diff --git a/src/plugins/dns/dns.c b/src/plugins/dns/dns.c
index 76ce3dabd30..ac6d1229441 100644
--- a/src/plugins/dns/dns.c
+++ b/src/plugins/dns/dns.c
@@ -829,7 +829,7 @@ re_resolve:
clib_memset (ep, 0, sizeof (*ep));
ep->name = format (0, "%s%c", name, 0);
- _vec_len (ep->name) = vec_len (ep->name) - 1;
+ vec_set_len (ep->name, vec_len (ep->name) - 1);
hash_set_mem (dm->cache_entry_by_name, ep->name, ep - dm->entries);
@@ -988,7 +988,7 @@ found_last_request:
cname = vnet_dns_labels_to_name (rr->rdata, reply, &pos2);
/* Save the cname */
vec_add1 (cname, 0);
- _vec_len (cname) -= 1;
+ vec_dec_len (cname, 1);
ep = pool_elt_at_index (dm->entries, ep_index);
ep->cname = cname;
ep->flags |= (DNS_CACHE_ENTRY_FLAG_CNAME | DNS_CACHE_ENTRY_FLAG_VALID);
@@ -1007,7 +1007,7 @@ found_last_request:
clib_memset (next_ep, 0, sizeof (*next_ep));
next_ep->name = vec_dup (cname);
vec_add1 (next_ep->name, 0);
- _vec_len (next_ep->name) -= 1;
+ vec_dec_len (next_ep->name, 1);
hash_set_mem (dm->cache_entry_by_name, next_ep->name,
next_ep - dm->entries);
@@ -2611,7 +2611,7 @@ test_dns_expire_command_fn (vlib_main_t * vm,
if (unformat (input, "%v", &name))
{
vec_add1 (name, 0);
- _vec_len (name) -= 1;
+ vec_dec_len (name, 1);
}
else
return clib_error_return (0, "no name provided");
diff --git a/src/plugins/dns/request_node.c b/src/plugins/dns/request_node.c
index 72a76d12e4f..9179bf8dbdd 100644
--- a/src/plugins/dns/request_node.c
+++ b/src/plugins/dns/request_node.c
@@ -214,7 +214,7 @@ dns46_request_inline (vlib_main_t * vm,
*/
name0 = vnet_dns_labels_to_name (label0, (u8 *) d0, (u8 **) & q0);
vec_add1 (name0, 0);
- _vec_len (name0) -= 1;
+ vec_dec_len (name0, 1);
t0->request_type = DNS_PEER_PENDING_NAME_TO_IP;
diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c
index f49a94fa98f..af522a56198 100644
--- a/src/plugins/dpdk/device/cli.c
+++ b/src/plugins/dpdk/device/cli.c
@@ -142,7 +142,7 @@ show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input,
err = clib_error_return_unix (0, "read");
goto error;
}
- _vec_len (s) = len + (n < 0 ? 0 : n);
+ vec_set_len (s, len + (n < 0 ? 0 : n));
}
vlib_cli_output (vm, "%v", s);
@@ -198,7 +198,7 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
first = vec_len (allocated_buffers) - n_free;
vlib_buffer_free (vm, allocated_buffers + first, n_free);
- _vec_len (allocated_buffers) = first;
+ vec_set_len (allocated_buffers, first);
}
if (n_alloc)
{
@@ -208,7 +208,7 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
n_alloc);
- _vec_len (allocated_buffers) = first + actual_alloc;
+ vec_set_len (allocated_buffers, first + actual_alloc);
if (actual_alloc < n_alloc)
vlib_cli_output (vm, "WARNING: only allocated %d buffers",
diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h
index 4e4438a007e..ed30cd8cd23 100644
--- a/src/plugins/dpdk/device/dpdk_priv.h
+++ b/src/plugins/dpdk/device/dpdk_priv.h
@@ -63,11 +63,11 @@ dpdk_get_xstats (dpdk_device_t * xd)
ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
if (ret < 0 || ret > len)
{
- _vec_len (xd->xstats) = 0;
+ vec_set_len (xd->xstats, 0);
return;
}
- _vec_len (xd->xstats) = len;
+ vec_set_len (xd->xstats, len);
}
#define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index a94f83bc42d..9d68775d86a 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -921,7 +921,7 @@ dpdk_log_read_ready (clib_file_t * uf)
n = read (uf->file_descriptor, s + len, n_try);
if (n < 0 && errno != EAGAIN)
return clib_error_return_unix (0, "read");
- _vec_len (s) = len + (n < 0 ? 0 : n);
+ vec_set_len (s, len + (n < 0 ? 0 : n));
}
unformat_init_vector (&input, s);
@@ -1254,7 +1254,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
/* NULL terminate the "argv" vector, in case of stupidity */
vec_add1 (conf->eal_init_args, 0);
- _vec_len (conf->eal_init_args) -= 1;
+ vec_dec_len (conf->eal_init_args, 1);
/* Set up DPDK eal and packet mbuf pool early. */
diff --git a/src/plugins/gtpu/gtpu.c b/src/plugins/gtpu/gtpu.c
index db596703158..33af26d70ee 100644
--- a/src/plugins/gtpu/gtpu.c
+++ b/src/plugins/gtpu/gtpu.c
@@ -292,7 +292,7 @@ ip_udp_gtpu_rewrite (gtpu_tunnel_t * t, bool is_ip6)
t->rewrite = r.rw;
/* Now only support 8-byte gtpu header. TBD */
- _vec_len (t->rewrite) = sizeof (ip4_gtpu_header_t) - 4;
+ vec_set_len (t->rewrite, sizeof (ip4_gtpu_header_t) - 4);
return;
}
@@ -419,7 +419,7 @@ int vnet_gtpu_add_mod_del_tunnel
vnet_interface_main_t *im = &vnm->interface_main;
hw_if_index = gtm->free_gtpu_tunnel_hw_if_indices
[vec_len (gtm->free_gtpu_tunnel_hw_if_indices) - 1];
- _vec_len (gtm->free_gtpu_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (gtm->free_gtpu_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = t - gtm->tunnels;
diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c
index 1d33a855240..b7bc85b82a9 100644
--- a/src/plugins/hs_apps/echo_client.c
+++ b/src/plugins/hs_apps/echo_client.c
@@ -248,7 +248,7 @@ ec_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
conn_indices + vec_len (conn_indices) -
nconns_this_batch,
nconns_this_batch * sizeof (u32));
- _vec_len (conn_indices) -= nconns_this_batch;
+ vec_dec_len (conn_indices, nconns_this_batch);
}
/*
diff --git a/src/plugins/hs_apps/http_cli.c b/src/plugins/hs_apps/http_cli.c
index fec1427994c..d742121ad2c 100644
--- a/src/plugins/hs_apps/http_cli.c
+++ b/src/plugins/hs_apps/http_cli.c
@@ -221,7 +221,7 @@ hcs_cli_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
else if (request[i] == ' ')
{
/* vlib_cli_input is vector-based, no need for a NULL */
- _vec_len (request) = i;
+ vec_set_len (request, i);
break;
}
i++;
@@ -269,7 +269,7 @@ alloc_cli_process (hcs_cli_args_t *args)
{
n = vlib_get_node (vm, hcm->free_http_cli_process_node_indices[l - 1]);
vlib_node_set_state (vm, n->index, VLIB_NODE_STATE_POLLING);
- _vec_len (hcm->free_http_cli_process_node_indices) = l - 1;
+ vec_set_len (hcm->free_http_cli_process_node_indices, l - 1);
}
else
{
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c
index 828e57d3640..f40715f055d 100644
--- a/src/plugins/http/http.c
+++ b/src/plugins/http/http.c
@@ -329,7 +329,7 @@ read_request (http_conn_t *hc)
if (svm_fifo_is_empty (ts->rx_fifo))
svm_fifo_unset_event (ts->rx_fifo);
- _vec_len (hc->rx_buf) = cursize + n_read;
+ vec_set_len (hc->rx_buf, cursize + n_read);
return 0;
}
diff --git a/src/plugins/http_static/builtinurl/json_urls.c b/src/plugins/http_static/builtinurl/json_urls.c
index 0d83d39fade..808893aac79 100644
--- a/src/plugins/http_static/builtinurl/json_urls.c
+++ b/src/plugins/http_static/builtinurl/json_urls.c
@@ -51,7 +51,7 @@ trim_path_from_request (u8 *s, char *path)
* like a c-string.
*/
*cp = 0;
- _vec_len (s) = cp - s;
+ vec_set_len (s, cp - s);
break;
}
cp++;
diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c
index 4eafb1f0111..b92af892eaf 100644
--- a/src/plugins/http_static/static_server.c
+++ b/src/plugins/http_static/static_server.c
@@ -224,7 +224,7 @@ try_index_file (hss_main_t *hsm, hss_session_t *hs, u8 *path)
u32 plen;
/* Remove the trailing space */
- _vec_len (path) -= 1;
+ vec_dec_len (path, 1);
plen = vec_len (path);
/* Append "index.html" */
diff --git a/src/plugins/ikev2/ikev2_crypto.c b/src/plugins/ikev2/ikev2_crypto.c
index a9ab1bc8067..3d4ad0a28ed 100644
--- a/src/plugins/ikev2/ikev2_crypto.c
+++ b/src/plugins/ikev2/ikev2_crypto.c
@@ -488,7 +488,7 @@ BN_bn2binpad (const BIGNUM * a, unsigned char *to, int tolen)
{
vec_insert (to, pad, 0);
clib_memset (to, 0, pad);
- _vec_len (to) -= pad;
+ vec_dec_len (to, pad);
}
return tolen;
}
@@ -553,7 +553,7 @@ ikev2_generate_dh (ikev2_sa_t * sa, ikev2_sa_transform_t * t)
{
vec_insert (sa->dh_shared_key, pad, 0);
clib_memset (sa->dh_shared_key, 0, pad);
- _vec_len (sa->dh_shared_key) -= pad;
+ vec_dec_len (sa->dh_shared_key, pad);
}
BN_clear_free (ex);
}
@@ -679,7 +679,7 @@ ikev2_complete_dh (ikev2_sa_t * sa, ikev2_sa_transform_t * t)
{
vec_insert (sa->dh_shared_key, pad, 0);
clib_memset (sa->dh_shared_key, 0, pad);
- _vec_len (sa->dh_shared_key) -= pad;
+ vec_dec_len (sa->dh_shared_key, pad);
}
BN_clear_free (ex);
DH_free (dh);
diff --git a/src/plugins/ioam/export-common/ioam_export.h b/src/plugins/ioam/export-common/ioam_export.h
index f242ad7a788..1b764f66b15 100644
--- a/src/plugins/ioam/export-common/ioam_export.h
+++ b/src/plugins/ioam/export-common/ioam_export.h
@@ -287,7 +287,7 @@ ioam_export_header_create (ioam_export_main_t * em,
(DEFAULT_EXPORT_RECORDS *
DEFAULT_EXPORT_SIZE));
ip->checksum = ip4_header_checksum (ip);
- _vec_len (rewrite) = sizeof (ip4_ipfix_data_packet_t);
+ vec_set_len (rewrite, sizeof (ip4_ipfix_data_packet_t));
em->record_header = rewrite;
return (1);
}
diff --git a/src/plugins/l2tp/l2tp.c b/src/plugins/l2tp/l2tp.c
index 08fa6d1e60b..a975fa7f059 100644
--- a/src/plugins/l2tp/l2tp.c
+++ b/src/plugins/l2tp/l2tp.c
@@ -377,7 +377,7 @@ create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
{
hw_if_index = lm->free_l2tpv3_tunnel_hw_if_indices
[vec_len (lm->free_l2tpv3_tunnel_hw_if_indices) - 1];
- _vec_len (lm->free_l2tpv3_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (lm->free_l2tpv3_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = s - lm->sessions;
diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c
index 3997af897eb..31450286f34 100644
--- a/src/plugins/lacp/input.c
+++ b/src/plugins/lacp/input.c
@@ -155,7 +155,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
{
mif->last_marker_pdu_recd_time = vlib_time_now (vm);
if (mif->last_marker_pkt)
- _vec_len (mif->last_marker_pkt) = 0;
+ vec_set_len (mif->last_marker_pkt, 0);
vec_validate (mif->last_marker_pkt,
vlib_buffer_length_in_chain (vm, b0) - 1);
nbytes = vlib_buffer_contents (vm, bi0, mif->last_marker_pkt);
@@ -176,7 +176,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
* and reuse it.
*/
if (mif->last_rx_pkt)
- _vec_len (mif->last_rx_pkt) = 0;
+ vec_set_len (mif->last_rx_pkt, 0);
/*
* Make sure the per-neighbor rx buffer is big enough to hold
@@ -225,7 +225,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
mif->pdu_received++;
if (mif->last_rx_pkt)
- _vec_len (mif->last_rx_pkt) = 0;
+ vec_set_len (mif->last_rx_pkt, 0);
return e;
}
diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c
index 5bc7cf25a97..dfdc5066a3d 100644
--- a/src/plugins/lb/lb.c
+++ b/src/plugins/lb/lb.c
@@ -422,7 +422,7 @@ out:
sort_arr[i].as_index = as - lbm->ass;
i++;
}
- _vec_len(sort_arr) = i;
+ vec_set_len (sort_arr, i);
vec_sort_with_function(sort_arr, lb_pseudorand_compare);
diff --git a/src/plugins/lisp/lisp-cp/control.c b/src/plugins/lisp/lisp-cp/control.c
index 7293e03eea0..24dd50b7de0 100644
--- a/src/plugins/lisp/lisp-cp/control.c
+++ b/src/plugins/lisp/lisp-cp/control.c
@@ -4830,7 +4830,7 @@ send_map_resolver_service (vlib_main_t * vm,
{
process_expired_mapping (lcm, mi[0]);
}
- _vec_len (expired) = 0;
+ vec_set_len (expired, 0);
}
}
diff --git a/src/plugins/lisp/lisp-gpe/interface.c b/src/plugins/lisp/lisp-gpe/interface.c
index 9dcf52d1ba6..05669ae975f 100644
--- a/src/plugins/lisp/lisp-gpe/interface.c
+++ b/src/plugins/lisp/lisp-gpe/interface.c
@@ -429,7 +429,7 @@ lisp_gpe_create_iface (lisp_gpe_main_t * lgm, u32 vni, u32 dp_table,
if (flen > 0)
{
hw_if_index = lgm->free_tunnel_hw_if_indices[flen - 1];
- _vec_len (lgm->free_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (lgm->free_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
diff --git a/src/plugins/lldp/lldp_input.c b/src/plugins/lldp/lldp_input.c
index 327ef10f9de..b8aa846e385 100644
--- a/src/plugins/lldp/lldp_input.c
+++ b/src/plugins/lldp/lldp_input.c
@@ -48,13 +48,13 @@ lldp_rpc_update_peer_cb (const lldp_intf_update_t * a)
if (n->chassis_id)
{
- _vec_len (n->chassis_id) = 0;
+ vec_set_len (n->chassis_id, 0);
}
vec_add (n->chassis_id, chassis_id, a->chassis_id_len);
n->chassis_id_subtype = a->chassis_id_subtype;
if (n->port_id)
{
- _vec_len (n->port_id) = 0;
+ vec_set_len (n->port_id, 0);
}
vec_add (n->port_id, portid, a->portid_len);
n->port_id_subtype = a->portid_subtype;
diff --git a/src/plugins/lldp/lldp_node.c b/src/plugins/lldp/lldp_node.c
index dbb54af91f0..d4b6d529d9b 100644
--- a/src/plugins/lldp/lldp_node.c
+++ b/src/plugins/lldp/lldp_node.c
@@ -220,7 +220,7 @@ lldp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
#endif
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/plugins/memif/device.c b/src/plugins/memif/device.c
index 94789223ea7..f049a7be38e 100644
--- a/src/plugins/memif/device.c
+++ b/src/plugins/memif/device.c
@@ -194,8 +194,8 @@ retry:
else
{
/* we need to rollback vectors before bailing out */
- _vec_len (ptd->buffers) = saved_ptd_buffers_len;
- _vec_len (ptd->copy_ops) = saved_ptd_copy_ops_len;
+ vec_set_len (ptd->buffers, saved_ptd_buffers_len);
+ vec_set_len (ptd->copy_ops, saved_ptd_copy_ops_len);
vlib_error_count (vm, node->node_index,
MEMIF_TX_ERROR_ROLLBACK, 1);
slot = saved_slot;
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index b89665f9a29..f4543c837db 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -991,8 +991,6 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
bt->total_length_not_including_first_buffer = 0;
vnet_buffer (bt)->sw_if_index[VLIB_TX] = (u32) ~ 0;
- /* initially prealloc copy_ops so we can use
- _vec_len instead of vec_elen */
vec_validate_aligned (ptd->copy_ops, 0, CLIB_CACHE_LINE_BYTES);
vec_reset_length (ptd->copy_ops);
vec_validate_aligned (ptd->buffers, 0, CLIB_CACHE_LINE_BYTES);
diff --git a/src/plugins/memif/memif_api.c b/src/plugins/memif/memif_api.c
index a50e7ce8882..593306a1ec7 100644
--- a/src/plugins/memif/memif_api.c
+++ b/src/plugins/memif/memif_api.c
@@ -289,7 +289,7 @@ vl_api_memif_dump_t_handler (vl_api_memif_dump_t * mp)
vnm, swif, 0);
send_memif_details (reg, mif, swif, if_name, mp->context);
- _vec_len (if_name) = 0;
+ vec_set_len (if_name, 0);
}
/* *INDENT-ON* */
diff --git a/src/plugins/nsh/nsh_api.c b/src/plugins/nsh/nsh_api.c
index 1faaea36c50..4a9eab4daec 100644
--- a/src/plugins/nsh/nsh_api.c
+++ b/src/plugins/nsh/nsh_api.c
@@ -346,7 +346,7 @@ nsh_add_del_map (nsh_add_del_map_args_t * a, u32 * map_indexp)
{
nsh_hw_if = nm->free_nsh_tunnel_hw_if_indices
[vec_len (nm->free_nsh_tunnel_hw_if_indices) - 1];
- _vec_len (nm->free_nsh_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (nm->free_nsh_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, nsh_hw_if);
hi->dev_instance = map_index;
diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c
index 182f93b6156..2bdbd3abed8 100644
--- a/src/plugins/pppoe/pppoe.c
+++ b/src/plugins/pppoe/pppoe.c
@@ -374,7 +374,7 @@ int vnet_pppoe_add_del_session
vnet_interface_main_t *im = &vnm->interface_main;
hw_if_index = pem->free_pppoe_session_hw_if_indices
[vec_len (pem->free_pppoe_session_hw_if_indices) - 1];
- _vec_len (pem->free_pppoe_session_hw_if_indices) -= 1;
+ vec_dec_len (pem->free_pppoe_session_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = t - pem->sessions;
diff --git a/src/plugins/snort/enqueue.c b/src/plugins/snort/enqueue.c
index 147d3a4a67b..409c0e49078 100644
--- a/src/plugins/snort/enqueue.c
+++ b/src/plugins/snort/enqueue.c
@@ -197,7 +197,7 @@ snort_enq_node_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
}
__atomic_store_n (qp->enq_head, head, __ATOMIC_RELEASE);
- _vec_len (qp->freelist) = freelist_len;
+ vec_set_len (qp->freelist, freelist_len);
if (sm->input_mode == VLIB_NODE_STATE_INTERRUPT)
{
if (write (qp->enq_fd, &ctr, sizeof (ctr)) < 0)
diff --git a/src/plugins/unittest/bihash_test.c b/src/plugins/unittest/bihash_test.c
index c5cc752ade0..0789735c1d7 100644
--- a/src/plugins/unittest/bihash_test.c
+++ b/src/plugins/unittest/bihash_test.c
@@ -512,7 +512,7 @@ test_bihash_command_fn (vlib_main_t * vm,
/* Preallocate hash table, key vector */
tm->key_hash = hash_create (tm->nitems, sizeof (uword));
vec_validate (tm->keys, tm->nitems - 1);
- _vec_len (tm->keys) = 0;
+ vec_set_len (tm->keys, 0);
switch (which)
{
diff --git a/src/plugins/unittest/bitmap_test.c b/src/plugins/unittest/bitmap_test.c
index 04a06d39a18..adee9764f46 100644
--- a/src/plugins/unittest/bitmap_test.c
+++ b/src/plugins/unittest/bitmap_test.c
@@ -30,7 +30,7 @@ test_bitmap_command_fn (vlib_main_t * vm,
junk = clib_bitmap_next_clear (bm, 65);
bm2 = clib_bitmap_set_multiple (bm2, 0, ~0ULL, BITS (uword));
- _vec_len (bm2) = 1;
+ vec_set_len (bm2, 1);
junk = clib_bitmap_next_clear (bm2, 0);
diff --git a/src/plugins/unittest/fib_test.c b/src/plugins/unittest/fib_test.c
index 57ab29e1f72..d417d5ff6ea 100644
--- a/src/plugins/unittest/fib_test.c
+++ b/src/plugins/unittest/fib_test.c
@@ -10628,7 +10628,7 @@ fib_test_sticky (void)
fib_route_path_t *r_paths2 = NULL;
r_paths2 = vec_dup(r_paths);
- _vec_len(r_paths2) = 3;
+ vec_set_len (r_paths2, 3);
pl_index = fib_path_list_create(FIB_PATH_LIST_FLAG_SHARED, r_paths2);
fib_path_list_lock(pl_index);
@@ -10699,7 +10699,7 @@ fib_test_sticky (void)
fib_route_path_t *r_paths3 = NULL;
r_paths3 = vec_dup(r_paths);
- _vec_len(r_paths3) = 3;
+ vec_set_len (r_paths3, 3);
r_paths3[0].frp_weight = 3;
diff --git a/src/plugins/unittest/svm_fifo_test.c b/src/plugins/unittest/svm_fifo_test.c
index a57795c38b9..8e186a86c9d 100644
--- a/src/plugins/unittest/svm_fifo_test.c
+++ b/src/plugins/unittest/svm_fifo_test.c
@@ -2519,7 +2519,7 @@ sfifo_test_fifo_segment_mempig (int verbose)
fifo_segment_free_fifo (sp, f);
}
- _vec_len (flist) = 0;
+ vec_set_len (flist, 0);
for (i = 0; i < 1000; i++)
{
diff --git a/src/plugins/vmxnet3/vmxnet3_api.c b/src/plugins/vmxnet3/vmxnet3_api.c
index 90608082a3e..36fa7bd9958 100644
--- a/src/plugins/vmxnet3/vmxnet3_api.c
+++ b/src/plugins/vmxnet3/vmxnet3_api.c
@@ -179,7 +179,7 @@ vl_api_vmxnet3_dump_t_handler (vl_api_vmxnet3_dump_t * mp)
if_name = format (if_name, "%U%c", format_vnet_sw_interface_name, vnm,
swif, 0);
send_vmxnet3_details (reg, vd, swif, if_name, mp->context);
- _vec_len (if_name) = 0;
+ vec_set_len (if_name, 0);
}
/* *INDENT-ON* */
@@ -220,7 +220,7 @@ static void vl_api_sw_vmxnet3_interface_dump_t_handler
if_name = format (if_name, "%U%c", format_vnet_sw_interface_name, vnm,
swif, 0);
send_vmxnet3_details (reg, vd, swif, if_name, mp->context);
- _vec_len (if_name) = 0;
+ vec_set_len (if_name, 0);
}
}
/* *INDENT-ON* */