summaryrefslogtreecommitdiffstats
path: root/src/vnet
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/vnet
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/vnet')
-rw-r--r--src/vnet/bfd/bfd_main.c4
-rw-r--r--src/vnet/classify/vnet_classify.c6
-rw-r--r--src/vnet/config.c4
-rw-r--r--src/vnet/devices/af_packet/node.c5
-rw-r--r--src/vnet/dpo/load_balance.c6
-rw-r--r--src/vnet/dpo/load_balance_map.c2
-rw-r--r--src/vnet/fib/fib_path_list.c3
-rw-r--r--src/vnet/fib/fib_urpf_list.c2
-rw-r--r--src/vnet/gso/node.c2
-rw-r--r--src/vnet/interface.c4
-rw-r--r--src/vnet/interface_cli.c4
-rw-r--r--src/vnet/interface_format.c4
-rw-r--r--src/vnet/ip/ip_api.c2
-rw-r--r--src/vnet/ip/reass/ip4_full_reass.c2
-rw-r--r--src/vnet/ip/reass/ip4_sv_reass.c5
-rw-r--r--src/vnet/ip/reass/ip6_full_reass.c2
-rw-r--r--src/vnet/ip/reass/ip6_sv_reass.c5
-rw-r--r--src/vnet/ipsec/ipsec_cli.c2
-rw-r--r--src/vnet/l2/l2_input.c2
-rw-r--r--src/vnet/pg/input.c2
-rw-r--r--src/vnet/pg/pg.h2
-rw-r--r--src/vnet/tcp/tcp_debug.c2
-rw-r--r--src/vnet/tcp/tcp_input.c6
-rw-r--r--src/vnet/udp/udp_inlines.h2
-rw-r--r--src/vnet/unix/tuntap.c6
-rw-r--r--src/vnet/vxlan-gpe/vxlan_gpe.c2
26 files changed, 45 insertions, 43 deletions
diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c
index f77d66c9db8..4f5b36b37e4 100644
--- a/src/vnet/bfd/bfd_main.c
+++ b/src/vnet/bfd/bfd_main.c
@@ -1266,11 +1266,11 @@ bfd_process (vlib_main_t *vm, CLIB_UNUSED (vlib_node_runtime_t *rt),
bfd_unlock (bm);
if (expired)
{
- _vec_len (expired) = 0;
+ vec_set_len (expired, 0);
}
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c
index 1bdbee764a8..c9a6fc6ac5b 100644
--- a/src/vnet/classify/vnet_classify.c
+++ b/src/vnet/classify/vnet_classify.c
@@ -1320,7 +1320,7 @@ unformat_classify_mask (unformat_input_t * input, va_list * args)
if (match == 0)
clib_warning ("BUG: match 0");
- _vec_len (mask) = match * sizeof (u32x4);
+ vec_set_len (mask, match * sizeof (u32x4));
*matchp = match;
*maskp = mask;
@@ -2770,8 +2770,8 @@ unformat_classify_match (unformat_input_t * input, va_list * args)
sizeof (u32x4));
/* Set size, include skipped vectors */
- _vec_len (match) =
- (t->match_n_vectors + t->skip_n_vectors) * sizeof (u32x4);
+ vec_set_len (match,
+ (t->match_n_vectors + t->skip_n_vectors) * sizeof (u32x4));
*matchp = match;
diff --git a/src/vnet/config.c b/src/vnet/config.c
index 4ff001a17f8..c05da663fb7 100644
--- a/src/vnet/config.c
+++ b/src/vnet/config.c
@@ -97,7 +97,7 @@ find_config_with_features (vlib_main_t * vm,
config_string = cm->config_string_temp;
cm->config_string_temp = 0;
if (config_string)
- _vec_len (config_string) = 0;
+ vec_set_len (config_string, 0);
vec_foreach (f, feature_vector)
{
@@ -296,7 +296,7 @@ vnet_config_modify_end_node (vlib_main_t * vm,
if (new_features[last].node_index == cm->default_end_node_index)
{
vec_free (new_features->feature_config);
- _vec_len (new_features) = last;
+ vec_set_len (new_features, last);
}
}
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 323508bd304..631bbac1117 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -293,7 +293,7 @@ af_packet_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
n_required + n_free_bufs - 1);
n_free_bufs += vlib_buffer_alloc (
vm, &apm->rx_buffers[thread_index][n_free_bufs], n_required);
- _vec_len (apm->rx_buffers[thread_index]) = n_free_bufs;
+ vec_set_len (apm->rx_buffers[thread_index], n_free_bufs);
}
while (num_pkts && (n_free_bufs >= min_bufs))
@@ -341,7 +341,8 @@ af_packet_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
u32 last_empty_buffer =
vec_len (apm->rx_buffers[thread_index]) - 1;
bi0 = apm->rx_buffers[thread_index][last_empty_buffer];
- _vec_len (apm->rx_buffers[thread_index]) = last_empty_buffer;
+ vec_set_len (apm->rx_buffers[thread_index],
+ last_empty_buffer);
n_free_bufs--;
/* copy data */
diff --git a/src/vnet/dpo/load_balance.c b/src/vnet/dpo/load_balance.c
index 4666c9a7ca1..9001a351ccb 100644
--- a/src/vnet/dpo/load_balance.c
+++ b/src/vnet/dpo/load_balance.c
@@ -408,7 +408,7 @@ ip_multipath_normalize_next_hops (const load_balance_path_t * raw_next_hops,
{
nhs[0] = raw_next_hops[0];
nhs[0].path_weight = 1;
- _vec_len (nhs) = 1;
+ vec_set_len (nhs, 1);
sum_weight = 1;
goto done;
}
@@ -425,7 +425,7 @@ ip_multipath_normalize_next_hops (const load_balance_path_t * raw_next_hops,
if (nhs[0].path_weight == nhs[1].path_weight)
{
nhs[0].path_weight = nhs[1].path_weight = 1;
- _vec_len (nhs) = 2;
+ vec_set_len (nhs, 2);
sum_weight = 2;
goto done;
}
@@ -491,7 +491,7 @@ ip_multipath_normalize_next_hops (const load_balance_path_t * raw_next_hops,
if (error <= multipath_next_hop_error_tolerance*n_adj)
{
/* Truncate any next hops with zero weight. */
- _vec_len (nhs) = i;
+ vec_set_len (nhs, i);
break;
}
}
diff --git a/src/vnet/dpo/load_balance_map.c b/src/vnet/dpo/load_balance_map.c
index 55249747e5d..765cd856608 100644
--- a/src/vnet/dpo/load_balance_map.c
+++ b/src/vnet/dpo/load_balance_map.c
@@ -317,7 +317,7 @@ load_balance_map_fill (load_balance_map_t *lbm)
bucket += lbmp->lbmp_weight;
}
}
- _vec_len(tmp_buckets) = jj;
+ vec_set_len (tmp_buckets, jj);
/*
* If the number of temporaries written is as many as we need, implying
diff --git a/src/vnet/fib/fib_path_list.c b/src/vnet/fib/fib_path_list.c
index d7e860ecb8c..ebd2c0e9be1 100644
--- a/src/vnet/fib/fib_path_list.c
+++ b/src/vnet/fib/fib_path_list.c
@@ -964,8 +964,7 @@ fib_path_list_copy_and_path_add (fib_node_index_t orig_path_list_index,
}
if (duplicate)
{
- _vec_len(path_list->fpl_paths) =
- vec_len(path_list->fpl_paths) - 1;
+ vec_set_len(path_list->fpl_paths, vec_len(path_list->fpl_paths) - 1);
fib_path_destroy(new_path_index);
}
else
diff --git a/src/vnet/fib/fib_urpf_list.c b/src/vnet/fib/fib_urpf_list.c
index 55f3b8a526b..b1bbe7399d1 100644
--- a/src/vnet/fib/fib_urpf_list.c
+++ b/src/vnet/fib/fib_urpf_list.c
@@ -173,7 +173,7 @@ fib_urpf_list_bake (index_t ui)
if (urpf->furpf_itfs[i] != urpf->furpf_itfs[j])
urpf->furpf_itfs[++i] = urpf->furpf_itfs[j];
/* set the length of the vector to the number of unique itfs */
- _vec_len(urpf->furpf_itfs) = i+1;
+ vec_set_len (urpf->furpf_itfs, i+1);
}
urpf->furpf_flags |= FIB_URPF_LIST_BAKED;
diff --git a/src/vnet/gso/node.c b/src/vnet/gso/node.c
index 093cd669e3c..97bccc8879c 100644
--- a/src/vnet/gso/node.c
+++ b/src/vnet/gso/node.c
@@ -759,7 +759,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
to_next, n_left_to_next);
}
/* The buffers were enqueued. Reset the length */
- _vec_len (ptd->split_buffers) = 0;
+ vec_set_len (ptd->split_buffers, 0);
/* Free the now segmented buffer */
vlib_buffer_free_one (vm, bi0);
b += 1;
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index c44f2647ddf..9ce7f6f9aef 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -163,7 +163,7 @@ serialize_vnet_interface_state (serialize_main_t * m, va_list * va)
vec_serialize (m, sts, serialize_vec_vnet_sw_hw_interface_state);
if (sts)
- _vec_len (sts) = 0;
+ vec_set_len (sts, 0);
/* *INDENT-OFF* */
pool_foreach (hif, im->hw_interfaces) {
@@ -992,7 +992,7 @@ vnet_register_interface (vnet_main_t * vnm,
VLIB_NODE_RUNTIME_PERF_RESET);
}
- _vec_len (im->deleted_hw_interface_nodes) -= 1;
+ vec_dec_len (im->deleted_hw_interface_nodes, 1);
}
else
{
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 452849eaf9f..4de908f88f0 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -415,7 +415,7 @@ show_sw_interfaces (vlib_main_t * vm,
/* Gather interfaces. */
sorted_sis =
vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
+ vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
@@ -1236,7 +1236,7 @@ show_interface_sec_mac_addr_fn (vlib_main_t * vm, unformat_input_t * input,
{
sorted_sis =
vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
+ vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c
index 1ef4704257c..e34b6fb62c0 100644
--- a/src/vnet/interface_format.c
+++ b/src/vnet/interface_format.c
@@ -369,11 +369,11 @@ format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
n_printed += 2;
if (n)
- _vec_len (n) = 0;
+ vec_set_len (n, 0);
n = format (n, "%s packets", cm->name);
s = format (s, "%-16v%16Ld", n, vtotal.packets);
- _vec_len (n) = 0;
+ vec_set_len (n, 0);
n = format (n, "%s bytes", cm->name);
s = format (s, "\n%U%-16v%16Ld",
format_white_space, indent, n, vtotal.bytes);
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 3ff3a6ce5e0..ae4ee0cec52 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -1237,7 +1237,7 @@ vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp)
/* Gather interfaces. */
sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
+ vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c
index 220117278c0..e4839aaa981 100644
--- a/src/vnet/ip/reass/ip4_full_reass.c
+++ b/src/vnet/ip/reass/ip4_full_reass.c
@@ -1615,7 +1615,7 @@ ip4_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
vec_free (pool_indexes_to_free);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ip/reass/ip4_sv_reass.c b/src/vnet/ip/reass/ip4_sv_reass.c
index 9971dafd9fd..dfe3f578e98 100644
--- a/src/vnet/ip/reass/ip4_sv_reass.c
+++ b/src/vnet/ip/reass/ip4_sv_reass.c
@@ -924,7 +924,8 @@ slow_path:
to_next, n_left_to_next, bi0,
next0);
}
- _vec_len (reass->cached_buffers) = 0; // buffers are owned by frame now
+ vec_set_len (reass->cached_buffers,
+ 0); // buffers are owned by frame now
}
goto next_packet;
@@ -1303,7 +1304,7 @@ ip4_sv_reass_walk_expired (vlib_main_t *vm,
vec_free (pool_indexes_to_free);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ip/reass/ip6_full_reass.c b/src/vnet/ip/reass/ip6_full_reass.c
index 1bcb6bd0f20..3b61d141d85 100644
--- a/src/vnet/ip/reass/ip6_full_reass.c
+++ b/src/vnet/ip/reass/ip6_full_reass.c
@@ -1647,7 +1647,7 @@ ip6_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
vec_free (vec_icmp_bi);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ip/reass/ip6_sv_reass.c b/src/vnet/ip/reass/ip6_sv_reass.c
index 23ae6784127..e1493c95e54 100644
--- a/src/vnet/ip/reass/ip6_sv_reass.c
+++ b/src/vnet/ip/reass/ip6_sv_reass.c
@@ -734,7 +734,8 @@ ip6_sv_reassembly_inline (vlib_main_t * vm,
to_next, n_left_to_next, bi0,
next0);
}
- _vec_len (reass->cached_buffers) = 0; // buffers are owned by frame now
+ vec_set_len (reass->cached_buffers,
+ 0); // buffers are owned by frame now
}
goto next_packet;
@@ -1050,7 +1051,7 @@ ip6_sv_reass_walk_expired (vlib_main_t *vm,
vec_free (pool_indexes_to_free);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ipsec/ipsec_cli.c b/src/vnet/ipsec/ipsec_cli.c
index 95e8145fe92..c48d6855169 100644
--- a/src/vnet/ipsec/ipsec_cli.c
+++ b/src/vnet/ipsec/ipsec_cli.c
@@ -652,7 +652,7 @@ ipsec_show_backends_command_fn (vlib_main_t * vm,
}
/* *INDENT-ON* */
vlib_cli_output (vm, "%v", s);
- _vec_len (s) = 0;
+ vec_set_len (s, 0);
vlib_cli_output (vm, "IPsec ESP backends available:");
s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
ipsec_esp_backend_t *eb;
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index de22cef600e..b09555aa6ed 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -809,7 +809,7 @@ show_int_mode (vlib_main_t * vm,
{
/* Gather interfaces. */
sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sis) = 0;
+ vec_set_len (sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces) { vec_add1 (sis, si[0]); }
/* *INDENT-ON* */
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index 14c8b98d540..6f38ed0869a 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -965,7 +965,7 @@ pg_generate_fix_multi_buffer_lengths (pg_main_t * pg,
if (vec_len (unused_buffers) > 0)
{
vlib_buffer_free_no_next (vm, unused_buffers, vec_len (unused_buffers));
- _vec_len (unused_buffers) = 0;
+ vec_set_len (unused_buffers, 0);
}
}
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index 963d23a8e01..e69ee6458e7 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -296,7 +296,7 @@ pg_free_edit_group (pg_stream_t * s)
pg_edit_group_free (g);
clib_memset (g, 0, sizeof (g[0]));
- _vec_len (s->edit_groups) = i;
+ vec_set_len (s->edit_groups, i);
}
typedef enum pg_interface_mode_t_
diff --git a/src/vnet/tcp/tcp_debug.c b/src/vnet/tcp/tcp_debug.c
index e3d7452b591..309b6951559 100644
--- a/src/vnet/tcp/tcp_debug.c
+++ b/src/vnet/tcp/tcp_debug.c
@@ -26,7 +26,7 @@ tcp_evt_track_register (elog_track_t * et)
if (fl_len)
{
track_index = tdm->free_track_indices[fl_len - 1];
- _vec_len (tdm->free_track_indices) -= 1;
+ vec_dec_len (tdm->free_track_indices, 1);
et->track_index_plus_one = track_index + 1;
}
else
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index 160619d2d95..4950553fc7a 100644
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -594,7 +594,7 @@ tcp_handle_postponed_dequeues (tcp_worker_ctx_t * wrk)
tc->burst_acked = 0;
}
- _vec_len (wrk->pending_deq_acked) = 0;
+ vec_set_len (wrk->pending_deq_acked, 0);
}
static void
@@ -1099,7 +1099,7 @@ tcp_handle_disconnects (tcp_worker_ctx_t * wrk)
tcp_disconnect_pending_off (tc);
session_transport_closing_notify (&tc->connection);
}
- _vec_len (wrk->pending_disconnects) = 0;
+ vec_set_len (wrk->pending_disconnects, 0);
}
if (vec_len (wrk->pending_resets))
@@ -1112,7 +1112,7 @@ tcp_handle_disconnects (tcp_worker_ctx_t * wrk)
tcp_disconnect_pending_off (tc);
tcp_handle_rst (tc);
}
- _vec_len (wrk->pending_resets) = 0;
+ vec_set_len (wrk->pending_resets, 0);
}
}
diff --git a/src/vnet/udp/udp_inlines.h b/src/vnet/udp/udp_inlines.h
index d79dc9a2bad..915f891f8b9 100644
--- a/src/vnet/udp/udp_inlines.h
+++ b/src/vnet/udp/udp_inlines.h
@@ -142,7 +142,7 @@ ip_udp_encap_two (vlib_main_t *vm, vlib_buffer_t *b0, vlib_buffer_t *b1,
udp_header_t *udp0, *udp1;
int payload_ip4 = (payload_family == AF_IP4);
- ASSERT (_vec_len (ec0) == _vec_len (ec1));
+ ASSERT (vec_len (ec0) == vec_len (ec1));
if (payload_family < N_AF)
{
diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c
index c588cfd208c..1ce13e79254 100644
--- a/src/vnet/unix/tuntap.c
+++ b/src/vnet/unix/tuntap.c
@@ -172,7 +172,7 @@ tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
/* Re-set iovecs if present. */
if (tm->threads[thread_index].iovecs)
- _vec_len (tm->threads[thread_index].iovecs) = 0;
+ vec_set_len (tm->threads[thread_index].iovecs, 0);
/** VLIB buffer chain -> Unix iovec(s). */
vec_add2 (tm->threads[thread_index].iovecs, iov, 1);
@@ -260,7 +260,7 @@ tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
vlib_buffer_alloc (vm,
tm->threads[thread_index].rx_buffers + n_left,
VLIB_FRAME_SIZE - n_left);
- _vec_len (tm->threads[thread_index].rx_buffers) = n_left + n_alloc;
+ vec_set_len (tm->threads[thread_index].rx_buffers, n_left + n_alloc);
}
}
@@ -324,7 +324,7 @@ tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
+ VNET_INTERFACE_COUNTER_RX,
thread_index, tm->sw_if_index, 1, n_bytes_in_packet);
- _vec_len (tm->threads[thread_index].rx_buffers) = i_rx;
+ vec_set_len (tm->threads[thread_index].rx_buffers, i_rx);
}
b = vlib_get_buffer (vm, bi);
diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.c b/src/vnet/vxlan-gpe/vxlan_gpe.c
index 8ef94d44337..a926847051f 100644
--- a/src/vnet/vxlan-gpe/vxlan_gpe.c
+++ b/src/vnet/vxlan-gpe/vxlan_gpe.c
@@ -544,7 +544,7 @@ int vnet_vxlan_gpe_add_del_tunnel
vnet_interface_main_t *im = &vnm->interface_main;
hw_if_index = ngm->free_vxlan_gpe_tunnel_hw_if_indices
[vec_len (ngm->free_vxlan_gpe_tunnel_hw_if_indices) - 1];
- _vec_len (ngm->free_vxlan_gpe_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (ngm->free_vxlan_gpe_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = t - ngm->tunnels;