aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/client/client.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/vpp-api/client/client.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/vpp-api/client/client.c')
-rw-r--r--src/vpp-api/client/client.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c
index 8bdcda01c4d..668461aad6c 100644
--- a/src/vpp-api/client/client.c
+++ b/src/vpp-api/client/client.c
@@ -133,8 +133,11 @@ static void *
vac_rx_thread_fn (void *arg)
{
unix_shared_memory_queue_t *q;
+ vl_api_memclnt_keepalive_t *mp;
+ vl_api_memclnt_keepalive_reply_t *rmp;
vac_main_t *pm = &vac_main;
api_main_t *am = &api_main;
+ vl_shmem_hdr_t *shmem_hdr;
uword msg;
q = am->vl_input_queue;
@@ -169,6 +172,17 @@ vac_rx_thread_fn (void *arg)
vl_msg_api_free((void *) msg);
break;
+ case VL_API_MEMCLNT_KEEPALIVE:
+ mp = (void *)msg;
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs(VL_API_MEMCLNT_KEEPALIVE_REPLY);
+ rmp->context = mp->context;
+ shmem_hdr = am->shmem_hdr;
+ vl_msg_api_send_shmem(shmem_hdr->vl_input_queue, (u8 *)&rmp);
+ vl_msg_api_free((void *) msg);
+ break;
+
default:
vac_api_handler((void *)msg);
}
@@ -370,8 +384,12 @@ vac_read (char **p, int *l, u16 timeout)
unix_shared_memory_queue_t *q;
api_main_t *am = &api_main;
vac_main_t *pm = &vac_main;
+ vl_api_memclnt_keepalive_t *mp;
+ vl_api_memclnt_keepalive_reply_t *rmp;
uword msg;
msgbuf_t *msgbuf;
+ int rv;
+ vl_shmem_hdr_t *shmem_hdr;
if (!pm->connected_to_vlib) return -1;
@@ -384,7 +402,9 @@ vac_read (char **p, int *l, u16 timeout)
set_timeout(timeout);
q = am->vl_input_queue;
- int rv = unix_shared_memory_queue_sub(q, (u8 *)&msg, 0);
+
+ again:
+ rv = unix_shared_memory_queue_sub(q, (u8 *)&msg, 0);
if (rv == 0) {
u16 msg_id = ntohs(*((u16 *)msg));
switch (msg_id) {
@@ -397,6 +417,21 @@ vac_read (char **p, int *l, u16 timeout)
case VL_API_MEMCLNT_READ_TIMEOUT:
printf("Received read timeout %ds\n", timeout);
goto error;
+ case VL_API_MEMCLNT_KEEPALIVE:
+ /* Handle an alive-check ping from vpp. */
+ mp = (void *)msg;
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs(VL_API_MEMCLNT_KEEPALIVE_REPLY);
+ rmp->context = mp->context;
+ shmem_hdr = am->shmem_hdr;
+ vl_msg_api_send_shmem(shmem_hdr->vl_input_queue, (u8 *)&rmp);
+ vl_msg_api_free((void *) msg);
+ /*
+ * Python code is blissfully unaware of these pings, so
+ * act as if it never happened...
+ */
+ goto again;
default:
msgbuf = (msgbuf_t *)(((u8 *)msg) - offsetof(msgbuf_t, data));