FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
session_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019 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>
23 #include <vnet/session/session.h>
24 
25 #include <vnet/ip/ip_types_api.h>
26 
27 #include <vnet/vnet_msg_enum.h>
28 
29 #define vl_typedefs /* define message structures */
30 #include <vnet/vnet_all_api_h.h>
31 #undef vl_typedefs
32 
33 #define vl_endianfun /* define message structures */
34 #include <vnet/vnet_all_api_h.h>
35 #undef vl_endianfun
36 
37 /* instantiate all the print functions we know about */
38 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
39 #define vl_printfun
40 #include <vnet/vnet_all_api_h.h>
41 #undef vl_printfun
42 
44 
45 #define foreach_session_api_msg \
46 _(APP_ATTACH, app_attach) \
47 _(APPLICATION_DETACH, application_detach) \
48 _(SESSION_ENABLE_DISABLE, session_enable_disable) \
49 _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \
50 _(SESSION_RULE_ADD_DEL, session_rule_add_del) \
51 _(SESSION_RULES_DUMP, session_rules_dump) \
52 _(APPLICATION_TLS_CERT_ADD, application_tls_cert_add) \
53 _(APPLICATION_TLS_KEY_ADD, application_tls_key_add) \
54 _(APP_ADD_CERT_KEY_PAIR, app_add_cert_key_pair) \
55 _(APP_DEL_CERT_KEY_PAIR, app_del_cert_key_pair) \
56 _(APP_WORKER_ADD_DEL, app_worker_add_del) \
57 
58 static transport_proto_t
59 api_session_transport_proto_decode (const vl_api_transport_proto_t * api_tp)
60 {
61  switch (*api_tp)
62  {
64  return TRANSPORT_PROTO_TCP;
66  return TRANSPORT_PROTO_UDP;
68  return TRANSPORT_PROTO_TLS;
70  return TRANSPORT_PROTO_QUIC;
71  default:
72  return TRANSPORT_PROTO_NONE;
73  }
74 }
75 
76 static vl_api_transport_proto_t
78 {
79  switch (tp)
80  {
81  case TRANSPORT_PROTO_TCP:
83  case TRANSPORT_PROTO_UDP:
85  case TRANSPORT_PROTO_TLS:
87  case TRANSPORT_PROTO_QUIC:
89  default:
91  }
92 }
93 
94 static int
95 session_send_fds (vl_api_registration_t * reg, int fds[], int n_fds)
96 {
97  clib_error_t *error;
99  return SESSION_E_BAPI_NO_FD;
100  error = vl_api_send_fd_msg (reg, fds, n_fds);
101  if (error)
102  {
103  clib_error_report (error);
104  return SESSION_E_BAPI_SEND_FD;
105  }
106  return 0;
107 }
108 
109 static int
111 {
112  int rv;
113  u8 try = 0;
114  while (try < 100)
115  {
118  SVM_Q_NOWAIT, msg);
119  if (!rv)
120  return 0;
121  try++;
122  usleep (1);
123  }
124  clib_warning ("failed to alloc msg");
125  return -1;
126 }
127 
128 static int
130 {
131  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
132  svm_msg_q_msg_t _msg, *msg = &_msg;
133  svm_msg_q_t *vpp_queue, *app_mq;
136  session_event_t *evt;
137  application_t *app;
138 
139  app = application_get (app_wrk->app_index);
140  app_mq = app_wrk->event_queue;
141  if (mq_try_lock_and_alloc_msg (app_mq, msg))
142  return SESSION_E_MQ_MSG_ALLOC;
143 
144  evt = svm_msg_q_msg_data (app_mq, msg);
145  clib_memset (evt, 0, sizeof (*evt));
146  evt->event_type = SESSION_CTRL_EVT_ACCEPTED;
147  mp = (session_accepted_msg_t *) evt->data;
148  clib_memset (mp, 0, sizeof (*mp));
149  mp->context = app->app_index;
153  mp->flags = s->flags;
154 
155  if (session_has_transport (s))
156  {
159  if (application_is_proxy (app))
160  {
161  listener =
164  if (listener)
166  }
168  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
169  mp->handle = session_handle (s);
170 
171  session_get_endpoint (s, &mp->rmt, 0 /* is_lcl */ );
172  }
173  else
174  {
175  ct_connection_t *ct;
176 
180  mp->rmt.is_ip4 = session_type_is_ip4 (listener->session_type);
181  mp->rmt.port = ct->c_rmt_port;
182  mp->handle = session_handle (s);
183  vpp_queue = session_main_get_vpp_event_queue (0);
184  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
185  }
186  svm_msg_q_add_and_unlock (app_mq, msg);
187 
188  return 0;
189 }
190 
191 static inline void
193  session_evt_type_t evt_type)
194 {
195  svm_msg_q_msg_t _msg, *msg = &_msg;
197  svm_msg_q_t *app_mq;
198  session_event_t *evt;
199 
200  app_mq = app_wrk->event_queue;
201  if (mq_try_lock_and_alloc_msg (app_mq, msg))
202  return;
203  evt = svm_msg_q_msg_data (app_mq, msg);
204  clib_memset (evt, 0, sizeof (*evt));
205  evt->event_type = evt_type;
206  mp = (session_disconnected_msg_t *) evt->data;
207  mp->handle = sh;
208  mp->context = app_wrk->api_client_index;
209  svm_msg_q_add_and_unlock (app_mq, msg);
210 }
211 
212 static inline void
214  svm_fifo_t * f, session_evt_type_t evt_type)
215 {
216  app_worker_t *app_wrk;
217  application_t *app;
218  int i;
219 
220  app = application_get (app_index);
221  if (!app)
222  return;
223 
224  for (i = 0; i < f->n_subscribers; i++)
225  {
226  if (!(app_wrk = application_get_worker (app, f->subscribers[i])))
227  continue;
229  }
230 }
231 
232 static void
234 {
235  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
237 
240 
244 }
245 
246 static void
248 {
249  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
251 
253 
257 }
258 
259 int
260 mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
261  session_t * s, session_error_t err)
262 {
263  svm_msg_q_msg_t _msg, *msg = &_msg;
265  svm_msg_q_t *vpp_mq, *app_mq;
267  app_worker_t *app_wrk;
268  session_event_t *evt;
269 
270  app_wrk = app_worker_get (app_wrk_index);
271  app_mq = app_wrk->event_queue;
272  if (!app_mq)
273  {
274  clib_warning ("app %u with api index: %u not attached",
275  app_wrk->app_index, app_wrk->api_client_index);
276  return -1;
277  }
278 
279  if (mq_try_lock_and_alloc_msg (app_mq, msg))
280  return SESSION_E_MQ_MSG_ALLOC;
281 
282  evt = svm_msg_q_msg_data (app_mq, msg);
283  clib_memset (evt, 0, sizeof (*evt));
284  evt->event_type = SESSION_CTRL_EVT_CONNECTED;
285  mp = (session_connected_msg_t *) evt->data;
286  clib_memset (mp, 0, sizeof (*mp));
287  mp->context = api_context;
288 
289  if (err)
290  goto done;
291 
292  if (session_has_transport (s))
293  {
294  tc = session_get_transport (s);
295  if (!tc)
296  {
297  clib_warning ("failed to retrieve transport!");
298  err = SESSION_E_REFUSED;
299  goto done;
300  }
301 
303  mp->handle = session_handle (s);
305 
306  session_get_endpoint (s, &mp->lcl, 1 /* is_lcl */ );
307 
311  }
312  else
313  {
314  ct_connection_t *cct;
315  session_t *ss;
316 
318  mp->handle = session_handle (s);
319  mp->lcl.port = cct->c_lcl_port;
320  mp->lcl.is_ip4 = cct->c_is_ip4;
326  ss = ct_session_get_peer (s);
327  mp->ct_rx_fifo = pointer_to_uword (ss->tx_fifo);
328  mp->ct_tx_fifo = pointer_to_uword (ss->rx_fifo);
330  }
331 
332 done:
333  mp->retval = err;
334 
335  svm_msg_q_add_and_unlock (app_mq, msg);
336  return 0;
337 }
338 
339 int
340 mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
341  session_handle_t handle, int rv)
342 {
343  svm_msg_q_msg_t _msg, *msg = &_msg;
344  svm_msg_q_t *app_mq, *vpp_evt_q;
347  app_worker_t *app_wrk;
348  session_event_t *evt;
349  app_listener_t *al;
350  session_t *ls = 0;
351  app_wrk = app_worker_get (app_wrk_index);
352  app_mq = app_wrk->event_queue;
353  if (!app_mq)
354  {
355  clib_warning ("app %u with api index: %u not attached",
356  app_wrk->app_index, app_wrk->api_client_index);
357  return -1;
358  }
359 
360  if (mq_try_lock_and_alloc_msg (app_mq, msg))
361  return SESSION_E_MQ_MSG_ALLOC;
362 
363  evt = svm_msg_q_msg_data (app_mq, msg);
364  clib_memset (evt, 0, sizeof (*evt));
365  evt->event_type = SESSION_CTRL_EVT_BOUND;
366  mp = (session_bound_msg_t *) evt->data;
367  mp->context = api_context;
368 
369  if (rv)
370  goto done;
371 
372  mp->handle = handle;
373  al = app_listener_get_w_handle (handle);
375  ls = app_listener_get_session (al);
376  else
378 
379  session_get_endpoint (ls, &tep, 1 /* is_lcl */ );
380  mp->lcl_port = tep.port;
381  mp->lcl_is_ip4 = tep.is_ip4;
382  clib_memcpy_fast (mp->lcl_ip, &tep.ip, sizeof (tep.ip));
383 
384  vpp_evt_q = session_main_get_vpp_event_queue (0);
385  mp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
386 
388  {
389  mp->rx_fifo = pointer_to_uword (ls->rx_fifo);
390  mp->tx_fifo = pointer_to_uword (ls->tx_fifo);
391  }
392 
393 done:
394  mp->retval = rv;
395  svm_msg_q_add_and_unlock (app_mq, msg);
396  return 0;
397 }
398 
399 void
401  u32 context, int rv)
402 {
403  svm_msg_q_msg_t _msg, *msg = &_msg;
405  svm_msg_q_t *app_mq;
406  session_event_t *evt;
407 
408  app_mq = app_wrk->event_queue;
409  if (mq_try_lock_and_alloc_msg (app_mq, msg))
410  return;
411 
412  evt = svm_msg_q_msg_data (app_mq, msg);
413  clib_memset (evt, 0, sizeof (*evt));
414  evt->event_type = SESSION_CTRL_EVT_UNLISTEN_REPLY;
415  ump = (session_unlisten_reply_msg_t *) evt->data;
416  ump->context = context;
417  ump->handle = sh;
418  ump->retval = rv;
419  svm_msg_q_add_and_unlock (app_mq, msg);
420 }
421 
422 static void
424 {
425  svm_msg_q_msg_t _msg, *msg = &_msg;
427  svm_msg_q_t *vpp_evt_q;
428  app_worker_t *app_wrk;
429  session_event_t *evt;
430  svm_msg_q_t *app_mq;
431 
432  app_wrk = app_worker_get (s->app_wrk_index);
433  app_mq = app_wrk->event_queue;
434  if (mq_try_lock_and_alloc_msg (app_mq, msg))
435  return;
436 
437  evt = svm_msg_q_msg_data (app_mq, msg);
438  clib_memset (evt, 0, sizeof (*evt));
439  evt->event_type = SESSION_CTRL_EVT_MIGRATED;
440  mp = (session_migrated_msg_t *) evt->data;
441  mp->handle = session_handle (s);
442  mp->new_handle = new_sh;
445  mp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
446  svm_msg_q_add_and_unlock (app_mq, msg);
447 }
448 
449 static int
450 mq_send_add_segment_cb (u32 app_wrk_index, u64 segment_handle)
451 {
452  int fds[SESSION_N_FD_TYPE], n_fds = 0;
453  svm_msg_q_msg_t _msg, *msg = &_msg;
456  app_worker_t *app_wrk;
457  session_event_t *evt;
458  svm_msg_q_t *app_mq;
459  fifo_segment_t *fs;
460  ssvm_private_t *sp;
461  u8 fd_flags = 0;
462 
463  app_wrk = app_worker_get (app_wrk_index);
464 
466  if (!reg)
467  {
468  clib_warning ("no api registration for client: %u",
469  app_wrk->api_client_index);
470  return -1;
471  }
472 
473  fs = segment_manager_get_segment_w_handle (segment_handle);
474  sp = &fs->ssvm;
475  if (ssvm_type (sp) == SSVM_SEGMENT_MEMFD)
476  {
478  {
479  clib_warning ("can't send memfd fd");
480  return -1;
481  }
482 
483  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
484  fds[n_fds] = sp->fd;
485  n_fds += 1;
486  }
487 
488  app_mq = app_wrk->event_queue;
489  if (mq_try_lock_and_alloc_msg (app_mq, msg))
490  return -1;
491 
492  if (n_fds)
493  session_send_fds (reg, fds, n_fds);
494 
495  evt = svm_msg_q_msg_data (app_mq, msg);
496  clib_memset (evt, 0, sizeof (*evt));
497  evt->event_type = SESSION_CTRL_EVT_APP_ADD_SEGMENT;
498  mp = (session_app_add_segment_msg_t *) evt->data;
499  clib_memset (mp, 0, sizeof (*mp));
500  mp->segment_size = sp->ssvm_size;
501  mp->fd_flags = fd_flags;
502  mp->segment_handle = segment_handle;
503  strncpy ((char *) mp->segment_name, (char *) sp->name,
504  sizeof (mp->segment_name) - 1);
505 
506  svm_msg_q_add_and_unlock (app_mq, msg);
507 
508  return 0;
509 }
510 
511 static int
512 mq_send_del_segment_cb (u32 app_wrk_index, u64 segment_handle)
513 {
514  svm_msg_q_msg_t _msg, *msg = &_msg;
517  app_worker_t *app_wrk;
518  session_event_t *evt;
519  svm_msg_q_t *app_mq;
520 
521  app_wrk = app_worker_get (app_wrk_index);
523  if (!reg)
524  {
525  clib_warning ("no registration: %u", app_wrk->api_client_index);
526  return -1;
527  }
528 
529  app_mq = app_wrk->event_queue;
530  if (mq_try_lock_and_alloc_msg (app_mq, msg))
531  return -1;
532 
533  evt = svm_msg_q_msg_data (app_mq, msg);
534  clib_memset (evt, 0, sizeof (*evt));
535  evt->event_type = SESSION_CTRL_EVT_APP_DEL_SEGMENT;
536  mp = (session_app_del_segment_msg_t *) evt->data;
537  clib_memset (mp, 0, sizeof (*mp));
538  mp->segment_handle = segment_handle;
539  svm_msg_q_add_and_unlock (app_mq, msg);
540 
541  return 0;
542 }
543 
544 static void
546 {
547  svm_msg_q_msg_t _msg, *msg = &_msg;
549  svm_msg_q_t *app_mq;
550  session_event_t *evt;
551  app_worker_t *app_wrk;
552 
553  /* Propagate transport cleanup notifications only if app didn't close */
554  if (ntf == SESSION_CLEANUP_TRANSPORT
555  && s->session_state != SESSION_STATE_TRANSPORT_DELETED)
556  return;
557 
558  app_wrk = app_worker_get_if_valid (s->app_wrk_index);
559  if (!app_wrk)
560  return;
561 
562  app_mq = app_wrk->event_queue;
563  if (mq_try_lock_and_alloc_msg (app_mq, msg))
564  return;
565 
566  evt = svm_msg_q_msg_data (app_mq, msg);
567  clib_memset (evt, 0, sizeof (*evt));
568  evt->event_type = SESSION_CTRL_EVT_CLEANUP;
569  mp = (session_cleanup_msg_t *) evt->data;
570  mp->handle = session_handle (s);
571  mp->type = ntf;
572  svm_msg_q_add_and_unlock (app_mq, msg);
573 }
574 
575 static session_cb_vft_t session_mq_cb_vft = {
577  .session_disconnect_callback = mq_send_session_disconnected_cb,
578  .session_connected_callback = mq_send_session_connected_cb,
579  .session_reset_callback = mq_send_session_reset_cb,
580  .session_migrate_callback = mq_send_session_migrate_cb,
581  .session_cleanup_callback = mq_send_session_cleanup_cb,
582  .add_segment_callback = mq_send_add_segment_cb,
583  .del_segment_callback = mq_send_del_segment_cb,
584 };
585 
586 static void
588 {
589  vl_api_session_enable_disable_reply_t *rmp;
591  int rv = 0;
592 
594  REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
595 }
596 
597 static void
599 {
600  int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
602  ssvm_private_t *segp, *evt_q_segment;
603  vnet_app_attach_args_t _a, *a = &_a;
604  u8 fd_flags = 0, ctrl_thread;
606  svm_msg_q_t *ctrl_mq;
607 
609  if (!reg)
610  return;
611 
612  if (session_main_is_enabled () == 0)
613  {
614  rv = VNET_API_ERROR_FEATURE_DISABLED;
615  goto done;
616  }
617 
619  sizeof (mp->options),
620  "Out of options, fix api message definition");
621 
622  clib_memset (a, 0, sizeof (*a));
623  a->api_client_index = mp->client_index;
624  a->options = mp->options;
625  a->session_cb_vft = &session_mq_cb_vft;
626 
627  a->namespace_id = vl_api_from_api_to_new_vec (mp, &mp->namespace_id);
628 
629  if ((rv = vnet_application_attach (a)))
630  {
631  clib_warning ("attach returned: %d", rv);
632  vec_free (a->namespace_id);
633  goto done;
634  }
635  vec_free (a->namespace_id);
636 
637  /* Send event queues segment */
638  if ((evt_q_segment = session_main_get_evt_q_segment ()))
639  {
640  fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
641  fds[n_fds] = evt_q_segment->fd;
642  n_fds += 1;
643  }
644  /* Send fifo segment fd if needed */
645  if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
646  {
647  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
648  fds[n_fds] = a->segment->fd;
649  n_fds += 1;
650  }
651  if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
652  {
653  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
654  fds[n_fds] = svm_msg_q_get_producer_eventfd (a->app_evt_q);
655  n_fds += 1;
656  }
657 
658 done:
659  /* *INDENT-OFF* */
660  REPLY_MACRO2 (VL_API_APP_ATTACH_REPLY, ({
661  if (!rv)
662  {
663  ctrl_thread = vlib_num_workers () ? 1 : 0;
664  ctrl_mq = session_main_get_vpp_event_queue (ctrl_thread);
665  segp = a->segment;
666  rmp->app_index = clib_host_to_net_u32 (a->app_index);
667  rmp->app_mq = pointer_to_uword (a->app_evt_q);
668  rmp->vpp_ctrl_mq = pointer_to_uword (ctrl_mq);
669  rmp->vpp_ctrl_mq_thread = ctrl_thread;
670  rmp->n_fds = n_fds;
671  rmp->fd_flags = fd_flags;
672  if (vec_len (segp->name))
673  {
675  }
676  rmp->segment_size = segp->ssvm_size;
677  rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
678  }
679  }));
680  /* *INDENT-ON* */
681 
682  if (n_fds)
683  session_send_fds (reg, fds, n_fds);
684 }
685 
686 static void
688 {
689  int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
692  application_t *app;
693  u8 fd_flags = 0;
694 
695  if (session_main_is_enabled () == 0)
696  {
697  rv = VNET_API_ERROR_FEATURE_DISABLED;
698  goto done;
699  }
700 
702  if (!reg)
703  return;
704 
705  app = application_get_if_valid (clib_net_to_host_u32 (mp->app_index));
706  if (!app)
707  {
708  rv = VNET_API_ERROR_INVALID_VALUE;
709  goto done;
710  }
711 
713  .app_index = app->app_index,
714  .wrk_map_index = clib_net_to_host_u32 (mp->wrk_index),
715  .api_client_index = mp->client_index,
716  .is_add = mp->is_add
717  };
718  rv = vnet_app_worker_add_del (&args);
719  if (rv)
720  {
721  clib_warning ("app worker add/del returned: %d", rv);
722  goto done;
723  }
724 
725  if (!mp->is_add)
726  goto done;
727 
728  /* Send fifo segment fd if needed */
729  if (ssvm_type (args.segment) == SSVM_SEGMENT_MEMFD)
730  {
731  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
732  fds[n_fds] = args.segment->fd;
733  n_fds += 1;
734  }
735  if (application_segment_manager_properties (app)->use_mq_eventfd)
736  {
737  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
738  fds[n_fds] = svm_msg_q_get_producer_eventfd (args.evt_q);
739  n_fds += 1;
740  }
741 
742  /* *INDENT-OFF* */
743 done:
744  REPLY_MACRO2 (VL_API_APP_WORKER_ADD_DEL_REPLY, ({
745  rmp->is_add = mp->is_add;
746  rmp->wrk_index = clib_host_to_net_u32 (args.wrk_map_index);
747  rmp->segment_handle = clib_host_to_net_u64 (args.segment_handle);
748  if (!rv && mp->is_add)
749  {
750  if (vec_len (args.segment->name))
751  {
752  vl_api_vec_to_api_string (args.segment->name, &rmp->segment_name);
753  }
754  rmp->app_event_queue_address = pointer_to_uword (args.evt_q);
755  rmp->n_fds = n_fds;
756  rmp->fd_flags = fd_flags;
757  }
758  }));
759  /* *INDENT-ON* */
760 
761  if (n_fds)
762  session_send_fds (reg, fds, n_fds);
763 }
764 
765 static void
767 {
768  vl_api_application_detach_reply_t *rmp;
769  int rv = VNET_API_ERROR_INVALID_VALUE_2;
770  vnet_app_detach_args_t _a, *a = &_a;
771  application_t *app;
772 
773  if (session_main_is_enabled () == 0)
774  {
775  rv = VNET_API_ERROR_FEATURE_DISABLED;
776  goto done;
777  }
778 
779  app = application_lookup (mp->client_index);
780  if (app)
781  {
782  a->app_index = app->app_index;
783  a->api_client_index = mp->client_index;
784  rv = vnet_application_detach (a);
785  }
786 
787 done:
788  REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY);
789 }
790 
791 static void
793 {
795  u32 appns_index = 0;
796  u8 *ns_id = 0;
797  int rv = 0;
798  if (session_main_is_enabled () == 0)
799  {
800  rv = VNET_API_ERROR_FEATURE_DISABLED;
801  goto done;
802  }
803 
804  ns_id = vl_api_from_api_to_new_vec (mp, &mp->namespace_id);
805 
807  .ns_id = ns_id,
808  .secret = clib_net_to_host_u64 (mp->secret),
809  .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
810  .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
811  .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id),
812  .is_add = 1
813  };
814  rv = vnet_app_namespace_add_del (&args);
815  if (!rv)
816  {
817  appns_index = app_namespace_index_from_id (ns_id);
818  if (appns_index == APP_NAMESPACE_INVALID_INDEX)
819  {
820  clib_warning ("app ns lookup failed");
821  rv = VNET_API_ERROR_UNSPECIFIED;
822  }
823  }
824  vec_free (ns_id);
825 
826  /* *INDENT-OFF* */
827 done:
828  REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_REPLY, ({
829  if (!rv)
830  rmp->appns_index = clib_host_to_net_u32 (appns_index);
831  }));
832  /* *INDENT-ON* */
833 }
834 
835 static void
837 {
838  vl_api_session_rule_add_del_reply_t *rmp;
840  session_rule_table_add_del_args_t *table_args = &args.table_args;
841  int rv = 0;
842 
843  clib_memset (&args, 0, sizeof (args));
844 
845  ip_prefix_decode (&mp->lcl, &table_args->lcl);
846  ip_prefix_decode (&mp->rmt, &table_args->rmt);
847 
848  table_args->lcl_port = mp->lcl_port;
849  table_args->rmt_port = mp->rmt_port;
850  table_args->action_index = clib_net_to_host_u32 (mp->action_index);
851  table_args->is_add = mp->is_add;
852  mp->tag[sizeof (mp->tag) - 1] = 0;
853  table_args->tag = format (0, "%s", mp->tag);
854  args.appns_index = clib_net_to_host_u32 (mp->appns_index);
855  args.scope = mp->scope;
856  args.transport_proto =
858  TRANSPORT_PROTO_UDP ? 1 : 0;
859 
860  rv = vnet_session_rule_add_del (&args);
861  if (rv)
862  clib_warning ("rule add del returned: %d", rv);
863  vec_free (table_args->tag);
864  REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY);
865 }
866 
867 static void
868 send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
869  u8 transport_proto, u32 appns_index, u8 * tag,
870  vl_api_registration_t * reg, u32 context)
871 {
873  session_mask_or_match_4_t *match =
874  (session_mask_or_match_4_t *) & rule->match;
875  session_mask_or_match_4_t *mask =
876  (session_mask_or_match_4_t *) & rule->mask;
877  fib_prefix_t lcl, rmt;
878 
879  rmp = vl_msg_api_alloc (sizeof (*rmp));
880  clib_memset (rmp, 0, sizeof (*rmp));
881  rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
882  rmp->context = context;
883 
884  clib_memset (&lcl, 0, sizeof (lcl));
885  clib_memset (&rmt, 0, sizeof (rmt));
886  ip_set (&lcl.fp_addr, &match->lcl_ip, 1);
887  ip_set (&rmt.fp_addr, &match->rmt_ip, 1);
888  lcl.fp_len = ip4_mask_to_preflen (&mask->lcl_ip);
889  rmt.fp_len = ip4_mask_to_preflen (&mask->rmt_ip);
890 
891  ip_prefix_encode (&lcl, &rmp->lcl);
892  ip_prefix_encode (&rmt, &rmp->rmt);
893  rmp->lcl_port = match->lcl_port;
894  rmp->rmt_port = match->rmt_port;
895  rmp->action_index = clib_host_to_net_u32 (rule->action_index);
896  rmp->scope =
898  rmp->transport_proto = api_session_transport_proto_encode (transport_proto);
899  rmp->appns_index = clib_host_to_net_u32 (appns_index);
900  if (tag)
901  {
902  clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
903  rmp->tag[vec_len (tag)] = 0;
904  }
905 
906  vl_api_send_msg (reg, (u8 *) rmp);
907 }
908 
909 static void
910 send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
911  u8 transport_proto, u32 appns_index, u8 * tag,
912  vl_api_registration_t * reg, u32 context)
913 {
915  session_mask_or_match_6_t *match =
916  (session_mask_or_match_6_t *) & rule->match;
917  session_mask_or_match_6_t *mask =
918  (session_mask_or_match_6_t *) & rule->mask;
919  fib_prefix_t lcl, rmt;
920 
921  rmp = vl_msg_api_alloc (sizeof (*rmp));
922  clib_memset (rmp, 0, sizeof (*rmp));
923  rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
924  rmp->context = context;
925 
926  clib_memset (&lcl, 0, sizeof (lcl));
927  clib_memset (&rmt, 0, sizeof (rmt));
928  ip_set (&lcl.fp_addr, &match->lcl_ip, 0);
929  ip_set (&rmt.fp_addr, &match->rmt_ip, 0);
930  lcl.fp_len = ip6_mask_to_preflen (&mask->lcl_ip);
931  rmt.fp_len = ip6_mask_to_preflen (&mask->rmt_ip);
932 
933  ip_prefix_encode (&lcl, &rmp->lcl);
934  ip_prefix_encode (&rmt, &rmp->rmt);
935  rmp->lcl_port = match->lcl_port;
936  rmp->rmt_port = match->rmt_port;
937  rmp->action_index = clib_host_to_net_u32 (rule->action_index);
938  rmp->scope =
940  rmp->transport_proto = api_session_transport_proto_encode (transport_proto);
941  rmp->appns_index = clib_host_to_net_u32 (appns_index);
942  if (tag)
943  {
944  clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
945  rmp->tag[vec_len (tag)] = 0;
946  }
947 
948  vl_api_send_msg (reg, (u8 *) rmp);
949 }
950 
951 static void
953  u8 tp, u8 is_local, u32 appns_index,
954  vl_api_registration_t * reg, u32 context)
955 {
956  mma_rule_16_t *rule16;
957  mma_rule_40_t *rule40;
958  mma_rules_table_16_t *srt16;
959  mma_rules_table_40_t *srt40;
960  u32 ri;
961 
962  if (is_local || fib_proto == FIB_PROTOCOL_IP4)
963  {
964  u8 *tag = 0;
965  /* *INDENT-OFF* */
966  srt16 = &srt->session_rules_tables_16;
967  pool_foreach (rule16, srt16->rules, ({
968  ri = mma_rules_table_rule_index_16 (srt16, rule16);
969  tag = session_rules_table_rule_tag (srt, ri, 1);
970  send_session_rule_details4 (rule16, is_local, tp, appns_index, tag,
971  reg, context);
972  }));
973  /* *INDENT-ON* */
974  }
975  if (is_local || fib_proto == FIB_PROTOCOL_IP6)
976  {
977  u8 *tag = 0;
978  /* *INDENT-OFF* */
979  srt40 = &srt->session_rules_tables_40;
980  pool_foreach (rule40, srt40->rules, ({
981  ri = mma_rules_table_rule_index_40 (srt40, rule40);
982  tag = session_rules_table_rule_tag (srt, ri, 1);
983  send_session_rule_details6 (rule40, is_local, tp, appns_index, tag,
984  reg, context);
985  }));
986  /* *INDENT-ON* */
987  }
988 }
989 
990 static void
992 {
994  session_table_t *st;
995  u8 tp;
996 
998  if (!reg)
999  return;
1000 
1001  /* *INDENT-OFF* */
1002  session_table_foreach (st, ({
1003  for (tp = 0; tp < TRANSPORT_N_PROTOS; tp++)
1004  {
1005  send_session_rules_table_details (&st->session_rules[tp],
1006  st->active_fib_proto, tp,
1007  st->is_local, st->appns_index, reg,
1008  mp->context);
1009  }
1010  }));
1011  /* *INDENT-ON* */
1012 }
1013 
1014 static void
1016 {
1019  u32 certkey_len, key_len, cert_len;
1020  int rv = 0;
1021  if (session_main_is_enabled () == 0)
1022  {
1023  rv = VNET_API_ERROR_FEATURE_DISABLED;
1024  goto done;
1025  }
1026 
1027  cert_len = clib_net_to_host_u16 (mp->cert_len);
1028  if (cert_len > 10000)
1029  {
1030  rv = VNET_API_ERROR_INVALID_VALUE;
1031  goto done;
1032  }
1033 
1034  certkey_len = clib_net_to_host_u16 (mp->certkey_len);
1035  if (certkey_len < cert_len)
1036  {
1037  rv = VNET_API_ERROR_INVALID_VALUE;
1038  goto done;
1039  }
1040 
1041  key_len = certkey_len - cert_len;
1042  if (key_len > 10000)
1043  {
1044  rv = VNET_API_ERROR_INVALID_VALUE;
1045  goto done;
1046  }
1047 
1048  clib_memset (a, 0, sizeof (*a));
1049  vec_validate (a->cert, cert_len);
1050  vec_validate (a->key, key_len);
1051  clib_memcpy_fast (a->cert, mp->certkey, cert_len);
1052  clib_memcpy_fast (a->key, mp->certkey + cert_len, key_len);
1053  rv = vnet_app_add_cert_key_pair (a);
1054  vec_free (a->cert);
1055  vec_free (a->key);
1056 
1057 done:
1058  /* *INDENT-OFF* */
1059  REPLY_MACRO2 (VL_API_APP_ADD_CERT_KEY_PAIR_REPLY, ({
1060  if (!rv)
1061  rmp->index = clib_host_to_net_u32 (a->index);
1062  }));
1063  /* *INDENT-ON* */
1064 }
1065 
1066 static void
1068 {
1069  vl_api_app_del_cert_key_pair_reply_t *rmp;
1070  u32 ckpair_index;
1071  int rv = 0;
1072  if (session_main_is_enabled () == 0)
1073  {
1074  rv = VNET_API_ERROR_FEATURE_DISABLED;
1075  goto done;
1076  }
1077  ckpair_index = clib_net_to_host_u32 (mp->index);
1078  rv = vnet_app_del_cert_key_pair (ckpair_index);
1079 
1080 done:
1081  REPLY_MACRO (VL_API_APP_DEL_CERT_KEY_PAIR_REPLY);
1082 }
1083 
1084 /* ### WILL BE DEPRECATED POST 20.01 ### */
1085 static void
1087  mp)
1088 {
1089  vl_api_application_tls_cert_add_reply_t *rmp;
1090  app_cert_key_pair_t *ckpair;
1091  application_t *app;
1092  u32 cert_len;
1093  int rv = 0;
1094  if (session_main_is_enabled () == 0)
1095  {
1096  rv = VNET_API_ERROR_FEATURE_DISABLED;
1097  goto done;
1098  }
1099  if (!(app = application_lookup (mp->client_index)))
1100  {
1101  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1102  goto done;
1103  }
1104  cert_len = clib_net_to_host_u16 (mp->cert_len);
1105  if (cert_len > 10000)
1106  {
1107  rv = VNET_API_ERROR_INVALID_VALUE;
1108  goto done;
1109  }
1110  ckpair = app_cert_key_pair_get_default ();
1111  vec_validate (ckpair->cert, cert_len);
1112  clib_memcpy_fast (ckpair->cert, mp->cert, cert_len);
1113 
1114 done:
1115  REPLY_MACRO (VL_API_APPLICATION_TLS_CERT_ADD_REPLY);
1116 }
1117 
1118 /* ### WILL BE DEPRECATED POST 20.01 ### */
1119 static void
1121  mp)
1122 {
1123  vl_api_application_tls_key_add_reply_t *rmp;
1124  app_cert_key_pair_t *ckpair;
1125  application_t *app;
1126  u32 key_len;
1127  int rv = 0;
1128  if (session_main_is_enabled () == 0)
1129  {
1130  rv = VNET_API_ERROR_FEATURE_DISABLED;
1131  goto done;
1132  }
1133  if (!(app = application_lookup (mp->client_index)))
1134  {
1135  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1136  goto done;
1137  }
1138  key_len = clib_net_to_host_u16 (mp->key_len);
1139  if (key_len > 10000)
1140  {
1141  rv = VNET_API_ERROR_INVALID_VALUE;
1142  goto done;
1143  }
1144  ckpair = app_cert_key_pair_get_default ();
1145  vec_validate (ckpair->key, key_len);
1146  clib_memcpy_fast (ckpair->key, mp->key, key_len);
1147 done:
1148  REPLY_MACRO (VL_API_APPLICATION_TLS_KEY_ADD_REPLY);
1149 }
1150 
1151 static clib_error_t *
1153 {
1154  application_t *app = application_lookup (client_index);
1155  vnet_app_detach_args_t _a, *a = &_a;
1156  if (app)
1157  {
1158  a->app_index = app->app_index;
1159  a->api_client_index = client_index;
1161  }
1162  return 0;
1163 }
1164 
1166 
1167 #define vl_msg_name_crc_list
1168 #include <vnet/vnet_all_api_h.h>
1169 #undef vl_msg_name_crc_list
1170 
1171 static void
1173 {
1174 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1175  foreach_vl_msg_name_crc_session;
1176 #undef _
1177 }
1178 
1179 /*
1180  * session_api_hookup
1181  * Add uri's API message handlers to the table.
1182  * vlib has already mapped shared memory and
1183  * added the client registration handlers.
1184  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
1185  */
1186 static clib_error_t *
1188 {
1189  api_main_t *am = vlibapi_get_main ();
1190 
1191 #define _(N,n) \
1192  vl_msg_api_set_handlers(VL_API_##N, #n, \
1193  vl_api_##n##_t_handler, \
1194  vl_noop_handler, \
1195  vl_api_##n##_t_endian, \
1196  vl_api_##n##_t_print, \
1197  sizeof(vl_api_##n##_t), 1);
1199 #undef _
1200 
1201  /*
1202  * Set up the (msg_name, crc, message-id) table
1203  */
1205 
1206  return 0;
1207 }
1208 
1210 
1211 /*
1212  * fd.io coding-style-patch-verification: ON
1213  *
1214  * Local Variables:
1215  * eval: (c-set-style "gnu")
1216  * End:
1217  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
struct _vnet_app_worker_add_del_args vnet_app_worker_add_del_args_t
string namespace_id[]
Definition: session.api:41
#define APP_NAMESPACE_INVALID_INDEX
static clib_error_t * session_api_hookup(vlib_main_t *vm)
Definition: session_api.c:1187
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
session_type_t session_type
Type built from transport and network protocol types.
static void vl_api_app_del_cert_key_pair_t_handler(vl_api_app_del_cert_key_pair_t *mp)
Definition: session_api.c:1067
app_cert_key_pair_t * app_cert_key_pair_get_default()
Definition: application.c:1700
void mq_send_unlisten_reply(app_worker_t *app_wrk, session_handle_t sh, u32 context, int rv)
Definition: session_api.c:400
int vnet_app_add_cert_key_pair(vnet_app_add_cert_key_pair_args_t *a)
Definition: application.c:1707
static void mq_notify_close_subscribers(u32 app_index, session_handle_t sh, svm_fifo_t *f, session_evt_type_t evt_type)
Definition: session_api.c:213
Add certificate and key.
Definition: session.api:103
transport_endpoint_t rmt
a
Definition: bitmap.h:538
VL_MSG_API_REAPER_FUNCTION(application_reaper_cb)
#define TRANSPORT_N_PROTOS
Definition: session.h:210
uword ssvm_size
Definition: ssvm.h:85
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:233
transport_proto
Definition: session.api:22
svm_fifo_t * tx_fifo
struct _session_rules_table_t session_rules_table_t
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vl_api_transport_proto_t transport_proto
Definition: session.api:310
Application add TLS key WILL BE DEPRECATED POST 20.01
Definition: session.api:142
static void vl_api_app_namespace_add_del_t_handler(vl_api_app_namespace_add_del_t *mp)
Definition: session_api.c:792
int vnet_app_namespace_add_del(vnet_app_namespace_add_del_args_t *a)
unsigned long u64
Definition: types.h:89
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
Definition: session.h:633
vl_api_transport_proto_t transport_proto
Definition: session.api:268
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
Definition: ip.c:93
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
static void mq_send_session_close_evt(app_worker_t *app_wrk, session_handle_t sh, session_evt_type_t evt_type)
Definition: session_api.c:192
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1620
add/del session rule
Definition: session.api:265
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_api_session_rule_scope_t scope
Definition: session.api:276
u32 ip4_mask_to_preflen(ip4_address_t *mask)
Definition: ip_types.c:485
fifo_segment_t * segment_manager_get_segment_w_handle(u64 segment_handle)
Session rules details.
Definition: session.api:307
static session_t * listen_session_get_from_handle(session_handle_t handle)
Definition: session.h:571
int vnet_app_del_cert_key_pair(u32 index)
Definition: application.c:1728
static int svm_msg_q_get_producer_eventfd(svm_msg_q_t *mq)
session_evt_type_t
static transport_proto_t session_get_transport_proto(session_t *s)
struct _vnet_app_namespace_add_del_args vnet_app_namespace_add_del_args_t
application_t * application_lookup(u32 api_client_index)
Definition: application.c:394
static int mq_send_del_segment_cb(u32 app_wrk_index, u64 segment_handle)
Definition: session_api.c:512
u16 key_len
Definition: ikev2_types.api:95
Request for map server summary status.
Definition: one.api:808
vlib_main_t * vm
Definition: in2out_ed.c:1582
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define foreach_session_api_msg
Definition: session_api.c:45
u32 flags
Session flags.
u16 mask
Definition: flow_types.api:52
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
app_worker_t * application_get_worker(application_t *app, u32 wrk_map_index)
Definition: application.c:663
application_t * application_get_if_valid(u32 app_index)
Definition: application.c:434
segment_manager_props_t * application_segment_manager_properties(application_t *app)
Definition: application.c:1312
static session_handle_t session_handle(session_t *s)
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
Definition: session.c:1631
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:179
int application_is_proxy(application_t *app)
Definition: application.c:1142
static void mq_send_session_reset_cb(session_t *s)
Definition: session_api.c:247
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
Definition: session_api.c:587
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:513
Application attach reply.
Definition: session.api:59
u32 session_index
global listening session index
Definition: application.h:89
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
Definition: memory_api.c:765
add/del application namespace
Definition: session.api:217
Aggregate type for a prefix.
Definition: fib_types.h:203
static void vl_api_application_tls_cert_add_t_handler(vl_api_application_tls_cert_add_t *mp)
Definition: session_api.c:1086
unsigned int u32
Definition: types.h:88
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:868
u32 app_namespace_index_from_id(const u8 *ns_id)
u16 fp_len
The mask length.
Definition: fib_types.h:207
struct _vnet_app_attach_args_t vnet_app_attach_args_t
static void vl_api_app_worker_add_del_t_handler(vl_api_app_worker_add_del_t *mp)
Definition: session_api.c:687
static void vl_api_session_rules_dump_t_handler(vl_api_one_map_server_dump_t *mp)
Definition: session_api.c:991
static void mq_send_session_cleanup_cb(session_t *s, session_cleanup_ntf_t ntf)
Definition: session_api.c:545
session_t * app_listener_get_local_session(app_listener_t *al)
Definition: application.c:289
#define VL_API_INVALID_FI
Definition: api_common.h:78
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:226
session_t * app_listener_get_session(app_listener_t *al)
Definition: application.c:280
bool is_add[default=true]
Definition: session.api:274
struct _session_rule_add_del_args session_rule_add_del_args_t
static int session_send_fds(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: session_api.c:95
int vnet_session_rule_add_del(session_rule_add_del_args_t *args)
#define REPLY_MACRO(t)
static clib_error_t * application_reaper_cb(u32 client_index)
Definition: session_api.c:1152
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
#define SESSION_INVALID_INDEX
Definition: session_types.h:22
u64 session_segment_handle(session_t *s)
Definition: session.c:1550
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1768
session_handle_t app_listen_session_handle(session_t *ls)
Get app listener handle for listening session.
Definition: application.c:78
static u64 listen_session_get_handle(session_t *s)
Definition: session.h:563
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:227
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
Definition: application.c:827
bool is_local
Definition: ikev2_types.api:33
static int mq_try_lock_and_alloc_msg(svm_msg_q_t *app_mq, svm_msg_q_msg_t *msg)
Definition: session_api.c:110
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
Add certificate and key.
Definition: session.api:90
ssvm_private_t ssvm
ssvm segment data
Definition: fifo_segment.h:68
session_handle_t listener_handle
Parent listener session index if the result of an accept.
session_t * app_worker_first_listener(app_worker_t *app, u8 fib_proto, u8 transport_proto)
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
#define clib_warning(format, args...)
Definition: error.h:59
struct _transport_connection transport_connection_t
static void mq_send_session_disconnected_cb(session_t *s)
Definition: session_api.c:233
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:952
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
static clib_error_t * vl_api_send_fd_msg(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: api.h:107
static u32 vl_api_registration_file_index(vl_api_registration_t *reg)
Definition: api.h:87
application_t * application_get(u32 app_index)
Definition: application.c:426
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: session.api:221
static u32 session_thread_from_handle(session_handle_t handle)
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:910
int fd
memfd segments
Definition: ssvm.h:94
app_listener_t * app_listener_get_w_handle(session_handle_t handle)
Get app listener for listener session handle.
Definition: application.c:88
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:198
bool is_enable[default=true]
Definition: session.api:201
session_t * ct_session_get_peer(session_t *s)
Reply for app namespace add/del.
Definition: session.api:232
Application detach from session layer.
Definition: session.api:77
static fib_protocol_t session_get_fib_proto(session_t *s)
static void mq_send_session_migrate_cb(session_t *s, session_handle_t new_sh)
Definition: session_api.c:423
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
Definition: application.c:887
enum _transport_proto transport_proto_t
#define clib_error_report(e)
Definition: error.h:113
struct _vnet_app_add_cert_key_pair_args_ vnet_app_add_cert_key_pair_args_t
static int mq_send_session_accepted_cb(session_t *s)
Definition: session_api.c:129
vl_api_session_rule_scope_t scope
Definition: session.api:317
static void vl_api_app_attach_t_handler(vl_api_app_attach_t *mp)
Definition: session_api.c:598
u32 ip6_mask_to_preflen(ip6_address_t *mask)
Definition: ip_types.c:547
struct _vnet_app_detach_args_t vnet_app_detach_args_t
static uword pointer_to_uword(const void *p)
Definition: types.h:131
static void vl_api_app_add_cert_key_pair_t_handler(vl_api_app_add_cert_key_pair_t *mp)
Definition: session_api.c:1015
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u8 * name
Definition: ssvm.h:88
u8 thread_index
Index of the thread that allocated the session.
static transport_proto_t api_session_transport_proto_decode(const vl_api_transport_proto_t *api_tp)
Definition: session_api.c:59
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:261
static void setup_message_id_table(api_main_t *am)
Definition: session_api.c:1172
u32 app_index
App index in app pool.
Definition: application.h:98
static u8 session_type_is_ip4(session_type_t st)
static session_cb_vft_t session_mq_cb_vft
Definition: session_api.c:575
add/del application worker
Definition: session.api:158
int mq_send_session_connected_cb(u32 app_wrk_index, u32 api_context, session_t *s, session_error_t err)
Definition: session_api.c:260
app_worker_t * app_worker_get(u32 wrk_index)
u64 session_handle_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
volatile u8 session_state
State in session layer state machine.
#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:1120
ssvm_private_t * session_main_get_evt_q_segment(void)
Definition: session.c:1541
connectionless service
static vl_api_transport_proto_t api_session_transport_proto_encode(const transport_proto_t tp)
Definition: session_api.c:77
VLIB_API_INIT_FUNCTION(session_api_hookup)
session_cleanup_ntf_t
struct _session_lookup_table session_table_t
int vnet_app_worker_add_del(vnet_app_worker_add_del_args_t *a)
Definition: application.c:735
static void vl_api_application_detach_t_handler(vl_api_application_detach_t *mp)
Definition: session_api.c:766
static u8 session_has_transport(session_t *s)
struct _session_rules_table_add_del_args session_rule_table_add_del_args_t
u32 app_index
Index of owning app.
Definition: application.h:43
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:389
static u8 svm_fifo_n_subscribers(svm_fifo_t *f)
Fifo number of subscribers getter.
Definition: svm_fifo.h:618
#define session_table_foreach(VAR, BODY)
Definition: session_table.h:74
Application add TLS certificate WILL BE DEPRECATED POST 20.01
Definition: session.api:127
static u32 vlib_num_workers()
Definition: threads.h:377
enum session_error_ session_error_t
transport_endpoint_t lcl
u32 app_wrk_index
Index of the app worker that owns the session.
static void vl_api_session_rule_add_del_t_handler(vl_api_session_rule_add_del_t *mp)
Definition: session_api.c:836
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
u32 api_client_index
API index for the worker.
Definition: application.h:63
int mq_send_session_bound_cb(u32 app_wrk_index, u32 api_context, session_handle_t handle, int rv)
Definition: session_api.c:340
svm_msg_q_t * event_queue
Application listens for events on this svm queue.
Definition: application.h:46
static transport_service_type_t session_transport_service_type(session_t *s)
struct _svm_fifo svm_fifo_t
Application attach to session layer.
Definition: session.api:37
u8 * vl_api_from_api_to_new_vec(void *mp, vl_api_string_t *astr)
Definition: api_shared.c:1188
Delete certificate and key.
Definition: session.api:114
int vl_api_vec_to_api_string(const u8 *vec, vl_api_string_t *str)
Definition: api_shared.c:1161
static int mq_send_add_segment_cb(u32 app_wrk_index, u64 segment_handle)
Definition: session_api.c:450
non-blocking call - works with both condvar and eventfd signaling
Definition: queue.h:44
bool is_add[default=true]
Definition: session.api:164
static u8 session_main_is_enabled()
Definition: session.h:639
ssvm_segment_type_t ssvm_type(const ssvm_private_t *ssvm)
Definition: ssvm.c:433