X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fmain.c;h=996fb1ed6a8928c7470cf520fc0aeb5a235457dd;hb=b49bc1ae6;hp=295ccec2515177888e191eb3495d597ae1be24d0;hpb=b7b929931a07fbb27b43d5cd105f366c3e29807e;p=vpp.git diff --git a/src/vat/main.c b/src/vat/main.c index 295ccec2515..996fb1ed6a8 100644 --- a/src/vat/main.c +++ b/src/vat/main.c @@ -15,6 +15,7 @@ #include "vat.h" #include "plugin.h" #include +#include vat_main_t vat_main; @@ -30,7 +31,7 @@ int connect_to_vpe (char *name) { vat_main_t *vam = &vat_main; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); if (vl_client_connect_to_vlib ("/vpe-api", name, 32) < 0) return -1; @@ -184,7 +185,7 @@ do_one_file (vat_main_t * vam) if (vam->client_index_invalid) { vat_main_t *vam = &vat_main; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vam->vl_input_queue = am->shmem_hdr->vl_input_queue; vam->my_client_index = am->my_client_index; @@ -270,6 +271,7 @@ setup_signal_handlers (void) /* ignore SIGPIPE, SIGCHLD */ case SIGPIPE: case SIGCHLD: + case SIGWINCH: sa.sa_sigaction = (void *) SIG_IGN; break; @@ -283,6 +285,36 @@ setup_signal_handlers (void) } } +static void +vat_find_plugin_path () +{ + char *p, path[PATH_MAX]; + int rv; + u8 *s; + + /* find executable path */ + if ((rv = readlink ("/proc/self/exe", path, PATH_MAX - 1)) == -1) + return; + + /* readlink doesn't provide null termination */ + path[rv] = 0; + + /* strip filename */ + if ((p = strrchr (path, '/')) == 0) + return; + *p = 0; + + /* strip bin/ */ + if ((p = strrchr (path, '/')) == 0) + return; + *p = 0; + + s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_api_test_plugins:" + "%s/lib/vpp_api_test_plugins", path, path); + vec_add1 (s, 0); + vat_plugin_path = (char *) s; +} + int main (int argc, char **argv) { @@ -309,6 +341,8 @@ main (int argc, char **argv) vec_validate (vam->cmd_reply, 0); vec_reset_length (vam->cmd_reply); + vat_find_plugin_path (); + unformat_init_command_line (a, argv); while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)