diff options
Diffstat (limited to 'src/vat/main.c')
-rw-r--r-- | src/vat/main.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/vat/main.c b/src/vat/main.c index 70352e6bf95..f4bb0cddee4 100644 --- a/src/vat/main.c +++ b/src/vat/main.c @@ -13,6 +13,7 @@ * limitations under the License. */ #include "vat.h" +#include <dlfcn.h> #include "plugin.h" #include <signal.h> #include <limits.h> @@ -42,7 +43,6 @@ connect_to_vpe (char *name) return 0; } -/* *INDENT-OFF* */ vlib_global_main_t vlib_global_main; @@ -97,7 +97,7 @@ do_one_file (vat_main_t * vam) rv = write (1, "exec# ", 6); } - _vec_len (vam->inbuf) = 4096; + vec_set_len (vam->inbuf, 4096); if (vam->do_exit || fgets ((char *) vam->inbuf, vec_len (vam->inbuf), vam->ifp) == 0) @@ -181,7 +181,7 @@ do_one_file (vat_main_t * vam) if (vam->regenerate_interface_table) { vam->regenerate_interface_table = 0; - api_sw_interface_dump (vam); + vam->api_sw_interface_dump (vam); } /* Hack to pick up new client index after memfd_segment_create pivot */ @@ -266,6 +266,7 @@ setup_signal_handlers (void) /* these signals take the default action */ case SIGABRT: case SIGKILL: + case SIGCONT: case SIGSTOP: case SIGUSR1: case SIGUSR2: @@ -313,8 +314,7 @@ vat_find_plugin_path () return; *p = 0; - s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_api_test_plugins:" - "%s/lib/vpp_api_test_plugins", path, path); + s = format (0, "%s/" CLIB_LIB_DIR "/vpp_api_test_plugins", path, path); vec_add1 (s, 0); vat_plugin_path = (char *) s; } @@ -381,6 +381,30 @@ vlib_call_init_exit_functions (vlib_main_t *vm, 1 /* do_sort */, is_global); } +static void +vat_register_interface_dump (vat_main_t *vam) +{ + void *handle; + plugin_info_t *pi; + + vec_foreach (pi, vat_plugin_main.plugin_info) + { + handle = dlsym (pi->handle, "api_sw_interface_dump"); + if (handle) + { + vam->api_sw_interface_dump = handle; + break; + } + } + + if (!vam->api_sw_interface_dump) + { + fformat (stderr, + "sw_interface_dump not found in interface_test plugin!\n"); + exit (1); + } +} + int main (int argc, char **argv) { @@ -485,9 +509,6 @@ main (int argc, char **argv) vam->json_output = json_output; - if (!json_output) - api_sw_interface_dump (vam); - vec_validate (vam->inbuf, 4096); load_features (); @@ -495,6 +516,11 @@ main (int argc, char **argv) vam->current_file = (u8 *) "plugin-init"; vat_plugin_init (vam); + vat_register_interface_dump (vam); + + if (!json_output) + vam->api_sw_interface_dump (vam); + /* Set up the init function hash table */ vgm->init_functions_called = hash_create (0, 0); |