summaryrefslogtreecommitdiffstats
path: root/src/vat
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-12-19 04:50:01 -0800
committerDave Barach <openvpp@barachs.net>2018-01-05 19:00:45 +0000
commit90a63988fa01685626b6d6a01b79ea5370f7fbac (patch)
tree69951111b8f8c43c5dbfc61cc5b133f74a58ddda /src/vat
parente6bfeab1c352ae73a19361c038e2a06a58c035db (diff)
sock api: add infra for bootstrapping shm clients
- add function to sock client that bootstraps shm api - allow sock clients to request custom shm ring configs Change-Id: Iabc1dd4f0dc8bbf8ba24de37f4966339fcf86107 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vat')
-rw-r--r--src/vat/api_format.c72
-rw-r--r--src/vat/main.c2
-rw-r--r--src/vat/vat.h2
3 files changed, 65 insertions, 11 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 445b4962b36..88c64473518 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -88,9 +88,9 @@ vl (void *p)
int
vat_socket_connect (vat_main_t * vam)
{
- return vl_socket_client_connect
- (&vam->socket_client_main, (char *) vam->socket_name,
- "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
+ vam->socket_client_main = &socket_client_main;
+ return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
+ 0 /* default socket rx, tx buffer */ );
}
#else /* vpp built-in case, we don't do sockets... */
int
@@ -99,10 +99,23 @@ vat_socket_connect (vat_main_t * vam)
return 0;
}
-void
-vl_socket_client_read_reply (socket_client_main_t * scm)
+int
+vl_socket_client_read (int wait)
+{
+ return -1;
+};
+
+int
+vl_socket_client_write ()
{
+ return -1;
};
+
+void *
+vl_socket_client_msg_alloc (int nbytes)
+{
+ return 0;
+}
#endif
@@ -1464,7 +1477,8 @@ static void vl_api_control_ping_reply_t_handler
vam->retval = retval;
vam->result_ready = 1;
}
- vam->socket_client_main.control_pings_outstanding--;
+ if (vam->socket_client_main)
+ vam->socket_client_main->control_pings_outstanding--;
}
static void vl_api_control_ping_reply_t_handler_json
@@ -2186,7 +2200,7 @@ static void vl_api_memfd_segment_create_reply_t_handler
#if VPP_API_TEST_BUILTIN == 0
vat_main_t *vam = &vat_main;
api_main_t *am = &api_main;
- socket_client_main_t *scm = &vam->socket_client_main;
+ socket_client_main_t *scm = vam->socket_client_main;
int my_fd = -1;
clib_error_t *error;
memfd_private_t memfd;
@@ -2224,8 +2238,7 @@ static void vl_api_memfd_segment_create_reply_t_handler
32 /* input_queue_length */ );
vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
- vl_socket_client_enable_disable (&vam->socket_client_main,
- 0 /* disable socket */ );
+ vl_socket_client_enable_disable (0 /* disable socket */ );
}
out:
@@ -21866,6 +21879,46 @@ api_memfd_segment_create (vat_main_t * vam)
}
static int
+api_sock_init_shm (vat_main_t * vam)
+{
+#if VPP_API_TEST_BUILTIN == 0
+ unformat_input_t *i = vam->input;
+ vl_api_shm_elem_config_t *config = 0;
+ u64 size = 64 << 20;
+ int rv;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "size %U", unformat_memory_size, &size))
+ ;
+ else
+ break;
+ }
+
+ /* Try customized config to see if it works */
+ vec_validate (config, 3);
+ config[0].type = VL_API_VLIB_RING;
+ config[0].count = 256;
+ config[0].size = 256;
+ config[1].type = VL_API_CLIENT_RING;
+ config[1].count = 256;
+ config[1].size = 1024;
+ config[2].type = VL_API_CLIENT_RING;
+ config[2].count = 8;
+ config[2].size = 4096;
+ config[3].type = VL_API_QUEUE;
+ config[3].count = 256;
+ config[3].size = sizeof (uword);
+ rv = vl_socket_client_init_shm (config);
+ if (!rv)
+ vam->client_index_invalid = 1;
+ return rv;
+#else
+ return -99;
+#endif
+}
+
+static int
api_dns_enable_disable (vat_main_t * vam)
{
unformat_input_t *line_input = vam->input;
@@ -23093,6 +23146,7 @@ _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n
" [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
_(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
_(memfd_segment_create,"size <nnn>") \
+_(sock_init_shm, "size <nnn>") \
_(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
_(dns_enable_disable, "[enable][disable]") \
_(dns_name_server_add_del, "<ip-address> [del]") \
diff --git a/src/vat/main.c b/src/vat/main.c
index aa990a31d93..723c5e8cc3a 100644
--- a/src/vat/main.c
+++ b/src/vat/main.c
@@ -389,7 +389,7 @@ main (int argc, char **argv)
if (vam->socket_name && vat_socket_connect (vam))
fformat (stderr, "WARNING: socket connection failed");
- if (vam->socket_client_main.socket_fd == 0
+ if ((!vam->socket_client_main || vam->socket_client_main->socket_fd == 0)
&& connect_to_vpe ("vpp_api_test") < 0)
{
svm_region_exit ();
diff --git a/src/vat/vat.h b/src/vat/vat.h
index 1ae46f30a7e..ddb4644848a 100644
--- a/src/vat/vat.h
+++ b/src/vat/vat.h
@@ -209,7 +209,7 @@ typedef struct
ip4_nbr_counter_t **ip4_nbr_counters;
ip6_nbr_counter_t **ip6_nbr_counters;
- socket_client_main_t socket_client_main;
+ socket_client_main_t *socket_client_main;
u8 *socket_name;
/* Convenience */