FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
session_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
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 <vnet/vnet.h>
17 #include <vlibmemory/api.h>
22 
23 #include <vnet/vnet_msg_enum.h>
24 
25 #define vl_typedefs /* define message structures */
26 #include <vnet/vnet_all_api_h.h>
27 #undef vl_typedefs
28 
29 #define vl_endianfun /* define message structures */
30 #include <vnet/vnet_all_api_h.h>
31 #undef vl_endianfun
32 
33 /* instantiate all the print functions we know about */
34 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
35 #define vl_printfun
36 #include <vnet/vnet_all_api_h.h>
37 #undef vl_printfun
38 
40 
41 #define foreach_session_api_msg \
42 _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \
43 _(APPLICATION_ATTACH, application_attach) \
44 _(APPLICATION_DETACH, application_detach) \
45 _(BIND_URI, bind_uri) \
46 _(UNBIND_URI, unbind_uri) \
47 _(CONNECT_URI, connect_uri) \
48 _(DISCONNECT_SESSION, disconnect_session) \
49 _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \
50 _(ACCEPT_SESSION_REPLY, accept_session_reply) \
51 _(RESET_SESSION_REPLY, reset_session_reply) \
52 _(BIND_SOCK, bind_sock) \
53 _(UNBIND_SOCK, unbind_sock) \
54 _(CONNECT_SOCK, connect_sock) \
55 _(SESSION_ENABLE_DISABLE, session_enable_disable) \
56 _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \
57 _(SESSION_RULE_ADD_DEL, session_rule_add_del) \
58 _(SESSION_RULES_DUMP, session_rules_dump) \
59 _(APPLICATION_TLS_CERT_ADD, application_tls_cert_add) \
60 _(APPLICATION_TLS_KEY_ADD, application_tls_key_add) \
61 _(APP_WORKER_ADD_DEL, app_worker_add_del) \
62 
63 static int
64 session_send_fds (vl_api_registration_t * reg, int fds[], int n_fds)
65 {
66  clib_error_t *error;
68  {
69  clib_warning ("can't send memfd fd");
70  return -1;
71  }
72  error = vl_api_send_fd_msg (reg, fds, n_fds);
73  if (error)
74  {
75  clib_error_report (error);
76  return -1;
77  }
78  return 0;
79 }
80 
81 static int
82 send_add_segment_callback (u32 api_client_index, u64 segment_handle)
83 {
84  int fds[SESSION_N_FD_TYPE], n_fds = 0;
88  ssvm_private_t *sp;
89  u8 fd_flags = 0;
90 
91  reg = vl_mem_api_client_index_to_registration (api_client_index);
92  if (!reg)
93  {
94  clib_warning ("no api registration for client: %u", api_client_index);
95  return -1;
96  }
97 
98  fs = segment_manager_get_segment_w_handle (segment_handle);
99  sp = &fs->ssvm;
100  if (ssvm_type (sp) == SSVM_SEGMENT_MEMFD)
101  {
103  {
104  clib_warning ("can't send memfd fd");
105  return -1;
106  }
107 
108  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
109  fds[n_fds] = sp->fd;
110  n_fds += 1;
111  }
112 
113  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
114  clib_memset (mp, 0, sizeof (*mp));
115  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT);
116  mp->segment_size = sp->ssvm_size;
117  mp->fd_flags = fd_flags;
118  mp->segment_handle = clib_host_to_net_u64 (segment_handle);
119  strncpy ((char *) mp->segment_name, (char *) sp->name,
120  sizeof (mp->segment_name) - 1);
121 
122  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
123 
124  if (n_fds)
125  return session_send_fds (reg, fds, n_fds);
126 
127  return 0;
128 }
129 
130 static int
131 send_del_segment_callback (u32 api_client_index, u64 segment_handle)
132 {
135 
136  reg = vl_mem_api_client_index_to_registration (api_client_index);
137  if (!reg)
138  {
139  clib_warning ("no registration: %u", api_client_index);
140  return -1;
141  }
142 
143  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
144  clib_memset (mp, 0, sizeof (*mp));
145  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_UNMAP_SEGMENT);
146  mp->segment_handle = clib_host_to_net_u64 (segment_handle);
147  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
148 
149  return 0;
150 }
151 
152 static int
154  u32 wrk_map_index, u64 mq_addr,
155  u64 peer_mq_addr)
156 {
159  svm_msg_q_t *mq, *peer_mq;
160  int fds[2];
161 
162  reg = vl_mem_api_client_index_to_registration (api_client_index);
163  if (!reg)
164  {
165  clib_warning ("no registration: %u", api_client_index);
166  return -1;
167  }
168 
169  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
170  clib_memset (mp, 0, sizeof (*mp));
171  mp->_vl_msg_id =
172  clib_host_to_net_u16 (VL_API_APP_CUT_THROUGH_REGISTRATION_ADD);
173 
174  mp->evt_q_address = mq_addr;
175  mp->peer_evt_q_address = peer_mq_addr;
176  mp->wrk_index = wrk_map_index;
177 
178  mq = uword_to_pointer (mq_addr, svm_msg_q_t *);
179  peer_mq = uword_to_pointer (peer_mq_addr, svm_msg_q_t *);
180 
181  if (svm_msg_q_get_producer_eventfd (mq) != -1)
182  {
183  mp->fd_flags |= SESSION_FD_F_MQ_EVENTFD;
184  mp->n_fds = 2;
185  /* app will overwrite exactly the fds we pass here. So
186  * when we swap mq with peer_mq (accept vs connect) the
187  * fds will still be valid */
188  fds[0] = svm_msg_q_get_consumer_eventfd (mq);
189  fds[1] = svm_msg_q_get_producer_eventfd (peer_mq);
190  }
191 
192  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
193 
194  if (mp->n_fds != 0)
195  session_send_fds (reg, fds, mp->n_fds);
196 
197  return 0;
198 }
199 
200 static int
202 {
203  app_worker_t *server_wrk = app_worker_get (s->app_wrk_index);
204  transport_proto_vft_t *tp_vft;
209  svm_msg_q_t *vpp_queue;
210  application_t *server;
211 
212  server = application_get (server_wrk->app_index);
213  reg =
215  if (!reg)
216  {
217  clib_warning ("no registration: %u", server_wrk->api_client_index);
218  return -1;
219  }
220 
221  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
222  clib_memset (mp, 0, sizeof (*mp));
223 
224  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION);
225  mp->context = server_wrk->wrk_index;
226  mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
227  mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
228 
229  if (session_has_transport (s))
230  {
231  listener = listen_session_get (s->listener_index);
233  if (application_is_proxy (server))
234  {
235  listener =
238  if (listener)
240  }
241  vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
242  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
243  mp->handle = session_handle (s);
245  tc = tp_vft->get_connection (s->connection_index, s->thread_index);
246  mp->port = tc->rmt_port;
247  mp->is_ip4 = tc->is_ip4;
248  clib_memcpy_fast (&mp->ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
249  }
250  else
251  {
252  local_session_t *ls = (local_session_t *) s;
253  local_session_t *ll;
255  {
256  listener = listen_session_get (ls->listener_index);
258  mp->is_ip4 = session_type_is_ip4 (listener->session_type);
259  }
260  else
261  {
263  ls->listener_index);
264  if (ll->transport_listener_index != ~0)
265  {
268  }
269  else
270  {
272  }
274  }
276  mp->port = ls->port;
279  }
280  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
281 
282  return 0;
283 }
284 
285 static void
287 {
288  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
291 
293  if (!reg)
294  {
295  clib_warning ("no registration: %u", app_wrk->api_client_index);
296  return;
297  }
298 
299  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
300  clib_memset (mp, 0, sizeof (*mp));
301  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION);
302  mp->handle = session_handle (s);
303  mp->context = app_wrk->api_client_index;
304  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
305 }
306 
307 static void
309 {
310  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
313 
315  if (!reg)
316  {
317  clib_warning ("no registration: %u", app_wrk->api_client_index);
318  return;
319  }
320 
321  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
322  clib_memset (mp, 0, sizeof (*mp));
323  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
324  mp->handle = session_handle (s);
325  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
326 }
327 
328 int
329 send_session_connected_callback (u32 app_wrk_index, u32 api_context,
330  stream_session_t * s, u8 is_fail)
331 {
335  svm_msg_q_t *vpp_queue;
336  app_worker_t *app_wrk;
337 
338  app_wrk = app_worker_get (app_wrk_index);
340  if (!reg)
341  {
342  clib_warning ("no registration: %u", app_wrk->api_client_index);
343  return -1;
344  }
345 
346  mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp));
347  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SESSION_REPLY);
348  mp->context = api_context;
349 
350  if (is_fail)
351  goto done;
352 
353  if (session_has_transport (s))
354  {
355  tc = session_get_transport (s);
356  if (!tc)
357  {
358  is_fail = 1;
359  goto done;
360  }
361 
362  vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
363  mp->handle = session_handle (s);
364  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
365  clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
366  mp->is_ip4 = tc->is_ip4;
367  mp->lcl_port = tc->lcl_port;
368  mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
369  mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
370  }
371  else
372  {
373  local_session_t *ls = (local_session_t *) s;
375  mp->lcl_port = ls->port;
378  mp->server_rx_fifo = pointer_to_uword (s->server_tx_fifo);
379  mp->server_tx_fifo = pointer_to_uword (s->server_rx_fifo);
380  }
381 
382 done:
383  mp->retval = is_fail ?
384  clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0;
385  vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp);
386  return 0;
387 }
388 
390  .session_accept_callback = send_session_accept_callback,
391  .session_disconnect_callback = send_session_disconnect_callback,
392  .session_connected_callback = send_session_connected_callback,
393  .session_reset_callback = send_session_reset_callback,
394  .add_segment_callback = send_add_segment_callback,
395  .del_segment_callback = send_del_segment_callback,
396 };
397 
398 static int
400 {
401  int rv;
402  u8 try = 0;
403  while (try < 100)
404  {
407  SVM_Q_NOWAIT, msg);
408  if (!rv)
409  return 0;
410  try++;
411  usleep (1);
412  }
413  clib_warning ("failed to alloc msg");
414  return -1;
415 }
416 
417 static int
419 {
420  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
421  svm_msg_q_msg_t _msg, *msg = &_msg;
422  svm_msg_q_t *vpp_queue, *app_mq;
423  transport_proto_vft_t *tp_vft;
427  session_event_t *evt;
428  application_t *app;
429 
430  app = application_get (app_wrk->app_index);
431  app_mq = app_wrk->event_queue;
432  if (mq_try_lock_and_alloc_msg (app_mq, msg))
433  return -1;
434 
435  evt = svm_msg_q_msg_data (app_mq, msg);
436  clib_memset (evt, 0, sizeof (*evt));
437  evt->event_type = SESSION_CTRL_EVT_ACCEPTED;
438  mp = (session_accepted_msg_t *) evt->data;
439  mp->context = app->app_index;
440  mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
441  mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
443 
444  if (session_has_transport (s))
445  {
446  listener = listen_session_get (s->listener_index);
448  if (application_is_proxy (app))
449  {
450  listener =
453  if (listener)
455  }
456  vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
457  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
458  mp->handle = session_handle (s);
460  tc = tp_vft->get_connection (s->connection_index, s->thread_index);
461  mp->port = tc->rmt_port;
462  mp->is_ip4 = tc->is_ip4;
463  clib_memcpy_fast (&mp->ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
464  }
465  else
466  {
467  local_session_t *ls = (local_session_t *) s;
468  local_session_t *ll;
469  u8 main_thread = vlib_num_workers ()? 1 : 0;
470 
472  app_wrk->wrk_map_index,
473  ls->server_evt_q,
474  ls->client_evt_q);
475 
477  {
478  listener = listen_session_get (ls->listener_index);
480  mp->is_ip4 = session_type_is_ip4 (listener->session_type);
481  }
482  else
483  {
485  if (ll->transport_listener_index != ~0)
486  {
489  }
490  else
491  {
493  }
495  }
497  mp->port = ls->port;
498  vpp_queue = session_manager_get_vpp_event_queue (main_thread);
499  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
502  }
503  svm_msg_q_add_and_unlock (app_mq, msg);
504 
505  return 0;
506 }
507 
508 static void
510 {
511  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
512  svm_msg_q_msg_t _msg, *msg = &_msg;
514  svm_msg_q_t *app_mq;
515  session_event_t *evt;
516 
517  app_mq = app_wrk->event_queue;
518  if (mq_try_lock_and_alloc_msg (app_mq, msg))
519  return;
520  evt = svm_msg_q_msg_data (app_mq, msg);
521  clib_memset (evt, 0, sizeof (*evt));
522  evt->event_type = SESSION_CTRL_EVT_DISCONNECTED;
523  mp = (session_disconnected_msg_t *) evt->data;
524  mp->handle = session_handle (s);
525  mp->context = app_wrk->api_client_index;
526  svm_msg_q_add_and_unlock (app_mq, msg);
527 }
528 
529 void
531  local_session_t * ls)
532 {
533  app_worker_t *app_wrk = app_worker_get (app_wrk_index);
534  svm_msg_q_msg_t _msg, *msg = &_msg;
536  svm_msg_q_t *app_mq;
537  session_event_t *evt;
538 
539  app_mq = app_wrk->event_queue;
540  if (mq_try_lock_and_alloc_msg (app_mq, msg))
541  return;
542  evt = svm_msg_q_msg_data (app_mq, msg);
543  clib_memset (evt, 0, sizeof (*evt));
544  evt->event_type = SESSION_CTRL_EVT_DISCONNECTED;
545  mp = (session_disconnected_msg_t *) evt->data;
547  mp->context = app_wrk->api_client_index;
548  svm_msg_q_add_and_unlock (app_mq, msg);
549 }
550 
551 static void
553 {
554  app_worker_t *app = app_worker_get (s->app_wrk_index);
555  svm_msg_q_msg_t _msg, *msg = &_msg;
557  svm_msg_q_t *app_mq;
558  session_event_t *evt;
559 
560  app_mq = app->event_queue;
561  if (mq_try_lock_and_alloc_msg (app_mq, msg))
562  return;
563  evt = svm_msg_q_msg_data (app_mq, msg);
564  clib_memset (evt, 0, sizeof (*evt));
565  evt->event_type = SESSION_CTRL_EVT_RESET;
566  mp = (session_reset_msg_t *) evt->data;
567  mp->handle = session_handle (s);
568  svm_msg_q_add_and_unlock (app_mq, msg);
569 }
570 
571 static int
572 mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
573  stream_session_t * s, u8 is_fail)
574 {
575  svm_msg_q_msg_t _msg, *msg = &_msg;
577  svm_msg_q_t *vpp_mq, *app_mq;
579  app_worker_t *app_wrk;
580  session_event_t *evt;
581 
582  app_wrk = app_worker_get (app_wrk_index);
583  app_mq = app_wrk->event_queue;
584  if (!app_mq)
585  {
586  clib_warning ("app %u with api index: %u not attached",
587  app_wrk->app_index, app_wrk->api_client_index);
588  return -1;
589  }
590 
591  if (mq_try_lock_and_alloc_msg (app_mq, msg))
592  return -1;
593 
594  evt = svm_msg_q_msg_data (app_mq, msg);
595  clib_memset (evt, 0, sizeof (*evt));
596  evt->event_type = SESSION_CTRL_EVT_CONNECTED;
597  mp = (session_connected_msg_t *) evt->data;
598  mp->context = api_context;
599 
600  if (is_fail)
601  goto done;
602 
604 
605  if (session_has_transport (s))
606  {
607  tc = session_get_transport (s);
608  if (!tc)
609  {
610  is_fail = 1;
611  goto done;
612  }
613 
614  vpp_mq = session_manager_get_vpp_event_queue (s->thread_index);
615  mp->handle = session_handle (s);
617  clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
618  mp->is_ip4 = tc->is_ip4;
619  mp->lcl_port = tc->lcl_port;
620  mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
621  mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
622  }
623  else
624  {
625  local_session_t *ls = (local_session_t *) s;
626  u8 main_thread = vlib_num_workers ()? 1 : 0;
627 
629  app_wrk->wrk_map_index,
630  ls->client_evt_q,
631  ls->server_evt_q);
632 
634  mp->lcl_port = ls->port;
635  vpp_mq = session_manager_get_vpp_event_queue (main_thread);
639  mp->server_rx_fifo = pointer_to_uword (s->server_tx_fifo);
640  mp->server_tx_fifo = pointer_to_uword (s->server_rx_fifo);
641  }
642 
643 done:
644  mp->retval = is_fail ?
645  clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0;
646 
647  svm_msg_q_add_and_unlock (app_mq, msg);
648  return 0;
649 }
650 
651 static int
652 mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
653  session_handle_t handle, int rv)
654 {
655  svm_msg_q_msg_t _msg, *msg = &_msg;
656  svm_msg_q_t *app_mq, *vpp_evt_q;
658  stream_session_t *ls = 0;
660  app_worker_t *app_wrk;
661  session_event_t *evt;
662  application_t *app;
663 
664  app_wrk = app_worker_get (app_wrk_index);
665  app = application_get (app_wrk->app_index);
666  app_mq = app_wrk->event_queue;
667  if (!app_mq)
668  {
669  clib_warning ("app %u with api index: %u not attached",
670  app_wrk->app_index, app_wrk->api_client_index);
671  return -1;
672  }
673 
674  if (mq_try_lock_and_alloc_msg (app_mq, msg))
675  return -1;
676 
677  evt = svm_msg_q_msg_data (app_mq, msg);
678  clib_memset (evt, 0, sizeof (*evt));
679  evt->event_type = SESSION_CTRL_EVT_BOUND;
680  mp = (session_bound_msg_t *) evt->data;
681  mp->context = api_context;
682 
683  if (rv)
684  goto done;
685 
686  mp->handle = handle;
688  {
689  ls = listen_session_get_from_handle (handle);
691  mp->lcl_port = tc->lcl_port;
692  mp->lcl_is_ip4 = tc->is_ip4;
693  clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
694  }
695  else
696  {
697  local_session_t *local;
699  mp->lcl_port = local->port;
701  }
702 
704  {
705  mp->rx_fifo = pointer_to_uword (ls->server_rx_fifo);
706  mp->tx_fifo = pointer_to_uword (ls->server_tx_fifo);
707  vpp_evt_q = session_manager_get_vpp_event_queue (0);
708  mp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
709  }
710 
711 done:
712  mp->retval = rv;
713  svm_msg_q_add_and_unlock (app_mq, msg);
714  return 0;
715 }
716 
718  .session_accept_callback = mq_send_session_accepted_cb,
719  .session_disconnect_callback = mq_send_session_disconnected_cb,
720  .session_connected_callback = mq_send_session_connected_cb,
721  .session_reset_callback = mq_send_session_reset_cb,
722  .add_segment_callback = send_add_segment_callback,
723  .del_segment_callback = send_del_segment_callback,
724 };
725 
726 static void
728 {
729  vl_api_session_enable_disable_reply_t *rmp;
731  int rv = 0;
732 
734  REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
735 }
736 
737 static void
739 {
740  int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
742  ssvm_private_t *segp, *evt_q_segment;
743  vnet_app_attach_args_t _a, *a = &_a;
745  clib_error_t *error = 0;
746  u8 fd_flags = 0;
747 
749  if (!reg)
750  return;
751 
752  if (session_manager_is_enabled () == 0)
753  {
754  rv = VNET_API_ERROR_FEATURE_DISABLED;
755  goto done;
756  }
757 
759  sizeof (mp->options),
760  "Out of options, fix api message definition");
761 
762  clib_memset (a, 0, sizeof (*a));
763  a->api_client_index = mp->client_index;
764  a->options = mp->options;
765 
766  if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_USE_MQ_FOR_CTRL_MSGS)
767  a->session_cb_vft = &session_mq_cb_vft;
768  else
769  a->session_cb_vft = &session_cb_vft;
770 
771  if (mp->namespace_id_len > 64)
772  {
773  rv = VNET_API_ERROR_INVALID_VALUE;
774  goto done;
775  }
776 
777  if (mp->namespace_id_len)
778  {
779  vec_validate (a->namespace_id, mp->namespace_id_len - 1);
780  clib_memcpy_fast (a->namespace_id, mp->namespace_id,
781  mp->namespace_id_len);
782  }
783 
784  if ((error = vnet_application_attach (a)))
785  {
786  rv = clib_error_get_code (error);
787  clib_error_report (error);
788  vec_free (a->namespace_id);
789  goto done;
790  }
791  vec_free (a->namespace_id);
792 
793  /* Send event queues segment */
794  if ((evt_q_segment = session_manager_get_evt_q_segment ()))
795  {
796  fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
797  fds[n_fds] = evt_q_segment->fd;
798  n_fds += 1;
799  }
800  /* Send fifo segment fd if needed */
801  if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
802  {
803  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
804  fds[n_fds] = a->segment->fd;
805  n_fds += 1;
806  }
807  if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
808  {
809  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
810  fds[n_fds] = svm_msg_q_get_producer_eventfd (a->app_evt_q);
811  n_fds += 1;
812  }
813 
814 done:
815 
816  /* *INDENT-OFF* */
817  REPLY_MACRO2 (VL_API_APPLICATION_ATTACH_REPLY, ({
818  if (!rv)
819  {
820  segp = a->segment;
821  rmp->app_index = clib_host_to_net_u32 (a->app_index);
822  rmp->segment_name_length = 0;
823  rmp->segment_size = segp->ssvm_size;
824  if (vec_len (segp->name))
825  {
826  memcpy (rmp->segment_name, segp->name, vec_len (segp->name));
827  rmp->segment_name_length = vec_len (segp->name);
828  }
829  rmp->app_event_queue_address = pointer_to_uword (a->app_evt_q);
830  rmp->n_fds = n_fds;
831  rmp->fd_flags = fd_flags;
832  rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
833  }
834  }));
835  /* *INDENT-ON* */
836 
837  if (n_fds)
838  session_send_fds (reg, fds, n_fds);
839 }
840 
841 static void
843 {
844  vl_api_application_detach_reply_t *rmp;
845  int rv = VNET_API_ERROR_INVALID_VALUE_2;
846  vnet_app_detach_args_t _a, *a = &_a;
847  application_t *app;
848 
849  if (session_manager_is_enabled () == 0)
850  {
851  rv = VNET_API_ERROR_FEATURE_DISABLED;
852  goto done;
853  }
854 
855  app = application_lookup (mp->client_index);
856  if (app)
857  {
858  a->app_index = app->app_index;
859  a->api_client_index = mp->client_index;
860  rv = vnet_application_detach (a);
861  }
862 
863 done:
864  REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY);
865 }
866 
867 static void
869 {
870  transport_connection_t *tc = 0;
871  vnet_bind_args_t _a, *a = &_a;
873  stream_session_t *s;
874  application_t *app = 0;
875  svm_msg_q_t *vpp_evt_q;
876  app_worker_t *app_wrk;
877  int rv;
878 
879  if (session_manager_is_enabled () == 0)
880  {
881  rv = VNET_API_ERROR_FEATURE_DISABLED;
882  goto done;
883  }
884 
885  app = application_lookup (mp->client_index);
886  if (app)
887  {
888  clib_memset (a, 0, sizeof (*a));
889  a->uri = (char *) mp->uri;
890  a->app_index = app->app_index;
891  rv = vnet_bind_uri (a);
892  }
893  else
894  {
895  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
896  }
897 
898 done:
899 
900  /* *INDENT-OFF* */
901  REPLY_MACRO2 (VL_API_BIND_URI_REPLY, ({
902  if (!rv)
903  {
904  rmp->handle = a->handle;
905  if (app && application_has_global_scope (app))
906  {
907  s = listen_session_get_from_handle (a->handle);
909  rmp->lcl_is_ip4 = tc->is_ip4;
910  rmp->lcl_port = tc->lcl_port;
911  clib_memcpy_fast (rmp->lcl_ip, &tc->lcl_ip, sizeof(tc->lcl_ip));
913  {
914  rmp->rx_fifo = pointer_to_uword (s->server_rx_fifo);
915  rmp->tx_fifo = pointer_to_uword (s->server_tx_fifo);
916  vpp_evt_q = session_manager_get_vpp_event_queue (0);
917  rmp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
918  }
919  }
920  }
921  }));
922  /* *INDENT-ON* */
923 
924  /* If app uses mq for control messages, send an mq message as well */
925  if (app && application_use_mq_for_ctrl (app))
926  {
927  app_wrk = application_get_worker (app, 0);
928  mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
929  rv);
930  }
931 }
932 
933 static void
935 {
936  vl_api_unbind_uri_reply_t *rmp;
937  application_t *app;
938  vnet_unbind_args_t _a, *a = &_a;
939  int rv;
940 
941  if (session_manager_is_enabled () == 0)
942  {
943  rv = VNET_API_ERROR_FEATURE_DISABLED;
944  goto done;
945  }
946 
947  app = application_lookup (mp->client_index);
948  if (app)
949  {
950  a->uri = (char *) mp->uri;
951  a->app_index = app->app_index;
952  rv = vnet_unbind_uri (a);
953  }
954  else
955  {
956  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
957  }
958 
959 done:
960  REPLY_MACRO (VL_API_UNBIND_URI_REPLY);
961 }
962 
963 static void
965 {
967  vnet_connect_args_t _a, *a = &_a;
968  application_t *app;
969  clib_error_t *error = 0;
970  int rv = 0;
971 
972  if (session_manager_is_enabled () == 0)
973  {
974  rv = VNET_API_ERROR_FEATURE_DISABLED;
975  goto done;
976  }
977 
978  app = application_lookup (mp->client_index);
979  if (app)
980  {
981  clib_memset (a, 0, sizeof (*a));
982  a->uri = (char *) mp->uri;
983  a->api_context = mp->context;
984  a->app_index = app->app_index;
985  if ((error = vnet_connect_uri (a)))
986  {
987  rv = clib_error_get_code (error);
988  clib_error_report (error);
989  }
990  }
991  else
992  {
993  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
994  }
995 
996  /*
997  * Don't reply to stream (tcp) connects. The reply will come once
998  * the connection is established. In case of the redirects, the reply
999  * will come from the server app.
1000  */
1001  if (rv == 0)
1002  return;
1003 
1004 done:
1005  /* *INDENT-OFF* */
1006  REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY);
1007  /* *INDENT-ON* */
1008 }
1009 
1010 static void
1012 {
1014  vnet_disconnect_args_t _a, *a = &_a;
1015  application_t *app;
1016  int rv = 0;
1017 
1018  if (session_manager_is_enabled () == 0)
1019  {
1020  rv = VNET_API_ERROR_FEATURE_DISABLED;
1021  goto done;
1022  }
1023 
1024  app = application_lookup (mp->client_index);
1025  if (app)
1026  {
1027  a->handle = mp->handle;
1028  a->app_index = app->app_index;
1029  rv = vnet_disconnect_session (a);
1030  }
1031  else
1032  {
1033  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1034  }
1035 
1036 done:
1037  REPLY_MACRO2 (VL_API_DISCONNECT_SESSION_REPLY, rmp->handle = mp->handle);
1038 }
1039 
1040 static void
1042  mp)
1043 {
1044  vnet_disconnect_args_t _a, *a = &_a;
1045  application_t *app;
1046 
1047  /* Client objected to disconnecting the session, log and continue */
1048  if (mp->retval)
1049  {
1050  clib_warning ("client retval %d", mp->retval);
1051  return;
1052  }
1053 
1054  /* Disconnect has been confirmed. Confirm close to transport */
1055  app = application_lookup (mp->context);
1056  if (app)
1057  {
1058  a->handle = mp->handle;
1059  a->app_index = app->app_index;
1061  }
1062 }
1063 
1064 static void
1066 {
1067  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
1068  app_worker_t *app_wrk;
1069  application_t *app;
1070  stream_session_t *s;
1071  u32 index, thread_index;
1072 
1073  app = application_lookup (mp->context);
1074  if (!app)
1075  return;
1076 
1077  session_parse_handle (mp->handle, &index, &thread_index);
1078  s = session_get_if_valid (index, thread_index);
1079  if (!s)
1080  {
1081  clib_warning ("Invalid session!");
1082  return;
1083  }
1084 
1085  app_wrk = app_worker_get (s->app_wrk_index);
1086  if (app_wrk->app_index != app->app_index)
1087  {
1088  clib_warning ("app %u does not own handle 0x%lx", app->app_index,
1089  mp->handle);
1090  return;
1091  }
1092 
1093  /* Client objected to resetting the session, log and continue */
1094  if (mp->retval)
1095  {
1096  clib_warning ("client retval %d", mp->retval);
1097  return;
1098  }
1099 
1100  /* This comes as a response to a reset, transport only waiting for
1101  * confirmation to remove connection state, no need to disconnect */
1102  a->handle = mp->handle;
1103  a->app_index = app->app_index;
1105 }
1106 
1107 static void
1109 {
1110  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
1111  local_session_t *ls;
1112  stream_session_t *s;
1113 
1114  /* Server isn't interested, kill the session */
1115  if (mp->retval)
1116  {
1117  a->app_index = mp->context;
1118  a->handle = mp->handle;
1120  return;
1121  }
1122 
1123  if (session_handle_is_local (mp->handle))
1124  {
1126  if (!ls || ls->app_wrk_index != mp->context)
1127  {
1128  clib_warning ("server %u doesn't own local handle %llu",
1129  mp->context, mp->handle);
1130  return;
1131  }
1133  return;
1135  }
1136  else
1137  {
1139  if (!s)
1140  {
1141  clib_warning ("session doesn't exist");
1142  return;
1143  }
1144  if (s->app_wrk_index != mp->context)
1145  {
1146  clib_warning ("app doesn't own session");
1147  return;
1148  }
1149  s->session_state = SESSION_STATE_READY;
1150  }
1151 }
1152 
1153 static void
1154 vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t
1155  * mp)
1156 {
1157  clib_warning ("not implemented");
1158 }
1159 
1160 static void
1162 {
1164  vnet_bind_args_t _a, *a = &_a;
1165  int rv = 0;
1166  clib_error_t *error;
1167  application_t *app = 0;
1168  app_worker_t *app_wrk;
1169  stream_session_t *s;
1170  transport_connection_t *tc = 0;
1171  ip46_address_t *ip46;
1172  svm_msg_q_t *vpp_evt_q;
1173 
1174  if (session_manager_is_enabled () == 0)
1175  {
1176  rv = VNET_API_ERROR_FEATURE_DISABLED;
1177  goto done;
1178  }
1179 
1180  app = application_lookup (mp->client_index);
1181  if (!app)
1182  {
1183  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1184  goto done;
1185  }
1186 
1187  ip46 = (ip46_address_t *) mp->ip;
1188  clib_memset (a, 0, sizeof (*a));
1189  a->sep.is_ip4 = mp->is_ip4;
1190  a->sep.ip = *ip46;
1191  a->sep.port = mp->port;
1192  a->sep.fib_index = mp->vrf;
1193  a->sep.sw_if_index = ENDPOINT_INVALID_INDEX;
1194  a->sep.transport_proto = mp->proto;
1195  a->app_index = app->app_index;
1196  a->wrk_map_index = mp->wrk_index;
1197 
1198  if ((error = vnet_bind (a)))
1199  {
1200  rv = clib_error_get_code (error);
1201  clib_error_report (error);
1202  }
1203 
1204 done:
1205  /* *INDENT-OFF* */
1206  REPLY_MACRO2 (VL_API_BIND_SOCK_REPLY,({
1207  if (!rv)
1208  {
1209  rmp->handle = a->handle;
1210  rmp->lcl_port = mp->port;
1211  rmp->lcl_is_ip4 = mp->is_ip4;
1212  if (app && application_has_global_scope (app))
1213  {
1214  s = listen_session_get_from_handle (a->handle);
1216  clib_memcpy_fast (rmp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
1218  {
1219  rmp->rx_fifo = pointer_to_uword (s->server_rx_fifo);
1220  rmp->tx_fifo = pointer_to_uword (s->server_tx_fifo);
1221  vpp_evt_q = session_manager_get_vpp_event_queue (0);
1222  rmp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
1223  }
1224  }
1225  }
1226  }));
1227  /* *INDENT-ON* */
1228 
1229  /* If app uses mq for control messages, send an mq message as well */
1230  if (app && application_use_mq_for_ctrl (app))
1231  {
1232  app_wrk = application_get_worker (app, mp->wrk_index);
1233  mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle,
1234  rv);
1235  }
1236 }
1237 
1238 static void
1240 {
1241  vl_api_unbind_sock_reply_t *rmp;
1242  vnet_unbind_args_t _a, *a = &_a;
1243  application_t *app;
1244  clib_error_t *error;
1245  int rv = 0;
1246 
1247  if (session_manager_is_enabled () == 0)
1248  {
1249  rv = VNET_API_ERROR_FEATURE_DISABLED;
1250  goto done;
1251  }
1252 
1253  app = application_lookup (mp->client_index);
1254  if (app)
1255  {
1256  a->app_index = app->app_index;
1257  a->handle = mp->handle;
1258  a->wrk_map_index = mp->wrk_index;
1259  if ((error = vnet_unbind (a)))
1260  {
1261  rv = clib_error_get_code (error);
1262  clib_error_report (error);
1263  }
1264  }
1265 
1266 done:
1267  REPLY_MACRO (VL_API_UNBIND_SOCK_REPLY);
1268 }
1269 
1270 static void
1272 {
1274  vnet_connect_args_t _a, *a = &_a;
1275  application_t *app = 0;
1276  clib_error_t *error = 0;
1277  int rv = 0;
1278 
1279  if (session_manager_is_enabled () == 0)
1280  {
1281  rv = VNET_API_ERROR_FEATURE_DISABLED;
1282  goto done;
1283  }
1284 
1285  app = application_lookup (mp->client_index);
1286  if (app)
1287  {
1288  svm_queue_t *client_q;
1289  ip46_address_t *ip46 = (ip46_address_t *) mp->ip;
1290 
1291  clib_memset (a, 0, sizeof (*a));
1293  mp->client_queue_address = pointer_to_uword (client_q);
1294  a->sep.is_ip4 = mp->is_ip4;
1295  a->sep.ip = *ip46;
1296  a->sep.port = mp->port;
1297  a->sep.transport_proto = mp->proto;
1298  a->sep.peer.fib_index = mp->vrf;
1299  a->sep.peer.sw_if_index = ENDPOINT_INVALID_INDEX;
1300  if (mp->hostname_len)
1301  {
1302  vec_validate (a->sep_ext.hostname, mp->hostname_len - 1);
1303  clib_memcpy_fast (a->sep_ext.hostname, mp->hostname,
1304  mp->hostname_len);
1305  }
1306  a->api_context = mp->context;
1307  a->app_index = app->app_index;
1308  a->wrk_map_index = mp->wrk_index;
1309  if ((error = vnet_connect (a)))
1310  {
1311  rv = clib_error_get_code (error);
1312  clib_error_report (error);
1313  }
1314  vec_free (a->sep_ext.hostname);
1315  }
1316  else
1317  {
1318  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1319  }
1320 
1321  if (rv == 0)
1322  return;
1323 
1324  /* Got some error, relay it */
1325 
1326 done:
1327  REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY);
1328 
1329  if (app && application_use_mq_for_ctrl (app))
1330  {
1331  app_worker_t *app_wrk = application_get_worker (app, mp->wrk_index);
1332  mq_send_session_connected_cb (app_wrk->wrk_index, mp->context, 0, 1);
1333  }
1334 }
1335 
1336 static void
1338 {
1339  int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
1341  vl_api_registration_t *reg;
1342  clib_error_t *error = 0;
1343  application_t *app;
1344  u8 fd_flags = 0;
1345 
1347  {
1348  rv = VNET_API_ERROR_FEATURE_DISABLED;
1349  goto done;
1350  }
1351 
1353  if (!reg)
1354  return;
1355 
1356  app = application_get_if_valid (clib_net_to_host_u32 (mp->app_index));
1357  if (!app)
1358  {
1359  rv = VNET_API_ERROR_INVALID_VALUE;
1360  goto done;
1361  }
1362 
1364  .app_index = app->app_index,
1365  .wrk_map_index = clib_net_to_host_u32 (mp->wrk_index),
1366  .api_client_index = mp->client_index,
1367  .is_add = mp->is_add
1368  };
1369  error = vnet_app_worker_add_del (&args);
1370  if (error)
1371  {
1372  rv = clib_error_get_code (error);
1373  clib_error_report (error);
1374  goto done;
1375  }
1376 
1377  if (!mp->is_add)
1378  goto done;
1379 
1380  /* Send fifo segment fd if needed */
1381  if (ssvm_type (args.segment) == SSVM_SEGMENT_MEMFD)
1382  {
1383  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
1384  fds[n_fds] = args.segment->fd;
1385  n_fds += 1;
1386  }
1387  if (application_segment_manager_properties (app)->use_mq_eventfd)
1388  {
1389  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
1390  fds[n_fds] = svm_msg_q_get_producer_eventfd (args.evt_q);
1391  n_fds += 1;
1392  }
1393 
1394  /* *INDENT-OFF* */
1395 done:
1396  REPLY_MACRO2 (VL_API_APP_WORKER_ADD_DEL_REPLY, ({
1397  rmp->is_add = mp->is_add;
1398  rmp->wrk_index = clib_host_to_net_u32 (args.wrk_map_index);
1399  rmp->segment_handle = clib_host_to_net_u64 (args.segment_handle);
1400  if (!rv && mp->is_add)
1401  {
1402  if (vec_len (args.segment->name))
1403  {
1404  memcpy (rmp->segment_name, args.segment->name,
1405  vec_len (args.segment->name));
1406  rmp->segment_name_length = vec_len (args.segment->name);
1407  }
1408  rmp->app_event_queue_address = pointer_to_uword (args.evt_q);
1409  rmp->n_fds = n_fds;
1410  rmp->fd_flags = fd_flags;
1411  }
1412  }));
1413  /* *INDENT-ON* */
1414 
1415  if (n_fds)
1416  session_send_fds (reg, fds, n_fds);
1417 }
1418 
1419 static void
1421 {
1423  clib_error_t *error = 0;
1424  u32 appns_index = 0;
1425  u8 *ns_id = 0;
1426  int rv = 0;
1428  {
1429  rv = VNET_API_ERROR_FEATURE_DISABLED;
1430  goto done;
1431  }
1432 
1433  if (mp->namespace_id_len > ARRAY_LEN (mp->namespace_id))
1434  {
1435  rv = VNET_API_ERROR_INVALID_VALUE;
1436  goto done;
1437  }
1438 
1439  vec_validate (ns_id, mp->namespace_id_len - 1);
1442  .ns_id = ns_id,
1443  .secret = clib_net_to_host_u64 (mp->secret),
1444  .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
1445  .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
1446  .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id),
1447  .is_add = 1
1448  };
1449  error = vnet_app_namespace_add_del (&args);
1450  if (error)
1451  {
1452  rv = clib_error_get_code (error);
1453  clib_error_report (error);
1454  }
1455  else
1456  {
1457  appns_index = app_namespace_index_from_id (ns_id);
1458  if (appns_index == APP_NAMESPACE_INVALID_INDEX)
1459  {
1460  clib_warning ("app ns lookup failed");
1461  rv = VNET_API_ERROR_UNSPECIFIED;
1462  }
1463  }
1464  vec_free (ns_id);
1465 
1466  /* *INDENT-OFF* */
1467 done:
1468  REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_REPLY, ({
1469  if (!rv)
1470  rmp->appns_index = clib_host_to_net_u32 (appns_index);
1471  }));
1472  /* *INDENT-ON* */
1473 }
1474 
1475 static void
1477 {
1478  vl_api_session_rule_add_del_reply_t *rmp;
1480  session_rule_table_add_del_args_t *table_args = &args.table_args;
1481  clib_error_t *error;
1482  u8 fib_proto;
1483  int rv = 0;
1484 
1485  clib_memset (&args, 0, sizeof (args));
1486  fib_proto = mp->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
1487 
1488  table_args->lcl.fp_len = mp->lcl_plen;
1489  table_args->lcl.fp_proto = fib_proto;
1490  table_args->rmt.fp_len = mp->rmt_plen;
1491  table_args->rmt.fp_proto = fib_proto;
1492  table_args->lcl_port = mp->lcl_port;
1493  table_args->rmt_port = mp->rmt_port;
1494  table_args->action_index = clib_net_to_host_u32 (mp->action_index);
1495  table_args->is_add = mp->is_add;
1496  mp->tag[sizeof (mp->tag) - 1] = 0;
1497  table_args->tag = format (0, "%s", mp->tag);
1498  args.appns_index = clib_net_to_host_u32 (mp->appns_index);
1499  args.scope = mp->scope;
1500  args.transport_proto = mp->transport_proto;
1501 
1502  clib_memset (&table_args->lcl.fp_addr, 0, sizeof (table_args->lcl.fp_addr));
1503  clib_memset (&table_args->rmt.fp_addr, 0, sizeof (table_args->rmt.fp_addr));
1504  ip_set (&table_args->lcl.fp_addr, mp->lcl_ip, mp->is_ip4);
1505  ip_set (&table_args->rmt.fp_addr, mp->rmt_ip, mp->is_ip4);
1506  error = vnet_session_rule_add_del (&args);
1507  if (error)
1508  {
1509  rv = clib_error_get_code (error);
1510  clib_error_report (error);
1511  }
1512  vec_free (table_args->tag);
1513  REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY);
1514 }
1515 
1516 static void
1517 send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
1518  u8 transport_proto, u32 appns_index, u8 * tag,
1519  vl_api_registration_t * reg, u32 context)
1520 {
1522  session_mask_or_match_4_t *match =
1523  (session_mask_or_match_4_t *) & rule->match;
1524  session_mask_or_match_4_t *mask =
1525  (session_mask_or_match_4_t *) & rule->mask;
1526 
1527  rmp = vl_msg_api_alloc (sizeof (*rmp));
1528  clib_memset (rmp, 0, sizeof (*rmp));
1529  rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
1530  rmp->context = context;
1531 
1532  rmp->is_ip4 = 1;
1533  clib_memcpy_fast (rmp->lcl_ip, &match->lcl_ip, sizeof (match->lcl_ip));
1534  clib_memcpy_fast (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip));
1535  rmp->lcl_plen = ip4_mask_to_preflen (&mask->lcl_ip);
1536  rmp->rmt_plen = ip4_mask_to_preflen (&mask->rmt_ip);
1537  rmp->lcl_port = match->lcl_port;
1538  rmp->rmt_port = match->rmt_port;
1539  rmp->action_index = clib_host_to_net_u32 (rule->action_index);
1540  rmp->scope =
1542  rmp->transport_proto = transport_proto;
1543  rmp->appns_index = clib_host_to_net_u32 (appns_index);
1544  if (tag)
1545  {
1546  clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
1547  rmp->tag[vec_len (tag)] = 0;
1548  }
1549 
1550  vl_api_send_msg (reg, (u8 *) rmp);
1551 }
1552 
1553 static void
1554 send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
1555  u8 transport_proto, u32 appns_index, u8 * tag,
1556  vl_api_registration_t * reg, u32 context)
1557 {
1559  session_mask_or_match_6_t *match =
1560  (session_mask_or_match_6_t *) & rule->match;
1561  session_mask_or_match_6_t *mask =
1562  (session_mask_or_match_6_t *) & rule->mask;
1563 
1564  rmp = vl_msg_api_alloc (sizeof (*rmp));
1565  clib_memset (rmp, 0, sizeof (*rmp));
1566  rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
1567  rmp->context = context;
1568 
1569  rmp->is_ip4 = 0;
1570  clib_memcpy_fast (rmp->lcl_ip, &match->lcl_ip, sizeof (match->lcl_ip));
1571  clib_memcpy_fast (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip));
1572  rmp->lcl_plen = ip6_mask_to_preflen (&mask->lcl_ip);
1573  rmp->rmt_plen = ip6_mask_to_preflen (&mask->rmt_ip);
1574  rmp->lcl_port = match->lcl_port;
1575  rmp->rmt_port = match->rmt_port;
1576  rmp->action_index = clib_host_to_net_u32 (rule->action_index);
1577  rmp->scope =
1579  rmp->transport_proto = transport_proto;
1580  rmp->appns_index = clib_host_to_net_u32 (appns_index);
1581  if (tag)
1582  {
1583  clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
1584  rmp->tag[vec_len (tag)] = 0;
1585  }
1586 
1587  vl_api_send_msg (reg, (u8 *) rmp);
1588 }
1589 
1590 static void
1592  u8 tp, u8 is_local, u32 appns_index,
1593  vl_api_registration_t * reg, u32 context)
1594 {
1595  mma_rule_16_t *rule16;
1596  mma_rule_40_t *rule40;
1597  mma_rules_table_16_t *srt16;
1598  mma_rules_table_40_t *srt40;
1599  u32 ri;
1600 
1601  if (is_local || fib_proto == FIB_PROTOCOL_IP4)
1602  {
1603  u8 *tag = 0;
1604  /* *INDENT-OFF* */
1605  srt16 = &srt->session_rules_tables_16;
1606  pool_foreach (rule16, srt16->rules, ({
1607  ri = mma_rules_table_rule_index_16 (srt16, rule16);
1608  tag = session_rules_table_rule_tag (srt, ri, 1);
1609  send_session_rule_details4 (rule16, is_local, tp, appns_index, tag,
1610  reg, context);
1611  }));
1612  /* *INDENT-ON* */
1613  }
1614  if (is_local || fib_proto == FIB_PROTOCOL_IP6)
1615  {
1616  u8 *tag = 0;
1617  /* *INDENT-OFF* */
1618  srt40 = &srt->session_rules_tables_40;
1619  pool_foreach (rule40, srt40->rules, ({
1620  ri = mma_rules_table_rule_index_40 (srt40, rule40);
1621  tag = session_rules_table_rule_tag (srt, ri, 1);
1622  send_session_rule_details6 (rule40, is_local, tp, appns_index, tag,
1623  reg, context);
1624  }));
1625  /* *INDENT-ON* */
1626  }
1627 }
1628 
1629 static void
1631 {
1632  vl_api_registration_t *reg;
1633  session_table_t *st;
1634  u8 tp;
1635 
1637  if (!reg)
1638  return;
1639 
1640  /* *INDENT-OFF* */
1641  session_table_foreach (st, ({
1642  for (tp = 0; tp < TRANSPORT_N_PROTO; tp++)
1643  {
1644  send_session_rules_table_details (&st->session_rules[tp],
1645  st->active_fib_proto, tp,
1646  st->is_local, st->appns_index, reg,
1647  mp->context);
1648  }
1649  }));
1650  /* *INDENT-ON* */
1651 }
1652 
1653 static void
1655  mp)
1656 {
1658  vnet_app_add_tls_cert_args_t _a, *a = &_a;
1659  clib_error_t *error;
1660  application_t *app;
1661  u32 cert_len;
1662  int rv = 0;
1664  {
1665  rv = VNET_API_ERROR_FEATURE_DISABLED;
1666  goto done;
1667  }
1668  if (!(app = application_lookup (mp->client_index)))
1669  {
1670  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1671  goto done;
1672  }
1673  clib_memset (a, 0, sizeof (*a));
1674  a->app_index = app->app_index;
1675  cert_len = clib_net_to_host_u16 (mp->cert_len);
1676  if (cert_len > 10000)
1677  {
1678  rv = VNET_API_ERROR_INVALID_VALUE;
1679  goto done;
1680  }
1681  vec_validate (a->cert, cert_len);
1682  clib_memcpy_fast (a->cert, mp->cert, cert_len);
1683  if ((error = vnet_app_add_tls_cert (a)))
1684  {
1685  rv = clib_error_get_code (error);
1686  clib_error_report (error);
1687  }
1688  vec_free (a->cert);
1689 done:
1690  REPLY_MACRO (VL_API_APPLICATION_TLS_CERT_ADD_REPLY);
1691 }
1692 
1693 static void
1695  mp)
1696 {
1698  vnet_app_add_tls_key_args_t _a, *a = &_a;
1699  clib_error_t *error;
1700  application_t *app;
1701  u32 key_len;
1702  int rv = 0;
1704  {
1705  rv = VNET_API_ERROR_FEATURE_DISABLED;
1706  goto done;
1707  }
1708  if (!(app = application_lookup (mp->client_index)))
1709  {
1710  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1711  goto done;
1712  }
1713  clib_memset (a, 0, sizeof (*a));
1714  a->app_index = app->app_index;
1715  key_len = clib_net_to_host_u16 (mp->key_len);
1716  if (key_len > 10000)
1717  {
1718  rv = VNET_API_ERROR_INVALID_VALUE;
1719  goto done;
1720  }
1721  vec_validate (a->key, key_len);
1722  clib_memcpy_fast (a->key, mp->key, key_len);
1723  if ((error = vnet_app_add_tls_key (a)))
1724  {
1725  rv = clib_error_get_code (error);
1726  clib_error_report (error);
1727  }
1728  vec_free (a->key);
1729 done:
1730  REPLY_MACRO (VL_API_APPLICATION_TLS_KEY_ADD_REPLY);
1731 }
1732 
1733 static clib_error_t *
1735 {
1736  application_t *app = application_lookup (client_index);
1737  vnet_app_detach_args_t _a, *a = &_a;
1738  if (app)
1739  {
1740  a->app_index = app->app_index;
1741  a->api_client_index = client_index;
1743  }
1744  return 0;
1745 }
1746 
1748 
1749 #define vl_msg_name_crc_list
1750 #include <vnet/vnet_all_api_h.h>
1751 #undef vl_msg_name_crc_list
1752 
1753 static void
1755 {
1756 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1757  foreach_vl_msg_name_crc_session;
1758 #undef _
1759 }
1760 
1761 /*
1762  * session_api_hookup
1763  * Add uri's API message handlers to the table.
1764  * vlib has alread mapped shared memory and
1765  * added the client registration handlers.
1766  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
1767  */
1768 static clib_error_t *
1770 {
1771  api_main_t *am = &api_main;
1772 
1773 #define _(N,n) \
1774  vl_msg_api_set_handlers(VL_API_##N, #n, \
1775  vl_api_##n##_t_handler, \
1776  vl_noop_handler, \
1777  vl_api_##n##_t_endian, \
1778  vl_api_##n##_t_print, \
1779  sizeof(vl_api_##n##_t), 1);
1781 #undef _
1782 
1783  /*
1784  * Messages which bounce off the data-plane to
1785  * an API client. Simply tells the message handling infra not
1786  * to free the message.
1787  *
1788  * Bounced message handlers MUST NOT block the data plane
1789  */
1790  am->message_bounce[VL_API_CONNECT_URI] = 1;
1791  am->message_bounce[VL_API_CONNECT_SOCK] = 1;
1792 
1793  /*
1794  * Set up the (msg_name, crc, message-id) table
1795  */
1797 
1798  return 0;
1799 }
1800 
1802 
1803 /*
1804  * fd.io coding-style-patch-verification: ON
1805  *
1806  * Local Variables:
1807  * eval: (c-set-style "gnu")
1808  * End:
1809  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
static void vl_api_disconnect_session_reply_t_handler(vl_api_disconnect_session_reply_t *mp)
Definition: session_api.c:1041
u64 ssvm_size
Definition: ssvm.h:84
struct _vnet_app_worker_add_del_args vnet_app_worker_add_del_args_t
session_type_t listener_session_type
Has transport embedded when listener not purely local.
app_worker_t * app_worker_get(u32 wrk_index)
Definition: application.c:517
static u64 session_segment_handle(stream_session_t *s)
Definition: session.h:446
#define APP_NAMESPACE_INVALID_INDEX
static clib_error_t * session_api_hookup(vlib_main_t *vm)
Definition: session_api.c:1769
static void mq_send_session_reset_cb(stream_session_t *s)
Definition: session_api.c:552
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
static int send_del_segment_callback(u32 api_client_index, u64 segment_handle)
Definition: session_api.c:131
clib_error_t * vnet_app_namespace_add_del(vnet_app_namespace_add_del_args_t *a)
static session_handle_t application_local_session_handle(local_session_t *ls)
Definition: application.h:352
vpp->client reset session API Will be DEPRECATED.
Definition: session.api:265
a
Definition: bitmap.h:538
VL_MSG_API_REAPER_FUNCTION(application_reaper_cb)
struct _session_rules_table_t session_rules_table_t
*** Will be DEPRECATED.
Definition: session.api:146
u8 application_has_global_scope(application_t *app)
Definition: application.c:1048
struct _transport_connection transport_connection_t
struct _vnet_connect_args vnet_connect_args_t
Application add TLS key.
Definition: session.api:83
int vnet_bind_uri(vnet_bind_args_t *a)
static void vl_api_app_namespace_add_del_t_handler(vl_api_app_namespace_add_del_t *mp)
Definition: session_api.c:1420
unsigned long u64
Definition: types.h:89
void mq_send_local_session_disconnected_cb(u32 app_wrk_index, local_session_t *ls)
Definition: session_api.c:530
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
Definition: ip.c:90
clib_error_t * vnet_unbind(vnet_unbind_args_t *a)
svm_fifo_segment_private_t * segment_manager_get_segment_w_handle(u64 segment_handle)
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
add/del session rule
Definition: session.api:556
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:34
u8 * message_bounce
Don&#39;t automatically free message buffer vetor.
Definition: api_common.h:222
Session rules details.
Definition: session.api:602
static void vl_api_map_another_segment_reply_t_handler(vl_api_map_another_segment_reply_t *mp)
Definition: session_api.c:1154
struct _transport_proto_vft transport_proto_vft_t
local_session_t * application_get_local_session_from_handle(session_handle_t handle)
Definition: application.c:1453
Bind to an ip:port pair for a given transport protocol.
Definition: session.api:294
static int svm_msg_q_get_producer_eventfd(svm_msg_q_t *mq)
struct _vnet_app_namespace_add_del_args vnet_app_namespace_add_del_args_t
static int mq_send_session_bound_cb(u32 app_wrk_index, u32 api_context, session_handle_t handle, int rv)
Definition: session_api.c:652
client->vpp, reply to an accept message Will be DEPRECATED.
Definition: session.api:226
application_t * application_lookup(u32 api_client_index)
Definition: application.c:181
u32 wrk_map_index
Worker index in app&#39;s map pool.
Definition: application.h:68
Request for map server summary status.
Definition: one.api:883
static void vl_api_unbind_sock_t_handler(vl_api_unbind_sock_t *mp)
Definition: session_api.c:1239
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
Definition: session.h:382
transport_connection_t * session_get_transport(stream_session_t *s)
Definition: session.c:1358
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
#define foreach_session_api_msg
Definition: session_api.c:41
u64 session_handle_t
Definition: session.h:111
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
static u8 session_manager_is_enabled()
Definition: session.h:715
u8 application_use_mq_for_ctrl(application_t *app)
Definition: application.c:1054
void * vl_msg_api_alloc(int nbytes)
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
Definition: application.c:1976
unsigned char u8
Definition: types.h:56
static stream_session_t * listen_session_get_from_handle(session_handle_t handle)
Definition: session.h:672
app_worker_t * application_get_worker(application_t *app, u32 wrk_map_index)
Definition: application.c:456
application_t * application_get_if_valid(u32 app_index)
Definition: application.c:221
int svm_msg_q_lock_and_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index, u8 noblock, svm_msg_q_msg_t *msg)
Lock message queue and allocate message buffer on ring.
Reply for app worker add/del.
Definition: session.api:472
int send_session_connected_callback(u32 app_wrk_index, u32 api_context, stream_session_t *s, u8 is_fail)
Definition: session_api.c:329
connectionless service
int application_is_proxy(application_t *app)
Definition: application.c:1024
clib_error_t * vnet_session_rule_add_del(session_rule_add_del_args_t *args)
static void vl_api_connect_uri_t_handler(vl_api_connect_uri_t *mp)
Definition: session_api.c:964
int vnet_unbind_uri(vnet_unbind_args_t *a)
static svm_msg_q_t * session_manager_get_vpp_event_queue(u32 thread_index)
Definition: session.h:656
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
Definition: session_api.c:727
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:490
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static void send_session_reset_callback(stream_session_t *s)
Definition: session_api.c:308
int application_local_session_connect_notify(local_session_t *ls)
Definition: application.c:1763
u32 transport_listener_index
Transport listener index.
struct _stream_session_cb_vft session_cb_vft_t
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
Definition: memory_api.c:770
struct _vnet_unbind_args_t vnet_unbind_args_t
vpp/server->client, connect reply – used for all connect_* messages Will be DEPRECATED.
Definition: session.api:405
session_type_t session_type
Type.
static stream_session_t * listen_session_get(u32 index)
Definition: session.h:695
add/del application namespace
Definition: session.api:512
static void vl_api_application_tls_cert_add_t_handler(vl_api_application_tls_cert_add_t *mp)
Definition: session_api.c:1654
unsigned int u32
Definition: types.h:88
static local_session_t * application_get_local_listen_session(application_t *app, u32 session_index)
Definition: application.h:359
static void send_session_rule_details4(mma_rule_16_t *rule, u8 is_local, u8 transport_proto, u32 appns_index, u8 *tag, vl_api_registration_t *reg, u32 context)
Definition: session_api.c:1517
u32 app_namespace_index_from_id(const u8 *ns_id)
struct _stream_session_t stream_session_t
struct _vnet_app_attach_args_t vnet_app_attach_args_t
transport_proto_vft_t * transport_protocol_get_vft(transport_proto_t transport_proto)
Get transport virtual function table.
Definition: transport.c:256
static void vl_api_app_worker_add_del_t_handler(vl_api_app_worker_add_del_t *mp)
Definition: session_api.c:1337
vpp->client unmap shared memory segment
Definition: session.api:125
static transport_proto_t session_get_transport_proto(stream_session_t *s)
Definition: session.h:427
static void vl_api_session_rules_dump_t_handler(vl_api_one_map_server_dump_t *mp)
Definition: session_api.c:1630
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
Definition: application.c:1988
static session_cb_vft_t session_cb_vft
Definition: session_api.c:389
Bind reply Will be DEPRECATED.
Definition: session.api:364
#define VL_API_INVALID_FI
Definition: api_common.h:76
static void vl_api_accept_session_reply_t_handler(vl_api_accept_session_reply_t *mp)
Definition: session_api.c:1108
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
Definition: api_common.h:60
struct _session_rule_add_del_args session_rule_add_del_args_t
client->vpp, attach application to session layer
Definition: session.api:27
u8 hostname[hostname_len]
Definition: session.api:347
static u8 session_handle_is_local(session_handle_t handle)
Definition: session.h:407
static void vl_api_disconnect_session_t_handler(vl_api_disconnect_session_t *mp)
Definition: session_api.c:1011
static int session_send_fds(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: session_api.c:64
static session_handle_t session_handle(stream_session_t *s)
Definition: session.h:364
#define REPLY_MACRO(t)
static u8 application_local_session_listener_has_transport(local_session_t *ls)
Definition: application.h:375
static clib_error_t * application_reaper_cb(u32 client_index)
Definition: session_api.c:1734
clib_error_t * vnet_connect(vnet_connect_args_t *a)
Unbind a given URI.
Definition: session.api:165
u32 wrk_index
Worker index in global worker pool.
Definition: application.h:65
static stream_session_t * session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:349
stream_session_t * app_worker_first_listener(app_worker_t *app, u8 fib_proto, u8 transport_proto)
Definition: application.c:1078
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1529
volatile u8 session_state
State.
vpp->client, accept this session Will be DEPRECATED.
Definition: session.api:204
u32 ip6_mask_to_preflen(ip6_address_t *mask)
Definition: ip.c:267
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
static int mq_try_lock_and_alloc_msg(svm_msg_q_t *app_mq, svm_msg_q_msg_t *msg)
Definition: session_api.c:399
An API client registration, only in vpp/vlib.
Definition: api_common.h:45
static int send_session_accept_callback(stream_session_t *s)
Definition: session_api.c:201
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
vlib_main_t * vm
Definition: buffer.c:301
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
Definition: memory_api.c:799
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define ENDPOINT_INVALID_INDEX
Definition: transport.h:153
transport_service_type_t session_transport_service_type(stream_session_t *s)
Definition: session.c:1211
#define clib_warning(format, args...)
Definition: error.h:59
u16 port
Port for connection.
u32 ip4_mask_to_preflen(ip4_address_t *mask)
Definition: ip.c:206
int vnet_disconnect_session(vnet_disconnect_args_t *a)
static void send_session_rules_table_details(session_rules_table_t *srt, u8 fib_proto, u8 tp, u8 is_local, u32 appns_index, vl_api_registration_t *reg, u32 context)
Definition: session_api.c:1591
#define ARRAY_LEN(x)
Definition: clib.h:62
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
u32 app_wrk_index
Server index.
Application attach reply.
Definition: session.api:50
static clib_error_t * vl_api_send_fd_msg(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: api.h:84
static u32 vl_api_registration_file_index(vl_api_registration_t *reg)
Definition: api.h:64
static u8 session_has_transport(stream_session_t *s)
Definition: session.h:454
application_t * application_get(u32 app_index)
Definition: application.c:213
static void send_session_rule_details6(mma_rule_40_t *rule, u8 is_local, u8 transport_proto, u32 appns_index, u8 *tag, vl_api_registration_t *reg, u32 context)
Definition: session_api.c:1554
static stream_session_t * session_get_from_handle_if_valid(session_handle_t handle)
Definition: session.h:399
int fd
memfd segments
Definition: ssvm.h:92
ssvm_private_t * session_manager_get_evt_q_segment(void)
Definition: session.c:1305
#define uword_to_pointer(u, type)
Definition: types.h:136
static int svm_msg_q_get_consumer_eventfd(svm_msg_q_t *mq)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
enable/disable session layer
Definition: session.api:492
static void vl_api_connect_sock_t_handler(vl_api_connect_sock_t *mp)
Definition: session_api.c:1271
clib_error_t * vnet_bind(vnet_bind_args_t *a)
static local_session_t * application_get_local_listener_w_handle(session_handle_t handle)
Definition: application.h:365
Reply for app namespace add/del.
Definition: session.api:528
client->vpp, attach application to session layer
Definition: session.api:95
static int mq_send_session_accepted_cb(stream_session_t *s)
Definition: session_api.c:418
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
static void vl_api_bind_sock_t_handler(vl_api_bind_sock_t *mp)
Definition: session_api.c:1161
vpp->client, please map an additional shared memory segment
Definition: session.api:110
#define clib_error_report(e)
Definition: error.h:113
ask app to add a new cut-through registration
Definition: session.api:432
struct _vnet_app_detach_args_t vnet_app_detach_args_t
static uword pointer_to_uword(const void *p)
Definition: types.h:131
Connect to a remote peer.
Definition: session.api:335
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u8 * name
Definition: ssvm.h:86
static void vl_api_application_attach_t_handler(vl_api_application_attach_t *mp)
Definition: session_api.c:738
static void setup_message_id_table(api_main_t *am)
Definition: session_api.c:1754
u32 app_index
App index in app pool.
Definition: application.h:124
bidirectional disconnect API
Definition: session.api:238
static session_cb_vft_t session_mq_cb_vft
Definition: session_api.c:717
add/del application worker
Definition: session.api:451
static void mq_send_session_disconnected_cb(stream_session_t *s)
Definition: session_api.c:509
clib_error_t * vnet_connect_uri(vnet_connect_args_t *a)
transport_connection_t * listen_session_get_transport(stream_session_t *s)
Definition: session.c:1371
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Bind to a given URI.
Definition: session.api:139
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
#define STATIC_ASSERT(truth,...)
static void vl_api_application_tls_key_add_t_handler(vl_api_application_tls_key_add_t *mp)
Definition: session_api.c:1694
#define clib_error_get_code(err)
Definition: error.h:77
VLIB_API_INIT_FUNCTION(session_api_hookup)
struct _session_lookup_table session_table_t
struct _svm_queue svm_queue_t
void * vl_mem_api_alloc_as_if_client_w_reg(vl_api_registration_t *reg, int nbytes)
static void send_session_disconnect_callback(stream_session_t *s)
Definition: session_api.c:286
static void vl_api_application_detach_t_handler(vl_api_application_detach_t *mp)
Definition: session_api.c:842
struct _session_rules_table_add_del_args session_rule_table_add_del_args_t
u32 app_index
Index of owning app.
Definition: application.h:71
#define session_table_foreach(VAR, BODY)
Definition: session_table.h:77
Application add TLS certificate.
Definition: session.api:69
static int send_app_cut_through_registration_add(u32 api_client_index, u32 wrk_map_index, u64 mq_addr, u64 peer_mq_addr)
Definition: session_api.c:153
client->vpp reset session reply Will be DEPRECATED.
Definition: session.api:277
static u32 vlib_num_workers()
Definition: threads.h:366
static int send_add_segment_callback(u32 api_client_index, u64 segment_handle)
Definition: session_api.c:82
Connect to a given URI.
Definition: session.api:181
static void vl_api_session_rule_add_del_t_handler(vl_api_session_rule_add_del_t *mp)
Definition: session_api.c:1476
bidirectional disconnect reply API Will be DEPRECATED.
Definition: session.api:252
u32 api_client_index
API index for the worker.
Definition: application.h:104
segment_manager_properties_t * application_segment_manager_properties(application_t *app)
Definition: application.c:1264
static fib_protocol_t session_get_fib_proto(stream_session_t *s)
Definition: session.h:433
static int mq_send_session_connected_cb(u32 app_wrk_index, u32 api_context, stream_session_t *s, u8 is_fail)
Definition: session_api.c:572
svm_msg_q_t * event_queue
Application listens for events on this svm queue.
Definition: application.h:74
api_main_t api_main
Definition: api_shared.c:35
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
struct _vnet_bind_args_t vnet_bind_args_t
static u8 session_type_is_ip4(session_type_t st)
Definition: session.h:421
static u64 listen_session_get_handle(stream_session_t *s)
Definition: session.h:665
static void vl_api_bind_uri_t_handler(vl_api_bind_uri_t *mp)
Definition: session_api.c:868
static void vl_api_reset_session_reply_t_handler(vl_api_reset_session_reply_t *mp)
Definition: session_api.c:1065
clib_error_t * vnet_app_worker_add_del(vnet_app_worker_add_del_args_t *a)
Definition: application.c:953
non-blocking call - works with both condvar and eventfd signaling
Definition: queue.h:44
static void vl_api_unbind_uri_t_handler(vl_api_unbind_uri_t *mp)
Definition: session_api.c:934
ssvm_segment_type_t ssvm_type(const ssvm_private_t *ssvm)
Definition: ssvm.c:429