summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-26 11:38:01 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:35:22 +0100
commit92ccf9bcd2692b4b415f31044560c735d639a35c (patch)
treef5308e25329d6853921b7ea4a74d5c3b6f149b25 /src/vnet
parentfd8deb48c7ad63b47c5d7465ceefcadef0316f93 (diff)
vlib: convert foreach_vlib_main macro to be more gdb and clang-format friendly
Type: improvement Change-Id: I1152e58d7bfcb3c4347147f87a834d45ad51cdfe Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/interface.c73
-rw-r--r--src/vnet/session/session.c60
-rw-r--r--src/vnet/tcp/tcp_syn_filter4.c26
-rw-r--r--src/vnet/unix/gdb_funcs.c86
4 files changed, 119 insertions, 126 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 13deaccea2d..f648440fbf8 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -875,23 +875,23 @@ vnet_register_interface (vnet_main_t * vnm,
vlib_node_rename (vm, hw->tx_node_index, "%v", tx_node_name);
vlib_node_rename (vm, hw->output_node_index, "%v", output_node_name);
- /* *INDENT-OFF* */
- foreach_vlib_main ({
- vnet_interface_output_runtime_t *rt;
-
- rt = vlib_node_get_runtime_data (this_vlib_main, hw->output_node_index);
- ASSERT (rt->is_deleted == 1);
- rt->is_deleted = 0;
- rt->hw_if_index = hw_index;
- rt->sw_if_index = hw->sw_if_index;
- rt->dev_instance = hw->dev_instance;
-
- rt = vlib_node_get_runtime_data (this_vlib_main, hw->tx_node_index);
- rt->hw_if_index = hw_index;
- rt->sw_if_index = hw->sw_if_index;
- rt->dev_instance = hw->dev_instance;
- });
- /* *INDENT-ON* */
+ foreach_vlib_main ()
+ {
+ vnet_interface_output_runtime_t *rt;
+
+ rt =
+ vlib_node_get_runtime_data (this_vlib_main, hw->output_node_index);
+ ASSERT (rt->is_deleted == 1);
+ rt->is_deleted = 0;
+ rt->hw_if_index = hw_index;
+ rt->sw_if_index = hw->sw_if_index;
+ rt->dev_instance = hw->dev_instance;
+
+ rt = vlib_node_get_runtime_data (this_vlib_main, hw->tx_node_index);
+ rt->hw_if_index = hw_index;
+ rt->sw_if_index = hw->sw_if_index;
+ rt->dev_instance = hw->dev_instance;
+ }
/* The new class may differ from the old one.
* Functions have to be updated. */
@@ -900,14 +900,13 @@ vnet_register_interface (vnet_main_t * vnm,
node->node_fn_registrations = if_out_node->node_fn_registrations;
node->function = if_out_node->function;
- /* *INDENT-OFF* */
- foreach_vlib_main ({
- nrt = vlib_node_get_runtime (this_vlib_main, hw->output_node_index);
- nrt->function = node->function;
- vlib_node_runtime_perf_counter (this_vlib_main, nrt, 0, 0, 0,
- VLIB_NODE_RUNTIME_PERF_RESET);
- });
- /* *INDENT-ON* */
+ foreach_vlib_main ()
+ {
+ nrt = vlib_node_get_runtime (this_vlib_main, hw->output_node_index);
+ nrt->function = node->function;
+ vlib_node_runtime_perf_counter (this_vlib_main, nrt, 0, 0, 0,
+ VLIB_NODE_RUNTIME_PERF_RESET);
+ }
node = vlib_get_node (vm, hw->tx_node_index);
if (dev_class->tx_fn_registrations)
@@ -919,14 +918,14 @@ vnet_register_interface (vnet_main_t * vnm,
else
node->function = dev_class->tx_function;
node->format_trace = dev_class->format_tx_trace;
- /* *INDENT-OFF* */
- foreach_vlib_main ({
- nrt = vlib_node_get_runtime (this_vlib_main, hw->tx_node_index);
- nrt->function = node->function;
- vlib_node_runtime_perf_counter (this_vlib_main, nrt, 0, 0, 0,
- VLIB_NODE_RUNTIME_PERF_RESET);
- });
- /* *INDENT-ON* */
+
+ foreach_vlib_main ()
+ {
+ nrt = vlib_node_get_runtime (this_vlib_main, hw->tx_node_index);
+ nrt->function = node->function;
+ vlib_node_runtime_perf_counter (this_vlib_main, nrt, 0, 0, 0,
+ VLIB_NODE_RUNTIME_PERF_RESET);
+ }
_vec_len (im->deleted_hw_interface_nodes) -= 1;
}
@@ -1074,17 +1073,15 @@ vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
/* Put output/tx nodes into recycle pool */
vnet_hw_interface_nodes_t *dn;
- /* *INDENT-OFF* */
- foreach_vlib_main
- ({
+ foreach_vlib_main ()
+ {
vnet_interface_output_runtime_t *rt =
vlib_node_get_runtime_data (this_vlib_main, hw->output_node_index);
/* Mark node runtime as deleted so output node (if called)
* will drop packets. */
rt->is_deleted = 1;
- });
- /* *INDENT-ON* */
+ }
vlib_node_rename (vm, hw->output_node_index,
"interface-%d-output-deleted", hw_if_index);
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 469ec0ed529..2400a19a351 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1590,16 +1590,14 @@ session_register_transport (transport_proto_t transport_proto,
vec_validate (smm->session_type_to_next, session_type);
vec_validate (smm->session_tx_fns, session_type);
- /* *INDENT-OFF* */
if (output_node != ~0)
{
- foreach_vlib_main (({
- next_index = vlib_node_add_next (this_vlib_main,
- session_queue_node.index,
- output_node);
- }));
+ foreach_vlib_main ()
+ {
+ next_index = vlib_node_add_next (
+ this_vlib_main, session_queue_node.index, output_node);
+ }
}
- /* *INDENT-ON* */
smm->session_type_to_next[session_type] = next_index;
smm->session_tx_fns[session_type] =
@@ -1755,31 +1753,29 @@ session_node_enable_disable (u8 is_en)
vlib_thread_main_t *vtm = vlib_get_thread_main ();
u8 have_workers = vtm->n_threads != 0;
- /* *INDENT-OFF* */
- foreach_vlib_main (({
- if (have_workers && ii == 0)
- {
- if (is_en)
- {
- vlib_node_set_state (this_vlib_main,
- session_queue_process_node.index, state);
- vlib_node_t *n = vlib_get_node (this_vlib_main,
- session_queue_process_node.index);
- vlib_start_process (this_vlib_main, n->runtime_index);
- }
- else
- {
- vlib_process_signal_event_mt (this_vlib_main,
- session_queue_process_node.index,
- SESSION_Q_PROCESS_STOP, 0);
- }
- if (!session_main.poll_main)
- continue;
- }
- vlib_node_set_state (this_vlib_main, session_queue_node.index,
- state);
- }));
- /* *INDENT-ON* */
+ foreach_vlib_main ()
+ {
+ if (have_workers && ii == 0)
+ {
+ if (is_en)
+ {
+ vlib_node_set_state (this_vlib_main,
+ session_queue_process_node.index, state);
+ vlib_node_t *n = vlib_get_node (
+ this_vlib_main, session_queue_process_node.index);
+ vlib_start_process (this_vlib_main, n->runtime_index);
+ }
+ else
+ {
+ vlib_process_signal_event_mt (this_vlib_main,
+ session_queue_process_node.index,
+ SESSION_Q_PROCESS_STOP, 0);
+ }
+ if (!session_main.poll_main)
+ continue;
+ }
+ vlib_node_set_state (this_vlib_main, session_queue_node.index, state);
+ }
}
clib_error_t *
diff --git a/src/vnet/tcp/tcp_syn_filter4.c b/src/vnet/tcp/tcp_syn_filter4.c
index d151eb77c3c..b107899cfb9 100644
--- a/src/vnet/tcp/tcp_syn_filter4.c
+++ b/src/vnet/tcp/tcp_syn_filter4.c
@@ -450,19 +450,19 @@ syn_filter_enable_disable (u32 sw_if_index, int enable_disable)
{
syn_filter4_runtime_t *rt;
- /* *INDENT-OFF* */
- foreach_vlib_main ({
- rt = vlib_node_get_runtime_data (this_vlib_main, syn_filter4_node.index);
- vec_validate (rt->syn_counts, 1023);
- /*
- * Given perfect disperson / optimal hashing results:
- * Allow 128k (successful) syns/sec. 1024, buckets each of which
- * absorb 128 syns before filtering. Reset table once a second.
- * Reality bites, lets try resetting once every 100ms.
- */
- rt->reset_interval = 0.1; /* reset interval in seconds */
- });
- /* *INDENT-ON* */
+ foreach_vlib_main ()
+ {
+ rt = vlib_node_get_runtime_data (this_vlib_main,
+ syn_filter4_node.index);
+ vec_validate (rt->syn_counts, 1023);
+ /*
+ * Given perfect disperson / optimal hashing results:
+ * Allow 128k (successful) syns/sec. 1024, buckets each of which
+ * absorb 128 syns before filtering. Reset table once a second.
+ * Reality bites, lets try resetting once every 100ms.
+ */
+ rt->reset_interval = 0.1; /* reset interval in seconds */
+ }
}
rv = vnet_feature_enable_disable ("ip4-local", "syn-filter-4",
diff --git a/src/vnet/unix/gdb_funcs.c b/src/vnet/unix/gdb_funcs.c
index ce8db3a8ae3..797cb0eb7d1 100644
--- a/src/vnet/unix/gdb_funcs.c
+++ b/src/vnet/unix/gdb_funcs.c
@@ -238,51 +238,51 @@ gdb_show_traces ()
/* Get active traces from pool. */
- /* *INDENT-OFF* */
- foreach_vlib_main (
- ({
- fmt = "------------------- Start of thread %d %s -------------------\n";
- s = format (s, fmt, index, vlib_worker_threads[index].name);
-
- tm = &this_vlib_main->trace_main;
-
- trace_apply_filter(this_vlib_main);
-
- traces = 0;
- pool_foreach (h, tm->trace_buffer_pool)
- {
- vec_add1 (traces, h[0]);
+ foreach_vlib_main ()
+ {
+ fmt = "------------------- Start of thread %d %s -------------------\n";
+ s = format (s, fmt, index, vlib_worker_threads[index].name);
+
+ tm = &this_vlib_main->trace_main;
+
+ trace_apply_filter (this_vlib_main);
+
+ traces = 0;
+ pool_foreach (h, tm->trace_buffer_pool)
+ {
+ vec_add1 (traces, h[0]);
+ }
+
+ if (vec_len (traces) == 0)
+ {
+ s = format (s, "No packets in trace buffer\n");
+ goto done;
+ }
+
+ /* Sort them by increasing time. */
+ vec_sort_with_function (traces, trace_cmp);
+
+ for (i = 0; i < vec_len (traces); i++)
+ {
+ if (i == max)
+ {
+ fformat (stderr,
+ "Limiting display to %d packets."
+ " To display more specify max.",
+ max);
+ goto done;
+ }
+
+ s = format (s, "Packet %d\n%U\n\n", i + 1, format_vlib_trace,
+ vlib_get_first_main (), traces[i]);
+ }
+
+ done:
+ vec_free (traces);
+
+ index++;
}
- if (vec_len (traces) == 0)
- {
- s = format (s, "No packets in trace buffer\n");
- goto done;
- }
-
- /* Sort them by increasing time. */
- vec_sort_with_function (traces, trace_cmp);
-
- for (i = 0; i < vec_len (traces); i++)
- {
- if (i == max)
- {
- fformat (stderr, "Limiting display to %d packets."
- " To display more specify max.", max);
- goto done;
- }
-
- s = format (s, "Packet %d\n%U\n\n", i + 1, format_vlib_trace,
- vlib_get_first_main (), traces[i]);
- }
-
- done:
- vec_free (traces);
-
- index++;
- }));
- /* *INDENT-ON* */
-
fformat (stderr, "%v", s);
vec_free (s);
}