session: segment handle in accept/connect notifications
[vpp.git] / src / vcl / vcl_bapi.c
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <vcl/vcl_private.h>
17 #include <vlibmemory/api.h>
18 #include <vpp/api/vpe_msg_enum.h>
19
20 #define vl_typedefs             /* define message structures */
21 #include <vpp/api/vpe_all_api_h.h>
22 #undef vl_typedefs
23
24 /* declare message handlers for each api */
25
26 #define vl_endianfun            /* define message structures */
27 #include <vpp/api/vpe_all_api_h.h>
28 #undef vl_endianfun
29
30 /* instantiate all the print functions we know about */
31 #define vl_print(handle, ...)
32 #define vl_printfun
33 #include <vpp/api/vpe_all_api_h.h>
34 #undef vl_printfun
35
36 u8 *
37 format_api_error (u8 * s, va_list * args)
38 {
39   i32 error = va_arg (*args, u32);
40   uword *p;
41
42   p = hash_get (vcm->error_string_by_error_number, -error);
43
44   if (p)
45     s = format (s, "%s (%d)", p[0], error);
46   else
47     s = format (s, "%d", error);
48   return s;
49 }
50
51 static void
52   vl_api_session_enable_disable_reply_t_handler
53   (vl_api_session_enable_disable_reply_t * mp)
54 {
55   if (mp->retval)
56     {
57       clib_warning ("VCL<%d>: session_enable_disable failed: %U", getpid (),
58                     format_api_error, ntohl (mp->retval));
59     }
60   else
61     vcm->app_state = STATE_APP_ENABLED;
62 }
63
64 static int
65 ssvm_segment_attach (char *name, ssvm_segment_type_t type, int fd)
66 {
67   svm_fifo_segment_create_args_t _a, *a = &_a;
68   int rv;
69
70   memset (a, 0, sizeof (*a));
71   a->segment_name = (char *) name;
72   a->segment_type = type;
73
74   if (type == SSVM_SEGMENT_MEMFD)
75     a->memfd_fd = fd;
76
77   if ((rv = svm_fifo_segment_attach (a)))
78     {
79       clib_warning ("svm_fifo_segment_attach ('%s') failed", name);
80       return rv;
81     }
82   vec_reset_length (a->new_segment_indices);
83   return 0;
84 }
85
86 static void
87 vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
88                                            mp)
89 {
90   vcl_worker_t *wrk = vcl_worker_get (0);
91   u32 n_fds = 0;
92   int *fds = 0;
93
94   if (mp->retval)
95     {
96       clib_warning ("VCL<%d>: attach failed: %U", getpid (),
97                     format_api_error, ntohl (mp->retval));
98       return;
99     }
100
101   wrk->app_event_queue = uword_to_pointer (mp->app_event_queue_address,
102                                            svm_msg_q_t *);
103   if (mp->n_fds)
104     {
105       vec_validate (fds, mp->n_fds);
106       vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5);
107
108       if (mp->fd_flags & SESSION_FD_F_VPP_MQ_SEGMENT)
109         if (ssvm_segment_attach ("vpp-mq-seg", SSVM_SEGMENT_MEMFD,
110                                  fds[n_fds++]))
111           return;
112
113       if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT)
114         if (ssvm_segment_attach ((char *) mp->segment_name,
115                                  SSVM_SEGMENT_MEMFD, fds[n_fds++]))
116           return;
117
118       if (mp->fd_flags & SESSION_FD_F_MQ_EVENTFD)
119         {
120           svm_msg_q_set_consumer_eventfd (wrk->app_event_queue, fds[n_fds]);
121           vcl_mq_epoll_add_evfd (wrk, wrk->app_event_queue);
122           n_fds++;
123         }
124
125       vec_free (fds);
126     }
127   else
128     {
129       if (ssvm_segment_attach ((char *) mp->segment_name, SSVM_SEGMENT_SHM,
130                                -1))
131         return;
132     }
133
134   vcm->app_index = clib_net_to_host_u32 (mp->app_index);
135   vcm->app_state = STATE_APP_ATTACHED;
136 }
137
138 static void
139 vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t *
140                                            mp)
141 {
142   int n_fds = 0, *fds = 0;
143   vcl_worker_t *wrk;
144   u32 wrk_index;
145
146   if (mp->retval)
147     {
148       clib_warning ("VCL<%d>: add/del worker failed: %U", getpid (),
149                     format_api_error, ntohl (mp->retval));
150       goto failed;
151     }
152   wrk_index = mp->context;
153   wrk = vcl_worker_get (wrk_index);
154   wrk->vpp_wrk_index = clib_net_to_host_u32 (mp->wrk_index);
155
156   if (!mp->is_add)
157     return;
158
159   wrk->app_event_queue = uword_to_pointer (mp->app_event_queue_address,
160                                            svm_msg_q_t *);
161
162   if (mp->n_fds)
163     {
164       vec_validate (fds, mp->n_fds);
165       vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5);
166
167       if (mp->fd_flags & SESSION_FD_F_VPP_MQ_SEGMENT)
168         if (ssvm_segment_attach ("vpp-worker-seg", SSVM_SEGMENT_MEMFD,
169                                  fds[n_fds++]))
170           goto failed;
171
172       if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT)
173         if (ssvm_segment_attach ((char *) mp->segment_name,
174                                  SSVM_SEGMENT_MEMFD, fds[n_fds++]))
175           goto failed;
176
177       if (mp->fd_flags & SESSION_FD_F_MQ_EVENTFD)
178         {
179           svm_msg_q_set_consumer_eventfd (wrk->app_event_queue, fds[n_fds]);
180           vcl_mq_epoll_add_evfd (wrk, wrk->app_event_queue);
181           n_fds++;
182         }
183
184       vec_free (fds);
185     }
186   else
187     {
188       if (ssvm_segment_attach ((char *) mp->segment_name, SSVM_SEGMENT_SHM,
189                                -1))
190         goto failed;
191     }
192   vcm->app_state = STATE_APP_READY;
193   VDBG (0, "worker %u vpp-worker %u added", wrk_index, wrk->vpp_wrk_index);
194   return;
195
196 failed:
197   vcm->app_state = STATE_APP_FAILED;
198 }
199
200 static void
201 vl_api_application_detach_reply_t_handler (vl_api_application_detach_reply_t *
202                                            mp)
203 {
204   if (mp->retval)
205     clib_warning ("VCL<%d>: detach failed: %U", getpid (), format_api_error,
206                   ntohl (mp->retval));
207
208   vcm->app_state = STATE_APP_ENABLED;
209 }
210
211 static void
212 vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
213 {
214   ssvm_segment_type_t seg_type = SSVM_SEGMENT_SHM;
215   int fd = -1;
216
217   vcm->mounting_segment = 1;
218
219   if (mp->fd_flags)
220     {
221       vl_socket_client_recv_fd_msg (&fd, 1, 5);
222       seg_type = SSVM_SEGMENT_MEMFD;
223     }
224
225   if (PREDICT_FALSE (ssvm_segment_attach ((char *) mp->segment_name,
226                                           seg_type, fd)))
227     {
228       clib_warning ("VCL<%d>: svm_fifo_segment_attach ('%s') failed",
229                     getpid (), mp->segment_name);
230       return;
231     }
232
233   VDBG (1, "VCL<%d>: mapped new segment '%s' size %d", getpid (),
234         mp->segment_name, mp->segment_size);
235   vcm->mounting_segment = 0;
236 }
237
238 static void
239 vl_api_unmap_segment_t_handler (vl_api_unmap_segment_t * mp)
240 {
241
242 /*
243  * XXX Need segment_name to session_id hash,
244  * XXX - have sessionID by handle hash currently
245  */
246
247   VDBG (1, "Unmapped segment '%s'",
248         clib_net_to_host_u64 (mp->segment_handle));
249 }
250
251 static void
252   vl_api_app_cut_through_registration_add_t_handler
253   (vl_api_app_cut_through_registration_add_t * mp)
254 {
255   vcl_cut_through_registration_t *ctr;
256   u32 mqc_index = ~0;
257   vcl_worker_t *wrk;
258   int *fds = 0;
259
260   if (mp->n_fds)
261     {
262       ASSERT (mp->n_fds == 2);
263       vec_validate (fds, mp->n_fds);
264       vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5);
265     }
266
267   wrk = vcl_worker_get (mp->wrk_index);
268   ctr = vcl_ct_registration_lock_and_alloc (wrk);
269   ctr->mq = uword_to_pointer (mp->evt_q_address, svm_msg_q_t *);
270   ctr->peer_mq = uword_to_pointer (mp->peer_evt_q_address, svm_msg_q_t *);
271   VDBG (0, "Adding ct registration %u", vcl_ct_registration_index (wrk, ctr));
272
273   if (mp->n_fds && (mp->fd_flags & SESSION_FD_F_MQ_EVENTFD))
274     {
275       svm_msg_q_set_consumer_eventfd (ctr->mq, fds[0]);
276       svm_msg_q_set_producer_eventfd (ctr->peer_mq, fds[1]);
277       mqc_index = vcl_mq_epoll_add_evfd (wrk, ctr->mq);
278       ctr->epoll_evt_conn_index = mqc_index;
279       vec_free (fds);
280     }
281   vcl_ct_registration_lookup_add (wrk, mp->evt_q_address,
282                                   vcl_ct_registration_index (wrk, ctr));
283   vcl_ct_registration_unlock (wrk);
284 }
285
286 static void
287 vl_api_bind_sock_reply_t_handler (vl_api_bind_sock_reply_t * mp)
288 {
289   /* Expecting a similar message on mq. So ignore this */
290   VDBG (1, "VCL<%d>: bapi msg vpp handle 0x%llx, sid %u: bind retval: %u!",
291         getpid (), mp->handle, mp->context, mp->retval);
292 }
293
294 static void
295 vl_api_unbind_sock_reply_t_handler (vl_api_unbind_sock_reply_t * mp)
296 {
297   if (mp->retval)
298     clib_warning ("VCL<%d>: ERROR: sid %u: unbind failed: %U",
299                   getpid (), mp->context, format_api_error,
300                   ntohl (mp->retval));
301
302   else
303     VDBG (1, "VCL<%d>: sid %u: unbind succeeded!", getpid (), mp->context);
304 }
305
306 static void
307 vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t *
308                                            mp)
309 {
310   if (mp->retval)
311     clib_warning ("VCL<%d>: ERROR: sid %u: disconnect failed: %U",
312                   getpid (), mp->context, format_api_error,
313                   ntohl (mp->retval));
314 }
315
316 static void
317 vl_api_connect_session_reply_t_handler (vl_api_connect_sock_reply_t * mp)
318 {
319   if (mp->retval)
320     clib_warning ("VCL<%d>: ERROR: sid %u: connect failed: %U",
321                   getpid (), mp->context, format_api_error,
322                   ntohl (mp->retval));
323 }
324
325 #define foreach_sock_msg                                                \
326 _(SESSION_ENABLE_DISABLE_REPLY, session_enable_disable_reply)           \
327 _(BIND_SOCK_REPLY, bind_sock_reply)                                     \
328 _(UNBIND_SOCK_REPLY, unbind_sock_reply)                                 \
329 _(CONNECT_SESSION_REPLY, connect_session_reply)                         \
330 _(DISCONNECT_SESSION_REPLY, disconnect_session_reply)                   \
331 _(APPLICATION_ATTACH_REPLY, application_attach_reply)                   \
332 _(APPLICATION_DETACH_REPLY, application_detach_reply)                   \
333 _(MAP_ANOTHER_SEGMENT, map_another_segment)                             \
334 _(UNMAP_SEGMENT, unmap_segment)                                         \
335 _(APP_CUT_THROUGH_REGISTRATION_ADD, app_cut_through_registration_add)   \
336 _(APP_WORKER_ADD_DEL_REPLY, app_worker_add_del_reply)                   \
337
338 void
339 vppcom_api_hookup (void)
340 {
341 #define _(N, n)                                                 \
342     vl_msg_api_set_handlers(VL_API_##N, #n,                     \
343                            vl_api_##n##_t_handler,              \
344                            vl_noop_handler,                     \
345                            vl_api_##n##_t_endian,               \
346                            vl_api_##n##_t_print,                \
347                            sizeof(vl_api_##n##_t), 1);
348   foreach_sock_msg;
349 #undef _
350 }
351
352 /*
353  * VPP-API message functions
354  */
355 void
356 vppcom_send_session_enable_disable (u8 is_enable)
357 {
358   vcl_worker_t *wrk = vcl_worker_get_current ();
359   vl_api_session_enable_disable_t *bmp;
360   bmp = vl_msg_api_alloc (sizeof (*bmp));
361   memset (bmp, 0, sizeof (*bmp));
362
363   bmp->_vl_msg_id = ntohs (VL_API_SESSION_ENABLE_DISABLE);
364   bmp->client_index = wrk->my_client_index;
365   bmp->context = htonl (0xfeedface);
366   bmp->is_enable = is_enable;
367   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
368 }
369
370 void
371 vppcom_app_send_attach (void)
372 {
373   vcl_worker_t *wrk = vcl_worker_get_current ();
374   vl_api_application_attach_t *bmp;
375   u8 nsid_len = vec_len (vcm->cfg.namespace_id);
376   u8 app_is_proxy = (vcm->cfg.app_proxy_transport_tcp ||
377                      vcm->cfg.app_proxy_transport_udp);
378
379   bmp = vl_msg_api_alloc (sizeof (*bmp));
380   memset (bmp, 0, sizeof (*bmp));
381
382   bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_ATTACH);
383   bmp->client_index = wrk->my_client_index;
384   bmp->context = htonl (0xfeedface);
385   bmp->options[APP_OPTIONS_FLAGS] =
386     APP_OPTIONS_FLAGS_ACCEPT_REDIRECT | APP_OPTIONS_FLAGS_ADD_SEGMENT |
387     (vcm->cfg.app_scope_local ? APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE : 0) |
388     (vcm->cfg.app_scope_global ? APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE : 0) |
389     (app_is_proxy ? APP_OPTIONS_FLAGS_IS_PROXY : 0) |
390     APP_OPTIONS_FLAGS_USE_MQ_FOR_CTRL_MSGS |
391     (vcm->cfg.use_mq_eventfd ? APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD : 0);
392   bmp->options[APP_OPTIONS_PROXY_TRANSPORT] =
393     (u64) ((vcm->cfg.app_proxy_transport_tcp ? 1 << TRANSPORT_PROTO_TCP : 0) |
394            (vcm->cfg.app_proxy_transport_udp ? 1 << TRANSPORT_PROTO_UDP : 0));
395   bmp->options[APP_OPTIONS_SEGMENT_SIZE] = vcm->cfg.segment_size;
396   bmp->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = vcm->cfg.add_segment_size;
397   bmp->options[APP_OPTIONS_RX_FIFO_SIZE] = vcm->cfg.rx_fifo_size;
398   bmp->options[APP_OPTIONS_TX_FIFO_SIZE] = vcm->cfg.tx_fifo_size;
399   bmp->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
400     vcm->cfg.preallocated_fifo_pairs;
401   bmp->options[APP_OPTIONS_EVT_QUEUE_SIZE] = vcm->cfg.event_queue_size;
402   if (nsid_len)
403     {
404       bmp->namespace_id_len = nsid_len;
405       clib_memcpy_fast (bmp->namespace_id, vcm->cfg.namespace_id, nsid_len);
406       bmp->options[APP_OPTIONS_NAMESPACE_SECRET] = vcm->cfg.namespace_secret;
407     }
408   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
409 }
410
411 void
412 vppcom_app_send_detach (void)
413 {
414   vcl_worker_t *wrk = vcl_worker_get_current ();
415   vl_api_application_detach_t *bmp;
416   bmp = vl_msg_api_alloc (sizeof (*bmp));
417   memset (bmp, 0, sizeof (*bmp));
418
419   bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_DETACH);
420   bmp->client_index = wrk->my_client_index;
421   bmp->context = htonl (0xfeedface);
422   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
423 }
424
425 void
426 vcl_send_app_worker_add_del (u8 is_add)
427 {
428   vcl_worker_t *wrk = vcl_worker_get_current ();
429   vl_api_app_worker_add_del_t *mp;
430   u32 wrk_index = wrk->wrk_index;
431
432   mp = vl_msg_api_alloc (sizeof (*mp));
433   memset (mp, 0, sizeof (*mp));
434
435   mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL);
436   mp->client_index = wrk->my_client_index;
437   mp->app_index = clib_host_to_net_u32 (vcm->app_index);
438   mp->context = wrk_index;
439   mp->is_add = is_add;
440   if (!is_add)
441     mp->wrk_index = clib_host_to_net_u32 (wrk_index);
442
443   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & mp);
444 }
445
446 void
447 vppcom_send_connect_sock (vcl_session_t * session)
448 {
449   vcl_worker_t *wrk = vcl_worker_get_current ();
450   vl_api_connect_sock_t *cmp;
451
452   cmp = vl_msg_api_alloc (sizeof (*cmp));
453   memset (cmp, 0, sizeof (*cmp));
454   cmp->_vl_msg_id = ntohs (VL_API_CONNECT_SOCK);
455   cmp->client_index = wrk->my_client_index;
456   cmp->context = session->session_index;
457   cmp->wrk_index = wrk->vpp_wrk_index;
458   cmp->is_ip4 = session->transport.is_ip4;
459   clib_memcpy_fast (cmp->ip, &session->transport.rmt_ip, sizeof (cmp->ip));
460   cmp->port = session->transport.rmt_port;
461   cmp->proto = session->session_type;
462   clib_memcpy_fast (cmp->options, session->options, sizeof (cmp->options));
463   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & cmp);
464 }
465
466 void
467 vppcom_send_disconnect_session (u64 vpp_handle)
468 {
469   vcl_worker_t *wrk = vcl_worker_get_current ();
470   vl_api_disconnect_session_t *dmp;
471
472   dmp = vl_msg_api_alloc (sizeof (*dmp));
473   memset (dmp, 0, sizeof (*dmp));
474   dmp->_vl_msg_id = ntohs (VL_API_DISCONNECT_SESSION);
475   dmp->client_index = wrk->my_client_index;
476   dmp->handle = vpp_handle;
477   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & dmp);
478 }
479
480 /* VPP combines bind and listen as one operation. VCL manages the separation
481  * of bind and listen locally via vppcom_session_bind() and
482  * vppcom_session_listen() */
483 void
484 vppcom_send_bind_sock (vcl_session_t * session)
485 {
486   vcl_worker_t *wrk = vcl_worker_get_current ();
487   vl_api_bind_sock_t *bmp;
488
489   /* Assumes caller has acquired spinlock: vcm->sessions_lockp */
490   bmp = vl_msg_api_alloc (sizeof (*bmp));
491   memset (bmp, 0, sizeof (*bmp));
492
493   bmp->_vl_msg_id = ntohs (VL_API_BIND_SOCK);
494   bmp->client_index = wrk->my_client_index;
495   bmp->context = session->session_index;
496   bmp->wrk_index = wrk->vpp_wrk_index;
497   bmp->is_ip4 = session->transport.is_ip4;
498   clib_memcpy_fast (bmp->ip, &session->transport.lcl_ip, sizeof (bmp->ip));
499   bmp->port = session->transport.lcl_port;
500   bmp->proto = session->session_type;
501   clib_memcpy_fast (bmp->options, session->options, sizeof (bmp->options));
502   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
503 }
504
505 void
506 vppcom_send_unbind_sock (u64 vpp_handle)
507 {
508   vcl_worker_t *wrk = vcl_worker_get_current ();
509   vl_api_unbind_sock_t *ump;
510
511   ump = vl_msg_api_alloc (sizeof (*ump));
512   memset (ump, 0, sizeof (*ump));
513
514   ump->_vl_msg_id = ntohs (VL_API_UNBIND_SOCK);
515   ump->client_index = wrk->my_client_index;
516   ump->wrk_index = wrk->vpp_wrk_index;
517   ump->handle = vpp_handle;
518   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & ump);
519 }
520
521 void
522 vppcom_send_accept_session_reply (u64 handle, u32 context, int retval)
523 {
524   vcl_worker_t *wrk = vcl_worker_get_current ();
525   vl_api_accept_session_reply_t *rmp;
526
527   rmp = vl_msg_api_alloc (sizeof (*rmp));
528   memset (rmp, 0, sizeof (*rmp));
529   rmp->_vl_msg_id = ntohs (VL_API_ACCEPT_SESSION_REPLY);
530   rmp->retval = htonl (retval);
531   rmp->context = context;
532   rmp->handle = handle;
533   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & rmp);
534 }
535
536 u32
537 vcl_max_nsid_len (void)
538 {
539   vl_api_application_attach_t *mp;
540   return (sizeof (mp->namespace_id) - 1);
541 }
542
543 void
544 vppcom_init_error_string_table (void)
545 {
546   vcm->error_string_by_error_number = hash_create (0, sizeof (uword));
547
548 #define _(n, v, s) hash_set (vcm->error_string_by_error_number, -v, s);
549   foreach_vnet_api_error;
550 #undef _
551
552   hash_set (vcm->error_string_by_error_number, 99, "Misc");
553 }
554
555 int
556 vppcom_connect_to_vpp (char *app_name)
557 {
558   vcl_worker_t *wrk = vcl_worker_get_current ();
559   api_main_t *am = &api_main;
560   vppcom_cfg_t *vcl_cfg = &vcm->cfg;
561
562   if (vcl_cfg->vpp_api_socket_name)
563     {
564       if (vl_socket_client_connect ((char *) vcl_cfg->vpp_api_socket_name,
565                                     app_name, 0 /* default rx/tx buffer */ ))
566         {
567           VERR ("app (%s) socket connect failed!", app_name);
568           return VPPCOM_ECONNREFUSED;
569         }
570
571       if (vl_socket_client_init_shm (0))
572         {
573           VERR ("app (%s) init shm failed!", app_name);
574           return VPPCOM_ECONNREFUSED;
575         }
576     }
577   else
578     {
579       if (!vcl_cfg->vpp_api_filename)
580         vcl_cfg->vpp_api_filename = format (0, "/vpe-api%c", 0);
581
582       VDBG (0, "app (%s) connecting to VPP api (%s)...",
583             app_name, vcl_cfg->vpp_api_filename);
584
585       if (vl_client_connect_to_vlib ((char *) vcl_cfg->vpp_api_filename,
586                                      app_name, vcm->cfg.vpp_api_q_length) < 0)
587         {
588           VERR ("app (%s) connect failed!", app_name);
589           return VPPCOM_ECONNREFUSED;
590         }
591
592     }
593
594   wrk->vl_input_queue = am->shmem_hdr->vl_input_queue;
595   wrk->my_client_index = (u32) am->my_client_index;
596   wrk->wrk_state = STATE_APP_CONN_VPP;
597
598   VDBG (0, "app (%s) is connected to VPP!", app_name);
599   vcl_evt (VCL_EVT_INIT, vcm);
600   return VPPCOM_OK;
601 }
602
603 /*
604  * fd.io coding-style-patch-verification: ON
605  *
606  * Local Variables:
607  * eval: (c-set-style "gnu")
608  * End:
609  */