FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * api.c - message handler registration
4  *
5  * Copyright (c) 2010-2018 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/mman.h>
25 #include <sys/stat.h>
26 #include <netinet/in.h>
27 #include <signal.h>
28 #include <pthread.h>
29 #include <unistd.h>
30 #include <time.h>
31 #include <fcntl.h>
32 #include <string.h>
33 #include <pwd.h>
34 #include <grp.h>
35 
36 #include <vppinfra/clib.h>
37 #include <vppinfra/vec.h>
38 #include <vppinfra/hash.h>
39 #include <vppinfra/bitmap.h>
40 #include <vppinfra/fifo.h>
41 #include <vppinfra/time.h>
42 #include <vppinfra/mheap.h>
43 #include <vppinfra/heap.h>
44 #include <vppinfra/pool.h>
45 #include <vppinfra/format.h>
46 #include <vppinfra/error.h>
47 
48 #include <vnet/api_errno.h>
49 #include <vnet/vnet.h>
50 
51 #include <vlib/vlib.h>
52 #include <vlib/unix/unix.h>
53 #include <vlibapi/api.h>
54 #include <vlibmemory/api.h>
55 
56 #undef BIHASH_TYPE
57 #undef __included_bihash_template_h__
58 
59 #include <vnet/ip/format.h>
60 
61 #include <vpp/api/vpe_msg_enum.h>
62 #include <vpp/api/types.h>
63 
64 #define vl_typedefs /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
66 #undef vl_typedefs
67 #define vl_endianfun /* define message structures */
68 #include <vpp/api/vpe_all_api_h.h>
69 #undef vl_endianfun
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
72 #define vl_printfun
73 #include <vpp/api/vpe_all_api_h.h>
74 #undef vl_printfun
76 
77 #define foreach_vpe_api_msg \
78 _(CONTROL_PING, control_ping) \
79 _(CLI, cli) \
80 _(CLI_INBAND, cli_inband) \
81 _(GET_NODE_INDEX, get_node_index) \
82 _(ADD_NODE_NEXT, add_node_next) \
83 _(SHOW_VERSION, show_version) \
84 _(SHOW_THREADS, show_threads) \
85 _(GET_NODE_GRAPH, get_node_graph) \
86 _(GET_NEXT_INDEX, get_next_index) \
87 
88 #define QUOTE_(x) #x
89 #define QUOTE(x) QUOTE_(x)
90 
91 typedef enum
92 {
95 } resolve_t;
96 
98 
99 /* Clean up all registrations belonging to the indicated client */
100 static clib_error_t *
102 {
105  uword *p;
106 
107 #define _(a) \
108  p = hash_get (vam->a##_registration_hash, client_index); \
109  if (p) { \
110  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
111  pool_put (vam->a##_registrations, rp); \
112  hash_unset (vam->a##_registration_hash, client_index); \
113  }
115 #undef _
116  return 0;
117 }
118 
120 
121 static void
123 {
125  int rv = 0;
126 
127  /* *INDENT-OFF* */
128  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
129  ({
130  rmp->vpe_pid = ntohl (getpid());
131  }));
132  /* *INDENT-ON* */
133 }
134 
135 static void
136 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
137 {
138  u8 **shmem_vecp = (u8 **) arg;
139  u8 *shmem_vec;
140  void *oldheap;
141  api_main_t *am = &api_main;
142  u32 offset;
143 
144  shmem_vec = *shmem_vecp;
145 
146  offset = vec_len (shmem_vec);
147 
148  pthread_mutex_lock (&am->vlib_rp->mutex);
149  oldheap = svm_push_data_heap (am->vlib_rp);
150 
151  vec_validate (shmem_vec, offset + buffer_bytes - 1);
152 
153  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
154 
155  svm_pop_heap (oldheap);
156  pthread_mutex_unlock (&am->vlib_rp->mutex);
157 
158  *shmem_vecp = shmem_vec;
159 }
160 
161 
162 static void
164 {
165  vl_api_cli_reply_t *rp;
168  api_main_t *am = &api_main;
169  unformat_input_t input;
170  u8 *shmem_vec = 0;
171  void *oldheap;
172 
174  if (!reg)
175  return;;
176 
177  rp = vl_msg_api_alloc (sizeof (*rp));
178  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
179  rp->context = mp->context;
180 
181  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
182 
183  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
184 
185  pthread_mutex_lock (&am->vlib_rp->mutex);
186  oldheap = svm_push_data_heap (am->vlib_rp);
187 
188  vec_add1 (shmem_vec, 0);
189 
190  svm_pop_heap (oldheap);
191  pthread_mutex_unlock (&am->vlib_rp->mutex);
192 
193  rp->reply_in_shmem = (uword) shmem_vec;
194 
195  vl_api_send_msg (reg, (u8 *) rp);
196 }
197 
198 static void
199 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
200 {
201  u8 **mem_vecp = (u8 **) arg;
202  u8 *mem_vec = *mem_vecp;
203  u32 offset = vec_len (mem_vec);
204 
205  vec_validate (mem_vec, offset + buffer_bytes - 1);
206  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
207  *mem_vecp = mem_vec;
208 }
209 
210 static void
212 {
214  int rv = 0;
216  unformat_input_t input;
217  u8 *out_vec = 0;
218  u32 len = 0;
219 
220  if (vl_msg_api_get_msg_length (mp) <
221  vl_api_string_len (&mp->cmd) + sizeof (*mp))
222  {
223  rv = -1;
224  goto error;
225  }
226 
227  unformat_init_string (&input, (char *) vl_api_from_api_string (&mp->cmd),
228  vl_api_string_len (&mp->cmd));
229  vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
230 
231  len = vec_len (out_vec);
232 
233 error:
234  /* *INDENT-OFF* */
235  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
236  ({
237  vl_api_to_api_string(len, (const char *)out_vec, &rmp->reply);
238  }));
239  /* *INDENT-ON* */
240  vec_free (out_vec);
241 }
242 
243 static void
245 {
247  int rv = 0;
248  char *vpe_api_get_build_directory (void);
249  char *vpe_api_get_version (void);
250  char *vpe_api_get_build_date (void);
251 
252  u32 program_len = strnlen_s ("vpe", 32);
253  u32 version_len = strnlen_s (vpe_api_get_version (), 32);
254  u32 build_date_len = strnlen_s (vpe_api_get_build_date (), 32);
255  u32 build_directory_len = strnlen_s (vpe_api_get_build_directory (), 256);
256 
257  u32 n = program_len + version_len + build_date_len + build_directory_len;
258 
259  /* *INDENT-OFF* */
260  REPLY_MACRO3(VL_API_SHOW_VERSION_REPLY, n,
261  ({
262  char *p = (char *)&rmp->program;
263  p += vl_api_to_api_string(program_len, "vpe", (vl_api_string_t *)p);
264  p += vl_api_to_api_string(version_len, vpe_api_get_version(), (vl_api_string_t *)p);
265  p += vl_api_to_api_string(build_date_len, vpe_api_get_build_date(), (vl_api_string_t *)p);
267  }));
268  /* *INDENT-ON* */
269 }
270 
271 static void
273 {
275  td->id = htonl (index);
276  if (w->name)
277  strncpy ((char *) td->name, (char *) w->name, ARRAY_LEN (td->name) - 1);
278  if (w->registration)
279  strncpy ((char *) td->type, (char *) w->registration->name,
280  ARRAY_LEN (td->type) - 1);
281  td->pid = htonl (w->lwp);
282  td->cpu_id = htonl (w->cpu_id);
283  td->core = htonl (w->core_id);
284  td->cpu_socket = htonl (w->socket_id);
285 }
286 
287 static void
289 {
291  int rv = 0, count = 0;
292 
293 #if !defined(__powerpc64__)
297  int i, msg_size = 0;
299  if (!count)
300  return;
301 
302  msg_size = sizeof (*rmp) + sizeof (rmp->thread_data[0]) * count;
304  if (!reg)
305  return;
306 
307  rmp = vl_msg_api_alloc (msg_size);
308  clib_memset (rmp, 0, msg_size);
309  rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
310  rmp->context = mp->context;
311  rmp->count = htonl (count);
312  td = rmp->thread_data;
313 
314  for (i = 0; i < count; i++)
315  {
316  get_thread_data (&td[i], i);
317  }
318 
319  vl_api_send_msg (reg, (u8 *) rmp);
320 #else
321 
322  /* unimplemented support */
323  rv = -9;
324  clib_warning ("power pc does not support show threads api");
325  /* *INDENT-OFF* */
326  REPLY_MACRO2(VL_API_SHOW_THREADS_REPLY,
327  ({
328  rmp->count = htonl(count);
329  }));
330  /* *INDENT-ON* */
331 #endif
332 }
333 
334 static void
336 {
339  vlib_node_t *n;
340  int rv = 0;
341  u32 node_index = ~0;
342 
343  n = vlib_get_node_by_name (vm, mp->node_name);
344 
345  if (n == 0)
346  rv = VNET_API_ERROR_NO_SUCH_NODE;
347  else
348  node_index = n->index;
349 
350  /* *INDENT-OFF* */
351  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
352  ({
353  rmp->node_index = ntohl(node_index);
354  }));
355  /* *INDENT-ON* */
356 }
357 
358 static void
360 {
363  vlib_node_t *node, *next_node;
364  int rv = 0;
365  u32 next_node_index = ~0, next_index = ~0;
366  uword *p;
367 
368  node = vlib_get_node_by_name (vm, mp->node_name);
369 
370  if (node == 0)
371  {
372  rv = VNET_API_ERROR_NO_SUCH_NODE;
373  goto out;
374  }
375 
376  next_node = vlib_get_node_by_name (vm, mp->next_name);
377 
378  if (next_node == 0)
379  {
380  rv = VNET_API_ERROR_NO_SUCH_NODE2;
381  goto out;
382  }
383  else
384  next_node_index = next_node->index;
385 
386  p = hash_get (node->next_slot_by_node, next_node_index);
387 
388  if (p == 0)
389  {
390  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
391  goto out;
392  }
393  else
394  next_index = p[0];
395 
396 out:
397  /* *INDENT-OFF* */
398  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
399  ({
400  rmp->next_index = ntohl(next_index);
401  }));
402  /* *INDENT-ON* */
403 }
404 
405 static void
407 {
410  vlib_node_t *n, *next;
411  int rv = 0;
412  u32 next_index = ~0;
413 
414  n = vlib_get_node_by_name (vm, mp->node_name);
415 
416  if (n == 0)
417  {
418  rv = VNET_API_ERROR_NO_SUCH_NODE;
419  goto out;
420  }
421 
422  next = vlib_get_node_by_name (vm, mp->next_name);
423 
424  if (next == 0)
425  rv = VNET_API_ERROR_NO_SUCH_NODE2;
426  else
427  next_index = vlib_node_add_next (vm, n->index, next->index);
428 
429 out:
430  /* *INDENT-OFF* */
431  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
432  ({
433  rmp->next_index = ntohl(next_index);
434  }));
435  /* *INDENT-ON* */
436 }
437 
438 static void
440 {
441  int rv = 0;
442  u8 *vector = 0;
443  api_main_t *am = &api_main;
445  void *oldheap;
447  static vlib_node_t ***node_dups;
448  static vlib_main_t **stat_vms;
449 
450  pthread_mutex_lock (&am->vlib_rp->mutex);
451  oldheap = svm_push_data_heap (am->vlib_rp);
452 
453  /*
454  * Keep the number of memcpy ops to a minimum (e.g. 1).
455  */
456  vec_validate (vector, 16384);
457  vec_reset_length (vector);
458 
459  vlib_node_get_nodes (vm, 0 /* main threads */ ,
460  0 /* include stats */ ,
461  1 /* barrier sync */ ,
462  &node_dups, &stat_vms);
463  vector = vlib_node_serialize (vm, node_dups, vector, 1 /* include nexts */ ,
464  1 /* include stats */ );
465 
466  svm_pop_heap (oldheap);
467  pthread_mutex_unlock (&am->vlib_rp->mutex);
468 
469  /* *INDENT-OFF* */
470  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
471  ({
472  rmp->reply_in_shmem = (uword) vector;
473  }));
474  /* *INDENT-ON* */
475 }
476 
477 #define BOUNCE_HANDLER(nn) \
478 static void vl_api_##nn##_t_handler ( \
479  vl_api_##nn##_t *mp) \
480 { \
481  vpe_client_registration_t *reg; \
482  vpe_api_main_t * vam = &vpe_api_main; \
483  svm_queue_t * q; \
484  \
485  /* One registration only... */ \
486  pool_foreach(reg, vam->nn##_registrations, \
487  ({ \
488  q = vl_api_client_index_to_input_queue (reg->client_index); \
489  if (q) { \
490  /* \
491  * If the queue is stuffed, turf the msg and complain \
492  * It's unlikely that the intended recipient is \
493  * alive; avoid deadlock at all costs. \
494  */ \
495  if (q->cursize == q->maxsize) { \
496  clib_warning ("ERROR: receiver queue full, drop msg"); \
497  vl_msg_api_free (mp); \
498  return; \
499  } \
500  vl_msg_api_send_shmem (q, (u8 *)&mp); \
501  return; \
502  } \
503  })); \
504  vl_msg_api_free (mp); \
505 }
506 
507 static void setup_message_id_table (api_main_t * am);
508 
509 /*
510  * vpe_api_hookup
511  * Add vpe's API message handlers to the table.
512  * vlib has already mapped shared memory and
513  * added the client registration handlers.
514  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
515  */
516 static clib_error_t *
518 {
519  api_main_t *am = &api_main;
520 
521 #define _(N,n) \
522  vl_msg_api_set_handlers(VL_API_##N, #n, \
523  vl_api_##n##_t_handler, \
524  vl_noop_handler, \
525  vl_api_##n##_t_endian, \
526  vl_api_##n##_t_print, \
527  sizeof(vl_api_##n##_t), 1);
529 #undef _
530 
531  /*
532  * Trace space for classifier mask+match
533  */
534  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
535  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
536  += 5 * sizeof (u32x4);
537 
538  /*
539  * Thread-safe API messages
540  */
541  am->is_mp_safe[VL_API_CONTROL_PING] = 1;
542  am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
543  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
544  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
545 
546  /*
547  * Set up the (msg_name, crc, message-id) table
548  */
550 
551  return 0;
552 }
553 
555 
556 clib_error_t *
558 {
560 
561  am->vlib_main = vm;
562  am->vnet_main = vnet_get_main ();
563 #define _(a) \
564  am->a##_registration_hash = hash_create (0, sizeof (uword));
566 #undef _
567 
568  vl_set_memory_region_name ("/vpe-api");
569  vl_mem_api_enable_disable (vm, 1 /* enable it */ );
570 
571  return 0;
572 }
573 
574 static clib_error_t *
576 {
577  u8 *chroot_path;
578  u64 baseva, size, pvt_heap_size;
579  int uid, gid, rv;
580  const int max_buf_size = 4096;
581  char *s, *buf;
582  struct passwd _pw, *pw;
583  struct group _grp, *grp;
584  clib_error_t *e;
585  buf = vec_new (char, 128);
587  {
588  if (unformat (input, "prefix %s", &chroot_path))
589  {
590  vec_add1 (chroot_path, 0);
591  vl_set_memory_root_path ((char *) chroot_path);
592  }
593  else if (unformat (input, "uid %d", &uid))
594  vl_set_memory_uid (uid);
595  else if (unformat (input, "gid %d", &gid))
596  vl_set_memory_gid (gid);
597  else if (unformat (input, "baseva %llx", &baseva))
599  else if (unformat (input, "global-size %lldM", &size))
600  vl_set_global_memory_size (size * (1ULL << 20));
601  else if (unformat (input, "global-size %lldG", &size))
602  vl_set_global_memory_size (size * (1ULL << 30));
603  else if (unformat (input, "global-size %lld", &size))
605  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
606  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
607  else if (unformat (input, "global-pvt-heap-size size %lld",
608  &pvt_heap_size))
609  vl_set_global_pvt_heap_size (pvt_heap_size);
610  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
611  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
612  else if (unformat (input, "api-pvt-heap-size size %lld",
613  &pvt_heap_size))
614  vl_set_api_pvt_heap_size (pvt_heap_size);
615  else if (unformat (input, "api-size %lldM", &size))
616  vl_set_api_memory_size (size * (1ULL << 20));
617  else if (unformat (input, "api-size %lldG", &size))
618  vl_set_api_memory_size (size * (1ULL << 30));
619  else if (unformat (input, "api-size %lld", &size))
620  vl_set_api_memory_size (size);
621  else if (unformat (input, "uid %s", &s))
622  {
623  /* lookup the username */
624  pw = NULL;
625  while (((rv =
626  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
627  && (vec_len (buf) <= max_buf_size))
628  {
629  vec_resize (buf, vec_len (buf) * 2);
630  }
631  if (rv < 0)
632  {
633  e = clib_error_return_code (0, rv,
636  "cannot fetch username %s", s);
637  vec_free (s);
638  vec_free (buf);
639  return e;
640  }
641  if (pw == NULL)
642  {
643  e =
644  clib_error_return_fatal (0, "username %s does not exist", s);
645  vec_free (s);
646  vec_free (buf);
647  return e;
648  }
649  vec_free (s);
650  vl_set_memory_uid (pw->pw_uid);
651  }
652  else if (unformat (input, "gid %s", &s))
653  {
654  /* lookup the group name */
655  grp = NULL;
656  while (((rv =
657  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
658  && (vec_len (buf) <= max_buf_size))
659  {
660  vec_resize (buf, vec_len (buf) * 2);
661  }
662  if (rv != 0)
663  {
664  e = clib_error_return_code (0, rv,
667  "cannot fetch group %s", s);
668  vec_free (s);
669  vec_free (buf);
670  return e;
671  }
672  if (grp == NULL)
673  {
674  e = clib_error_return_fatal (0, "group %s does not exist", s);
675  vec_free (s);
676  vec_free (buf);
677  return e;
678  }
679  vec_free (s);
680  vec_free (buf);
681  vl_set_memory_gid (grp->gr_gid);
682  }
683  else
684  return clib_error_return (0, "unknown input `%U'",
685  format_unformat_error, input);
686  }
687  return 0;
688 }
689 
691 
692 void *
694 {
695  return (void *) &unformat_vnet_sw_interface;
696 }
697 
698 static u8 *
699 format_arp_event (u8 * s, va_list * args)
700 {
701  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
702 
703  s = format (s, "pid %d: ", ntohl (event->pid));
704  s = format (s, "resolution for %U", format_vl_api_ip4_address, event->ip);
705  return s;
706 }
707 
708 static u8 *
709 format_nd_event (u8 * s, va_list * args)
710 {
711  vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
712 
713  s = format (s, "pid %d: ", ntohl (event->pid));
714  s = format (s, "resolution for %U", format_vl_api_ip6_address, event->ip);
715  return s;
716 }
717 
718 static clib_error_t *
720  unformat_input_t * input, vlib_cli_command_t * cmd)
721 {
723  vl_api_ip4_arp_event_t *arp_event;
724  vl_api_ip6_nd_event_t *nd_event;
725 
726  if (pool_elts (am->arp_events) == 0 && pool_elts (am->nd_events) == 0 &&
727  pool_elts (am->wc_ip4_arp_events_registrations) == 0 &&
728  pool_elts (am->wc_ip6_nd_events_registrations) == 0)
729  {
730  vlib_cli_output (vm, "No active arp or nd event registrations");
731  return 0;
732  }
733 
734  /* *INDENT-OFF* */
735  pool_foreach (arp_event, am->arp_events,
736  ({
737  vlib_cli_output (vm, "%U", format_arp_event, arp_event);
738  }));
739 
741  pool_foreach(reg, am->wc_ip4_arp_events_registrations,
742  ({
743  vlib_cli_output (vm, "pid %d: bd mac/ip4 binding events",
744  ntohl (reg->client_pid));
745  }));
746 
747  pool_foreach (nd_event, am->nd_events,
748  ({
749  vlib_cli_output (vm, "%U", format_nd_event, nd_event);
750  }));
751 
752  pool_foreach(reg, am->wc_ip6_nd_events_registrations,
753  ({
754  vlib_cli_output (vm, "pid %d: bd mac/ip6 binding events",
755  ntohl (reg->client_pid));
756  }));
757  /* *INDENT-ON* */
758 
759  return 0;
760 }
761 
762 /* *INDENT-OFF* */
763 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
764  .path = "show arp-nd-event registrations",
765  .function = show_ip_arp_nd_events_fn,
766  .short_help = "Show ip4 arp and ip6 nd event registrations",
767 };
768 /* *INDENT-ON* */
769 
770 #define vl_msg_name_crc_list
771 #include <vpp/api/vpe_all_api_h.h>
772 #undef vl_msg_name_crc_list
773 
774 static void
776 {
777 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
778  foreach_vl_msg_name_crc_memclnt;
779  foreach_vl_msg_name_crc_vpe;
780 #undef _
781 
782 #define vl_api_version_tuple(n,mj, mi, p) \
783  vl_msg_api_add_version (am, #n, mj, mi, p);
784 #include <vpp/api/vpe_all_api_h.h>
785 #undef vl_api_version_tuple
786 }
787 
788 
789 /*
790  * fd.io coding-style-patch-verification: ON
791  *
792  * Local Variables:
793  * eval: (c-set-style "gnu")
794  * End:
795  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
static clib_error_t * memclnt_delete_callback(u32 client_index)
Definition: api.c:101
vnet_main_t * vnet_main
static void svm_pop_heap(void *oldheap)
Definition: svm.h:94
Reply for get next node index.
Definition: vpe.api:280
vpe parser cli string response
Definition: vpe.api:102
#define foreach_vpe_api_msg
Definition: api.c:77
show_threads_reply
Definition: vpe.api:232
void vl_set_global_memory_baseva(u64 baseva)
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
Definition: api.c:163
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:725
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
Optimized string handling code, including c11-compliant "safe C library" variants.
Control ping from client to api server request.
Definition: vpe.api:59
int size
for sanity checking
Definition: api_common.h:81
void vl_set_memory_uid(int uid)
unsigned long u64
Definition: types.h:89
Fixed length block allocator.
void vl_set_global_pvt_heap_size(u64 size)
vl_api_thread_data_t thread_data[count]
Definition: vpe.api:237
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:58
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 index
Definition: node.h:279
VLIB_API_INIT_FUNCTION(vpe_api_hookup)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:34
static int vl_api_to_api_string(u32 len, const char *buf, vl_api_string_t *str)
Definition: api_types.h:35
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:575
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
int i
vlib_main_t * vlib_main
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
unformat_function_t unformat_vnet_sw_interface
u8 * vlib_node_serialize(vlib_main_t *vm, vlib_node_t ***node_dups, u8 *vector, int include_nexts, int include_stats)
void * vl_msg_api_alloc(int nbytes)
u8 * format_vl_api_ip6_address(u8 *s, va_list *args)
Definition: types.c:61
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1092
unsigned char u8
Definition: types.h:56
trace_cfg_t * api_trace_cfg
Current trace configuration.
Definition: api_common.h:249
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Process a vpe parser cli string request.
Definition: vpe.api:84
void vl_set_global_memory_size(u64 size)
resolve_t
Definition: api.c:91
#define clib_memcpy(d, s, n)
Definition: string.h:180
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:359
Get node index using name request.
Definition: vpe.api:132
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:439
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:86
u32 context
Definition: vpe.api:87
void vlib_node_get_nodes(vlib_main_t *vm, u32 max_threads, int include_stats, int barrier_sync, vlib_node_t ****node_dupsp, vlib_main_t ***stat_vmsp)
Get list of nodes.
Definition: node.c:569
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:311
struct _vl_api_ip4_arp_event * arp_events
#define clib_error_return_fatal(e, args...)
Definition: error.h:105
#define clib_error_return(e, args...)
Definition: error.h:99
svm_region_t * vlib_rp
Current binary api segment descriptor.
Definition: api_common.h:255
get_node_graph_reply
Definition: vpe.api:254
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:242
unsigned int u32
Definition: types.h:88
void unformat_init_string(unformat_input_t *input, char *string, int string_len)
Definition: unformat.c:1023
size_t strnlen_s(const char *s, size_t maxsize)
compute the length in s, no more than maxsize
Definition: string.c:433
u64 cmd_in_shmem
Definition: vpe.api:88
void vl_set_memory_root_path(const char *name)
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:36
#define hash_get(h, key)
Definition: hash.h:249
uword size
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:136
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:335
char * vpe_api_get_version(void)
Return the image version string.
Definition: version.c:153
struct _unformat_input_t unformat_input_t
static u8 * format_nd_event(u8 *s, va_list *args)
Definition: api.c:709
Tell client about an IP4 ARP resolution event or MAC/IP info from ARP requests in L2 BDs...
Definition: ip.api:832
void vl_set_api_pvt_heap_size(u64 size)
u32 client_index
Definition: vpe.api:86
#define REPLY_MACRO3(t, n, body)
struct _vl_api_ip6_nd_event * nd_events
u8 len
Definition: ip_types.api:49
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
IP Set the next node for a given node response.
Definition: vpe.api:158
Get node index using name request.
Definition: vpe.api:120
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1031
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
Definition: api.c:406
An API client registration, only in vpp/vlib.
Definition: api_common.h:45
void vl_mem_api_enable_disable(vlib_main_t *vm, int yesno)
Definition: vlib_api.c:448
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:216
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
static u32 vl_api_string_len(vl_api_string_t *astr)
Definition: api_types.h:50
vlib_main_t * vm
Definition: buffer.c:312
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:557
static u8 * vl_api_from_api_string(vl_api_string_t *astr)
Definition: api_types.h:44
#define clib_warning(format, args...)
Definition: error.h:59
char * vpe_api_get_build_directory(void)
Return the image build directory name.
Definition: version.c:146
void vl_set_memory_gid(int gid)
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:199
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:244
thread data
Definition: vpe.api:215
#define ARRAY_LEN(x)
Definition: clib.h:62
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
static clib_error_t * show_ip_arp_nd_events_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: api.c:719
u8 * format_vl_api_ip4_address(u8 *s, va_list *args)
Definition: types.c:51
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:211
static void setup_message_id_table(api_main_t *am)
Definition: api.c:775
Control ping from the client to the server response.
Definition: vpe.api:71
void vl_set_memory_region_name(const char *name)
Definition: memory_api.c:1007
Bitmaps built as vectors of machine words.
Set the next node for a given node request.
Definition: vpe.api:145
uword * next_slot_by_node
Definition: node.h:347
Query relative index via node names.
Definition: vpe.api:267
show version
Definition: vpe.api:169
size_t count
Definition: vapi.c:47
static void vl_api_show_threads_t_handler(vl_api_show_threads_t *mp)
Definition: api.c:288
VL_MSG_API_REAPER_FUNCTION(memclnt_delete_callback)
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
template key/value backing page structure
Definition: bihash_doc.h:44
u64 reply_in_shmem
Definition: vpe.api:106
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:693
u64 uword
Definition: types.h:112
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:699
static void get_thread_data(vl_api_thread_data_t *td, int index)
Definition: api.c:272
show version response
Definition: vpe.api:182
vpe_api_main_t vpe_api_main
Definition: interface_api.c:49
Tell client about an IP6 ND resolution or MAC/IP info from ICMP6 Neighbor Solicitation in L2 BDs...
Definition: ip.api:874
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:122
struct clib_bihash_value offset
template key/value backing page structure
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
char * vpe_api_get_build_date(void)
return the build date
Definition: version.c:160
void vl_set_api_memory_size(u64 size)
u8 * is_mp_safe
Message is mp safe vector.
Definition: api_common.h:225
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:93
unsigned long long u32x4
Definition: ixge.c:28
u32 vl_msg_api_get_msg_length(void *msg_arg)
Definition: api_shared.c:642
vlib_thread_registration_t * registration
Definition: threads.h:102
api_main_t api_main
Definition: api_shared.c:35
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:517
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:762
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
#define foreach_registration_hash
pthread_mutex_t mutex
Definition: svm_common.h:37
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
show_threads display the information about vpp threads running on system along with their process id...
Definition: vpe.api:197
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128