FD.io VPP  v18.07.1-19-g511ce25
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-2016 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 <vpp/stats/stats.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 _(GET_NODE_GRAPH, get_node_graph) \
84 _(GET_NEXT_INDEX, get_next_index) \
85 
86 #define QUOTE_(x) #x
87 #define QUOTE(x) QUOTE_(x)
88 
89 typedef enum
90 {
93 } resolve_t;
94 
96 
97 /* Clean up all registrations belonging to the indicated client */
98 static clib_error_t *
100 {
103  uword *p;
104  int stats_memclnt_delete_callback (u32 client_index);
105 
106  stats_memclnt_delete_callback (client_index);
107 
108 #define _(a) \
109  p = hash_get (vam->a##_registration_hash, client_index); \
110  if (p) { \
111  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
112  pool_put (vam->a##_registrations, rp); \
113  hash_unset (vam->a##_registration_hash, client_index); \
114  }
116 #undef _
117  return 0;
118 }
119 
121 
122 static void
124 {
126  int rv = 0;
127 
128  /* *INDENT-OFF* */
129  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
130  ({
131  rmp->vpe_pid = ntohl (getpid());
132  }));
133  /* *INDENT-ON* */
134 }
135 
136 static void
137 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
138 {
139  u8 **shmem_vecp = (u8 **) arg;
140  u8 *shmem_vec;
141  void *oldheap;
142  api_main_t *am = &api_main;
143  u32 offset;
144 
145  shmem_vec = *shmem_vecp;
146 
147  offset = vec_len (shmem_vec);
148 
149  pthread_mutex_lock (&am->vlib_rp->mutex);
150  oldheap = svm_push_data_heap (am->vlib_rp);
151 
152  vec_validate (shmem_vec, offset + buffer_bytes - 1);
153 
154  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
155 
156  svm_pop_heap (oldheap);
157  pthread_mutex_unlock (&am->vlib_rp->mutex);
158 
159  *shmem_vecp = shmem_vec;
160 }
161 
162 
163 static void
165 {
166  vl_api_cli_reply_t *rp;
169  api_main_t *am = &api_main;
170  unformat_input_t input;
171  u8 *shmem_vec = 0;
172  void *oldheap;
173 
175  if (!reg)
176  return;;
177 
178  rp = vl_msg_api_alloc (sizeof (*rp));
179  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
180  rp->context = mp->context;
181 
182  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
183 
184  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
185 
186  pthread_mutex_lock (&am->vlib_rp->mutex);
187  oldheap = svm_push_data_heap (am->vlib_rp);
188 
189  vec_add1 (shmem_vec, 0);
190 
191  svm_pop_heap (oldheap);
192  pthread_mutex_unlock (&am->vlib_rp->mutex);
193 
194  rp->reply_in_shmem = (uword) shmem_vec;
195 
196  vl_api_send_msg (reg, (u8 *) rp);
197 }
198 
199 static void
200 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
201 {
202  u8 **mem_vecp = (u8 **) arg;
203  u8 *mem_vec = *mem_vecp;
204  u32 offset = vec_len (mem_vec);
205 
206  vec_validate (mem_vec, offset + buffer_bytes - 1);
207  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
208  *mem_vecp = mem_vec;
209 }
210 
211 static void
213 {
215  int rv = 0;
217  unformat_input_t input;
218  u8 *out_vec = 0;
219 
220  unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
221  vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
222 
223  u32 len = vec_len (out_vec);
224  /* *INDENT-OFF* */
225  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
226  ({
227  rmp->length = htonl (len);
228  clib_memcpy (rmp->reply, out_vec, len);
229  }));
230  /* *INDENT-ON* */
231  vec_free (out_vec);
232 }
233 
234 static void
236 {
238  int rv = 0;
239  char *vpe_api_get_build_directory (void);
240  char *vpe_api_get_version (void);
241  char *vpe_api_get_build_date (void);
242 
243  /* *INDENT-OFF* */
244  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
245  ({
246  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
247  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
248  ARRAY_LEN(rmp->build_directory)-1);
249  strncpy ((char *) rmp->version, vpe_api_get_version(),
250  ARRAY_LEN(rmp->version)-1);
251  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
252  ARRAY_LEN(rmp->build_date)-1);
253  }));
254  /* *INDENT-ON* */
255 }
256 
257 static void
259 {
262  vlib_node_t *n;
263  int rv = 0;
264  u32 node_index = ~0;
265 
266  n = vlib_get_node_by_name (vm, mp->node_name);
267 
268  if (n == 0)
269  rv = VNET_API_ERROR_NO_SUCH_NODE;
270  else
271  node_index = n->index;
272 
273  /* *INDENT-OFF* */
274  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
275  ({
276  rmp->node_index = ntohl(node_index);
277  }));
278  /* *INDENT-ON* */
279 }
280 
281 static void
283 {
286  vlib_node_t *node, *next_node;
287  int rv = 0;
288  u32 next_node_index = ~0, next_index = ~0;
289  uword *p;
290 
291  node = vlib_get_node_by_name (vm, mp->node_name);
292 
293  if (node == 0)
294  {
295  rv = VNET_API_ERROR_NO_SUCH_NODE;
296  goto out;
297  }
298 
299  next_node = vlib_get_node_by_name (vm, mp->next_name);
300 
301  if (next_node == 0)
302  {
303  rv = VNET_API_ERROR_NO_SUCH_NODE2;
304  goto out;
305  }
306  else
307  next_node_index = next_node->index;
308 
309  p = hash_get (node->next_slot_by_node, next_node_index);
310 
311  if (p == 0)
312  {
313  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
314  goto out;
315  }
316  else
317  next_index = p[0];
318 
319 out:
320  /* *INDENT-OFF* */
321  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
322  ({
323  rmp->next_index = ntohl(next_index);
324  }));
325  /* *INDENT-ON* */
326 }
327 
328 static void
330 {
333  vlib_node_t *n, *next;
334  int rv = 0;
335  u32 next_index = ~0;
336 
337  n = vlib_get_node_by_name (vm, mp->node_name);
338 
339  if (n == 0)
340  {
341  rv = VNET_API_ERROR_NO_SUCH_NODE;
342  goto out;
343  }
344 
345  next = vlib_get_node_by_name (vm, mp->next_name);
346 
347  if (next == 0)
348  rv = VNET_API_ERROR_NO_SUCH_NODE2;
349  else
350  next_index = vlib_node_add_next (vm, n->index, next->index);
351 
352 out:
353  /* *INDENT-OFF* */
354  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
355  ({
356  rmp->next_index = ntohl(next_index);
357  }));
358  /* *INDENT-ON* */
359 }
360 
361 static void
363 {
364  int rv = 0;
365  u8 *vector = 0;
366  api_main_t *am = &api_main;
368  void *oldheap;
370  static vlib_node_t ***node_dups;
371  static vlib_main_t **stat_vms;
372 
373  pthread_mutex_lock (&am->vlib_rp->mutex);
374  oldheap = svm_push_data_heap (am->vlib_rp);
375 
376  /*
377  * Keep the number of memcpy ops to a minimum (e.g. 1).
378  */
379  vec_validate (vector, 16384);
380  vec_reset_length (vector);
381 
382  vlib_node_get_nodes (vm, 0 /* main threads */ ,
383  0 /* include stats */ ,
384  1 /* barrier sync */ ,
385  &node_dups, &stat_vms);
386  vector = vlib_node_serialize (vm, node_dups, vector, 1 /* include nexts */ ,
387  1 /* include stats */ );
388 
389  svm_pop_heap (oldheap);
390  pthread_mutex_unlock (&am->vlib_rp->mutex);
391 
392  /* *INDENT-OFF* */
393  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
394  ({
395  rmp->reply_in_shmem = (uword) vector;
396  }));
397  /* *INDENT-ON* */
398 }
399 
400 #define BOUNCE_HANDLER(nn) \
401 static void vl_api_##nn##_t_handler ( \
402  vl_api_##nn##_t *mp) \
403 { \
404  vpe_client_registration_t *reg; \
405  vpe_api_main_t * vam = &vpe_api_main; \
406  svm_queue_t * q; \
407  \
408  /* One registration only... */ \
409  pool_foreach(reg, vam->nn##_registrations, \
410  ({ \
411  q = vl_api_client_index_to_input_queue (reg->client_index); \
412  if (q) { \
413  /* \
414  * If the queue is stuffed, turf the msg and complain \
415  * It's unlikely that the intended recipient is \
416  * alive; avoid deadlock at all costs. \
417  */ \
418  if (q->cursize == q->maxsize) { \
419  clib_warning ("ERROR: receiver queue full, drop msg"); \
420  vl_msg_api_free (mp); \
421  return; \
422  } \
423  vl_msg_api_send_shmem (q, (u8 *)&mp); \
424  return; \
425  } \
426  })); \
427  vl_msg_api_free (mp); \
428 }
429 
430 static void setup_message_id_table (api_main_t * am);
431 
432 /*
433  * vpe_api_hookup
434  * Add vpe's API message handlers to the table.
435  * vlib has alread mapped shared memory and
436  * added the client registration handlers.
437  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
438  */
439 static clib_error_t *
441 {
442  api_main_t *am = &api_main;
443 
444 #define _(N,n) \
445  vl_msg_api_set_handlers(VL_API_##N, #n, \
446  vl_api_##n##_t_handler, \
447  vl_noop_handler, \
448  vl_api_##n##_t_endian, \
449  vl_api_##n##_t_print, \
450  sizeof(vl_api_##n##_t), 1);
452 #undef _
453 
454  /*
455  * Trace space for classifier mask+match
456  */
457  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
458  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
459  += 5 * sizeof (u32x4);
460 
461  /*
462  * Thread-safe API messages
463  */
464  am->is_mp_safe[VL_API_CONTROL_PING] = 1;
465  am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
466  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
467  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
468 
469  /*
470  * Set up the (msg_name, crc, message-id) table
471  */
473 
474  return 0;
475 }
476 
478 
479 clib_error_t *
481 {
483 
484  am->vlib_main = vm;
485  am->vnet_main = vnet_get_main ();
486 #define _(a) \
487  am->a##_registration_hash = hash_create (0, sizeof (uword));
489 #undef _
490 
491  vl_set_memory_region_name ("/vpe-api");
492  vl_mem_api_enable_disable (vm, 1 /* enable it */ );
493 
494  return 0;
495 }
496 
497 static clib_error_t *
499 {
500  u8 *chroot_path;
501  u64 baseva, size, pvt_heap_size;
502  int uid, gid, rv;
503  const int max_buf_size = 4096;
504  char *s, *buf;
505  struct passwd _pw, *pw;
506  struct group _grp, *grp;
507  clib_error_t *e;
508  buf = vec_new (char, 128);
510  {
511  if (unformat (input, "prefix %s", &chroot_path))
512  {
513  vec_add1 (chroot_path, 0);
514  vl_set_memory_root_path ((char *) chroot_path);
515  }
516  else if (unformat (input, "uid %d", &uid))
517  vl_set_memory_uid (uid);
518  else if (unformat (input, "gid %d", &gid))
519  vl_set_memory_gid (gid);
520  else if (unformat (input, "baseva %llx", &baseva))
522  else if (unformat (input, "global-size %lldM", &size))
523  vl_set_global_memory_size (size * (1ULL << 20));
524  else if (unformat (input, "global-size %lldG", &size))
525  vl_set_global_memory_size (size * (1ULL << 30));
526  else if (unformat (input, "global-size %lld", &size))
528  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
529  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
530  else if (unformat (input, "global-pvt-heap-size size %lld",
531  &pvt_heap_size))
532  vl_set_global_pvt_heap_size (pvt_heap_size);
533  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
534  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
535  else if (unformat (input, "api-pvt-heap-size size %lld",
536  &pvt_heap_size))
537  vl_set_api_pvt_heap_size (pvt_heap_size);
538  else if (unformat (input, "api-size %lldM", &size))
539  vl_set_api_memory_size (size * (1ULL << 20));
540  else if (unformat (input, "api-size %lldG", &size))
541  vl_set_api_memory_size (size * (1ULL << 30));
542  else if (unformat (input, "api-size %lld", &size))
543  vl_set_api_memory_size (size);
544  else if (unformat (input, "uid %s", &s))
545  {
546  /* lookup the username */
547  pw = NULL;
548  while (((rv =
549  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
550  && (vec_len (buf) <= max_buf_size))
551  {
552  vec_resize (buf, vec_len (buf) * 2);
553  }
554  if (rv < 0)
555  {
556  e = clib_error_return_code (0, rv,
559  "cannot fetch username %s", s);
560  vec_free (s);
561  vec_free (buf);
562  return e;
563  }
564  if (pw == NULL)
565  {
566  e =
567  clib_error_return_fatal (0, "username %s does not exist", s);
568  vec_free (s);
569  vec_free (buf);
570  return e;
571  }
572  vec_free (s);
573  vl_set_memory_uid (pw->pw_uid);
574  }
575  else if (unformat (input, "gid %s", &s))
576  {
577  /* lookup the group name */
578  grp = NULL;
579  while (((rv =
580  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
581  && (vec_len (buf) <= max_buf_size))
582  {
583  vec_resize (buf, vec_len (buf) * 2);
584  }
585  if (rv != 0)
586  {
587  e = clib_error_return_code (0, rv,
590  "cannot fetch group %s", s);
591  vec_free (s);
592  vec_free (buf);
593  return e;
594  }
595  if (grp == NULL)
596  {
597  e = clib_error_return_fatal (0, "group %s does not exist", s);
598  vec_free (s);
599  vec_free (buf);
600  return e;
601  }
602  vec_free (s);
603  vec_free (buf);
604  vl_set_memory_gid (grp->gr_gid);
605  }
606  else
607  return clib_error_return (0, "unknown input `%U'",
608  format_unformat_error, input);
609  }
610  return 0;
611 }
612 
614 
615 void *
617 {
618  return (void *) &unformat_vnet_sw_interface;
619 }
620 
621 static u8 *
622 format_arp_event (u8 * s, va_list * args)
623 {
624  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
625 
626  s = format (s, "pid %d: ", ntohl (event->pid));
627  s = format (s, "resolution for %U", format_ip4_address, &event->address);
628  return s;
629 }
630 
631 static u8 *
632 format_nd_event (u8 * s, va_list * args)
633 {
634  vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
635 
636  s = format (s, "pid %d: ", ntohl (event->pid));
637  s = format (s, "resolution for %U", format_ip6_address, event->address);
638  return s;
639 }
640 
641 static clib_error_t *
643  unformat_input_t * input, vlib_cli_command_t * cmd)
644 {
646  vl_api_ip4_arp_event_t *arp_event;
647  vl_api_ip6_nd_event_t *nd_event;
648 
649  if (pool_elts (am->arp_events) == 0 && pool_elts (am->nd_events) == 0 &&
650  pool_elts (am->wc_ip4_arp_events_registrations) == 0 &&
651  pool_elts (am->wc_ip6_nd_events_registrations) == 0)
652  {
653  vlib_cli_output (vm, "No active arp or nd event registrations");
654  return 0;
655  }
656 
657  /* *INDENT-OFF* */
658  pool_foreach (arp_event, am->arp_events,
659  ({
660  vlib_cli_output (vm, "%U", format_arp_event, arp_event);
661  }));
662 
664  pool_foreach(reg, am->wc_ip4_arp_events_registrations,
665  ({
666  vlib_cli_output (vm, "pid %d: bd mac/ip4 binding events",
667  ntohl (reg->client_pid));
668  }));
669 
670  pool_foreach (nd_event, am->nd_events,
671  ({
672  vlib_cli_output (vm, "%U", format_nd_event, nd_event);
673  }));
674 
675  pool_foreach(reg, am->wc_ip6_nd_events_registrations,
676  ({
677  vlib_cli_output (vm, "pid %d: bd mac/ip6 binding events",
678  ntohl (reg->client_pid));
679  }));
680  /* *INDENT-ON* */
681 
682  return 0;
683 }
684 
685 /* *INDENT-OFF* */
686 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
687  .path = "show arp-nd-event registrations",
688  .function = show_ip_arp_nd_events_fn,
689  .short_help = "Show ip4 arp and ip6 nd event registrations",
690 };
691 /* *INDENT-ON* */
692 
693 #define vl_msg_name_crc_list
694 #include <vpp/api/vpe_all_api_h.h>
695 #undef vl_msg_name_crc_list
696 
697 static void
699 {
700 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
701  foreach_vl_msg_name_crc_memclnt;
702  foreach_vl_msg_name_crc_vpe;
703 #undef _
704 
705 #define vl_api_version_tuple(n,mj, mi, p) \
706  vl_msg_api_add_version (am, #n, mj, mi, p);
707 #include <vpp/api/vpe_all_api_h.h>
708 #undef vl_api_version_tuple
709 }
710 
711 
712 /*
713  * fd.io coding-style-patch-verification: ON
714  *
715  * Local Variables:
716  * eval: (c-set-style "gnu")
717  * End:
718  */
#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:99
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:236
vpe parser cli string response
Definition: vpe.api:105
#define foreach_vpe_api_msg
Definition: api.c:76
void vl_set_global_memory_baseva(u64 baseva)
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
Definition: api.c:164
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:644
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)
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:55
u32 index
Definition: node.h:273
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:498
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
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:1110
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:89
format_function_t format_ip4_address
Definition: format.h:81
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:282
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:362
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:567
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:309
unsigned long long u32x4
Definition: ixge.c:28
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:254
get_node_graph_reply
Definition: vpe.api:210
#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)
#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:137
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:258
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:632
Tell client about an IP4 ARP resolution event or MAC/IP info from ARP requests in L2 BDs...
Definition: ip.api:745
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:329
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:195
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
format_function_t format_ip6_address
Definition: format.h:99
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:480
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:200
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:235
#define ARRAY_LEN(x)
Definition: clib.h:59
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:154
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:642
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:212
static void setup_message_id_table(api_main_t *am)
Definition: api.c:698
int stats_memclnt_delete_callback(u32 client_index)
Definition: stats.c:3152
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:918
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:338
Query relative index via node names.
Definition: vpe.api:223
show version
Definition: vpe.api:173
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:616
u64 uword
Definition: types.h:112
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:622
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:787
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:123
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
api_main_t api_main
Definition: api_shared.c:35
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:440
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:681
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
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128