summaryrefslogtreecommitdiffstats
path: root/src/vat/main.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-09-10 15:04:27 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2017-10-03 11:03:47 +0000
commit59b2565cd91a67ced650739f36129650830211ac (patch)
tree1ae3b8d69d7952500b07186169fb31e0f72ae04e /src/vat/main.c
parent35ffa3e8f6b032f6e324234d495f769049d8feea (diff)
Repair vlib API socket server
- Teach vpp_api_test to send/receive API messages over sockets - Add memfd-based shared memory - Add api messages to create memfd-based shared memory segments - vpp_api_test supports both socket and shared memory segment connections - vpp_api_test pivot from socket to shared memory API messaging - add socket client support to libvlibclient.so - dead client reaper sends ping messages, container-friendly - dead client reaper falls back to kill (<pid>, 0) live checking if e.g. a python app goes silent for tens of seconds - handle ping messages in python client support code - teach show api ring about pairwise shared-memory segments - fix ip probing of already resolved destinations (VPP-998) We'll need this work to implement proper host-stack client isolation Change-Id: Ic23b65f75c854d0393d9a2e9d6b122a9551be769 Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vat/main.c')
-rw-r--r--src/vat/main.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/vat/main.c b/src/vat/main.c
index 1bad2ebb14d..e2c9b70889a 100644
--- a/src/vat/main.c
+++ b/src/vat/main.c
@@ -190,6 +190,17 @@ do_one_file (vat_main_t * vam)
vam->regenerate_interface_table = 0;
api_sw_interface_dump (vam);
}
+
+ /* Hack to pick up new client index after memfd_segment_create pivot */
+ if (vam->client_index_invalid)
+ {
+ vat_main_t *vam = &vat_main;
+ api_main_t *am = &api_main;
+
+ vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
+ vam->my_client_index = am->my_client_index;
+ vam->client_index_invalid = 0;
+ }
}
}
@@ -313,6 +324,8 @@ main (int argc, char **argv)
eval_current_line);
init_error_string_table (vam);
+ vec_validate (vam->cmd_reply, 0);
+ vec_reset_length (vam->cmd_reply);
unformat_init_command_line (a, argv);
@@ -326,6 +339,12 @@ main (int argc, char **argv)
interactive = 0;
else if (unformat (a, "json"))
json_output = 1;
+ else if (unformat (a, "socket-name %s", &vam->socket_name))
+ ;
+ else if (unformat (a, "default-socket"))
+ {
+ vam->socket_name = format (0, "%s%c", API_SOCKET_FILE, 0);
+ }
else if (unformat (a, "plugin_path %s", (u8 *) & vat_plugin_path))
vec_add1 (vat_plugin_path, 0);
else if (unformat (a, "plugin_name_filter %s",
@@ -337,9 +356,12 @@ main (int argc, char **argv)
}
else
{
- fformat (stderr,
- "%s: usage [in <f1> ... in <fn>] [out <fn>] [script] [json]\n",
- argv[0]);
+ fformat
+ (stderr,
+ "%s: usage [in <f1> ... in <fn>] [out <fn>] [script] [json]\n"
+ "[plugin_path <path>][default-socket][socket-name <name>]\n"
+ "[plugin_name_filter <filter>][chroot prefix <path>]\n",
+ argv[0]);
exit (1);
}
}
@@ -363,7 +385,11 @@ main (int argc, char **argv)
setup_signal_handlers ();
- if (connect_to_vpe ("vpp_api_test") < 0)
+ if (vam->socket_name && vat_socket_connect (vam))
+ fformat (stderr, "WARNING: socket connection failed");
+
+ if (vam->socket_client_main.socket_fd == 0
+ && connect_to_vpe ("vpp_api_test") < 0)
{
svm_region_exit ();
fformat (stderr, "Couldn't connect to vpe, exiting...\n");
@@ -373,9 +399,7 @@ main (int argc, char **argv)
vam->json_output = json_output;
if (!json_output)
- {
- api_sw_interface_dump (vam);
- }
+ api_sw_interface_dump (vam);
vec_validate (vam->inbuf, 4096);