FD.io VPP  v21.10.1-2-g0a485f517
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/heap.h>
43 #include <vppinfra/pool.h>
44 #include <vppinfra/format.h>
45 #include <vppinfra/error.h>
46 
47 #include <vnet/api_errno.h>
48 #include <vnet/vnet.h>
49 
50 #include <vlib/log.h>
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 #include <vnet/classify/classify.api_enum.h>
64 #include <vnet/ip/ip.api_enum.h>
65 
66 #define vl_typedefs /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
68 #undef vl_typedefs
69 #define vl_endianfun /* define message structures */
70 #include <vpp/api/vpe_all_api_h.h>
71 #undef vl_endianfun
72 /* instantiate all the print functions we know about */
73 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
74 #define vl_printfun
75 #include <vpp/api/vpe_all_api_h.h>
76 #undef vl_printfun
78 
79 #define foreach_vpe_api_msg \
80 _(CONTROL_PING, control_ping) \
81 _(CLI, cli) \
82 _(CLI_INBAND, cli_inband) \
83 _(GET_NODE_INDEX, get_node_index) \
84 _(ADD_NODE_NEXT, add_node_next) \
85 _(SHOW_VERSION, show_version) \
86 _(SHOW_THREADS, show_threads) \
87 _(GET_NODE_GRAPH, get_node_graph) \
88 _(GET_NEXT_INDEX, get_next_index) \
89 _(LOG_DUMP, log_dump) \
90 _(SHOW_VPE_SYSTEM_TIME, show_vpe_system_time) \
91 _(GET_F64_ENDIAN_VALUE, get_f64_endian_value) \
92 _(GET_F64_INCREMENT_BY_ONE, get_f64_increment_by_one) \
93 
94 #define QUOTE_(x) #x
95 #define QUOTE(x) QUOTE_(x)
96 
97 typedef enum
98 {
101 } resolve_t;
102 
104 
105 /* Clean up all registrations belonging to the indicated client */
106 static clib_error_t *
108 {
111  uword *p;
112 
113 #define _(a) \
114  p = hash_get (vam->a##_registration_hash, client_index); \
115  if (p) { \
116  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
117  pool_put (vam->a##_registrations, rp); \
118  hash_unset (vam->a##_registration_hash, client_index); \
119  }
121 #undef _
122  return 0;
123 }
124 
126 
127 static void
129 {
131  int rv = 0;
132 
133  /* *INDENT-OFF* */
134  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
135  ({
136  rmp->vpe_pid = ntohl (getpid());
137  }));
138  /* *INDENT-ON* */
139 }
140 
141 static void
142 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
143 {
144  u8 **shmem_vecp = (u8 **) arg;
145  u8 *shmem_vec;
146  void *oldheap;
147  u32 offset;
148 
149  shmem_vec = *shmem_vecp;
150 
151  offset = vec_len (shmem_vec);
152 
153  oldheap = vl_msg_push_heap ();
154 
155  vec_validate (shmem_vec, offset + buffer_bytes - 1);
156 
157  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
158 
159  vl_msg_pop_heap (oldheap);
160 
161  *shmem_vecp = shmem_vec;
162 }
163 
164 
165 static void
167 {
168  vl_api_cli_reply_t *rp;
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  oldheap = vl_msg_push_heap ();
188  vec_add1 (shmem_vec, 0);
189  vl_msg_pop_heap (oldheap);
190 
191  rp->reply_in_shmem = (uword) shmem_vec;
192 
193  vl_api_send_msg (reg, (u8 *) rp);
194 }
195 
196 static void
197 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
198 {
199  u8 **mem_vecp = (u8 **) arg;
200  u8 *mem_vec = *mem_vecp;
201  u32 offset = vec_len (mem_vec);
202 
203  vec_validate (mem_vec, offset + buffer_bytes - 1);
204  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
205  *mem_vecp = mem_vec;
206 }
207 
208 static void
210 {
212  int rv = 0;
214  unformat_input_t input;
215  u8 *out_vec = 0;
216  u8 *cmd_vec = 0;
217 
218  if (vl_msg_api_get_msg_length (mp) <
219  vl_api_string_len (&mp->cmd) + sizeof (*mp))
220  {
221  rv = -1;
222  goto error;
223  }
224 
225  cmd_vec = vl_api_from_api_to_new_vec (mp, &mp->cmd);
226 
227  unformat_init_string (&input, (char *) cmd_vec,
228  vl_api_string_len (&mp->cmd));
229  rv = vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
230  unformat_free (&input);
231 
232 error:
233  /* *INDENT-OFF* */
234  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, vec_len (out_vec),
235  ({
236  vl_api_vec_to_api_string(out_vec, &rmp->reply);
237  }));
238  /* *INDENT-ON* */
239  vec_free (out_vec);
240  vec_free (cmd_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  /* *INDENT-OFF* */
253  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
254  ({
255  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
256  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
257  ARRAY_LEN(rmp->build_directory)-1);
258  strncpy ((char *) rmp->version, vpe_api_get_version(),
259  ARRAY_LEN(rmp->version)-1);
260  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
261  ARRAY_LEN(rmp->build_date)-1);
262  }));
263  /* *INDENT-ON* */
264 }
265 
266 static void
267 get_thread_data (vl_api_thread_data_t * td, int index)
268 {
270  td->id = htonl (index);
271  if (w->name)
272  strncpy ((char *) td->name, (char *) w->name, ARRAY_LEN (td->name) - 1);
273  if (w->registration)
274  strncpy ((char *) td->type, (char *) w->registration->name,
275  ARRAY_LEN (td->type) - 1);
276  td->pid = htonl (w->lwp);
277  td->cpu_id = htonl (w->cpu_id);
278  td->core = htonl (w->core_id);
279  td->cpu_socket = htonl (w->numa_id);
280 }
281 
282 static void
284 {
285  int count = 0;
286 
287 #if !defined(__powerpc64__)
290  vl_api_thread_data_t *td;
291  int i, msg_size = 0;
293  if (!count)
294  return;
295 
296  msg_size = sizeof (*rmp) + sizeof (rmp->thread_data[0]) * count;
298  if (!reg)
299  return;
300 
301  rmp = vl_msg_api_alloc (msg_size);
302  clib_memset (rmp, 0, msg_size);
303  rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
304  rmp->context = mp->context;
305  rmp->count = htonl (count);
306  td = rmp->thread_data;
307 
308  for (i = 0; i < count; i++)
309  {
310  get_thread_data (&td[i], i);
311  }
312 
313  vl_api_send_msg (reg, (u8 *) rmp);
314 #else
315 
316  /* unimplemented support */
317  rv = -9;
318  clib_warning ("power pc does not support show threads api");
319  /* *INDENT-OFF* */
320  REPLY_MACRO2(VL_API_SHOW_THREADS_REPLY,
321  ({
322  rmp->count = htonl(count);
323  }));
324  /* *INDENT-ON* */
325 #endif
326 }
327 
328 static void
330 {
333  vlib_node_t *n;
334  int rv = 0;
335  u32 node_index = ~0;
336 
338 
339  if (n == 0)
340  rv = VNET_API_ERROR_NO_SUCH_NODE;
341  else
342  node_index = n->index;
343 
344  /* *INDENT-OFF* */
345  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
346  ({
347  rmp->node_index = htonl(node_index);
348  }));
349  /* *INDENT-ON* */
350 }
351 
352 static void
354 {
357  vlib_node_t *node, *next_node;
358  int rv = 0;
359  u32 next_node_index = ~0, next_index = ~0;
360  uword *p;
361 
363 
364  if (node == 0)
365  {
366  rv = VNET_API_ERROR_NO_SUCH_NODE;
367  goto out;
368  }
369 
370  next_node = vlib_get_node_by_name (vm, mp->next_name);
371 
372  if (next_node == 0)
373  {
374  rv = VNET_API_ERROR_NO_SUCH_NODE2;
375  goto out;
376  }
377  else
378  next_node_index = next_node->index;
379 
380  p = hash_get (node->next_slot_by_node, next_node_index);
381 
382  if (p == 0)
383  {
384  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
385  goto out;
386  }
387  else
388  next_index = p[0];
389 
390 out:
391  /* *INDENT-OFF* */
392  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
393  ({
394  rmp->next_index = htonl(next_index);
395  }));
396  /* *INDENT-ON* */
397 }
398 
399 static void
401 {
404  vlib_node_t *n, *next;
405  int rv = 0;
406  u32 next_index = ~0;
407 
409 
410  if (n == 0)
411  {
412  rv = VNET_API_ERROR_NO_SUCH_NODE;
413  goto out;
414  }
415 
417 
418  if (next == 0)
419  rv = VNET_API_ERROR_NO_SUCH_NODE2;
420  else
421  next_index = vlib_node_add_next (vm, n->index, next->index);
422 
423 out:
424  /* *INDENT-OFF* */
425  REPLY_MACRO2(VL_API_ADD_NODE_NEXT_REPLY,
426  ({
427  rmp->next_index = htonl(next_index);
428  }));
429  /* *INDENT-ON* */
430 }
431 
432 static void
434 {
435  int rv = 0;
436  u8 *vector = 0;
438  void *oldheap;
440  static vlib_node_t ***node_dups;
441  static vlib_main_t **stat_vms;
442 
443  oldheap = vl_msg_push_heap ();
444 
445  /*
446  * Keep the number of memcpy ops to a minimum (e.g. 1).
447  */
448  vec_validate (vector, 16384);
449  vec_reset_length (vector);
450 
451  vlib_node_get_nodes (vm, 0 /* main threads */ ,
452  0 /* include stats */ ,
453  1 /* barrier sync */ ,
454  &node_dups, &stat_vms);
455  vector = vlib_node_serialize (vm, node_dups, vector, 1 /* include nexts */ ,
456  1 /* include stats */ );
457 
458  vl_msg_pop_heap (oldheap);
459 
460  /* *INDENT-OFF* */
461  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
462  ({
463  rmp->reply_in_shmem = (uword) vector;
464  }));
465  /* *INDENT-ON* */
466 }
467 
468 static void
470  f64 timestamp,
471  vl_api_log_level_t * level, u8 * msg_class, u8 * message)
472 {
473  u32 msg_size;
474 
476  int class_len =
477  clib_min (vec_len (msg_class) + 1, ARRAY_LEN (rmp->msg_class));
478  int message_len =
479  clib_min (vec_len (message) + 1, ARRAY_LEN (rmp->message));
480  msg_size = sizeof (*rmp) + class_len + message_len;
481 
482  rmp = vl_msg_api_alloc (msg_size);
483  clib_memset (rmp, 0, msg_size);
484  rmp->_vl_msg_id = ntohs (VL_API_LOG_DETAILS);
485 
486  rmp->context = context;
488  rmp->level = htonl (*level);
489 
490  memcpy (rmp->msg_class, msg_class, class_len - 1);
491  memcpy (rmp->message, message, message_len - 1);
492  /* enforced by memset() above */
493  ASSERT (0 == rmp->msg_class[class_len - 1]);
494  ASSERT (0 == rmp->message[message_len - 1]);
495 
496  vl_api_send_msg (reg, (u8 *) rmp);
497 }
498 
499 static void
501 {
502 
503  /* from log.c */
504  vlib_log_main_t *lm = &log_main;
505  vlib_log_entry_t *e;
506  int i = last_log_entry ();
507  int count = lm->count;
508  f64 time_offset, start_time;
510 
512  if (reg == 0)
513  return;
514 
515  start_time = clib_net_to_host_f64 (mp->start_timestamp);
516 
517  time_offset = (f64) lm->time_zero_timeval.tv_sec
518  + (((f64) lm->time_zero_timeval.tv_usec) * 1e-6) - lm->time_zero;
519 
520  while (count--)
521  {
522  e = vec_elt_at_index (lm->entries, i);
523  if (start_time <= e->timestamp + time_offset)
524  show_log_details (reg, mp->context, e->timestamp + time_offset,
525  (vl_api_log_level_t *) & e->level,
526  format (0, "%U", format_vlib_log_class, e->class),
527  e->string);
528  i = (i + 1) % lm->size;
529  }
530 
531 }
532 
533 static void
535 {
536  int rv = 0;
538  /* *INDENT-OFF* */
539  REPLY_MACRO2(VL_API_SHOW_VPE_SYSTEM_TIME_REPLY,
540  ({
542  }));
543  /* *INDENT-ON* */
544 }
545 
546 static void
548 {
549  int rv = 0;
550  f64 one = 1.0;
552  if (1.0 != clib_net_to_host_f64 (mp->f64_one))
553  rv = VNET_API_ERROR_API_ENDIAN_FAILED;
554 
555  /* *INDENT-OFF* */
556  REPLY_MACRO2(VL_API_GET_F64_ENDIAN_VALUE_REPLY,
557  ({
559  }));
560  /* *INDENT-ON* */
561 }
562 
563 static void
565  mp)
566 {
567  int rv = 0;
569 
570  /* *INDENT-OFF* */
571  REPLY_MACRO2(VL_API_GET_F64_INCREMENT_BY_ONE_REPLY,
572  ({
574  }));
575  /* *INDENT-ON* */
576 }
577 
578 #define BOUNCE_HANDLER(nn) \
579 static void vl_api_##nn##_t_handler ( \
580  vl_api_##nn##_t *mp) \
581 { \
582  vpe_client_registration_t *reg; \
583  vpe_api_main_t * vam = &vpe_api_main; \
584  svm_queue_t * q; \
585  \
586  /* One registration only... */ \
587  pool_foreach (reg, vam->nn##_registrations) \
588  ({ \
589  q = vl_api_client_index_to_input_queue (reg->client_index); \
590  if (q) { \
591  /* \
592  * If the queue is stuffed, turf the msg and complain \
593  * It's unlikely that the intended recipient is \
594  * alive; avoid deadlock at all costs. \
595  */ \
596  if (q->cursize == q->maxsize) { \
597  clib_warning ("ERROR: receiver queue full, drop msg"); \
598  vl_msg_api_free (mp); \
599  return; \
600  } \
601  vl_msg_api_send_shmem (q, (u8 *)&mp); \
602  return; \
603  } \
604  })); \
605  vl_msg_api_free (mp); \
606 }
607 
608 static void setup_message_id_table (api_main_t * am);
609 
610 /*
611  * vpe_api_hookup
612  * Add vpe's API message handlers to the table.
613  * vlib has already mapped shared memory and
614  * added the client registration handlers.
615  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
616  */
617 static clib_error_t *
619 {
621 
622 #define _(N,n) \
623  vl_msg_api_set_handlers(VL_API_##N, #n, \
624  vl_api_##n##_t_handler, \
625  vl_noop_handler, \
626  vl_api_##n##_t_endian, \
627  vl_api_##n##_t_print, \
628  sizeof(vl_api_##n##_t), 1);
630 #undef _
631 
632  /*
633  * Trace space for classifier mask+match
634  */
635  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
636  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size +=
637  5 * sizeof (u32x4);
638 
639  /*
640  * Thread-safe API messages
641  */
642  am->is_mp_safe[VL_API_CONTROL_PING] = 1;
643  am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
644  am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL] = 1;
645  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
646 
647  /*
648  * Set up the (msg_name, crc, message-id) table
649  */
651 
652  return 0;
653 }
654 
656 
657 clib_error_t *
659 {
661 
662  am->vlib_main = vm;
663  am->vnet_main = vnet_get_main ();
664 #define _(a) \
665  am->a##_registration_hash = hash_create (0, sizeof (uword));
667 #undef _
668 
669  vl_set_memory_region_name ("/vpe-api");
670  vl_mem_api_enable_disable (vm, 1 /* enable it */ );
671 
672  return 0;
673 }
674 
675 static clib_error_t *
677 {
678  u8 *chroot_path;
679  u64 baseva, size, pvt_heap_size;
680  int uid, gid, rv;
681  const int max_buf_size = 4096;
682  char *s, *buf;
683  struct passwd _pw, *pw;
684  struct group _grp, *grp;
685  clib_error_t *e;
686  buf = vec_new (char, 128);
688  {
689  if (unformat (input, "prefix %s", &chroot_path))
690  {
691  vec_add1 (chroot_path, 0);
692  vl_set_memory_root_path ((char *) chroot_path);
693  }
694  else if (unformat (input, "uid %d", &uid))
695  vl_set_memory_uid (uid);
696  else if (unformat (input, "gid %d", &gid))
697  vl_set_memory_gid (gid);
698  else if (unformat (input, "baseva %llx", &baseva))
700  else if (unformat (input, "global-size %lldM", &size))
701  vl_set_global_memory_size (size * (1ULL << 20));
702  else if (unformat (input, "global-size %lldG", &size))
703  vl_set_global_memory_size (size * (1ULL << 30));
704  else if (unformat (input, "global-size %lld", &size))
706  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
707  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
708  else if (unformat (input, "global-pvt-heap-size size %lld",
709  &pvt_heap_size))
710  vl_set_global_pvt_heap_size (pvt_heap_size);
711  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
712  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
713  else if (unformat (input, "api-pvt-heap-size size %lld",
714  &pvt_heap_size))
715  vl_set_api_pvt_heap_size (pvt_heap_size);
716  else if (unformat (input, "api-size %lldM", &size))
717  vl_set_api_memory_size (size * (1ULL << 20));
718  else if (unformat (input, "api-size %lldG", &size))
719  vl_set_api_memory_size (size * (1ULL << 30));
720  else if (unformat (input, "api-size %lld", &size))
722  else if (unformat (input, "uid %s", &s))
723  {
724  /* lookup the username */
725  pw = NULL;
726  while (((rv =
727  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
728  && (vec_len (buf) <= max_buf_size))
729  {
730  vec_resize (buf, vec_len (buf) * 2);
731  }
732  if (rv < 0)
733  {
734  e = clib_error_return_code (0, rv,
737  "cannot fetch username %s", s);
738  vec_free (s);
739  vec_free (buf);
740  return e;
741  }
742  if (pw == NULL)
743  {
744  e =
745  clib_error_return_fatal (0, "username %s does not exist", s);
746  vec_free (s);
747  vec_free (buf);
748  return e;
749  }
750  vec_free (s);
751  vl_set_memory_uid (pw->pw_uid);
752  }
753  else if (unformat (input, "gid %s", &s))
754  {
755  /* lookup the group name */
756  grp = NULL;
757  while (((rv =
758  getgrnam_r (s, &_grp, buf, vec_len (buf),
759  &grp)) == ERANGE)
760  && (vec_len (buf) <= max_buf_size))
761  {
762  vec_resize (buf, vec_len (buf) * 2);
763  }
764  if (rv != 0)
765  {
766  e = clib_error_return_code (0, rv,
769  "cannot fetch group %s", s);
770  vec_free (s);
771  vec_free (buf);
772  return e;
773  }
774  if (grp == NULL)
775  {
776  e = clib_error_return_fatal (0, "group %s does not exist", s);
777  vec_free (s);
778  vec_free (buf);
779  return e;
780  }
781  vec_free (s);
782  vec_free (buf);
783  vl_set_memory_gid (grp->gr_gid);
784  }
785  else
786  return clib_error_return (0, "unknown input `%U'",
787  format_unformat_error, input);
788  }
789  return 0;
790 }
791 
793 
794 void *
796 {
797  return (void *) &unformat_vnet_sw_interface;
798 }
799 
800 #define vl_msg_name_crc_list
802 #undef vl_msg_name_crc_list
803 
804 static void
806 {
807 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
808  foreach_vl_msg_name_crc_memclnt;
809  foreach_vl_msg_name_crc_vpe;
810 #undef _
811 
812 #define vl_api_version_tuple(n,mj, mi, p) \
813  vl_msg_api_add_version (am, #n, mj, mi, p);
814 #include <vpp/api/vpe_all_api_h.h>
815 #undef vl_api_version_tuple
816 }
817 
818 
819 /*
820  * fd.io coding-style-patch-verification: ON
821  *
822  * Local Variables:
823  * eval: (c-set-style "gnu")
824  * End:
825  */
vl_api_control_ping_t_handler
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:128
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vlib_log_entry_t::level
vlib_log_level_t level
Definition: log.h:44
vlib.h
vl_api_cli_t_handler
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
Definition: api.c:166
vlib_node_get_nodes
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:603
vpe_api_main
vpe_api_main_t vpe_api_main
Definition: interface_api.c:47
vlib_log_main_t::count
int count
Definition: log.h:97
vl_api_show_threads_t
show_threads display the information about vpp threads running on system along with their process id,...
Definition: vpe.api:198
foreach_registration_hash
#define foreach_registration_hash
Definition: api_helper_macros.h:394
vl_api_add_node_next_reply_t::next_index
u32 next_index
Definition: vpe.api:163
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
api.h
vlib_log_main_t::entries
vlib_log_entry_t * entries
Definition: log.h:95
vl_api_add_node_next_t::node_name
string node_name[64]
Definition: vpe.api:150
while
while(n_left_from > 0)
Definition: nat44_ei_hairpinning.c:419
vpe_api_get_build_date
char * vpe_api_get_build_date(void)
return the build date
Definition: version.c:161
unix_time_now
static f64 unix_time_now(void)
Definition: time.h:255
unformat_init_vector
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1037
vl_api_get_f64_increment_by_one_t::f64_value
f64 f64_value[default=1.0]
Definition: vpe.api:357
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vl_api_cli_t::cmd_in_shmem
u64 cmd_in_shmem
Definition: vpe.api:89
vl_api_get_next_index_reply_t::next_index
u32 next_index
Definition: vpe.api:285
buffer
char * buffer
Definition: cJSON.h:163
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
vlib_node_add_next
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
vec_new
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:365
vl_api_show_vpe_system_time_reply_t
Reply for show vpe system time.
Definition: vpe.api:317
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
vl_api_log_dump_t::start_timestamp
vl_api_timestamp_t start_timestamp
Definition: vpe.api:291
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_api_show_vpe_system_time_t
Show the current system timestamp.
Definition: vpe.api:306
vpe_api_hookup
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:614
clib_host_to_net_f64
static f64 clib_host_to_net_f64(f64 x)
Definition: byte_order.h:178
vl_api_show_threads_reply_t::count
u32 count
Definition: vpe.api:237
bitmap.h
clib.h
vl_api_cli_inband_t
Definition: vpe.api:91
next
u16 * next
Definition: nat44_ei_out2in.c:718
string.h
vpe_api_main_t
Definition: api_helper_macros.h:414
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
vl_api_get_node_graph_t_handler
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:433
vl_api_cli_t::client_index
u32 client_index
Definition: vpe.api:87
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vl_api_log_details_t::message
string message[256]
Definition: vpe.api:299
api_segment_config
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:672
vl_api_log_details_t::level
vl_api_log_level_t level
Definition: vpe.api:297
memclnt_delete_callback
static clib_error_t * memclnt_delete_callback(u32 client_index)
Definition: api.c:107
foreach_vpe_api_msg
#define foreach_vpe_api_msg
Definition: api.c:79
vl_api_get_next_index_t
Query relative index via node names.
Definition: vpe.api:268
am
app_main_t * am
Definition: application.c:489
vl_api_get_next_index_t::node_name
string node_name[64]
Definition: vpe.api:272
vl_set_memory_uid
void vl_set_memory_uid(int uid)
Definition: memory_shared.c:351
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
fifo.h
node_index
node node_index
Definition: interface_output.c:440
shmem_cli_output
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:142
vl_api_add_node_next_t::next_name
string next_name[64]
Definition: vpe.api:151
unformat_input_t
struct _unformat_input_t unformat_input_t
vl_api_log_details_t::msg_class
string msg_class[32]
Definition: vpe.api:298
vlib_worker_threads
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
vl_api_get_node_graph_reply_t
get_node_graph_reply
Definition: vpe.api:255
RESOLVE_IP4_ADD_DEL_ROUTE
@ RESOLVE_IP4_ADD_DEL_ROUTE
Definition: api.c:99
error
Definition: cJSON.c:88
VLIB_EARLY_CONFIG_FUNCTION
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:220
vpe_api_get_version
char * vpe_api_get_version(void)
Return the image version string.
Definition: version.c:154
vl_api_add_node_next_t
Set the next node for a given node request.
Definition: vpe.api:146
vl_set_global_pvt_heap_size
void vl_set_global_pvt_heap_size(u64 size)
Definition: memory_shared.c:391
resolve_t
resolve_t
Definition: api.c:97
vl_set_api_pvt_heap_size
void vl_set_api_pvt_heap_size(u64 size)
Definition: memory_shared.c:399
vlib_worker_thread_t::core_id
int core_id
Definition: threads.h:107
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
vpe_api_get_build_directory
char * vpe_api_get_build_directory(void)
Return the image build directory name.
Definition: version.c:147
vl_api_control_ping_reply_t
Control ping from the client to the server response.
Definition: vpe.api:72
vlib_log_entry_t::class
vlib_log_class_t class
Definition: log.h:45
hash.h
vl_api_get_next_index_t_handler
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:353
clib_error_return_code
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:93
count
u8 count
Definition: dhcp.api:208
vl_set_memory_region_name
void vl_set_memory_region_name(const char *name)
Definition: memory_api.c:986
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
vl_msg_api_get_msg_length
u32 vl_msg_api_get_msg_length(void *msg_arg)
Definition: api_shared.c:791
vlib_node_t::index
u32 index
Definition: node.h:269
error.h
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vl_api_get_node_index_t
Get node index using name request.
Definition: vpe.api:121
format.h
offset
struct clib_bihash_value offset
template key/value backing page structure
vl_api_get_f64_increment_by_one_t_handler
static void vl_api_get_f64_increment_by_one_t_handler(vl_api_get_f64_increment_by_one_t *mp)
Definition: api.c:564
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
hash_get
#define hash_get(h, key)
Definition: hash.h:249
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vlib_config_function_runtime_t
Definition: init.h:68
vl_api_get_node_index_t::node_name
string node_name[64]
Definition: vpe.api:125
vl_api_show_version_t_handler
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:244
log.h
vl_api_show_version_reply_t::program
string program[32]
Definition: vpe.api:187
last_log_entry
int last_log_entry()
Definition: log.c:62
uword
u64 uword
Definition: types.h:112
vl_api_get_f64_endian_value_t
f64 types are not standardized across the wire.
Definition: vpe.api:329
RESOLVE_IP6_ADD_DEL_ROUTE
@ RESOLVE_IP6_ADD_DEL_ROUTE
Definition: api.c:100
vlib_worker_thread_t::cpu_id
int cpu_id
Definition: threads.h:106
vlib_cli_input
int vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:675
vl_api_cli_reply_t
vpe parser cli string response
Definition: vpe.api:103
vl_api_get_f64_endian_value_t_handler
static void vl_api_get_f64_endian_value_t_handler(vl_api_get_f64_endian_value_t *mp)
Definition: api.c:547
vl_set_memory_root_path
void vl_set_memory_root_path(const char *name)
Definition: memory_shared.c:343
pool.h
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(af_xdp_plugin_api_hookup)
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
time.h
vl_api_get_node_graph_reply_t::reply_in_shmem
u64 reply_in_shmem
Definition: vpe.api:259
vlib_log_entry_t
Definition: log.h:42
vl_api_get_next_index_reply_t
Reply for get next node index.
Definition: vpe.api:281
f64
double f64
Definition: types.h:142
vlib_log_main_t::size
int size
Definition: log.h:97
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
vlib_worker_thread_t::lwp
long lwp
Definition: threads.h:105
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_worker_thread_t::numa_id
int numa_id
Definition: threads.h:108
format.h
vl_api_get_f64_endian_value_reply_t
get_f64_endian_value reply message
Definition: vpe.api:341
log_main
vlib_log_main_t log_main
Definition: log.c:23
vl_api_get_f64_increment_by_one_t
Verify f64 wire format by sending a value and receiving the value + 1.0.
Definition: vpe.api:353
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: api.c:801
vl_api_log_dump_t_handler
static void vl_api_log_dump_t_handler(vl_api_log_dump_t *mp)
Definition: api.c:500
vl_api_cli_inband_t_handler
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:209
clib_min
#define clib_min(x, y)
Definition: clib.h:342
CLIB_ERROR_ERRNO_VALID
@ CLIB_ERROR_ERRNO_VALID
Definition: error_bootstrap.h:51
vl_api_cli_inband_reply_t::reply
string reply[]
Definition: vpe.api:113
vpe_all_api_h.h
REPLY_MACRO3
#define REPLY_MACRO3(t, n, body)
Definition: api_helper_macros.h:141
vl_api_get_node_index_t_handler
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:329
vl_api_add_node_next_t_handler
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
Definition: api.c:400
vl_api_show_threads_t_handler
static void vl_api_show_threads_t_handler(vl_api_show_threads_t *mp)
Definition: api.c:283
vl_api_string_len
u32 vl_api_string_len(vl_api_string_t *astr)
Definition: api_shared.c:1184
vl_api_show_threads_reply_t::context
u32 context
Definition: vpe.api:235
vl_api_get_f64_endian_value_reply_t::f64_one_result
f64 f64_one_result
Definition: vpe.api:345
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
vl_api_get_f64_endian_value_t::f64_one
f64 f64_one[default=1.0]
Definition: vpe.api:333
vl_api_log_dump_t::client_index
u32 client_index
Definition: vpe.api:289
vlib_log_main_t::time_zero
f64 time_zero
Definition: log.h:107
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vlib_worker_thread_t::registration
vlib_thread_registration_t * registration
Definition: threads.h:97
size
u32 size
Definition: vhost_user.h:125
vl_api_log_details_t
Definition: vpe.api:294
index
u32 index
Definition: flow_types.api:221
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
inband_cli_output
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:197
vl_api_get_f64_increment_by_one_reply_t
get_f64_increment_by_one reply
Definition: vpe.api:365
vl_api_control_ping_t
Control ping from client to api server request.
Definition: vpe.api:60
vl_api_log_details_t::timestamp
vl_api_timestamp_t timestamp
Definition: vpe.api:296
vl_api_show_version_reply_t::build_directory
string build_directory[256]
Definition: vpe.api:190
types.h
vl_api_show_version_t
show version
Definition: vpe.api:170
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
unformat_init_string
void unformat_init_string(unformat_input_t *input, char *string, int string_len)
Definition: unformat.c:1029
u64
unsigned long u64
Definition: types.h:89
vl_api_show_threads_reply_t::thread_data
vl_api_thread_data_t thread_data[count]
Definition: vpe.api:238
vl_set_api_memory_size
void vl_set_api_memory_size(u64 size)
Definition: memory_shared.c:383
vl_api_cli_t
Process a vpe parser cli string request.
Definition: vpe.api:85
get_thread_data
static void get_thread_data(vl_api_thread_data_t *td, int index)
Definition: api.c:267
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:462
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vl_api_cli_t::context
u32 context
Definition: vpe.api:88
show_log_details
static void show_log_details(vl_api_registration_t *reg, u32 context, f64 timestamp, vl_api_log_level_t *level, u8 *msg_class, u8 *message)
Definition: api.c:469
vl_api_cli_inband_reply_t
Definition: vpe.api:109
buf
u64 buf
Definition: application.c:493
u32
unsigned int u32
Definition: types.h:88
vl_msg_push_heap
void * vl_msg_push_heap(void)
Definition: cli.c:745
VL_MSG_API_REAPER_FUNCTION
VL_MSG_API_REAPER_FUNCTION(memclnt_delete_callback)
vl_api_show_threads_t::client_index
u32 client_index
Definition: vpe.api:200
vl_api_show_vpe_system_time_reply_t::vpe_system_time
vl_api_timestamp_t vpe_system_time
Definition: vpe.api:321
vl_set_global_memory_size
void vl_set_global_memory_size(u64 size)
Definition: memory_shared.c:375
vlib_log_main_t::time_zero_timeval
struct timeval time_zero_timeval
Definition: log.h:106
vpe_msg_enum.h
api_helper_macros.h
vpe_api_init
clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:654
vlib_worker_thread_t
Definition: threads.h:81
u32x4
unsigned long long u32x4
Definition: ixge.c:28
vlib_log_entry_t::string
u8 * string
Definition: log.h:47
vl_api_log_details_t::context
u32 context
Definition: vpe.api:295
get_unformat_vnet_sw_interface
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:791
vec_resize
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
Definition: vec.h:296
vl_api_log_dump_t
Definition: vpe.api:288
vl_api_show_vpe_system_time_t_handler
static void vl_api_show_vpe_system_time_t_handler(vl_api_show_vpe_system_time_t *mp)
Definition: api.c:534
vlib_thread_registration_::name
char * name
Definition: threads.h:33
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
vec.h
vl_api_show_version_reply_t
show version response
Definition: vpe.api:183
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
clib_error_return_fatal
#define clib_error_return_fatal(e, args...)
Definition: error.h:105
vlib_log_entry_t::timestamp
f64 timestamp
Definition: log.h:46
vl_set_global_memory_baseva
void vl_set_global_memory_baseva(u64 baseva)
Definition: memory_shared.c:367
vlib_node_t
Definition: node.h:247
vl_api_control_ping_reply_t::vpe_pid
u32 vpe_pid
Definition: vpe.api:77
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
unix.h
vl_api_show_version_reply_t::build_date
string build_date[32]
Definition: vpe.api:189
vl_api_log_dump_t::context
u32 context
Definition: vpe.api:290
clib_net_to_host_f64
static f64 clib_net_to_host_f64(f64 x)
Definition: byte_order.h:177
vlib_log_main_t
Definition: log.h:93
vl_api_show_threads_t::context
u32 context
Definition: vpe.api:201
i
int i
Definition: flowhash_template.h:376
vlib_worker_thread_t::name
u8 * name
Definition: threads.h:98
vl_api_add_node_next_reply_t
IP Set the next node for a given node response.
Definition: vpe.api:159
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
context
u32 context
Definition: ip.api:852
rv
int __clib_unused rv
Definition: application.c:491
vl_api_get_next_index_t::next_name
string next_name[64]
Definition: vpe.api:273
vnet.h
api_errno.h
vl_msg_pop_heap
void vl_msg_pop_heap(void *oldheap)
Definition: cli.c:752
vl_api_get_node_graph_t
Definition: vpe.api:241
vl_api_get_node_index_reply_t
Get node index using name request.
Definition: vpe.api:133
vpe_client_registration_t
Definition: api_helper_macros.h:408
vl_api_show_threads_reply_t
show_threads_reply
Definition: vpe.api:233
vl_api_cli_inband_t::cmd
string cmd[]
Definition: vpe.api:95
timestamp
f64 timestamp
Definition: vpe_types.api:28
vl_api_show_version_reply_t::version
string version[32]
Definition: vpe.api:188
CLIB_ERROR_FATAL
@ CLIB_ERROR_FATAL
Definition: error_bootstrap.h:48
vl_api_cli_reply_t::reply_in_shmem
u64 reply_in_shmem
Definition: vpe.api:107
format_vlib_log_class
u8 * format_vlib_log_class(u8 *s, va_list *args)
Definition: log.c:89
vlib_node_serialize
u8 * vlib_node_serialize(vlib_main_t *vm, vlib_node_t ***node_dups, u8 *vector, int include_nexts, int include_stats)
Definition: node_serialize.c:51
heap.h
vl_api_cli_reply_t::context
u32 context
Definition: vpe.api:105
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vl_set_memory_gid
void vl_set_memory_gid(int gid)
Definition: memory_shared.c:359
vl_api_get_node_index_reply_t::node_index
u32 node_index
Definition: vpe.api:137
vl_api_get_f64_increment_by_one_reply_t::f64_value
f64 f64_value
Definition: vpe.api:369
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
vl_mem_api_enable_disable
void vl_mem_api_enable_disable(vlib_main_t *vm, int yesno)
Definition: vlib_api.c:445