FD.io VPP  v18.10-34-gcce845e
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 
63 #define vl_typedefs /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
65 #undef vl_typedefs
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
68 #undef vl_endianfun
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
71 #define vl_printfun
72 #include <vpp/api/vpe_all_api_h.h>
73 #undef vl_printfun
75 
76 #define foreach_vpe_api_msg \
77 _(CONTROL_PING, control_ping) \
78 _(CLI, cli) \
79 _(CLI_INBAND, cli_inband) \
80 _(GET_NODE_INDEX, get_node_index) \
81 _(ADD_NODE_NEXT, add_node_next) \
82 _(SHOW_VERSION, show_version) \
83 _(SHOW_THREADS, show_threads) \
84 _(GET_NODE_GRAPH, get_node_graph) \
85 _(GET_NEXT_INDEX, get_next_index) \
86 
87 #define QUOTE_(x) #x
88 #define QUOTE(x) QUOTE_(x)
89 
90 typedef enum
91 {
94 } resolve_t;
95 
97 
98 /* Clean up all registrations belonging to the indicated client */
99 static clib_error_t *
101 {
104  uword *p;
105  int stats_memclnt_delete_callback (u32 client_index);
106 
107  stats_memclnt_delete_callback (client_index);
108 
109 #define _(a) \
110  p = hash_get (vam->a##_registration_hash, client_index); \
111  if (p) { \
112  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
113  pool_put (vam->a##_registrations, rp); \
114  hash_unset (vam->a##_registration_hash, client_index); \
115  }
117 #undef _
118  return 0;
119 }
120 
122 
123 static void
125 {
127  int rv = 0;
128 
129  /* *INDENT-OFF* */
130  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
131  ({
132  rmp->vpe_pid = ntohl (getpid());
133  }));
134  /* *INDENT-ON* */
135 }
136 
137 static void
138 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
139 {
140  u8 **shmem_vecp = (u8 **) arg;
141  u8 *shmem_vec;
142  void *oldheap;
143  api_main_t *am = &api_main;
144  u32 offset;
145 
146  shmem_vec = *shmem_vecp;
147 
148  offset = vec_len (shmem_vec);
149 
150  pthread_mutex_lock (&am->vlib_rp->mutex);
151  oldheap = svm_push_data_heap (am->vlib_rp);
152 
153  vec_validate (shmem_vec, offset + buffer_bytes - 1);
154 
155  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
156 
157  svm_pop_heap (oldheap);
158  pthread_mutex_unlock (&am->vlib_rp->mutex);
159 
160  *shmem_vecp = shmem_vec;
161 }
162 
163 
164 static void
166 {
167  vl_api_cli_reply_t *rp;
170  api_main_t *am = &api_main;
171  unformat_input_t input;
172  u8 *shmem_vec = 0;
173  void *oldheap;
174 
176  if (!reg)
177  return;;
178 
179  rp = vl_msg_api_alloc (sizeof (*rp));
180  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
181  rp->context = mp->context;
182 
183  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
184 
185  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
186 
187  pthread_mutex_lock (&am->vlib_rp->mutex);
188  oldheap = svm_push_data_heap (am->vlib_rp);
189 
190  vec_add1 (shmem_vec, 0);
191 
192  svm_pop_heap (oldheap);
193  pthread_mutex_unlock (&am->vlib_rp->mutex);
194 
195  rp->reply_in_shmem = (uword) shmem_vec;
196 
197  vl_api_send_msg (reg, (u8 *) rp);
198 }
199 
200 static void
201 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
202 {
203  u8 **mem_vecp = (u8 **) arg;
204  u8 *mem_vec = *mem_vecp;
205  u32 offset = vec_len (mem_vec);
206 
207  vec_validate (mem_vec, offset + buffer_bytes - 1);
208  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
209  *mem_vecp = mem_vec;
210 }
211 
212 static void
214 {
216  int rv = 0;
218  unformat_input_t input;
219  u8 *out_vec = 0;
220 
221  unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
222  vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
223 
224  u32 len = vec_len (out_vec);
225  /* *INDENT-OFF* */
226  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
227  ({
228  rmp->length = htonl (len);
229  clib_memcpy (rmp->reply, out_vec, len);
230  }));
231  /* *INDENT-ON* */
232  vec_free (out_vec);
233 }
234 
235 static void
237 {
239  int rv = 0;
240  char *vpe_api_get_build_directory (void);
241  char *vpe_api_get_version (void);
242  char *vpe_api_get_build_date (void);
243 
244  /* *INDENT-OFF* */
245  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
246  ({
247  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
248  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
249  ARRAY_LEN(rmp->build_directory)-1);
250  strncpy ((char *) rmp->version, vpe_api_get_version(),
251  ARRAY_LEN(rmp->version)-1);
252  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
253  ARRAY_LEN(rmp->build_date)-1);
254  }));
255  /* *INDENT-ON* */
256 }
257 
258 static void
260 {
262  td->id = htonl (index);
263  if (w->name)
264  strncpy ((char *) td->name, (char *) w->name, ARRAY_LEN (td->name) - 1);
265  if (w->registration)
266  strncpy ((char *) td->type, (char *) w->registration->name,
267  ARRAY_LEN (td->type) - 1);
268  td->pid = htonl (w->lwp);
269  td->cpu_id = htonl (w->cpu_id);
270  td->core = htonl (w->core_id);
271  td->cpu_socket = htonl (w->socket_id);
272 }
273 
274 static void
276 {
278  int rv = 0, count = 0;
279 
280 #if !defined(__powerpc64__)
284  int i, msg_size = 0;
286  if (!count)
287  return;
288 
289  msg_size = sizeof (*rmp) + sizeof (rmp->thread_data[0]) * count;
291  if (!reg)
292  return;
293 
294  rmp = vl_msg_api_alloc (msg_size);
295  memset (rmp, 0, msg_size);
296  rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
297  rmp->context = mp->context;
298  rmp->count = htonl (count);
299  td = rmp->thread_data;
300 
301  for (i = 0; i < count; i++)
302  {
303  get_thread_data (&td[i], i);
304  }
305 
306  vl_api_send_msg (reg, (u8 *) rmp);
307 #else
308 
309  /* unimplemented support */
310  rv = -9;
311  clib_warning ("power pc does not support show threads api");
312  /* *INDENT-OFF* */
313  REPLY_MACRO2(VL_API_SHOW_THREADS_REPLY,
314  ({
315  rmp->count = htonl(count);
316  }));
317  /* *INDENT-ON* */
318 #endif
319 }
320 
321 static void
323 {
326  vlib_node_t *n;
327  int rv = 0;
328  u32 node_index = ~0;
329 
330  n = vlib_get_node_by_name (vm, mp->node_name);
331 
332  if (n == 0)
333  rv = VNET_API_ERROR_NO_SUCH_NODE;
334  else
335  node_index = n->index;
336 
337  /* *INDENT-OFF* */
338  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
339  ({
340  rmp->node_index = ntohl(node_index);
341  }));
342  /* *INDENT-ON* */
343 }
344 
345 static void
347 {
350  vlib_node_t *node, *next_node;
351  int rv = 0;
352  u32 next_node_index = ~0, next_index = ~0;
353  uword *p;
354 
355  node = vlib_get_node_by_name (vm, mp->node_name);
356 
357  if (node == 0)
358  {
359  rv = VNET_API_ERROR_NO_SUCH_NODE;
360  goto out;
361  }
362 
363  next_node = vlib_get_node_by_name (vm, mp->next_name);
364 
365  if (next_node == 0)
366  {
367  rv = VNET_API_ERROR_NO_SUCH_NODE2;
368  goto out;
369  }
370  else
371  next_node_index = next_node->index;
372 
373  p = hash_get (node->next_slot_by_node, next_node_index);
374 
375  if (p == 0)
376  {
377  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
378  goto out;
379  }
380  else
381  next_index = p[0];
382 
383 out:
384  /* *INDENT-OFF* */
385  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
386  ({
387  rmp->next_index = ntohl(next_index);
388  }));
389  /* *INDENT-ON* */
390 }
391 
392 static void
394 {
397  vlib_node_t *n, *next;
398  int rv = 0;
399  u32 next_index = ~0;
400 
401  n = vlib_get_node_by_name (vm, mp->node_name);
402 
403  if (n == 0)
404  {
405  rv = VNET_API_ERROR_NO_SUCH_NODE;
406  goto out;
407  }
408 
409  next = vlib_get_node_by_name (vm, mp->next_name);
410 
411  if (next == 0)
412  rv = VNET_API_ERROR_NO_SUCH_NODE2;
413  else
414  next_index = vlib_node_add_next (vm, n->index, next->index);
415 
416 out:
417  /* *INDENT-OFF* */
418  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
419  ({
420  rmp->next_index = ntohl(next_index);
421  }));
422  /* *INDENT-ON* */
423 }
424 
425 static void
427 {
428  int rv = 0;
429  u8 *vector = 0;
430  api_main_t *am = &api_main;
432  void *oldheap;
434  static vlib_node_t ***node_dups;
435  static vlib_main_t **stat_vms;
436 
437  pthread_mutex_lock (&am->vlib_rp->mutex);
438  oldheap = svm_push_data_heap (am->vlib_rp);
439 
440  /*
441  * Keep the number of memcpy ops to a minimum (e.g. 1).
442  */
443  vec_validate (vector, 16384);
444  vec_reset_length (vector);
445 
446  vlib_node_get_nodes (vm, 0 /* main threads */ ,
447  0 /* include stats */ ,
448  1 /* barrier sync */ ,
449  &node_dups, &stat_vms);
450  vector = vlib_node_serialize (vm, node_dups, vector, 1 /* include nexts */ ,
451  1 /* include stats */ );
452 
453  svm_pop_heap (oldheap);
454  pthread_mutex_unlock (&am->vlib_rp->mutex);
455 
456  /* *INDENT-OFF* */
457  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
458  ({
459  rmp->reply_in_shmem = (uword) vector;
460  }));
461  /* *INDENT-ON* */
462 }
463 
464 #define BOUNCE_HANDLER(nn) \
465 static void vl_api_##nn##_t_handler ( \
466  vl_api_##nn##_t *mp) \
467 { \
468  vpe_client_registration_t *reg; \
469  vpe_api_main_t * vam = &vpe_api_main; \
470  svm_queue_t * q; \
471  \
472  /* One registration only... */ \
473  pool_foreach(reg, vam->nn##_registrations, \
474  ({ \
475  q = vl_api_client_index_to_input_queue (reg->client_index); \
476  if (q) { \
477  /* \
478  * If the queue is stuffed, turf the msg and complain \
479  * It's unlikely that the intended recipient is \
480  * alive; avoid deadlock at all costs. \
481  */ \
482  if (q->cursize == q->maxsize) { \
483  clib_warning ("ERROR: receiver queue full, drop msg"); \
484  vl_msg_api_free (mp); \
485  return; \
486  } \
487  vl_msg_api_send_shmem (q, (u8 *)&mp); \
488  return; \
489  } \
490  })); \
491  vl_msg_api_free (mp); \
492 }
493 
494 static void setup_message_id_table (api_main_t * am);
495 
496 /*
497  * vpe_api_hookup
498  * Add vpe's API message handlers to the table.
499  * vlib has already mapped shared memory and
500  * added the client registration handlers.
501  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
502  */
503 static clib_error_t *
505 {
506  api_main_t *am = &api_main;
507 
508 #define _(N,n) \
509  vl_msg_api_set_handlers(VL_API_##N, #n, \
510  vl_api_##n##_t_handler, \
511  vl_noop_handler, \
512  vl_api_##n##_t_endian, \
513  vl_api_##n##_t_print, \
514  sizeof(vl_api_##n##_t), 1);
516 #undef _
517 
518  /*
519  * Trace space for classifier mask+match
520  */
521  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
522  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
523  += 5 * sizeof (u32x4);
524 
525  /*
526  * Thread-safe API messages
527  */
528  am->is_mp_safe[VL_API_CONTROL_PING] = 1;
529  am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
530  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
531  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
532 
533  /*
534  * Set up the (msg_name, crc, message-id) table
535  */
537 
538  return 0;
539 }
540 
542 
543 clib_error_t *
545 {
547 
548  am->vlib_main = vm;
549  am->vnet_main = vnet_get_main ();
550 #define _(a) \
551  am->a##_registration_hash = hash_create (0, sizeof (uword));
553 #undef _
554 
555  vl_set_memory_region_name ("/vpe-api");
556  vl_mem_api_enable_disable (vm, 1 /* enable it */ );
557 
558  return 0;
559 }
560 
561 static clib_error_t *
563 {
564  u8 *chroot_path;
565  u64 baseva, size, pvt_heap_size;
566  int uid, gid, rv;
567  const int max_buf_size = 4096;
568  char *s, *buf;
569  struct passwd _pw, *pw;
570  struct group _grp, *grp;
571  clib_error_t *e;
572  buf = vec_new (char, 128);
574  {
575  if (unformat (input, "prefix %s", &chroot_path))
576  {
577  vec_add1 (chroot_path, 0);
578  vl_set_memory_root_path ((char *) chroot_path);
579  }
580  else if (unformat (input, "uid %d", &uid))
581  vl_set_memory_uid (uid);
582  else if (unformat (input, "gid %d", &gid))
583  vl_set_memory_gid (gid);
584  else if (unformat (input, "baseva %llx", &baseva))
586  else if (unformat (input, "global-size %lldM", &size))
587  vl_set_global_memory_size (size * (1ULL << 20));
588  else if (unformat (input, "global-size %lldG", &size))
589  vl_set_global_memory_size (size * (1ULL << 30));
590  else if (unformat (input, "global-size %lld", &size))
592  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
593  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
594  else if (unformat (input, "global-pvt-heap-size size %lld",
595  &pvt_heap_size))
596  vl_set_global_pvt_heap_size (pvt_heap_size);
597  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
598  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
599  else if (unformat (input, "api-pvt-heap-size size %lld",
600  &pvt_heap_size))
601  vl_set_api_pvt_heap_size (pvt_heap_size);
602  else if (unformat (input, "api-size %lldM", &size))
603  vl_set_api_memory_size (size * (1ULL << 20));
604  else if (unformat (input, "api-size %lldG", &size))
605  vl_set_api_memory_size (size * (1ULL << 30));
606  else if (unformat (input, "api-size %lld", &size))
607  vl_set_api_memory_size (size);
608  else if (unformat (input, "uid %s", &s))
609  {
610  /* lookup the username */
611  pw = NULL;
612  while (((rv =
613  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
614  && (vec_len (buf) <= max_buf_size))
615  {
616  vec_resize (buf, vec_len (buf) * 2);
617  }
618  if (rv < 0)
619  {
620  e = clib_error_return_code (0, rv,
623  "cannot fetch username %s", s);
624  vec_free (s);
625  vec_free (buf);
626  return e;
627  }
628  if (pw == NULL)
629  {
630  e =
631  clib_error_return_fatal (0, "username %s does not exist", s);
632  vec_free (s);
633  vec_free (buf);
634  return e;
635  }
636  vec_free (s);
637  vl_set_memory_uid (pw->pw_uid);
638  }
639  else if (unformat (input, "gid %s", &s))
640  {
641  /* lookup the group name */
642  grp = NULL;
643  while (((rv =
644  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
645  && (vec_len (buf) <= max_buf_size))
646  {
647  vec_resize (buf, vec_len (buf) * 2);
648  }
649  if (rv != 0)
650  {
651  e = clib_error_return_code (0, rv,
654  "cannot fetch group %s", s);
655  vec_free (s);
656  vec_free (buf);
657  return e;
658  }
659  if (grp == NULL)
660  {
661  e = clib_error_return_fatal (0, "group %s does not exist", s);
662  vec_free (s);
663  vec_free (buf);
664  return e;
665  }
666  vec_free (s);
667  vec_free (buf);
668  vl_set_memory_gid (grp->gr_gid);
669  }
670  else
671  return clib_error_return (0, "unknown input `%U'",
672  format_unformat_error, input);
673  }
674  return 0;
675 }
676 
678 
679 void *
681 {
682  return (void *) &unformat_vnet_sw_interface;
683 }
684 
685 static u8 *
686 format_arp_event (u8 * s, va_list * args)
687 {
688  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
689 
690  s = format (s, "pid %d: ", ntohl (event->pid));
691  s = format (s, "resolution for %U", format_ip4_address, &event->address);
692  return s;
693 }
694 
695 static u8 *
696 format_nd_event (u8 * s, va_list * args)
697 {
698  vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
699 
700  s = format (s, "pid %d: ", ntohl (event->pid));
701  s = format (s, "resolution for %U", format_ip6_address, event->address);
702  return s;
703 }
704 
705 static clib_error_t *
707  unformat_input_t * input, vlib_cli_command_t * cmd)
708 {
710  vl_api_ip4_arp_event_t *arp_event;
711  vl_api_ip6_nd_event_t *nd_event;
712 
713  if (pool_elts (am->arp_events) == 0 && pool_elts (am->nd_events) == 0 &&
714  pool_elts (am->wc_ip4_arp_events_registrations) == 0 &&
715  pool_elts (am->wc_ip6_nd_events_registrations) == 0)
716  {
717  vlib_cli_output (vm, "No active arp or nd event registrations");
718  return 0;
719  }
720 
721  /* *INDENT-OFF* */
722  pool_foreach (arp_event, am->arp_events,
723  ({
724  vlib_cli_output (vm, "%U", format_arp_event, arp_event);
725  }));
726 
728  pool_foreach(reg, am->wc_ip4_arp_events_registrations,
729  ({
730  vlib_cli_output (vm, "pid %d: bd mac/ip4 binding events",
731  ntohl (reg->client_pid));
732  }));
733 
734  pool_foreach (nd_event, am->nd_events,
735  ({
736  vlib_cli_output (vm, "%U", format_nd_event, nd_event);
737  }));
738 
739  pool_foreach(reg, am->wc_ip6_nd_events_registrations,
740  ({
741  vlib_cli_output (vm, "pid %d: bd mac/ip6 binding events",
742  ntohl (reg->client_pid));
743  }));
744  /* *INDENT-ON* */
745 
746  return 0;
747 }
748 
749 /* *INDENT-OFF* */
750 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
751  .path = "show arp-nd-event registrations",
752  .function = show_ip_arp_nd_events_fn,
753  .short_help = "Show ip4 arp and ip6 nd event registrations",
754 };
755 /* *INDENT-ON* */
756 
757 #define vl_msg_name_crc_list
758 #include <vpp/api/vpe_all_api_h.h>
759 #undef vl_msg_name_crc_list
760 
761 static void
763 {
764 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
765  foreach_vl_msg_name_crc_memclnt;
766  foreach_vl_msg_name_crc_vpe;
767 #undef _
768 
769 #define vl_api_version_tuple(n,mj, mi, p) \
770  vl_msg_api_add_version (am, #n, mj, mi, p);
771 #include <vpp/api/vpe_all_api_h.h>
772 #undef vl_api_version_tuple
773 }
774 
775 
776 /*
777  * fd.io coding-style-patch-verification: ON
778  *
779  * Local Variables:
780  * eval: (c-set-style "gnu")
781  * End:
782  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:437
static clib_error_t * memclnt_delete_callback(u32 client_index)
Definition: api.c:100
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:284
vpe parser cli string response
Definition: vpe.api:105
#define foreach_vpe_api_msg
Definition: api.c:76
show_threads_reply
Definition: vpe.api:236
void vl_set_global_memory_baseva(u64 baseva)
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
Definition: api.c:165
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:688
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
Control ping from client to api server request.
Definition: vpe.api:61
int size
for sanity checking
Definition: api_common.h:80
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:241
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:57
u32 index
Definition: node.h:288
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 clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:562
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
int i
u8 cmd[length]
Definition: vpe.api:97
vlib_main_t * vlib_main
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
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)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1118
unsigned char u8
Definition: types.h:56
trace_cfg_t * api_trace_cfg
Current trace configuration.
Definition: api_common.h:248
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Process a vpe parser cli string request.
Definition: vpe.api:86
void vl_set_global_memory_size(u64 size)
resolve_t
Definition: api.c:90
format_function_t format_ip4_address
Definition: format.h:75
memset(h->entries, 0, sizeof(h->entries[0])*entries)
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:346
Get node index using name request.
Definition: vpe.api:136
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:443
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:426
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:86
u32 context
Definition: vpe.api:89
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:568
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:309
struct _vl_api_ip4_arp_event * arp_events
#define clib_error_return_fatal(e, args...)
Definition: error.h:105
int stats_memclnt_delete_callback(u32 client_index)
#define clib_error_return(e, args...)
Definition: error.h:99
svm_region_t * vlib_rp
Current binary api segment descriptor.
Definition: api_common.h:254
get_node_graph_reply
Definition: vpe.api:258
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:240
unsigned int u32
Definition: types.h:88
void unformat_init_string(unformat_input_t *input, char *string, int string_len)
Definition: unformat.c:1023
u64 cmd_in_shmem
Definition: vpe.api:90
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:138
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:322
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:696
Tell client about an IP4 ARP resolution event or MAC/IP info from ARP requests in L2 BDs...
Definition: ip.api:790
void vl_set_api_pvt_heap_size(u64 size)
u32 client_index
Definition: vpe.api:88
#define REPLY_MACRO3(t, n, body)
struct _vl_api_ip6_nd_event * nd_events
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:201
IP Set the next node for a given node response.
Definition: vpe.api:162
Get node index using name request.
Definition: vpe.api:124
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:393
An API client registration, only in vpp/vlib.
Definition: api_common.h:44
void vl_mem_api_enable_disable(vlib_main_t *vm, int yesno)
Definition: vlib_api.c:447
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:216
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
format_function_t format_ip6_address
Definition: format.h:93
vlib_main_t * vm
Definition: buffer.c:294
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:339
clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:544
#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
#define clib_memcpy(a, b, c)
Definition: string.h:75
void vl_set_memory_gid(int gid)
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:201
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:236
thread data
Definition: vpe.api:219
#define ARRAY_LEN(x)
Definition: clib.h:61
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:706
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:213
static void setup_message_id_table(api_main_t *am)
Definition: api.c:762
Control ping from the client to the server response.
Definition: vpe.api:73
void vl_set_memory_region_name(const char *name)
Definition: memory_api.c:945
Bitmaps built as vectors of machine words.
Set the next node for a given node request.
Definition: vpe.api:149
uword * next_slot_by_node
Definition: node.h:353
Query relative index via node names.
Definition: vpe.api:271
show version
Definition: vpe.api:173
size_t count
Definition: vapi.c:46
static void vl_api_show_threads_t_handler(vl_api_show_threads_t *mp)
Definition: api.c:275
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:109
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:680
u64 uword
Definition: types.h:112
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:686
static void get_thread_data(vl_api_thread_data_t *td, int index)
Definition: api.c:259
show version response
Definition: vpe.api:186
vpe_api_main_t vpe_api_main
Definition: pipe_api.c:39
Tell client about an IP6 ND resolution or MAC/IP info from ICMP6 Neighbor Solicitation in L2 BDs...
Definition: ip.api:832
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:124
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:224
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:93
unsigned long long u32x4
Definition: ixge.c:28
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:504
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
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:201
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128