FD.io VPP  v21.10.1-2-g0a485f517
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 #include <vnet/ip/ip_types_api.h>
25 
26 #include <vnet/format_fns.h>
27 #include <vnet/session/session.api_enum.h>
28 #include <vnet/session/session.api_types.h>
29 
30 #define REPLY_MSG_ID_BASE session_main.msg_id_base
32 
33 static transport_proto_t
34 api_session_transport_proto_decode (const vl_api_transport_proto_t * api_tp)
35 {
36  switch (*api_tp)
37  {
39  return TRANSPORT_PROTO_TCP;
41  return TRANSPORT_PROTO_UDP;
43  return TRANSPORT_PROTO_TLS;
45  return TRANSPORT_PROTO_QUIC;
46  default:
47  return TRANSPORT_PROTO_NONE;
48  }
49 }
50 
51 static vl_api_transport_proto_t
53 {
54  switch (tp)
55  {
56  case TRANSPORT_PROTO_TCP:
58  case TRANSPORT_PROTO_UDP:
60  case TRANSPORT_PROTO_TLS:
62  case TRANSPORT_PROTO_QUIC:
64  default:
66  }
67 }
68 
69 static int
70 session_send_fds (vl_api_registration_t * reg, int fds[], int n_fds)
71 {
74  return SESSION_E_BAPI_NO_FD;
75  error = vl_api_send_fd_msg (reg, fds, n_fds);
76  if (error)
77  {
79  return SESSION_E_BAPI_SEND_FD;
80  }
81  return 0;
82 }
83 
84 static int
86 {
87  int rv;
88  u8 try = 0;
89  while (try < 100)
90  {
93  SVM_Q_NOWAIT, msg);
94  if (!rv)
95  return 0;
96  /*
97  * Break the loop if mq is full, usually this is because the
98  * app has crashed or is hanging on somewhere.
99  */
100  if (rv != -1)
101  break;
102  try++;
103  usleep (1);
104  }
105  clib_warning ("failed to alloc msg");
106  return -1;
107 }
108 
109 static int
111 {
112  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
113  svm_msg_q_msg_t _msg, *msg = &_msg;
114  session_accepted_msg_t m = { 0 };
115  svm_msg_q_t *app_mq;
116  fifo_segment_t *eq_seg;
118  session_event_t *evt;
119  application_t *app;
120 
121  app = application_get (app_wrk->app_index);
122 
123  m.context = app->app_index;
127  m.flags = s->flags;
128 
129  eq_seg = application_get_rx_mqs_segment (app);
130 
131  if (session_has_transport (s))
132  {
135  if (application_is_proxy (app))
136  {
137  listener =
140  if (listener)
142  }
145  m.mq_index = s->thread_index;
146  m.handle = session_handle (s);
147 
148  session_get_endpoint (s, &m.rmt, 0 /* is_lcl */);
149  session_get_endpoint (s, &m.lcl, 1 /* is_lcl */);
150  }
151  else
152  {
153  ct_connection_t *ct;
154 
158  m.rmt.is_ip4 = session_type_is_ip4 (listener->session_type);
159  m.rmt.port = ct->c_rmt_port;
160  m.lcl.port = ct->c_lcl_port;
161  m.handle = session_handle (s);
164  m.mq_index = s->thread_index;
165  }
166 
167  app_mq = app_wrk->event_queue;
168  if (mq_try_lock_and_alloc_msg (app_mq, msg))
169  return SESSION_E_MQ_MSG_ALLOC;
170 
171  evt = svm_msg_q_msg_data (app_mq, msg);
172  clib_memset (evt, 0, sizeof (*evt));
173  evt->event_type = SESSION_CTRL_EVT_ACCEPTED;
174  clib_memcpy_fast (evt->data, &m, sizeof (m));
175  svm_msg_q_add_and_unlock (app_mq, msg);
176 
177  return 0;
178 }
179 
180 static inline void
182  session_evt_type_t evt_type)
183 {
184  svm_msg_q_msg_t _msg, *msg = &_msg;
186  svm_msg_q_t *app_mq;
187  session_event_t *evt;
188 
189  app_mq = app_wrk->event_queue;
190  if (mq_try_lock_and_alloc_msg (app_mq, msg))
191  return;
192  evt = svm_msg_q_msg_data (app_mq, msg);
193  clib_memset (evt, 0, sizeof (*evt));
194  evt->event_type = evt_type;
195  mp = (session_disconnected_msg_t *) evt->data;
196  mp->handle = sh;
197  mp->context = app_wrk->api_client_index;
198  svm_msg_q_add_and_unlock (app_mq, msg);
199 }
200 
201 static inline void
203  svm_fifo_t * f, session_evt_type_t evt_type)
204 {
205  app_worker_t *app_wrk;
206  application_t *app;
207  int i;
208 
209  app = application_get (app_index);
210  if (!app)
211  return;
212 
213  for (i = 0; i < f->shr->n_subscribers; i++)
214  {
215  if (!(app_wrk = application_get_worker (app, f->shr->subscribers[i])))
216  continue;
218  }
219 }
220 
221 static void
223 {
224  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
226 
229 
233 }
234 
235 static void
237 {
238  app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
240 
242 
246 }
247 
248 int
249 mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
250  session_t * s, session_error_t err)
251 {
252  svm_msg_q_msg_t _msg, *msg = &_msg;
253  session_connected_msg_t m = { 0 };
254  svm_msg_q_t *app_mq;
256  fifo_segment_t *eq_seg;
257  app_worker_t *app_wrk;
258  session_event_t *evt;
259  application_t *app;
260 
261  app_wrk = app_worker_get (app_wrk_index);
262 
263  m.context = api_context;
264  m.retval = err;
265 
266  if (err)
267  goto snd_msg;
268 
269  app = application_get (app_wrk->app_index);
270  eq_seg = application_get_rx_mqs_segment (app);
271 
272  if (session_has_transport (s))
273  {
274  tc = session_get_transport (s);
275  if (!tc)
276  {
277  clib_warning ("failed to retrieve transport!");
278  m.retval = SESSION_E_REFUSED;
279  goto snd_msg;
280  }
281 
282  m.handle = session_handle (s);
285 
286  session_get_endpoint (s, &m.lcl, 1 /* is_lcl */);
287 
291  m.mq_index = s->thread_index;
292  }
293  else
294  {
295  ct_connection_t *cct;
296  session_t *ss;
297 
299  m.handle = session_handle (s);
300  m.lcl.port = cct->c_lcl_port;
301  m.lcl.is_ip4 = cct->c_is_ip4;
307  ss = ct_session_get_peer (s);
311  m.mq_index = s->thread_index;
312  }
313 
314  /* Setup client session index in advance, in case data arrives
315  * before the app processes message and updates it */
316  s->rx_fifo->shr->client_session_index = api_context;
317  s->tx_fifo->shr->client_session_index = api_context;
318 
319 snd_msg:
320 
321  app_mq = app_wrk->event_queue;
322 
323  if (mq_try_lock_and_alloc_msg (app_mq, msg))
324  return SESSION_E_MQ_MSG_ALLOC;
325 
326  evt = svm_msg_q_msg_data (app_mq, msg);
327  clib_memset (evt, 0, sizeof (*evt));
328  evt->event_type = SESSION_CTRL_EVT_CONNECTED;
329  clib_memcpy_fast (evt->data, &m, sizeof (m));
330 
331  svm_msg_q_add_and_unlock (app_mq, msg);
332  return 0;
333 }
334 
335 int
336 mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
337  session_handle_t handle, int rv)
338 {
339  svm_msg_q_msg_t _msg, *msg = &_msg;
340  session_bound_msg_t m = { 0 };
341  svm_msg_q_t *app_mq;
343  fifo_segment_t *eq_seg;
344  app_worker_t *app_wrk;
345  session_event_t *evt;
346  application_t *app;
347  app_listener_t *al;
348  session_t *ls = 0;
349 
350  app_wrk = app_worker_get (app_wrk_index);
351 
352  m.context = api_context;
353  m.retval = rv;
354 
355  if (rv)
356  goto snd_msg;
357 
358  m.handle = handle;
359  al = app_listener_get_w_handle (handle);
361  ls = app_listener_get_session (al);
362  else
364 
365  session_get_endpoint (ls, &tep, 1 /* is_lcl */);
366  m.lcl_port = tep.port;
367  m.lcl_is_ip4 = tep.is_ip4;
368  clib_memcpy_fast (m.lcl_ip, &tep.ip, sizeof (tep.ip));
369  app = application_get (app_wrk->app_index);
370  eq_seg = application_get_rx_mqs_segment (app);
372  m.mq_index = ls->thread_index;
373 
375  ls->rx_fifo)
376  {
380  }
381 
382 snd_msg:
383 
384  app_mq = app_wrk->event_queue;
385 
386  if (mq_try_lock_and_alloc_msg (app_mq, msg))
387  return SESSION_E_MQ_MSG_ALLOC;
388 
389  evt = svm_msg_q_msg_data (app_mq, msg);
390  clib_memset (evt, 0, sizeof (*evt));
391  evt->event_type = SESSION_CTRL_EVT_BOUND;
392  clib_memcpy_fast (evt->data, &m, sizeof (m));
393 
394  svm_msg_q_add_and_unlock (app_mq, msg);
395  return 0;
396 }
397 
398 void
400  u32 context, int rv)
401 {
402  svm_msg_q_msg_t _msg, *msg = &_msg;
404  svm_msg_q_t *app_mq;
405  session_event_t *evt;
406 
407  app_mq = app_wrk->event_queue;
408  if (mq_try_lock_and_alloc_msg (app_mq, msg))
409  return;
410 
411  evt = svm_msg_q_msg_data (app_mq, msg);
412  clib_memset (evt, 0, sizeof (*evt));
413  evt->event_type = SESSION_CTRL_EVT_UNLISTEN_REPLY;
414  ump = (session_unlisten_reply_msg_t *) evt->data;
415  ump->context = context;
416  ump->handle = sh;
417  ump->retval = rv;
418  svm_msg_q_add_and_unlock (app_mq, msg);
419 }
420 
421 static void
423 {
424  svm_msg_q_msg_t _msg, *msg = &_msg;
425  session_migrated_msg_t m = { 0 };
426  fifo_segment_t *eq_seg;
427  app_worker_t *app_wrk;
428  session_event_t *evt;
429  svm_msg_q_t *app_mq;
430  application_t *app;
432 
434  app_wrk = app_worker_get (s->app_wrk_index);
435  app_mq = app_wrk->event_queue;
436  app = application_get (app_wrk->app_index);
437  eq_seg = application_get_rx_mqs_segment (app);
438 
439  m.handle = session_handle (s);
440  m.new_handle = new_sh;
444 
445  if (mq_try_lock_and_alloc_msg (app_mq, msg))
446  return;
447 
448  evt = svm_msg_q_msg_data (app_mq, msg);
449  clib_memset (evt, 0, sizeof (*evt));
450  evt->event_type = SESSION_CTRL_EVT_MIGRATED;
451  clib_memcpy_fast (evt->data, &m, sizeof (m));
452 
453  svm_msg_q_add_and_unlock (app_mq, msg);
454 }
455 
456 static int
457 mq_send_add_segment_cb (u32 app_wrk_index, u64 segment_handle)
458 {
459  int fds[SESSION_N_FD_TYPE], n_fds = 0;
460  svm_msg_q_msg_t _msg, *msg = &_msg;
463  app_worker_t *app_wrk;
464  session_event_t *evt;
465  svm_msg_q_t *app_mq;
466  fifo_segment_t *fs;
467  ssvm_private_t *sp;
468  u8 fd_flags = 0;
469 
470  app_wrk = app_worker_get (app_wrk_index);
471 
473  if (!reg)
474  {
475  clib_warning ("no api registration for client: %u",
476  app_wrk->api_client_index);
477  return -1;
478  }
479 
480  fs = segment_manager_get_segment_w_handle (segment_handle);
481  sp = &fs->ssvm;
482  if (ssvm_type (sp) == SSVM_SEGMENT_MEMFD)
483  {
485  {
486  clib_warning ("can't send memfd fd");
487  return -1;
488  }
489 
490  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
491  fds[n_fds] = sp->fd;
492  n_fds += 1;
493  }
494 
495  app_mq = app_wrk->event_queue;
496  if (mq_try_lock_and_alloc_msg (app_mq, msg))
497  return -1;
498 
499  if (n_fds)
500  session_send_fds (reg, fds, n_fds);
501 
502  evt = svm_msg_q_msg_data (app_mq, msg);
503  clib_memset (evt, 0, sizeof (*evt));
504  evt->event_type = SESSION_CTRL_EVT_APP_ADD_SEGMENT;
505  mp = (session_app_add_segment_msg_t *) evt->data;
506  clib_memset (mp, 0, sizeof (*mp));
507  mp->segment_size = sp->ssvm_size;
508  mp->fd_flags = fd_flags;
509  mp->segment_handle = segment_handle;
510  strncpy ((char *) mp->segment_name, (char *) sp->name,
511  sizeof (mp->segment_name) - 1);
512 
513  svm_msg_q_add_and_unlock (app_mq, msg);
514 
515  return 0;
516 }
517 
518 static int
519 mq_send_del_segment_cb (u32 app_wrk_index, u64 segment_handle)
520 {
521  svm_msg_q_msg_t _msg, *msg = &_msg;
524  app_worker_t *app_wrk;
525  session_event_t *evt;
526  svm_msg_q_t *app_mq;
527 
528  app_wrk = app_worker_get (app_wrk_index);
530  if (!reg)
531  {
532  clib_warning ("no registration: %u", app_wrk->api_client_index);
533  return -1;
534  }
535 
536  app_mq = app_wrk->event_queue;
537  if (mq_try_lock_and_alloc_msg (app_mq, msg))
538  return -1;
539 
540  evt = svm_msg_q_msg_data (app_mq, msg);
541  clib_memset (evt, 0, sizeof (*evt));
542  evt->event_type = SESSION_CTRL_EVT_APP_DEL_SEGMENT;
543  mp = (session_app_del_segment_msg_t *) evt->data;
544  clib_memset (mp, 0, sizeof (*mp));
545  mp->segment_handle = segment_handle;
546  svm_msg_q_add_and_unlock (app_mq, msg);
547 
548  return 0;
549 }
550 
551 static void
553 {
554  svm_msg_q_msg_t _msg, *msg = &_msg;
556  svm_msg_q_t *app_mq;
557  session_event_t *evt;
558  app_worker_t *app_wrk;
559 
560  /* Propagate transport cleanup notifications only if app didn't close */
561  if (ntf == SESSION_CLEANUP_TRANSPORT
562  && s->session_state != SESSION_STATE_TRANSPORT_DELETED)
563  return;
564 
565  app_wrk = app_worker_get_if_valid (s->app_wrk_index);
566  if (!app_wrk)
567  return;
568 
569  app_mq = app_wrk->event_queue;
570  if (mq_try_lock_and_alloc_msg (app_mq, msg))
571  return;
572 
573  evt = svm_msg_q_msg_data (app_mq, msg);
574  clib_memset (evt, 0, sizeof (*evt));
575  evt->event_type = SESSION_CTRL_EVT_CLEANUP;
576  mp = (session_cleanup_msg_t *) evt->data;
577  mp->handle = session_handle (s);
578  mp->type = ntf;
579  svm_msg_q_add_and_unlock (app_mq, msg);
580 }
581 
584  .session_disconnect_callback = mq_send_session_disconnected_cb,
585  .session_connected_callback = mq_send_session_connected_cb,
586  .session_reset_callback = mq_send_session_reset_cb,
587  .session_migrate_callback = mq_send_session_migrate_cb,
588  .session_cleanup_callback = mq_send_session_cleanup_cb,
589  .add_segment_callback = mq_send_add_segment_cb,
590  .del_segment_callback = mq_send_del_segment_cb,
591 };
592 
593 static void
595 {
596  vl_api_session_enable_disable_reply_t *rmp;
598  int rv = 0;
599 
601  REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
602 }
603 
604 static void
606 {
607  int rv = 0, *fds = 0, n_fds = 0, n_workers, i;
608  fifo_segment_t *segp, *rx_mqs_seg = 0;
609  vnet_app_attach_args_t _a, *a = &_a;
611  u8 fd_flags = 0, ctrl_thread;
613  svm_msg_q_t *rx_mq;
614  application_t *app;
615 
617  if (!reg)
618  return;
619 
620  n_workers = vlib_num_workers ();
622  {
623  rv = VNET_API_ERROR_FEATURE_DISABLED;
624  goto done;
625  }
626  /* Only support binary api with socket transport */
628  {
629  rv = VNET_API_ERROR_APP_UNSUPPORTED_CFG;
630  goto done;
631  }
632 
634  sizeof (mp->options),
635  "Out of options, fix api message definition");
636 
637  clib_memset (a, 0, sizeof (*a));
638  a->api_client_index = mp->client_index;
639  a->options = mp->options;
640  a->session_cb_vft = &session_mq_cb_vft;
641  a->namespace_id = vl_api_from_api_to_new_vec (mp, &mp->namespace_id);
642 
643  if ((rv = vnet_application_attach (a)))
644  {
645  clib_warning ("attach returned: %d", rv);
646  vec_free (a->namespace_id);
647  goto done;
648  }
649  vec_free (a->namespace_id);
650 
651  vec_validate (fds, 3 /* segs + tx evtfd */ + n_workers);
652 
653  /* Send rx mqs segment */
654  app = application_get (a->app_index);
655  rx_mqs_seg = application_get_rx_mqs_segment (app);
656 
657  fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
658  fds[n_fds] = rx_mqs_seg->ssvm.fd;
659  n_fds += 1;
660 
661  /* Send fifo segment fd if needed */
662  if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
663  {
664  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
665  fds[n_fds] = a->segment->fd;
666  n_fds += 1;
667  }
668  if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
669  {
670  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
671  fds[n_fds] = svm_msg_q_get_eventfd (a->app_evt_q);
672  n_fds += 1;
673  }
674 
676  {
677  fd_flags |= SESSION_FD_F_VPP_MQ_EVENTFD;
678  for (i = 0; i < n_workers + 1; i++)
679  {
680  rx_mq = application_rx_mq_get (app, i);
681  fds[n_fds] = svm_msg_q_get_eventfd (rx_mq);
682  n_fds += 1;
683  }
684  }
685 
686 done:
687  /* *INDENT-OFF* */
688  REPLY_MACRO2 (VL_API_APP_ATTACH_REPLY, ({
689  if (!rv)
690  {
691  ctrl_thread = n_workers ? 1 : 0;
692  segp = (fifo_segment_t *) a->segment;
693  rmp->app_index = clib_host_to_net_u32 (a->app_index);
694  rmp->app_mq = fifo_segment_msg_q_offset (segp, 0);
695  rmp->vpp_ctrl_mq = fifo_segment_msg_q_offset (rx_mqs_seg, ctrl_thread);
696  rmp->vpp_ctrl_mq_thread = ctrl_thread;
697  rmp->n_fds = n_fds;
698  rmp->fd_flags = fd_flags;
699  if (vec_len (segp->ssvm.name))
700  {
702  }
703  rmp->segment_size = segp->ssvm.ssvm_size;
704  rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
705  }
706  }));
707  /* *INDENT-ON* */
708 
709  if (n_fds)
710  session_send_fds (reg, fds, n_fds);
711  vec_free (fds);
712 }
713 
714 static void
716 {
717  int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
720  application_t *app;
721  u8 fd_flags = 0;
722 
724  {
725  rv = VNET_API_ERROR_FEATURE_DISABLED;
726  goto done;
727  }
728 
730  if (!reg)
731  return;
732 
733  app = application_get_if_valid (clib_net_to_host_u32 (mp->app_index));
734  if (!app)
735  {
736  rv = VNET_API_ERROR_INVALID_VALUE;
737  goto done;
738  }
739 
741  .app_index = app->app_index,
742  .wrk_map_index = clib_net_to_host_u32 (mp->wrk_index),
743  .api_client_index = mp->client_index,
744  .is_add = mp->is_add
745  };
746  rv = vnet_app_worker_add_del (&args);
747  if (rv)
748  {
749  clib_warning ("app worker add/del returned: %d", rv);
750  goto done;
751  }
752 
753  if (!mp->is_add)
754  goto done;
755 
756  /* Send fifo segment fd if needed */
757  if (ssvm_type (args.segment) == SSVM_SEGMENT_MEMFD)
758  {
759  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
760  fds[n_fds] = args.segment->fd;
761  n_fds += 1;
762  }
763  if (application_segment_manager_properties (app)->use_mq_eventfd)
764  {
765  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
766  fds[n_fds] = svm_msg_q_get_eventfd (args.evt_q);
767  n_fds += 1;
768  }
769 
770  /* *INDENT-OFF* */
771 done:
772  REPLY_MACRO2 (VL_API_APP_WORKER_ADD_DEL_REPLY, ({
773  rmp->is_add = mp->is_add;
774  rmp->wrk_index = clib_host_to_net_u32 (args.wrk_map_index);
775  rmp->segment_handle = clib_host_to_net_u64 (args.segment_handle);
776  if (!rv && mp->is_add)
777  {
779  fifo_segment_msg_q_offset ((fifo_segment_t *) args.segment, 0);
780  rmp->n_fds = n_fds;
781  rmp->fd_flags = fd_flags;
782  if (vec_len (args.segment->name))
783  {
784  vl_api_vec_to_api_string (args.segment->name, &rmp->segment_name);
785  }
786  }
787  }));
788  /* *INDENT-ON* */
789 
790  if (n_fds)
791  session_send_fds (reg, fds, n_fds);
792 }
793 
794 static void
796 {
797  vl_api_application_detach_reply_t *rmp;
798  int rv = VNET_API_ERROR_INVALID_VALUE_2;
799  vnet_app_detach_args_t _a, *a = &_a;
800  application_t *app;
801 
803  {
804  rv = VNET_API_ERROR_FEATURE_DISABLED;
805  goto done;
806  }
807 
808  app = application_lookup (mp->client_index);
809  if (app)
810  {
811  a->app_index = app->app_index;
812  a->api_client_index = mp->client_index;
814  }
815 
816 done:
817  REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY);
818 }
819 
820 static void
822 {
824  u32 appns_index = 0;
825  u8 *ns_id = 0;
826  int rv = 0;
827  if (session_main_is_enabled () == 0)
828  {
829  rv = VNET_API_ERROR_FEATURE_DISABLED;
830  goto done;
831  }
832 
833  ns_id = vl_api_from_api_to_new_vec (mp, &mp->namespace_id);
834 
836  .ns_id = ns_id,
837  .netns = 0,
838  .sock_name = 0,
839  .secret = clib_net_to_host_u64 (mp->secret),
840  .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
841  .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
842  .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id),
843  .is_add = 1
844  };
845  rv = vnet_app_namespace_add_del (&args);
846  if (!rv)
847  {
848  appns_index = app_namespace_index_from_id (ns_id);
849  if (appns_index == APP_NAMESPACE_INVALID_INDEX)
850  {
851  clib_warning ("app ns lookup failed");
852  rv = VNET_API_ERROR_UNSPECIFIED;
853  }
854  }
855  vec_free (ns_id);
856 
857  /* *INDENT-OFF* */
858 done:
859  REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_REPLY, ({
860  if (!rv)
861  rmp->appns_index = clib_host_to_net_u32 (appns_index);
862  }));
863  /* *INDENT-ON* */
864 }
865 
866 static void
869 {
871  u8 *ns_id = 0, *netns = 0;
872  u32 appns_index = 0;
873  int rv = 0;
874 
875  if (session_main_is_enabled () == 0)
876  {
877  rv = VNET_API_ERROR_FEATURE_DISABLED;
878  goto done;
879  }
880 
881  mp->namespace_id[sizeof (mp->namespace_id) - 1] = 0;
882  mp->netns[sizeof (mp->netns) - 1] = 0;
883  ns_id = format (0, "%s", &mp->namespace_id);
884  netns = format (0, "%s", &mp->netns);
885 
887  .ns_id = ns_id,
888  .netns = netns,
889  .sock_name = 0,
890  .secret = clib_net_to_host_u64 (mp->secret),
891  .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
892  .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
893  .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id),
894  .is_add = 1
895  };
896  rv = vnet_app_namespace_add_del (&args);
897  if (!rv)
898  {
899  appns_index = app_namespace_index_from_id (ns_id);
900  if (appns_index == APP_NAMESPACE_INVALID_INDEX)
901  {
902  clib_warning ("app ns lookup failed id:%s", ns_id);
903  rv = VNET_API_ERROR_UNSPECIFIED;
904  }
905  }
906  vec_free (ns_id);
907  vec_free (netns);
908 
909 done:
910  REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_V2_REPLY, ({
911  if (!rv)
912  rmp->appns_index = clib_host_to_net_u32 (appns_index);
913  }));
914 }
915 
916 static void
919 {
921  u8 *ns_id = 0, *netns = 0, *sock_name = 0;
922  u32 appns_index = 0;
923  int rv = 0;
924  if (session_main_is_enabled () == 0)
925  {
926  rv = VNET_API_ERROR_FEATURE_DISABLED;
927  goto done;
928  }
929  mp->namespace_id[sizeof (mp->namespace_id) - 1] = 0;
930  mp->netns[sizeof (mp->netns) - 1] = 0;
931  ns_id = format (0, "%s", &mp->namespace_id);
932  netns = format (0, "%s", &mp->netns);
933  sock_name = vl_api_from_api_to_new_vec (mp, &mp->sock_name);
935  .ns_id = ns_id,
936  .netns = netns,
937  .sock_name = sock_name,
938  .secret = clib_net_to_host_u64 (mp->secret),
939  .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
940  .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
941  .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id),
942  .is_add = mp->is_add,
943  };
944  rv = vnet_app_namespace_add_del (&args);
945  if (!rv && mp->is_add)
946  {
947  appns_index = app_namespace_index_from_id (ns_id);
948  if (appns_index == APP_NAMESPACE_INVALID_INDEX)
949  {
950  clib_warning ("app ns lookup failed id:%s", ns_id);
951  rv = VNET_API_ERROR_UNSPECIFIED;
952  }
953  }
954  vec_free (ns_id);
955  vec_free (netns);
956  vec_free (sock_name);
957 done:
958  REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_V3_REPLY, ({
959  if (!rv)
960  rmp->appns_index = clib_host_to_net_u32 (appns_index);
961  }));
962 }
963 
964 static void
966 {
967  vl_api_session_rule_add_del_reply_t *rmp;
969  session_rule_table_add_del_args_t *table_args = &args.table_args;
970  int rv = 0;
971 
972  clib_memset (&args, 0, sizeof (args));
973 
974  ip_prefix_decode (&mp->lcl, &table_args->lcl);
975  ip_prefix_decode (&mp->rmt, &table_args->rmt);
976 
977  table_args->lcl_port = mp->lcl_port;
978  table_args->rmt_port = mp->rmt_port;
979  table_args->action_index = clib_net_to_host_u32 (mp->action_index);
980  table_args->is_add = mp->is_add;
981  mp->tag[sizeof (mp->tag) - 1] = 0;
982  table_args->tag = format (0, "%s", mp->tag);
983  args.appns_index = clib_net_to_host_u32 (mp->appns_index);
984  args.scope = mp->scope;
985  args.transport_proto =
987  TRANSPORT_PROTO_UDP ? 1 : 0;
988 
989  rv = vnet_session_rule_add_del (&args);
990  if (rv)
991  clib_warning ("rule add del returned: %d", rv);
992  vec_free (table_args->tag);
993  REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY);
994 }
995 
996 static void
997 send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
998  u8 transport_proto, u32 appns_index, u8 * tag,
1000 {
1002  session_mask_or_match_4_t *match =
1003  (session_mask_or_match_4_t *) & rule->match;
1004  session_mask_or_match_4_t *mask =
1005  (session_mask_or_match_4_t *) & rule->mask;
1006  fib_prefix_t lcl, rmt;
1007 
1008  rmp = vl_msg_api_alloc (sizeof (*rmp));
1009  clib_memset (rmp, 0, sizeof (*rmp));
1010  rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SESSION_RULES_DETAILS);
1011  rmp->context = context;
1012 
1013  clib_memset (&lcl, 0, sizeof (lcl));
1014  clib_memset (&rmt, 0, sizeof (rmt));
1015  ip_set (&lcl.fp_addr, &match->lcl_ip, 1);
1016  ip_set (&rmt.fp_addr, &match->rmt_ip, 1);
1017  lcl.fp_len = ip4_mask_to_preflen (&mask->lcl_ip);
1018  rmt.fp_len = ip4_mask_to_preflen (&mask->rmt_ip);
1019 
1020  ip_prefix_encode (&lcl, &rmp->lcl);
1021  ip_prefix_encode (&rmt, &rmp->rmt);
1022  rmp->lcl_port = match->lcl_port;
1023  rmp->rmt_port = match->rmt_port;
1024  rmp->action_index = clib_host_to_net_u32 (rule->action_index);
1025  rmp->scope =
1028  rmp->appns_index = clib_host_to_net_u32 (appns_index);
1029  if (tag)
1030  {
1031  clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
1032  rmp->tag[vec_len (tag)] = 0;
1033  }
1034 
1035  vl_api_send_msg (reg, (u8 *) rmp);
1036 }
1037 
1038 static void
1039 send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
1040  u8 transport_proto, u32 appns_index, u8 * tag,
1042 {
1044  session_mask_or_match_6_t *match =
1045  (session_mask_or_match_6_t *) & rule->match;
1046  session_mask_or_match_6_t *mask =
1047  (session_mask_or_match_6_t *) & rule->mask;
1048  fib_prefix_t lcl, rmt;
1049 
1050  rmp = vl_msg_api_alloc (sizeof (*rmp));
1051  clib_memset (rmp, 0, sizeof (*rmp));
1052  rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SESSION_RULES_DETAILS);
1053  rmp->context = context;
1054 
1055  clib_memset (&lcl, 0, sizeof (lcl));
1056  clib_memset (&rmt, 0, sizeof (rmt));
1057  ip_set (&lcl.fp_addr, &match->lcl_ip, 0);
1058  ip_set (&rmt.fp_addr, &match->rmt_ip, 0);
1059  lcl.fp_len = ip6_mask_to_preflen (&mask->lcl_ip);
1060  rmt.fp_len = ip6_mask_to_preflen (&mask->rmt_ip);
1061 
1062  ip_prefix_encode (&lcl, &rmp->lcl);
1063  ip_prefix_encode (&rmt, &rmp->rmt);
1064  rmp->lcl_port = match->lcl_port;
1065  rmp->rmt_port = match->rmt_port;
1066  rmp->action_index = clib_host_to_net_u32 (rule->action_index);
1067  rmp->scope =
1070  rmp->appns_index = clib_host_to_net_u32 (appns_index);
1071  if (tag)
1072  {
1073  clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
1074  rmp->tag[vec_len (tag)] = 0;
1075  }
1076 
1077  vl_api_send_msg (reg, (u8 *) rmp);
1078 }
1079 
1080 static void
1082  u8 tp, u8 is_local, u32 appns_index,
1084 {
1085  mma_rule_16_t *rule16;
1086  mma_rule_40_t *rule40;
1087  mma_rules_table_16_t *srt16;
1088  mma_rules_table_40_t *srt40;
1089  u32 ri;
1090 
1091  if (is_local || fib_proto == FIB_PROTOCOL_IP4)
1092  {
1093  u8 *tag = 0;
1094  /* *INDENT-OFF* */
1095  srt16 = &srt->session_rules_tables_16;
1096  pool_foreach (rule16, srt16->rules) {
1097  ri = mma_rules_table_rule_index_16 (srt16, rule16);
1098  tag = session_rules_table_rule_tag (srt, ri, 1);
1099  send_session_rule_details4 (rule16, is_local, tp, appns_index, tag,
1100  reg, context);
1101  }
1102  /* *INDENT-ON* */
1103  }
1104  if (is_local || fib_proto == FIB_PROTOCOL_IP6)
1105  {
1106  u8 *tag = 0;
1107  /* *INDENT-OFF* */
1108  srt40 = &srt->session_rules_tables_40;
1109  pool_foreach (rule40, srt40->rules) {
1110  ri = mma_rules_table_rule_index_40 (srt40, rule40);
1111  tag = session_rules_table_rule_tag (srt, ri, 1);
1112  send_session_rule_details6 (rule40, is_local, tp, appns_index, tag,
1113  reg, context);
1114  }
1115  /* *INDENT-ON* */
1116  }
1117 }
1118 
1119 static void
1121 {
1122  vl_api_registration_t *reg;
1123  session_table_t *st;
1124  u8 tp;
1125 
1127  if (!reg)
1128  return;
1129 
1130  /* *INDENT-OFF* */
1131  session_table_foreach (st, ({
1132  for (tp = 0; tp < TRANSPORT_N_PROTOS; tp++)
1133  {
1134  send_session_rules_table_details (&st->session_rules[tp],
1135  st->active_fib_proto, tp,
1136  st->is_local, st->appns_index, reg,
1137  mp->context);
1138  }
1139  }));
1140  /* *INDENT-ON* */
1141 }
1142 
1143 static void
1145 {
1148  u32 certkey_len, key_len, cert_len;
1149  int rv = 0;
1150  if (session_main_is_enabled () == 0)
1151  {
1152  rv = VNET_API_ERROR_FEATURE_DISABLED;
1153  goto done;
1154  }
1155 
1156  cert_len = clib_net_to_host_u16 (mp->cert_len);
1157  if (cert_len > 10000)
1158  {
1159  rv = VNET_API_ERROR_INVALID_VALUE;
1160  goto done;
1161  }
1162 
1163  certkey_len = clib_net_to_host_u16 (mp->certkey_len);
1164  if (certkey_len < cert_len)
1165  {
1166  rv = VNET_API_ERROR_INVALID_VALUE;
1167  goto done;
1168  }
1169 
1170  key_len = certkey_len - cert_len;
1171  if (key_len > 10000)
1172  {
1173  rv = VNET_API_ERROR_INVALID_VALUE;
1174  goto done;
1175  }
1176 
1177  clib_memset (a, 0, sizeof (*a));
1178  a->cert = mp->certkey;
1179  a->key = mp->certkey + cert_len;
1180  a->cert_len = cert_len;
1181  a->key_len = key_len;
1183 
1184 done:
1185  /* *INDENT-OFF* */
1186  REPLY_MACRO2 (VL_API_APP_ADD_CERT_KEY_PAIR_REPLY, ({
1187  if (!rv)
1188  rmp->index = clib_host_to_net_u32 (a->index);
1189  }));
1190  /* *INDENT-ON* */
1191 }
1192 
1193 static void
1195 {
1196  vl_api_app_del_cert_key_pair_reply_t *rmp;
1197  u32 ckpair_index;
1198  int rv = 0;
1199  if (session_main_is_enabled () == 0)
1200  {
1201  rv = VNET_API_ERROR_FEATURE_DISABLED;
1202  goto done;
1203  }
1204  ckpair_index = clib_net_to_host_u32 (mp->index);
1205  rv = vnet_app_del_cert_key_pair (ckpair_index);
1206 
1207 done:
1208  REPLY_MACRO (VL_API_APP_DEL_CERT_KEY_PAIR_REPLY);
1209 }
1210 
1211 static clib_error_t *
1213 {
1214  application_t *app = application_lookup (client_index);
1215  vnet_app_detach_args_t _a, *a = &_a;
1216  if (app)
1217  {
1218  a->app_index = app->app_index;
1219  a->api_client_index = client_index;
1221  }
1222  return 0;
1223 }
1224 
1226 
1227 /*
1228  * Socket api functions
1229  */
1230 
1231 static void
1232 sapi_send_fds (app_worker_t * app_wrk, int *fds, int n_fds)
1233 {
1234  app_sapi_msg_t smsg = { 0 };
1235  app_namespace_t *app_ns;
1236  application_t *app;
1237  clib_socket_t *cs;
1238  u32 cs_index;
1239 
1240  app = application_get (app_wrk->app_index);
1241  app_ns = app_namespace_get (app->ns_index);
1242  cs_index = appns_sapi_handle_sock_index (app_wrk->api_client_index);
1243  cs = appns_sapi_get_socket (app_ns, cs_index);
1244  if (PREDICT_FALSE (!cs))
1245  return;
1246 
1247  /* There's no payload for the message only the type */
1249  clib_socket_sendmsg (cs, &smsg, sizeof (smsg), fds, n_fds);
1250 }
1251 
1252 static int
1253 mq_send_add_segment_sapi_cb (u32 app_wrk_index, u64 segment_handle)
1254 {
1255  int fds[SESSION_N_FD_TYPE], n_fds = 0;
1256  svm_msg_q_msg_t _msg, *msg = &_msg;
1258  app_worker_t *app_wrk;
1259  session_event_t *evt;
1260  svm_msg_q_t *app_mq;
1261  fifo_segment_t *fs;
1262  ssvm_private_t *sp;
1263  u8 fd_flags = 0;
1264 
1265  app_wrk = app_worker_get (app_wrk_index);
1266 
1267  fs = segment_manager_get_segment_w_handle (segment_handle);
1268  sp = &fs->ssvm;
1270 
1271  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
1272  fds[n_fds] = sp->fd;
1273  n_fds += 1;
1274 
1275  app_mq = app_wrk->event_queue;
1276  if (mq_try_lock_and_alloc_msg (app_mq, msg))
1277  return -1;
1278 
1279  /*
1280  * Send the fd over api socket
1281  */
1282  sapi_send_fds (app_wrk, fds, n_fds);
1283 
1284  /*
1285  * Send the actual message over mq
1286  */
1287  evt = svm_msg_q_msg_data (app_mq, msg);
1288  clib_memset (evt, 0, sizeof (*evt));
1289  evt->event_type = SESSION_CTRL_EVT_APP_ADD_SEGMENT;
1290  mp = (session_app_add_segment_msg_t *) evt->data;
1291  clib_memset (mp, 0, sizeof (*mp));
1292  mp->segment_size = sp->ssvm_size;
1293  mp->fd_flags = fd_flags;
1294  mp->segment_handle = segment_handle;
1295  strncpy ((char *) mp->segment_name, (char *) sp->name,
1296  sizeof (mp->segment_name) - 1);
1297 
1298  svm_msg_q_add_and_unlock (app_mq, msg);
1299 
1300  return 0;
1301 }
1302 
1303 static int
1304 mq_send_del_segment_sapi_cb (u32 app_wrk_index, u64 segment_handle)
1305 {
1306  svm_msg_q_msg_t _msg, *msg = &_msg;
1308  app_worker_t *app_wrk;
1309  session_event_t *evt;
1310  svm_msg_q_t *app_mq;
1311 
1312  app_wrk = app_worker_get (app_wrk_index);
1313 
1314  app_mq = app_wrk->event_queue;
1315  if (mq_try_lock_and_alloc_msg (app_mq, msg))
1316  return -1;
1317 
1318  evt = svm_msg_q_msg_data (app_mq, msg);
1319  clib_memset (evt, 0, sizeof (*evt));
1320  evt->event_type = SESSION_CTRL_EVT_APP_DEL_SEGMENT;
1321  mp = (session_app_del_segment_msg_t *) evt->data;
1322  clib_memset (mp, 0, sizeof (*mp));
1323  mp->segment_handle = segment_handle;
1324  svm_msg_q_add_and_unlock (app_mq, msg);
1325 
1326  return 0;
1327 }
1328 
1331  .session_disconnect_callback = mq_send_session_disconnected_cb,
1332  .session_connected_callback = mq_send_session_connected_cb,
1333  .session_reset_callback = mq_send_session_reset_cb,
1334  .session_migrate_callback = mq_send_session_migrate_cb,
1335  .session_cleanup_callback = mq_send_session_cleanup_cb,
1336  .add_segment_callback = mq_send_add_segment_sapi_cb,
1337  .del_segment_callback = mq_send_del_segment_sapi_cb,
1338 };
1339 
1340 static void
1342  app_sapi_attach_msg_t * mp)
1343 {
1344  int rv = 0, *fds = 0, n_fds = 0, i, n_workers;
1345  vnet_app_attach_args_t _a, *a = &_a;
1347  u8 fd_flags = 0, ctrl_thread;
1348  app_ns_api_handle_t *handle;
1349  fifo_segment_t *rx_mqs_seg;
1350  app_sapi_msg_t msg = { 0 };
1351  app_worker_t *app_wrk;
1352  application_t *app;
1353  svm_msg_q_t *rx_mq;
1354 
1355  /* Make sure name is null terminated */
1356  mp->name[63] = 0;
1357 
1358  clib_memset (a, 0, sizeof (*a));
1359  a->api_client_index = appns_sapi_socket_handle (app_ns, cs);
1360  a->name = format (0, "%s", (char *) mp->name);
1361  a->options = mp->options;
1362  a->session_cb_vft = &session_mq_sapi_cb_vft;
1363  a->use_sock_api = 1;
1364  a->options[APP_OPTIONS_NAMESPACE] = app_namespace_index (app_ns);
1365 
1366  if ((rv = vnet_application_attach (a)))
1367  {
1368  clib_warning ("attach returned: %d", rv);
1369  goto done;
1370  }
1371 
1372  n_workers = vlib_num_workers ();
1373  vec_validate (fds, 3 /* segs + tx evtfd */ + n_workers);
1374 
1375  /* Send event queues segment */
1376  app = application_get (a->app_index);
1377  rx_mqs_seg = application_get_rx_mqs_segment (app);
1378 
1379  fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
1380  fds[n_fds] = rx_mqs_seg->ssvm.fd;
1381  n_fds += 1;
1382 
1383  /* Send fifo segment fd if needed */
1384  if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
1385  {
1386  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
1387  fds[n_fds] = a->segment->fd;
1388  n_fds += 1;
1389  }
1390  if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
1391  {
1392  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
1393  fds[n_fds] = svm_msg_q_get_eventfd (a->app_evt_q);
1394  n_fds += 1;
1395  }
1396 
1398  {
1399  fd_flags |= SESSION_FD_F_VPP_MQ_EVENTFD;
1400  for (i = 0; i < n_workers + 1; i++)
1401  {
1402  rx_mq = application_rx_mq_get (app, i);
1403  fds[n_fds] = svm_msg_q_get_eventfd (rx_mq);
1404  n_fds += 1;
1405  }
1406  }
1407 
1408 done:
1409 
1411  rmp = &msg.attach_reply;
1412  rmp->retval = rv;
1413  if (!rv)
1414  {
1415  ctrl_thread = n_workers ? 1 : 0;
1416  rmp->app_index = a->app_index;
1417  rmp->app_mq =
1418  fifo_segment_msg_q_offset ((fifo_segment_t *) a->segment, 0);
1419  rmp->vpp_ctrl_mq = fifo_segment_msg_q_offset (rx_mqs_seg, ctrl_thread);
1420  rmp->vpp_ctrl_mq_thread = ctrl_thread;
1421  rmp->n_fds = n_fds;
1422  rmp->fd_flags = fd_flags;
1423  /* No segment name and size since we only support memfds
1424  * in this configuration */
1425  rmp->segment_handle = a->segment_handle;
1426  rmp->api_client_handle = a->api_client_index;
1427 
1428  /* Update app index for socket */
1429  handle = (app_ns_api_handle_t *) & cs->private_data;
1430  app_wrk = application_get_worker (app, 0);
1431  handle->aah_app_wrk_index = app_wrk->wrk_index;
1432  }
1433 
1434  clib_socket_sendmsg (cs, &msg, sizeof (msg), fds, n_fds);
1435  vec_free (a->name);
1436  vec_free (fds);
1437 }
1438 
1439 void
1441 {
1442  app_namespace_t *app_ns = app_namespace_get (api_handle >> 16);
1443  u16 sock_index = api_handle & 0xffff;
1444  app_ns_api_handle_t *handle;
1445  clib_socket_t *cs;
1446  clib_file_t *cf;
1447 
1448  cs = appns_sapi_get_socket (app_ns, sock_index);
1449  if (!cs)
1450  return;
1451 
1452  handle = (app_ns_api_handle_t *) & cs->private_data;
1453  cf = clib_file_get (&file_main, handle->aah_file_index);
1454  clib_file_del (&file_main, cf);
1455 
1456  clib_socket_close (cs);
1457  appns_sapi_free_socket (app_ns, cs);
1458 }
1459 
1460 static void
1462  clib_socket_t * cs,
1464 {
1465  int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
1467  app_ns_api_handle_t *handle;
1468  app_sapi_msg_t msg = { 0 };
1469  app_worker_t *app_wrk;
1470  u32 sapi_handle = -1;
1471  application_t *app;
1472  u8 fd_flags = 0;
1473 
1474  app = application_get_if_valid (mp->app_index);
1475  if (!app)
1476  {
1477  rv = VNET_API_ERROR_INVALID_VALUE;
1478  goto done;
1479  }
1480 
1481  sapi_handle = appns_sapi_socket_handle (app_ns, cs);
1482 
1484  .app_index = app->app_index,
1485  .wrk_map_index = mp->wrk_index,
1486  .api_client_index = sapi_handle,
1487  .is_add = mp->is_add
1488  };
1489  rv = vnet_app_worker_add_del (&args);
1490  if (rv)
1491  {
1492  clib_warning ("app worker add/del returned: %d", rv);
1493  goto done;
1494  }
1495 
1496  if (!mp->is_add)
1497  goto done;
1498 
1499  /* Send fifo segment fd if needed */
1500  if (ssvm_type (args.segment) == SSVM_SEGMENT_MEMFD)
1501  {
1502  fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
1503  fds[n_fds] = args.segment->fd;
1504  n_fds += 1;
1505  }
1506  if (application_segment_manager_properties (app)->use_mq_eventfd)
1507  {
1508  fd_flags |= SESSION_FD_F_MQ_EVENTFD;
1509  fds[n_fds] = svm_msg_q_get_eventfd (args.evt_q);
1510  n_fds += 1;
1511  }
1512 
1513 done:
1514 
1516  rmp = &msg.worker_add_del_reply;
1517  rmp->retval = rv;
1518  rmp->is_add = mp->is_add;
1519  rmp->api_client_handle = sapi_handle;
1520  rmp->wrk_index = args.wrk_map_index;
1521  rmp->segment_handle = args.segment_handle;
1522  if (!rv && mp->is_add)
1523  {
1524  /* No segment name and size. This supports only memfds */
1526  fifo_segment_msg_q_offset ((fifo_segment_t *) args.segment, 0);
1527  rmp->n_fds = n_fds;
1528  rmp->fd_flags = fd_flags;
1529 
1530  /* Update app index for socket */
1531  handle = (app_ns_api_handle_t *) & cs->private_data;
1532  app_wrk = application_get_worker (app, args.wrk_map_index);
1533  handle->aah_app_wrk_index = app_wrk->wrk_index;
1534  }
1535 
1536  clib_socket_sendmsg (cs, &msg, sizeof (msg), fds, n_fds);
1537 }
1538 
1539 static void
1542 {
1545  app_sapi_msg_t msg = { 0 };
1546  int rv = 0;
1547 
1548  if (mp->is_add)
1549  {
1550  const u32 max_certkey_len = 2e4, max_cert_len = 1e4, max_key_len = 1e4;
1551  clib_error_t *err;
1552  u8 *certkey = 0;
1553  u32 key_len;
1554 
1555  if (mp->certkey_len > max_certkey_len)
1556  {
1557  rv = SESSION_E_INVALID;
1558  goto send_reply;
1559  }
1560 
1561  vec_validate (certkey, mp->certkey_len - 1);
1562  err = clib_socket_recvmsg (cs, certkey, mp->certkey_len, 0, 0);
1563  if (err)
1564  {
1565  clib_error_report (err);
1566  clib_error_free (err);
1567  rv = SESSION_E_INVALID;
1568  goto send_reply;
1569  }
1570 
1571  if (mp->cert_len > max_cert_len)
1572  {
1573  rv = SESSION_E_INVALID;
1574  goto send_reply;
1575  }
1576 
1577  if (mp->certkey_len < mp->cert_len)
1578  {
1579  rv = SESSION_E_INVALID;
1580  goto send_reply;
1581  }
1582 
1583  key_len = mp->certkey_len - mp->cert_len;
1584  if (key_len > max_key_len)
1585  {
1586  rv = SESSION_E_INVALID;
1587  goto send_reply;
1588  }
1589 
1590  clib_memset (a, 0, sizeof (*a));
1591  a->cert = certkey;
1592  a->key = certkey + mp->cert_len;
1593  a->cert_len = mp->cert_len;
1594  a->key_len = key_len;
1596 
1597  vec_free (certkey);
1598  }
1599  else
1600  {
1602  }
1603 
1604 send_reply:
1605 
1607  rmp = &msg.cert_key_add_del_reply;
1608  rmp->retval = rv;
1609  rmp->context = mp->context;
1610  if (!rv && mp->is_add)
1611  rmp->index = a->index;
1612 
1613  clib_socket_sendmsg (cs, &msg, sizeof (msg), 0, 0);
1614 }
1615 
1616 static void
1618 {
1619  app_ns_api_handle_t *handle;
1620  app_worker_t *app_wrk;
1621  u32 api_client_handle;
1622 
1623  api_client_handle = appns_sapi_socket_handle (app_ns, cs);
1624 
1625  /* Cleanup everything because app worker closed socket or crashed */
1626  handle = (app_ns_api_handle_t *) & cs->private_data;
1627  app_wrk = app_worker_get (handle->aah_app_wrk_index);
1628 
1630  .app_index = app_wrk->app_index,
1631  .wrk_map_index = app_wrk->wrk_map_index,
1632  .api_client_index = api_client_handle,
1633  .is_add = 0
1634  };
1635  /* Send rpc to main thread for worker barrier */
1637  sizeof (args));
1638 }
1639 
1640 static clib_error_t *
1642 {
1645  app_sapi_msg_t msg = { 0 };
1646  app_namespace_t *app_ns;
1647  clib_error_t *err = 0;
1648  clib_socket_t *cs;
1649 
1650  app_ns = app_namespace_get (handle->aah_app_ns_index);
1651  cs = appns_sapi_get_socket (app_ns, handle->aah_sock_index);
1652  if (!cs)
1653  goto error;
1654 
1655  err = clib_socket_recvmsg (cs, &msg, sizeof (msg), 0, 0);
1656  if (err)
1657  {
1658  clib_error_free (err);
1659  sapi_socket_detach (app_ns, cs);
1660  goto error;
1661  }
1662 
1663  handle = (app_ns_api_handle_t *) & cs->private_data;
1664 
1666 
1667  switch (msg.type)
1668  {
1670  session_api_attach_handler (app_ns, cs, &msg.attach);
1671  break;
1673  sapi_add_del_worker_handler (app_ns, cs, &msg.worker_add_del);
1674  break;
1677  break;
1678  default:
1679  clib_warning ("app wrk %u unknown message type: %u",
1680  handle->aah_app_wrk_index, msg.type);
1681  break;
1682  }
1683 
1685 
1686 error:
1687  return 0;
1688 }
1689 
1690 static clib_error_t *
1692 {
1694  clib_warning ("called for app ns %u", handle->aah_app_ns_index);
1695  return 0;
1696 }
1697 
1698 static clib_error_t *
1700 {
1702  app_namespace_t *app_ns;
1703  clib_socket_t *cs;
1704 
1705  app_ns = app_namespace_get (handle->aah_app_ns_index);
1706  cs = appns_sapi_get_socket (app_ns, handle->aah_sock_index);
1707  if (!cs)
1708  return 0;
1709 
1710  sapi_socket_detach (app_ns, cs);
1711  return 0;
1712 }
1713 
1714 static clib_error_t *
1716 {
1718  app_namespace_t *app_ns;
1719  clib_file_t cf = { 0 };
1720  clib_error_t *err = 0;
1721  clib_socket_t *ccs, *scs;
1722 
1723  /* Listener files point to namespace */
1724  app_ns = app_namespace_get (handle.aah_app_ns_index);
1725 
1726  /*
1727  * Initialize client socket
1728  */
1729  ccs = appns_sapi_alloc_socket (app_ns);
1730 
1731  /* Grab server socket after client is initialized */
1732  scs = appns_sapi_get_socket (app_ns, handle.aah_sock_index);
1733  if (!scs)
1734  goto error;
1735 
1736  err = clib_socket_accept (scs, ccs);
1737  if (err)
1738  {
1739  clib_error_report (err);
1740  goto error;
1741  }
1742 
1743  cf.read_function = sapi_sock_read_ready;
1744  cf.write_function = sapi_sock_write_ready;
1745  cf.error_function = sapi_sock_error;
1746  cf.file_descriptor = ccs->fd;
1747  /* File points to app namespace and socket */
1748  handle.aah_sock_index = appns_sapi_socket_index (app_ns, ccs);
1749  cf.private_data = handle.as_u64;
1750  cf.description = format (0, "app sock conn fd: %d", ccs->fd);
1751 
1752  /* Poll until we get an attach message. Socket points to file and
1753  * application that owns the socket */
1754  handle.aah_app_wrk_index = APP_INVALID_INDEX;
1755  handle.aah_file_index = clib_file_add (&file_main, &cf);
1756  ccs->private_data = handle.as_u64;
1757 
1758  return err;
1759 
1760 error:
1761  appns_sapi_free_socket (app_ns, ccs);
1762  return err;
1763 }
1764 
1765 void
1767 {
1768  app_ns_api_handle_t *handle;
1769  clib_socket_t *cs;
1770 
1771  pool_foreach (cs, app_ns->app_sockets)
1772  {
1773  handle = (app_ns_api_handle_t *) &cs->private_data;
1774  clib_file_del_by_index (&file_main, handle->aah_file_index);
1775 
1776  clib_socket_close (cs);
1777  clib_socket_free (cs);
1778  }
1779  pool_free (app_ns->app_sockets);
1780 }
1781 
1782 int
1784 {
1785  char *subdir = "/app_ns_sockets/";
1786  app_ns_api_handle_t *handle;
1787  clib_file_t cf = { 0 };
1788  struct stat file_stat;
1789  clib_error_t *err;
1790  clib_socket_t *cs;
1791  char dir[4096];
1792 
1793  if (app_ns->netns)
1794  {
1795  if (!app_ns->sock_name)
1796  app_ns->sock_name = format (0, "@vpp/session/%v%c", app_ns->ns_id, 0);
1797  if (app_ns->sock_name[0] != '@')
1798  return VNET_API_ERROR_INVALID_VALUE;
1799  }
1800  else
1801  {
1802  snprintf (dir, sizeof (dir), "%s%s", vlib_unix_get_runtime_dir (),
1803  subdir);
1804  err = vlib_unix_recursive_mkdir ((char *) dir);
1805  if (err)
1806  {
1807  clib_error_report (err);
1808  return VNET_API_ERROR_SYSCALL_ERROR_1;
1809  }
1810 
1811  if (!app_ns->sock_name)
1812  app_ns->sock_name = format (0, "%s%v%c", dir, app_ns->ns_id, 0);
1813  }
1814 
1815  /*
1816  * Create and initialize socket to listen on
1817  */
1818  cs = appns_sapi_alloc_socket (app_ns);
1819  cs->config = (char *) vec_dup (app_ns->sock_name);
1820  cs->flags = CLIB_SOCKET_F_IS_SERVER |
1823 
1824  if ((err = clib_socket_init_netns (cs, app_ns->netns)))
1825  {
1826  clib_error_report (err);
1827  return -1;
1828  }
1829 
1830  if (!app_ns->netns && stat ((char *) app_ns->sock_name, &file_stat) == -1)
1831  return -1;
1832 
1833  /*
1834  * Start polling it
1835  */
1837  cf.file_descriptor = cs->fd;
1838  /* File points to namespace */
1839  handle = (app_ns_api_handle_t *) & cf.private_data;
1840  handle->aah_app_ns_index = app_namespace_index (app_ns);
1841  handle->aah_sock_index = appns_sapi_socket_index (app_ns, cs);
1842  cf.description = format (0, "app sock listener: %s", app_ns->sock_name);
1843 
1844  /* Socket points to clib file index */
1845  handle = (app_ns_api_handle_t *) & cs->private_data;
1846  handle->aah_file_index = clib_file_add (&file_main, &cf);
1847  handle->aah_app_wrk_index = APP_INVALID_INDEX;
1848 
1849  return 0;
1850 }
1851 
1852 static void
1855 {
1856  /* deprecated */
1857 }
1858 
1859 static void
1861 {
1862  /* deprecated */
1863 }
1864 
1865 #include <vnet/session/session.api.c>
1866 static clib_error_t *
1868 {
1869  /*
1870  * Set up the (msg_name, crc, message-id) table
1871  */
1873 
1874  return 0;
1875 }
1876 
1878 
1879 /*
1880  * fd.io coding-style-patch-verification: ON
1881  *
1882  * Local Variables:
1883  * eval: (c-set-style "gnu")
1884  * End:
1885  */
ct_connection_
Definition: application_local.h:41
session_accepted_msg_::rmt
transport_endpoint_t rmt
Definition: application_interface.h:385
clib_file::file_descriptor
u32 file_descriptor
Definition: file.h:54
ip4_mask_to_preflen
u32 ip4_mask_to_preflen(ip4_address_t *mask)
Definition: ip_types.c:500
vl_api_app_worker_add_del_reply_t::segment_name
string segment_name[]
Definition: session.api:191
sapi_socket_detach
static void sapi_socket_detach(app_namespace_t *app_ns, clib_socket_t *cs)
Definition: session_api.c:1617
session_connected_msg_::context
u32 context
Definition: application_interface.h:430
CLIB_SOCKET_F_IS_SERVER
#define CLIB_SOCKET_F_IS_SERVER
Definition: socket.h:58
session_migrate_msg_
Definition: application_interface.h:531
session_accepted_msg_::context
u32 context
Definition: application_interface.h:376
APP_SAPI_MSG_TYPE_ATTACH_REPLY
@ APP_SAPI_MSG_TYPE_ATTACH_REPLY
Definition: application_interface.h:817
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
vlib_num_workers
static u32 vlib_num_workers()
Definition: threads.h:333
vl_api_session_rules_details_t
Session rules details.
Definition: session.api:383
app_worker_::wrk_index
u32 wrk_index
Worker index in global worker pool.
Definition: application.h:37
api.h
file_main
clib_file_main_t file_main
Definition: main.c:63
vl_api_registration_file_index
static u32 vl_api_registration_file_index(vl_api_registration_t *reg)
Definition: api.h:87
vlib_worker_thread_barrier_release
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1375
session_error_t
enum session_error_ session_error_t
session_evt_type_t
session_evt_type_t
Definition: session_types.h:326
vl_api_session_rules_details_t::transport_proto
vl_api_transport_proto_t transport_proto
Definition: session.api:386
app_sapi_cert_key_add_del_reply_msg_
Definition: application_interface.h:876
vl_api_app_attach_t::namespace_id
string namespace_id[]
Definition: session.api:41
VL_MSG_API_REAPER_FUNCTION
VL_MSG_API_REAPER_FUNCTION(application_reaper_cb)
vl_api_session_rules_dump_t
Dump session rules.
Definition: session.api:360
application_rx_mq_get
svm_msg_q_t * application_rx_mq_get(application_t *app, u32 mq_index)
Definition: application.c:615
ip_set
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
Definition: ip.c:95
app_sapi_attach_msg_::options
u64 options[18]
Definition: application_interface.h:828
SESSION_RULE_SCOPE_API_GLOBAL
@ SESSION_RULE_SCOPE_API_GLOBAL
Definition: session.api:316
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
vl_api_session_rule_add_del_t::tag
string tag[64]
Definition: session.api:353
app_sapi_attach_reply_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:841
session_mq_sapi_cb_vft
static session_cb_vft_t session_mq_sapi_cb_vft
Definition: session_api.c:1329
vl_api_app_worker_add_del_reply_t::segment_handle
u64 segment_handle
Definition: session.api:189
vl_api_app_add_cert_key_pair_t
Add certificate and key.
Definition: session.api:90
vl_api_application_detach_t
Application detach from session layer.
Definition: session.api:77
session_connected_msg_::server_rx_fifo
uword server_rx_fifo
Definition: application_interface.h:433
vl_api_session_rule_add_del_t::rmt
vl_api_prefix_t rmt
Definition: session.api:346
app_sapi_worker_add_del_reply_msg_::api_client_handle
u32 api_client_handle
Definition: application_interface.h:861
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
vnet_app_namespace_add_del_args_t
struct _vnet_app_namespace_add_del_args vnet_app_namespace_add_del_args_t
app_sapi_attach_reply_msg_::api_client_handle
u32 api_client_handle
Definition: application_interface.h:842
session_bound_msg_::handle
u64 handle
Definition: application_interface.h:347
mq_notify_close_subscribers
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:202
svm_msg_q_add_and_unlock
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.
Definition: message_queue.c:394
vl_api_app_worker_add_del_t::client_index
u32 client_index
Definition: session.api:162
vl_api_app_attach_reply_t::segment_handle
u64 segment_handle
Definition: session.api:69
APP_SAPI_MSG_TYPE_ADD_DEL_WORKER
@ APP_SAPI_MSG_TYPE_ADD_DEL_WORKER
Definition: application_interface.h:818
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
APP_NAMESPACE_INVALID_INDEX
#define APP_NAMESPACE_INVALID_INDEX
Definition: application_namespace.h:81
vl_api_session_rule_add_del_t::is_add
bool is_add[default=true]
Definition: session.api:350
mq_send_unlisten_reply
void mq_send_unlisten_reply(app_worker_t *app_wrk, session_handle_t sh, u32 context, int rv)
Definition: session_api.c:399
svm_fifo_n_subscribers
static u8 svm_fifo_n_subscribers(svm_fifo_t *f)
Fifo number of subscribers getter.
Definition: svm_fifo.h:649
vl_api_app_namespace_add_del_v2_t::ip4_fib_id
u32 ip4_fib_id
Definition: session.api:249
vnet_app_worker_add_del_args_t
struct _vnet_app_worker_add_del_args vnet_app_worker_add_del_args_t
SESSION_CTRL_EVT_CONNECTED
@ SESSION_CTRL_EVT_CONNECTED
Definition: session_types.h:341
f
vlib_frame_t * f
Definition: interface_output.c:1098
vl_api_app_namespace_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: session.api:224
app_sapi_msg_::worker_add_del_reply
app_sapi_worker_add_del_reply_msg_t worker_add_del_reply
Definition: application_interface.h:891
session_get_endpoint
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
Definition: session.c:1754
ssvm_private_t::ssvm_size
uword ssvm_size
Definition: ssvm.h:84
SESSION_CTRL_EVT_DISCONNECTED
@ SESSION_CTRL_EVT_DISCONNECTED
Definition: session_types.h:342
vl_api_session_rule_add_del_t
add/del session rule
Definition: session.api:341
vl_api_session_rules_details_t::rmt_port
u16 rmt_port
Definition: session.api:390
fifo_segment_msg_q_offset
uword fifo_segment_msg_q_offset(fifo_segment_t *fs, u32 mq_index)
Message queue offset on segment.
Definition: fifo_segment.c:1163
mq_send_session_close_evt
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:181
vl_api_app_namespace_add_del_v2_t::namespace_id
string namespace_id[64]
Definition: session.api:251
session_rules_table.h
listen_session_get_handle
static u64 listen_session_get_handle(session_t *s)
Definition: session.h:623
ct_session_get_peer
session_t * ct_session_get_peer(session_t *s)
Definition: application_local.c:120
svm_msg_q_msg_data
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
Definition: message_queue.c:287
mq_send_add_segment_sapi_cb
static int mq_send_add_segment_sapi_cb(u32 app_wrk_index, u64 segment_handle)
Definition: session_api.c:1253
app_namespace_t
struct _app_namespace app_namespace_t
app_map_another_segment_msg_
Definition: application_interface.h:514
session_::tx_fifo
svm_fifo_t * tx_fifo
Definition: session_types.h:179
clib_socket_recvmsg
static clib_error_t * clib_socket_recvmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:160
session_bound_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:355
vl_api_app_worker_add_del_reply_t::fd_flags
u8 fd_flags
Definition: session.api:188
vl_api_app_add_cert_key_pair_t::certkey_len
u16 certkey_len
Definition: session.api:94
TRANSPORT_PROTO_API_QUIC
@ TRANSPORT_PROTO_API_QUIC
Definition: session.api:28
vl_api_app_del_cert_key_pair_t::index
u32 index
Definition: session.api:117
fifo_segment_t
Definition: fifo_segment.h:68
session_accepted_msg_::server_rx_fifo
uword server_rx_fifo
Definition: application_interface.h:379
app_listener_get_local_session
session_t * app_listener_get_local_session(app_listener_t *al)
Definition: application.c:315
vl_api_app_worker_add_del_reply_t
Reply for app worker add/del.
Definition: session.api:181
session_segment_handle
u64 session_segment_handle(session_t *s)
Definition: session.c:1680
session_
Definition: session_types.h:175
app_sapi_worker_add_del_msg_::wrk_index
u32 wrk_index
Definition: application_interface.h:851
session_bound_msg_::rx_fifo
uword rx_fifo
Definition: application_interface.h:352
application_segment_manager_properties
segment_manager_props_t * application_segment_manager_properties(application_t *app)
Definition: application.c:1656
session_connected_msg_::vpp_event_queue_address
uword vpp_event_queue_address
Definition: application_interface.h:439
clib_file::read_function
clib_file_function_t * read_function
Definition: file.h:67
vl_api_app_add_cert_key_pair_t::certkey
u8 certkey[certkey_len]
Definition: session.api:95
session_handle_t
u64 session_handle_t
Definition: session_types.h:111
app_unmap_segment_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:528
session_connected_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:435
app_sapi_worker_add_del_msg_::app_index
u32 app_index
Definition: application_interface.h:850
u16
unsigned short u16
Definition: types.h:57
SESSION_INVALID_INDEX
#define SESSION_INVALID_INDEX
Definition: session_types.h:22
application_::app_index
u32 app_index
App index in app pool.
Definition: application.h:111
APP_INVALID_INDEX
#define APP_INVALID_INDEX
Definition: application.h:226
SVM_Q_NOWAIT
@ SVM_Q_NOWAIT
non-blocking call - works with both condvar and eventfd signaling
Definition: queue.h:44
clib_file::private_data
u64 private_data
Definition: file.h:64
app_sapi_attach_reply_msg_::n_fds
u8 n_fds
Definition: application_interface.h:844
vnet_application_detach
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
Definition: application.c:1216
fib_prefix_t_::fp_len
u16 fp_len
The mask length.
Definition: fib_types.h:206
app_listen_session_handle
session_handle_t app_listen_session_handle(session_t *ls)
Get app listener handle for listening session.
Definition: application.c:78
svm_msg_q_msg_t
Definition: message_queue.h:93
session_::thread_index
u8 thread_index
Index of the thread that allocated the session.
Definition: session_types.h:194
vl_api_app_namespace_add_del_v3_t
add/del application namespace
Definition: session.api:270
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_app_namespace_add_del_t::ip4_fib_id
u32 ip4_fib_id
Definition: session.api:225
app_sapi_worker_add_del_reply_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:860
mq_send_add_segment_cb
static int mq_send_add_segment_cb(u32 app_wrk_index, u64 segment_handle)
Definition: session_api.c:457
session_connected_msg_
Definition: application_interface.h:428
session_api_hookup
static clib_error_t * session_api_hookup(vlib_main_t *vm)
Definition: session_api.c:1867
vl_api_session_rules_details_t::context
u32 context
Definition: session.api:385
listener
Definition: test_stats.cpp:7
app_sapi_worker_add_del_reply_msg_::app_event_queue_address
u64 app_event_queue_address
Definition: application_interface.h:859
app_sapi_attach_msg_
Definition: application_interface.h:825
app_sapi_attach_reply_msg_::app_mq
u64 app_mq
Definition: application_interface.h:839
session_cleanup_msg_::handle
session_handle_t handle
Definition: application_interface.h:542
session_disconnected_msg_::handle
u64 handle
Definition: application_interface.h:462
application_
Definition: application.h:108
clib_file::description
u8 * description
Definition: file.h:70
session_thread_from_handle
static u32 session_thread_from_handle(session_handle_t handle)
Definition: session_types.h:295
app_sapi_cert_key_add_del_reply_msg_::index
u32 index
Definition: application_interface.h:880
appns_sapi_get_socket
static clib_socket_t * appns_sapi_get_socket(app_namespace_t *app_ns, u32 sock_index)
Definition: application_namespace.h:131
session_bound_msg_::lcl_port
u16 lcl_port
Definition: application_interface.h:351
vnet_app_detach_args_t
struct _vnet_app_detach_args_t vnet_app_detach_args_t
app_ns_api_handle_
Definition: application_namespace.h:101
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
transport_connection_t
struct _transport_connection transport_connection_t
app_sapi_cert_key_add_del_msg_
Definition: application_interface.h:867
app_sapi_cert_key_add_del_msg_::context
u32 context
Definition: application_interface.h:869
vl_api_session_rules_dump_t::context
u32 context
Definition: session.api:363
session_unlisten_reply_msg_::handle
u64 handle
Definition: application_interface.h:370
session_bound_msg_::tx_fifo
uword tx_fifo
Definition: application_interface.h:353
app_worker_first_listener
session_t * app_worker_first_listener(app_worker_t *app, u8 fib_proto, u8 transport_proto)
Definition: application_worker.c:541
app_namespace_get
app_namespace_t * app_namespace_get(u32 index)
Definition: application_namespace.c:38
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
app_sapi_worker_add_del_reply_msg_::n_fds
u8 n_fds
Definition: application_interface.h:862
APP_OPTIONS_N_OPTIONS
@ APP_OPTIONS_N_OPTIONS
Definition: application_interface.h:223
vl_api_app_attach_reply_t::app_mq
u64 app_mq
Definition: session.api:62
vl_api_app_del_cert_key_pair_t_handler
static void vl_api_app_del_cert_key_pair_t_handler(vl_api_app_del_cert_key_pair_t *mp)
Definition: session_api.c:1194
SSVM_SEGMENT_MEMFD
@ SSVM_SEGMENT_MEMFD
Definition: ssvm.h:50
TRANSPORT_PROTO_API_NONE
@ TRANSPORT_PROTO_API_NONE
Definition: session.api:26
error
Definition: cJSON.c:88
sapi_socket_close_w_handle
void sapi_socket_close_w_handle(u32 api_handle)
Definition: session_api.c:1440
vl_api_app_namespace_add_del_v3_t::netns
string netns[64]
Definition: session.api:279
ip_prefix_encode
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:273
vl_api_session_rules_details_t::appns_index
u32 appns_index
Definition: session.api:392
TRANSPORT_PROTO_API_TLS
@ TRANSPORT_PROTO_API_TLS
Definition: session.api:27
sapi_sock_write_ready
static clib_error_t * sapi_sock_write_ready(clib_file_t *cf)
Definition: session_api.c:1691
session_cb_vft_::session_accept_callback
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
Definition: application_interface.h:41
application_local.h
vl_api_session_enable_disable_t_handler
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
Definition: session_api.c:594
mq_send_del_segment_cb
static int mq_send_del_segment_cb(u32 app_wrk_index, u64 segment_handle)
Definition: session_api.c:519
svm_fifo_t
struct _svm_fifo svm_fifo_t
session_connected_msg_::handle
u64 handle
Definition: application_interface.h:432
segment_manager_get_segment_w_handle
fifo_segment_t * segment_manager_get_segment_w_handle(u64 segment_handle)
Definition: segment_manager.c:290
appns_sapi_socket_index
static u32 appns_sapi_socket_index(app_namespace_t *app_ns, clib_socket_t *cs)
Definition: application_namespace.h:145
session_bound_msg_::lcl_ip
u8 lcl_ip[16]
Definition: application_interface.h:350
application_use_private_rx_mqs
u8 application_use_private_rx_mqs(void)
Definition: application.c:677
SESSION_CLEANUP_TRANSPORT
@ SESSION_CLEANUP_TRANSPORT
Definition: session_types.h:115
APP_SAPI_MSG_TYPE_ADD_DEL_CERT_KEY_REPLY
@ APP_SAPI_MSG_TYPE_ADD_DEL_CERT_KEY_REPLY
Definition: application_interface.h:822
vl_api_application_detach_t::client_index
u32 client_index
Definition: session.api:78
application_get
application_t * application_get(u32 app_index)
Definition: application.c:710
vl_api_session_rules_dump_t_handler
static void vl_api_session_rules_dump_t_handler(vl_api_session_rules_dump_t *mp)
Definition: session_api.c:1120
vl_api_app_namespace_add_del_v2_t
add/del application namespace
Definition: session.api:244
session_cb_vft_
Definition: application_interface.h:32
session_::app_wrk_index
u32 app_wrk_index
Index of the app worker that owns the session.
Definition: session_types.h:191
vl_api_session_rules_details_t::rmt
vl_api_prefix_t rmt
Definition: session.api:388
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vl_api_session_rule_add_del_t::action_index
u32 action_index
Definition: session.api:349
APP_SAPI_MSG_TYPE_ADD_DEL_CERT_KEY
@ APP_SAPI_MSG_TYPE_ADD_DEL_CERT_KEY
Definition: application_interface.h:821
app_map_another_segment_msg_::fd_flags
u8 fd_flags
Definition: application_interface.h:518
session_::rx_fifo
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
Definition: session_types.h:178
vl_api_app_namespace_add_del_t::secret
u64 secret
Definition: session.api:223
app_listener_::session_index
u32 session_index
global listening session index
Definition: application.h:86
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
SESSION_CTRL_EVT_UNLISTEN_REPLY
@ SESSION_CTRL_EVT_UNLISTEN_REPLY
Definition: session_types.h:338
sapi_add_del_worker_handler
static void sapi_add_del_worker_handler(app_namespace_t *app_ns, clib_socket_t *cs, app_sapi_worker_add_del_msg_t *mp)
Definition: session_api.c:1461
session_connected_msg_::mq_index
u32 mq_index
Definition: application_interface.h:441
session_rules_table_t
struct _session_rules_table_t session_rules_table_t
vl_api_app_attach_t
Application attach to session layer.
Definition: session.api:37
SESSION_CTRL_EVT_BOUND
@ SESSION_CTRL_EVT_BOUND
Definition: session_types.h:337
mq_send_session_cleanup_cb
static void mq_send_session_cleanup_cb(session_t *s, session_cleanup_ntf_t ntf)
Definition: session_api.c:552
session_get_transport
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1743
vl_api_app_attach_reply_t::app_index
u32 app_index
Definition: session.api:65
vec_dup
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:444
mq_try_lock_and_alloc_msg
static int mq_try_lock_and_alloc_msg(svm_msg_q_t *app_mq, svm_msg_q_msg_t *msg)
Definition: session_api.c:85
clib_socket_close
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:177
clib_file
Definition: file.h:51
vl_api_app_namespace_add_del_v3_t::secret
u64 secret
Definition: session.api:273
vl_api_application_tls_cert_add_t_handler
static void vl_api_application_tls_cert_add_t_handler(vl_api_application_tls_cert_add_t *mp)
Definition: session_api.c:1853
vnet_app_del_cert_key_pair
int vnet_app_del_cert_key_pair(u32 index)
Definition: application.c:2060
session_migrate_msg_::new_handle
session_handle_t new_handle
Definition: application_interface.h:535
app_sapi_cert_key_add_del_msg_::certkey_len
u16 certkey_len
Definition: application_interface.h:872
vlib_worker_thread_barrier_sync
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:173
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
session_migrate_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:536
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
app_worker_get_if_valid
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
Definition: application_worker.c:47
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
session_accepted_msg_::handle
u64 handle
Definition: application_interface.h:378
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
SESSION_CTRL_EVT_CLEANUP
@ SESSION_CTRL_EVT_CLEANUP
Definition: session_types.h:359
vl_api_app_namespace_add_del_v3_reply_t
Definition: session.api:308
app_sapi_worker_add_del_reply_msg_::fd_flags
u8 fd_flags
Definition: application_interface.h:863
session_table_foreach
#define session_table_foreach(VAR, BODY)
Definition: session_table.h:75
vl_api_app_namespace_add_del_v2_t::secret
u64 secret
Definition: session.api:247
vl_api_app_namespace_add_del_reply_t::appns_index
u32 appns_index
Definition: session.api:293
mq_send_session_reset_cb
static void mq_send_session_reset_cb(session_t *s)
Definition: session_api.c:236
vl_api_app_attach_reply_t::vpp_ctrl_mq_thread
u8 vpp_ctrl_mq_thread
Definition: session.api:64
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: session_api.c:30
ip_prefix_decode
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:245
vl_api_session_rules_dump_t::client_index
u32 client_index
Definition: session.api:362
vl_api_session_rule_add_del_t::rmt_port
u16 rmt_port
Definition: session.api:348
application_get_rx_mqs_segment
fifo_segment_t * application_get_rx_mqs_segment(application_t *app)
Definition: application.c:683
vl_api_app_namespace_add_del_t::namespace_id
string namespace_id[]
Definition: session.api:227
session_type_is_ip4
static u8 session_type_is_ip4(session_type_t st)
Definition: session_types.h:236
vlib_unix_get_runtime_dir
static char * vlib_unix_get_runtime_dir(void)
Definition: unix.h:151
session_connected_msg_::ct_tx_fifo
uword ct_tx_fifo
Definition: application_interface.h:437
vl_api_app_add_cert_key_pair_t::cert_len
u16 cert_len
Definition: session.api:93
clib_socket_sendmsg
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:153
vl_api_app_worker_add_del_t_handler
static void vl_api_app_worker_add_del_t_handler(vl_api_app_worker_add_del_t *mp)
Definition: session_api.c:715
appns_sapi_alloc_socket
static clib_socket_t * appns_sapi_alloc_socket(app_namespace_t *app_ns)
Definition: application_namespace.h:123
session_get_fib_proto
static fib_protocol_t session_get_fib_proto(session_t *s)
Definition: session_types.h:248
vl_api_app_namespace_add_del_v3_reply_t::appns_index
u32 appns_index
Definition: session.api:312
sapi_sock_accept_ready
static clib_error_t * sapi_sock_accept_ready(clib_file_t *scf)
Definition: session_api.c:1715
app_sapi_worker_add_del_reply_msg_
Definition: application_interface.h:855
send_session_rule_details4
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:997
vl_api_app_namespace_add_del_v3_t::is_add
bool is_add[default=true]
Definition: session.api:274
vl_api_session_rules_details_t::action_index
u32 action_index
Definition: session.api:391
app_sapi_worker_add_del_msg_::is_add
u8 is_add
Definition: application_interface.h:852
app_sapi_attach_msg_::name
u8 name[64]
Definition: application_interface.h:827
SESSION_RULE_SCOPE_API_LOCAL
@ SESSION_RULE_SCOPE_API_LOCAL
Definition: session.api:317
session_accepted_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:381
session_handle
static session_handle_t session_handle(session_t *s)
Definition: session_types.h:283
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
application_::ns_index
u32 ns_index
Namespace the application belongs to.
Definition: application.h:129
send_session_rules_table_details
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:1081
session_bound_msg_::retval
i32 retval
Definition: application_interface.h:348
vl_api_app_namespace_add_del_v2_t::ip6_fib_id
u32 ip6_fib_id
Definition: session.api:250
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
vlib_unix_recursive_mkdir
clib_error_t * vlib_unix_recursive_mkdir(char *path)
Definition: util.c:103
session_unlisten_reply_msg_::retval
i32 retval
Definition: application_interface.h:371
clib_socket_free
static void clib_socket_free(clib_socket_t *s)
Definition: socket.h:167
app_sapi_cert_key_add_del_reply_msg_::context
u32 context
Definition: application_interface.h:878
application_get_if_valid
application_t * application_get_if_valid(u32 app_index)
Definition: application.c:718
app_worker_::event_queue
svm_msg_q_t * event_queue
Application listens for events on this svm queue.
Definition: application.h:46
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
vnet_app_add_cert_key_pair
int vnet_app_add_cert_key_pair(vnet_app_add_cert_key_pair_args_t *a)
Definition: application.c:2037
session_bound_msg_::mq_index
u32 mq_index
Definition: application_interface.h:356
STATIC_ASSERT
#define STATIC_ASSERT(truth,...)
Definition: error_bootstrap.h:111
app_sapi_msg_::attach_reply
app_sapi_attach_reply_msg_t attach_reply
Definition: application_interface.h:889
app_sapi_msg_::worker_add_del
app_sapi_worker_add_del_msg_t worker_add_del
Definition: application_interface.h:890
clib_socket_init_netns
__clib_export clib_error_t * clib_socket_init_netns(clib_socket_t *s, u8 *namespace)
Definition: socket.c:557
svm_msg_q_
Definition: message_queue.h:72
vl_api_session_rules_details_t::tag
string tag[64]
Definition: session.api:394
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
vnet_app_add_cert_key_pair_args_t
struct _vnet_app_add_cert_key_pair_args_ vnet_app_add_cert_key_pair_args_t
vl_api_app_del_cert_key_pair_t
Delete certificate and key.
Definition: session.api:114
clib_file_get
static clib_file_t * clib_file_get(clib_file_main_t *fm, u32 file_index)
Definition: file.h:152
application_is_proxy
int application_is_proxy(application_t *app)
Definition: application.c:1494
SESSION_N_FD_TYPE
@ SESSION_N_FD_TYPE
Definition: application_interface.h:262
session_disconnected_msg_::context
u32 context
Definition: application_interface.h:461
session_::listener_handle
session_handle_t listener_handle
Parent listener session index if the result of an accept.
Definition: session_types.h:208
app_listener_get_w_handle
app_listener_t * app_listener_get_w_handle(session_handle_t handle)
Get app listener for listener session handle.
Definition: application.c:88
VL_API_INVALID_FI
#define VL_API_INVALID_FI
Definition: api_common.h:79
vnet_application_attach
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
Definition: application.c:1142
mq_send_session_migrate_cb
static void mq_send_session_migrate_cb(session_t *s, session_handle_t new_sh)
Definition: session_api.c:422
mq_send_del_segment_sapi_cb
static int mq_send_del_segment_sapi_cb(u32 app_wrk_index, u64 segment_handle)
Definition: session_api.c:1304
vl_api_app_attach_reply_t::vpp_ctrl_mq
u64 vpp_ctrl_mq
Definition: session.api:63
vl_api_app_namespace_add_del_v2_reply_t::appns_index
u32 appns_index
Definition: session.api:305
session_rules_table_rule_tag
u8 * session_rules_table_rule_tag(session_rules_table_t *srt, u32 ri, u8 is_ip4)
Definition: session_rules_table.c:37
session_disconnected_msg_
Definition: application_interface.h:458
APP_SAPI_MSG_TYPE_SEND_FDS
@ APP_SAPI_MSG_TYPE_SEND_FDS
Definition: application_interface.h:820
fifo_segment_t::ssvm
ssvm_private_t ssvm
ssvm segment data
Definition: fifo_segment.h:70
vl_api_app_worker_add_del_t::is_add
bool is_add[default=true]
Definition: session.api:166
session_accepted_msg_::listener_handle
u64 listener_handle
Definition: application_interface.h:377
session_bound_msg_::vpp_evt_q
uword vpp_evt_q
Definition: application_interface.h:354
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
appns_sapi_handle_sock_index
static u32 appns_sapi_handle_sock_index(u32 sapi_sock_handle)
Definition: application_namespace.h:157
vl_api_session_rules_details_t::scope
vl_api_session_rule_scope_t scope
Definition: session.api:393
APP_SAPI_MSG_TYPE_ADD_DEL_WORKER_REPLY
@ APP_SAPI_MSG_TYPE_ADD_DEL_WORKER_REPLY
Definition: application_interface.h:819
SESSION_CTRL_EVT_ACCEPTED
@ SESSION_CTRL_EVT_ACCEPTED
Definition: session_types.h:339
mq_send_session_disconnected_cb
static void mq_send_session_disconnected_cb(session_t *s)
Definition: session_api.c:222
application_reaper_cb
static clib_error_t * application_reaper_cb(u32 client_index)
Definition: session_api.c:1212
app_sapi_msg_
Definition: application_interface.h:883
sapi_add_del_cert_key_handler
static void sapi_add_del_cert_key_handler(app_namespace_t *app_ns, clib_socket_t *cs, app_sapi_cert_key_add_del_msg_t *mp)
Definition: session_api.c:1540
app_sapi_msg_::cert_key_add_del
app_sapi_cert_key_add_del_msg_t cert_key_add_del
Definition: application_interface.h:892
vl_api_app_worker_add_del_t::wrk_index
u32 wrk_index
Definition: session.api:165
session_migrate_msg_::handle
session_handle_t handle
Definition: application_interface.h:534
vl_api_send_fd_msg
static clib_error_t * vl_api_send_fd_msg(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: api.h:107
session_send_fds
static int session_send_fds(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: session_api.c:70
vl_api_vec_to_api_string
int vl_api_vec_to_api_string(const u8 *vec, vl_api_string_t *str)
Definition: api_shared.c:1175
application_lookup
application_t * application_lookup(u32 api_client_index)
Definition: application.c:420
session_main_is_enabled
static u8 session_main_is_enabled()
Definition: session.h:723
api_session_transport_proto_decode
static transport_proto_t api_session_transport_proto_decode(const vl_api_transport_proto_t *api_tp)
Definition: session_api.c:34
format_fns.h
u64
unsigned long u64
Definition: types.h:89
session_bound_msg_::lcl_is_ip4
u8 lcl_is_ip4
Definition: application_interface.h:349
session_mq_cb_vft
static session_cb_vft_t session_mq_cb_vft
Definition: session_api.c:582
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
app_sapi_cert_key_add_del_msg_::index
u32 index
Definition: application_interface.h:870
app_sapi_attach_reply_msg_
Definition: application_interface.h:835
app_namespace_index_from_id
u32 app_namespace_index_from_id(const u8 *ns_id)
Definition: application_namespace.c:188
clib_file_del
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
Definition: file.h:109
api_session_transport_proto_encode
static vl_api_transport_proto_t api_session_transport_proto_encode(const transport_proto_t tp)
Definition: session_api.c:52
vl_api_app_worker_add_del_t::app_index
u32 app_index
Definition: session.api:164
app_sapi_cert_key_add_del_msg_::is_add
u8 is_add
Definition: application_interface.h:873
vl_api_application_tls_key_add_t_handler
static void vl_api_application_tls_key_add_t_handler(vl_api_application_tls_key_add_t *mp)
Definition: session_api.c:1860
app_sapi_attach_reply_msg_::vpp_ctrl_mq_thread
u8 vpp_ctrl_mq_thread
Definition: application_interface.h:843
session_connected_msg_::ct_segment_handle
u64 ct_segment_handle
Definition: application_interface.h:438
vl_api_app_worker_add_del_reply_t::wrk_index
u32 wrk_index
Definition: session.api:185
u32
unsigned int u32
Definition: types.h:88
app_map_another_segment_msg_::segment_name
u8 segment_name[128]
Definition: application_interface.h:520
vl_api_app_namespace_add_del_v3_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: session.api:275
vl_api_app_worker_add_del_reply_t::is_add
bool is_add[default=true]
Definition: session.api:190
appns_sapi_socket_handle
static u32 appns_sapi_socket_handle(app_namespace_t *app_ns, clib_socket_t *cs)
Definition: application_namespace.h:151
session_rule_table_add_del_args_t
struct _session_rules_table_add_del_args session_rule_table_add_del_args_t
transport_endpoint_
Definition: transport_types.h:193
send_session_rule_details6
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:1039
TRANSPORT_N_PROTOS
#define TRANSPORT_N_PROTOS
Definition: session.h:259
vl_api_session_rule_add_del_t::lcl_port
u16 lcl_port
Definition: session.api:347
ssvm_type
ssvm_segment_type_t ssvm_type(const ssvm_private_t *ssvm)
Definition: ssvm.c:451
vl_api_app_namespace_add_del_v3_t::ip6_fib_id
u32 ip6_fib_id
Definition: session.api:277
sapi_sock_read_ready
static clib_error_t * sapi_sock_read_ready(clib_file_t *cf)
Definition: session_api.c:1641
transport_proto_t
enum _transport_proto transport_proto_t
CLIB_SOCKET_F_ALLOW_GROUP_WRITE
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
Definition: socket.h:62
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
session_unlisten_reply_msg_::context
u32 context
Definition: application_interface.h:369
vl_api_app_add_cert_key_pair_t_handler
static void vl_api_app_add_cert_key_pair_t_handler(vl_api_app_add_cert_key_pair_t *mp)
Definition: session_api.c:1144
vl_api_session_rules_details_t::lcl_port
u16 lcl_port
Definition: session.api:389
mq_send_session_bound_cb
int mq_send_session_bound_cb(u32 app_wrk_index, u32 api_context, session_handle_t handle, int rv)
Definition: session_api.c:336
app_worker_get
app_worker_t * app_worker_get(u32 wrk_index)
Definition: application_worker.c:41
vl_api_app_attach_t::client_index
u32 client_index
Definition: session.api:38
appns_sapi_free_socket
static void appns_sapi_free_socket(app_namespace_t *app_ns, clib_socket_t *cs)
Definition: application_namespace.h:139
vl_api_session_enable_disable_t
enable/disable session layer
Definition: session.api:200
session_migrate_msg_::vpp_thread_index
u32 vpp_thread_index
Definition: application_interface.h:537
session_cleanup_msg_
Definition: application_interface.h:540
app_sapi_attach_reply_msg_::fd_flags
u8 fd_flags
Definition: application_interface.h:845
app_worker_
Definition: application.h:32
session_cleanup_msg_::type
u8 type
Definition: application_interface.h:543
session_migrate_msg_::vpp_evt_q
uword vpp_evt_q
Definition: application_interface.h:533
api_helper_macros.h
vl_api_app_attach_reply_t::segment_name
string segment_name[]
Definition: session.api:70
application_get_worker
app_worker_t * application_get_worker(application_t *app, u32 wrk_map_index)
Definition: application.c:976
session_accepted_msg_::server_tx_fifo
uword server_tx_fifo
Definition: application_interface.h:380
vl_api_app_attach_t::options
u64 options[18]
Definition: session.api:40
vl_api_session_rule_add_del_t::appns_index
u32 appns_index
Definition: session.api:351
vl_api_app_add_cert_key_pair_reply_t::index
u32 index
Definition: session.api:106
vlib_rpc_call_main_thread
void vlib_rpc_call_main_thread(void *callback, u8 *args, u32 arg_size)
Definition: threads.c:1616
app_sapi_worker_add_del_reply_msg_::retval
i32 retval
Definition: application_interface.h:857
clib_file_add
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
vl_api_app_namespace_add_del_v2_reply_t
Reply for app namespace add/del.
Definition: session.api:301
session_bound_msg_::context
u32 context
Definition: application_interface.h:346
session_accepted_msg_::flags
u8 flags
Definition: application_interface.h:386
app_sapi_cert_key_add_del_msg_::cert_len
u16 cert_len
Definition: application_interface.h:871
app_map_another_segment_msg_::segment_size
u32 segment_size
Definition: application_interface.h:519
app_namespace_index
u32 app_namespace_index(app_namespace_t *app_ns)
Definition: application_namespace.c:53
mq_send_session_accepted_cb
static int mq_send_session_accepted_cb(session_t *s)
Definition: session_api.c:110
SESSION_INVALID_HANDLE
#define SESSION_INVALID_HANDLE
Definition: session_types.h:23
APP_OPTIONS_FLAGS
@ APP_OPTIONS_FLAGS
Definition: application_interface.h:205
session_connected_msg_::server_tx_fifo
uword server_tx_fifo
Definition: application_interface.h:434
vl_api_app_namespace_add_del_t
add/del application namespace
Definition: session.api:219
vl_api_app_add_cert_key_pair_reply_t
Add certificate and key.
Definition: session.api:103
vl_api_from_api_to_new_vec
u8 * vl_api_from_api_to_new_vec(void *mp, vl_api_string_t *astr)
Definition: api_shared.c:1202
TRANSPORT_SERVICE_CL
@ TRANSPORT_SERVICE_CL
connectionless service
Definition: transport_types.h:40
vnet_app_worker_add_del
int vnet_app_worker_add_del(vnet_app_worker_add_del_args_t *a)
Definition: application.c:1048
app_sapi_worker_add_del_reply_msg_::wrk_index
u32 wrk_index
Definition: application_interface.h:858
vl_api_session_rule_add_del_t::transport_proto
vl_api_transport_proto_t transport_proto
Definition: session.api:344
ip6_mask_to_preflen
u32 ip6_mask_to_preflen(ip6_address_t *mask)
Definition: ip_types.c:562
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
svm_msg_q_lock_and_alloc_msg_w_ring
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.
Definition: message_queue.c:239
session_get_transport_proto
static transport_proto_t session_get_transport_proto(session_t *s)
Definition: session_types.h:242
TRANSPORT_PROTO_API_UDP
@ TRANSPORT_PROTO_API_UDP
Definition: session.api:25
app_worker_::wrk_map_index
u32 wrk_map_index
Worker index in app's map pool.
Definition: application.h:40
application_interface.h
vl_api_app_attach_reply_t::n_fds
u8 n_fds
Definition: session.api:66
vl_api_app_namespace_add_del_v2_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: session.api:248
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
ssvm_private_t::name
u8 * name
Definition: ssvm.h:87
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:525
ssvm_private_t::fd
int fd
memfd segments
Definition: ssvm.h:93
session_transport_service_type
static transport_service_type_t session_transport_service_type(session_t *s)
Definition: session_types.h:261
mq_send_session_connected_cb
int mq_send_session_connected_cb(u32 app_wrk_index, u32 api_context, session_t *s, session_error_t err)
Definition: session_api.c:249
vl_api_app_attach_reply_t::segment_size
u32 segment_size
Definition: session.api:68
vl_api_app_namespace_add_del_v3_t::sock_name
string sock_name[]
Definition: session.api:280
vl_api_session_rule_add_del_t::scope
vl_api_session_rule_scope_t scope
Definition: session.api:352
SESSION_CTRL_EVT_RESET
@ SESSION_CTRL_EVT_RESET
Definition: session_types.h:336
vl_api_app_attach_reply_t::fd_flags
u8 fd_flags
Definition: session.api:67
vl_api_application_tls_cert_add_t
Application add TLS certificate.
Definition: session.api:127
sapi_sock_error
static clib_error_t * sapi_sock_error(clib_file_t *cf)
Definition: session_api.c:1699
session.h
vl_api_session_rules_details_t::lcl
vl_api_prefix_t lcl
Definition: session.api:387
i
int i
Definition: flowhash_template.h:376
session_connected_msg_::ct_rx_fifo
uword ct_rx_fifo
Definition: application_interface.h:436
pool_free
#define pool_free(p)
Free a pool.
Definition: pool.h:447
CLIB_SOCKET_F_PASSCRED
#define CLIB_SOCKET_F_PASSCRED
Definition: socket.h:64
session_unlisten_reply_msg_
Definition: application_interface.h:367
vl_api_application_detach_t_handler
static void vl_api_application_detach_t_handler(vl_api_application_detach_t *mp)
Definition: session_api.c:795
vnet_session_rule_add_del
int vnet_session_rule_add_del(session_rule_add_del_args_t *args)
Definition: session_lookup.c:1317
vl_api_app_attach_reply_t
Application attach reply.
Definition: session.api:59
app_sapi_msg_::type
app_sapi_msg_type_e type
Definition: application_interface.h:885
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
app_sapi_msg_::attach
app_sapi_attach_msg_t attach
Definition: application_interface.h:888
clib_file_del_by_index
static void clib_file_del_by_index(clib_file_main_t *um, uword index)
Definition: file.h:119
APP_SAPI_MSG_TYPE_ATTACH
@ APP_SAPI_MSG_TYPE_ATTACH
Definition: application_interface.h:816
session_api_attach_handler
static void session_api_attach_handler(app_namespace_t *app_ns, clib_socket_t *cs, app_sapi_attach_msg_t *mp)
Definition: session_api.c:1341
context
u32 context
Definition: ip.api:852
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
sapi_send_fds
static void sapi_send_fds(app_worker_t *app_wrk, int *fds, int n_fds)
Definition: session_api.c:1232
vl_api_app_namespace_add_del_v3_t::namespace_id
string namespace_id[64]
Definition: session.api:278
session_::flags
u32 flags
Session flags.
Definition: session_types.h:197
rv
int __clib_unused rv
Definition: application.c:491
key_len
u16 key_len
Definition: ikev2_types.api:95
session_table.h
SESSION_CTRL_EVT_MIGRATED
@ SESSION_CTRL_EVT_MIGRATED
Definition: session_types.h:358
appns_sapi_del_ns_socket
void appns_sapi_del_ns_socket(app_namespace_t *app_ns)
Definition: session_api.c:1766
vl_api_app_namespace_add_del_v2_t::netns
string netns[64]
Definition: session.api:252
vl_api_app_namespace_add_del_reply_t
Reply for app namespace add/del.
Definition: session.api:288
session_bound_msg_
Definition: application_interface.h:344
vl_api_app_namespace_add_del_v3_t::ip4_fib_id
u32 ip4_fib_id
Definition: session.api:276
transport_proto
transport_proto
Definition: session.api:22
vl_api_app_worker_add_del_reply_t::n_fds
u8 n_fds
Definition: session.api:187
fifo_segment_fifo_offset
uword fifo_segment_fifo_offset(svm_fifo_t *f)
Definition: fifo_segment.c:1049
vnet.h
vnet_app_attach_args_t
struct _vnet_app_attach_args_t vnet_app_attach_args_t
ssvm_private_t
Definition: ssvm.h:81
app_worker_::app_index
u32 app_index
Index of owning app.
Definition: application.h:43
clib_socket_t
struct _socket_t clib_socket_t
vl_api_app_namespace_add_del_v2_t_handler
static void vl_api_app_namespace_add_del_v2_t_handler(vl_api_app_namespace_add_del_v2_t *mp)
Definition: session_api.c:867
APP_OPTIONS_NAMESPACE
@ APP_OPTIONS_NAMESPACE
Definition: application_interface.h:214
session_has_transport
static u8 session_has_transport(session_t *s)
Definition: session_types.h:255
app_sapi_attach_reply_msg_::retval
i32 retval
Definition: application_interface.h:837
vl_api_app_namespace_add_del_v3_t_handler
static void vl_api_app_namespace_add_del_v3_t_handler(vl_api_app_namespace_add_del_v3_t *mp)
Definition: session_api.c:917
vnet_app_namespace_add_del
int vnet_app_namespace_add_del(vnet_app_namespace_add_del_args_t *a)
Definition: application_namespace.c:85
TRANSPORT_PROTO_API_TCP
@ TRANSPORT_PROTO_API_TCP
Definition: session.api:24
app_sapi_attach_reply_msg_::app_index
u32 app_index
Definition: application_interface.h:838
SESSION_MQ_CTRL_EVT_RING
@ SESSION_MQ_CTRL_EVT_RING
Definition: session_types.h:402
vl_api_app_namespace_add_del_t::ip6_fib_id
u32 ip6_fib_id
Definition: session.api:226
vl_mem_api_client_index_to_registration
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
Definition: memory_api.c:771
is_local
bool is_local
Definition: ikev2_types.api:33
session_accepted_msg_::lcl
transport_endpoint_t lcl
Definition: application_interface.h:384
app_worker_::api_client_index
u32 api_client_index
API index for the worker.
Definition: application.h:60
session_accepted_msg_
Definition: application_interface.h:374
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(session_api_hookup)
session_accepted_msg_::mq_index
u32 mq_index
Definition: application_interface.h:383
vl_api_session_rule_add_del_t::lcl
vl_api_prefix_t lcl
Definition: session.api:345
session_accepted_msg_::vpp_event_queue_address
uword vpp_event_queue_address
Definition: application_interface.h:382
vl_api_application_tls_key_add_t
Application add TLS key.
Definition: session.api:143
vl_api_app_worker_add_del_t
add/del application worker
Definition: session.api:160
ip_types_api.h
app_listener_get_session
session_t * app_listener_get_session(app_listener_t *al)
Definition: application.c:306
session_cleanup_ntf_t
session_cleanup_ntf_t
Definition: session_types.h:113
vl_api_session_rule_add_del_t_handler
static void vl_api_session_rule_add_del_t_handler(vl_api_session_rule_add_del_t *mp)
Definition: session_api.c:965
session_::session_state
volatile u8 session_state
State in session layer state machine.
Definition: session_types.h:185
appns_sapi_enabled
u8 appns_sapi_enabled(void)
Definition: application_namespace.c:232
app_sapi_cert_key_add_del_reply_msg_::retval
i32 retval
Definition: application_interface.h:879
session_connected_msg_::retval
i32 retval
Definition: application_interface.h:431
app_sapi_msg_::cert_key_add_del_reply
app_sapi_cert_key_add_del_reply_msg_t cert_key_add_del_reply
Definition: application_interface.h:893
vl_api_app_namespace_add_del_t_handler
static void vl_api_app_namespace_add_del_t_handler(vl_api_app_namespace_add_del_t *mp)
Definition: session_api.c:821
app_map_another_segment_msg_::segment_handle
u64 segment_handle
Definition: application_interface.h:521
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
listen_session_get_from_handle
static session_t * listen_session_get_from_handle(session_handle_t handle)
Definition: session.h:631
vl_api_app_worker_add_del_reply_t::app_event_queue_address
u64 app_event_queue_address
Definition: session.api:186
session_table_t
struct _session_lookup_table session_table_t
app_sapi_worker_add_del_reply_msg_::is_add
u8 is_add
Definition: application_interface.h:864
CLIB_SOCKET_F_SEQPACKET
#define CLIB_SOCKET_F_SEQPACKET
Definition: socket.h:63
appns_sapi_add_ns_socket
int appns_sapi_add_ns_socket(app_namespace_t *app_ns)
Definition: session_api.c:1783
vl_api_app_attach_t_handler
static void vl_api_app_attach_t_handler(vl_api_app_attach_t *mp)
Definition: session_api.c:605
vnet_session_enable_disable
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1925
app_sapi_attach_reply_msg_::vpp_ctrl_mq
u64 vpp_ctrl_mq
Definition: application_interface.h:840
svm_msg_q_get_eventfd
static int svm_msg_q_get_eventfd(svm_msg_q_t *mq)
Definition: message_queue.h:431
session_rule_add_del_args_t
struct _session_rule_add_del_args session_rule_add_del_args_t
app_unmap_segment_msg_
Definition: application_interface.h:524
application.h
SESSION_CTRL_EVT_APP_ADD_SEGMENT
@ SESSION_CTRL_EVT_APP_ADD_SEGMENT
Definition: session_types.h:356
clib_socket_accept
__clib_export clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:593
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
vl_api_session_enable_disable_t::is_enable
bool is_enable[default=true]
Definition: session.api:203
app_listener_
Definition: application.h:79
session_connected_msg_::lcl
transport_endpoint_t lcl
Definition: application_interface.h:440
SESSION_CTRL_EVT_APP_DEL_SEGMENT
@ SESSION_CTRL_EVT_APP_DEL_SEGMENT
Definition: session_types.h:357
app_sapi_worker_add_del_msg_
Definition: application_interface.h:848