+ /* And create a plausible svm_region in it */
+ memset (a, 0, sizeof (*a));
+ a->baseva = memfd->sh->memfd_va + MMAP_PAGESIZE;
+ a->size = memfd->memfd_size - MMAP_PAGESIZE;
+ /* $$$$ might want a different config parameter */
+ a->pvt_heap_size = am->api_pvt_heap_size;
+ a->flags = SVM_FLAGS_MHEAP;
+ svm_region_init_mapped_region (a, (svm_region_t *) a->baseva);
+
+ vlib_rp = (svm_region_t *) a->baseva;
+
+ /*
+ * Part deux, initialize the svm_region_t shared-memory header
+ * api allocation rings, and so on.
+ */
+ vl_init_shmem (vlib_rp, 1 /* is_vlib (dont-care) */ , 1 /* is_private */ );
+
+ vec_add1 (am->vlib_private_rps, vlib_rp);
+
+ memfd->sh->ready = 1;
+
+ /* Recompute the set of input queues to poll in memclnt_process */
+ vec_reset_length (vl_api_queue_cursizes);
+
+reply:
+
+ /* send the reply message */
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ rmp->_vl_msg_id = htons (VL_API_MEMFD_SEGMENT_CREATE_REPLY);
+ rmp->context = mp->context;
+ rmp->retval = htonl (rv);
+
+ vl_msg_api_send (regp, (u8 *) rmp);
+
+ if (rv != 0)
+ return;
+
+ /*
+ * We need the reply message to make it out the back door
+ * before we send the magic fd message.
+ */
+ vlib_process_suspend (vm, 11e-6);
+
+ cf = file_main.file_pool + regp->clib_file_index;
+
+ /* send the magic "here's your sign (aka fd)" socket message */
+ send_fd_msg (cf->file_descriptor, memfd->fd);
+}
+
+#define foreach_vlib_api_msg \
+_(SOCKCLNT_CREATE, sockclnt_create) \
+_(SOCKCLNT_DELETE, sockclnt_delete) \
+_(MEMFD_SEGMENT_CREATE, memfd_segment_create)
+
+clib_error_t *
+socksvr_api_init (vlib_main_t * vm)
+{
+ clib_file_main_t *fm = &file_main;
+ clib_file_t template = { 0 };
+ vl_api_registration_t *rp;
+ vl_msg_api_msg_config_t cfg;
+ vl_msg_api_msg_config_t *c = &cfg;
+ socket_main_t *sm = &socket_main;
+ clib_socket_t *sock = &sm->socksvr_listen_socket;
+ clib_error_t *error;
+
+ /* If not explicitly configured, do not bind/enable, etc. */
+ if (sm->socket_name == 0)
+ return 0;
+
+#define _(N,n) do { \
+ c->id = VL_API_##N; \
+ c->name = #n; \
+ c->handler = vl_api_##n##_t_handler; \
+ c->cleanup = vl_noop_handler; \
+ c->endian = vl_api_##n##_t_endian; \
+ c->print = vl_api_##n##_t_print; \
+ c->size = sizeof(vl_api_##n##_t); \
+ c->traced = 1; /* trace, so these msgs print */ \
+ c->replay = 0; /* don't replay client create/delete msgs */ \
+ c->message_bounce = 0; /* don't bounce this message */ \
+ vl_msg_api_config(c);} while (0);
+
+ foreach_vlib_api_msg;
+#undef _
+
+ vec_resize (sm->input_buffer, 4096);
+
+ sock->config = (char *) sm->socket_name;
+
+ /* mkdir of file socket, only under /run */
+ if (strncmp (sock->config, "/run", 4) == 0)