aboutsummaryrefslogtreecommitdiffstats
path: root/src/vat/main.c
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2020-05-11 08:43:51 -0500
committerDave Barach <openvpp@barachs.net>2020-10-06 10:49:27 +0000
commitc0b195450b31f7092834c0f14a27ca929faf8bca (patch)
tree0129c95d2dcd184db08eb88243769d1beb74e273 /src/vat/main.c
parentd20bc1d30a913e783a39919268c9870cbfe8817f (diff)
feature: Add packet trace API
Also spiffed up the vpp_api_test plugin loader so it executes VLIB_INIT_FUNCTIONs and VLIB_API_INIT_FUNCTIONs. Type: feature Change-Id: Id9a4f455d73738c41bcfea220df2112bb9679681 Signed-off-by: Jon Loeliger <jdl@netgate.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vat/main.c')
-rw-r--r--src/vat/main.c77
1 files changed, 75 insertions, 2 deletions
diff --git a/src/vat/main.c b/src/vat/main.c
index aaedf6c450b..3e63aea260f 100644
--- a/src/vat/main.c
+++ b/src/vat/main.c
@@ -42,15 +42,31 @@ connect_to_vpe (char *name)
return 0;
}
+/* *INDENT-OFF* */
+
+
vlib_main_t vlib_global_main;
-vlib_main_t **vlib_mains;
+
+static struct
+{
+ vec_header_t h;
+ vlib_main_t *vm;
+} __attribute__ ((packed)) __bootstrap_vlib_main_vector
+__attribute__ ((aligned (CLIB_CACHE_LINE_BYTES))) =
+{
+ .h.len = 1,
+ .vm = &vlib_global_main,
+};
+/* *INDENT-ON* */
+
+vlib_main_t **vlib_mains = &__bootstrap_vlib_main_vector.vm;
+
void
vlib_cli_output (struct vlib_main_t *vm, char *fmt, ...)
{
clib_warning ("BUG");
}
-
static u8 *
format_api_error (u8 * s, va_list * args)
{
@@ -338,6 +354,45 @@ load_features (void)
}
}
+static inline clib_error_t *
+call_init_exit_functions_internal (vlib_main_t * vm,
+ _vlib_init_function_list_elt_t ** headp,
+ int call_once, int do_sort)
+{
+ clib_error_t *error = 0;
+ _vlib_init_function_list_elt_t *i;
+
+#if 0
+ /* Not worth copying the topological sort code */
+ if (do_sort && (error = vlib_sort_init_exit_functions (headp)))
+ return (error);
+#endif
+
+ i = *headp;
+ while (i)
+ {
+ if (call_once && !hash_get (vm->init_functions_called, i->f))
+ {
+ if (call_once)
+ hash_set1 (vm->init_functions_called, i->f);
+ error = i->f (vm);
+ if (error)
+ return error;
+ }
+ i = i->next_init_function;
+ }
+ return error;
+}
+
+clib_error_t *
+vlib_call_init_exit_functions (vlib_main_t * vm,
+ _vlib_init_function_list_elt_t ** headp,
+ int call_once)
+{
+ return call_init_exit_functions_internal (vm, headp, call_once,
+ 1 /* do_sort */ );
+}
+
int
main (int argc, char **argv)
{
@@ -351,6 +406,8 @@ main (int argc, char **argv)
u8 json_output = 0;
int i;
f64 timeout;
+ clib_error_t *error;
+ vlib_main_t *vm = &vlib_global_main;
clib_mem_init_thread_safe (0, 128 << 20);
@@ -447,6 +504,22 @@ main (int argc, char **argv)
vam->current_file = (u8 *) "plugin-init";
vat_plugin_init (vam);
+ /* Set up the init function hash table */
+ vm->init_functions_called = hash_create (0, 0);
+
+ /* Execute plugin init and api_init functions */
+ error = vlib_call_init_exit_functions
+ (vm, &vm->init_function_registrations, 1 /* call once */ );
+
+ if (error)
+ clib_error_report (error);
+
+ error = vlib_call_init_exit_functions
+ (vm, &vm->api_init_function_registrations, 1 /* call_once */ );
+
+ if (error)
+ clib_error_report (error);
+
for (i = 0; i < vec_len (input_files); i++)
{
vam->ifp = fopen ((char *) input_files[i], "r");