FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
api_shared.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * api_shared.c - API message handling, common code for both clients
4  * and the vlib process itself.
5  *
6  *
7  * Copyright (c) 2009 Cisco and/or its affiliates.
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at:
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *------------------------------------------------------------------
20  */
21 
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stddef.h>
25 #include <string.h>
26 #include <vppinfra/format.h>
27 #include <vppinfra/byte_order.h>
28 #include <vppinfra/error.h>
29 #include <vlib/vlib.h>
30 #include <vlib/unix/unix.h>
31 #include <vlibapi/api.h>
32 #include <vppinfra/elog.h>
33 
34 /* *INDENT-OFF* */
35 api_main_t api_main =
36  {
37  .region_name = "/unset",
38  .api_uid = -1,
39  .api_gid = -1,
40  };
41 /* *INDENT-ON* */
42 
43 void
45 {
46  api_main_t *am = &api_main;
47  am->missing_clients++;
48 }
49 
50 int
52 {
53  return (am->rx_trace && am->rx_trace->enabled);
54 }
55 
56 int
58 {
59  return (am->tx_trace && am->tx_trace->enabled);
60 }
61 
62 /*
63  * vl_msg_api_trace
64  */
65 void
67 {
68  u8 **this_trace;
69  u8 **old_trace;
70  u8 *msg_copy;
71  u32 length;
72  trace_cfg_t *cfgp;
73  u16 msg_id = ntohs (*((u16 *) msg));
74  msgbuf_t *header = (msgbuf_t *) (((u8 *) msg) - offsetof (msgbuf_t, data));
75 
76  cfgp = am->api_trace_cfg + msg_id;
77 
78  if (!cfgp || !cfgp->trace_enable)
79  return;
80 
81  msg_copy = 0;
82 
83  if (tp->nitems == 0)
84  {
85  clib_warning ("tp->nitems is 0");
86  return;
87  }
88 
89  if (vec_len (tp->traces) < tp->nitems)
90  {
91  vec_add1 (tp->traces, 0);
92  this_trace = tp->traces + vec_len (tp->traces) - 1;
93  }
94  else
95  {
96  tp->wrapped = 1;
97  old_trace = tp->traces + tp->curindex++;
98  if (tp->curindex == tp->nitems)
99  tp->curindex = 0;
100  vec_free (*old_trace);
101  this_trace = old_trace;
102  }
103 
104  length = clib_net_to_host_u32 (header->data_len);
105 
106  vec_validate (msg_copy, length - 1);
107  clib_memcpy (msg_copy, msg, length);
108  *this_trace = msg_copy;
109 }
110 
111 int
113  int onoff)
114 {
115  vl_api_trace_t *tp;
116  int rv;
117 
118  switch (which)
119  {
120  case VL_API_TRACE_TX:
121  tp = am->tx_trace;
122  if (tp == 0)
123  {
124  vl_msg_api_trace_configure (am, which, 1024);
125  tp = am->tx_trace;
126  }
127  break;
128 
129  case VL_API_TRACE_RX:
130  tp = am->rx_trace;
131  if (tp == 0)
132  {
133  vl_msg_api_trace_configure (am, which, 1024);
134  tp = am->rx_trace;
135  }
136  break;
137 
138  default:
139  /* duh? */
140  return -1;
141  }
142 
143  /* Configured? */
144  if (tp == 0 || tp->nitems == 0)
145  return -1;
146 
147  rv = tp->enabled;
148  tp->enabled = onoff;
149 
150  return rv;
151 }
152 
153 int
155 {
156  vl_api_trace_t *tp;
157  int i;
158 
159  switch (which)
160  {
161  case VL_API_TRACE_TX:
162  tp = am->tx_trace;
163  break;
164 
165  case VL_API_TRACE_RX:
166  tp = am->rx_trace;
167  break;
168 
169  default:
170  /* duh? */
171  return -1;
172  }
173 
174  /* Configured? */
175  if (!tp || tp->nitems == 0)
176  return -1;
177 
178  tp->curindex = 0;
179  tp->wrapped = 0;
180 
181  for (i = 0; i < vec_len (tp->traces); i++)
182  {
183  vec_free (tp->traces[i]);
184  }
185  vec_free (tp->traces);
186 
187  return 0;
188 }
189 
190 int
192 {
193  vl_api_trace_t *tp;
194  vl_api_trace_file_header_t fh;
195  int i;
196  u8 *msg;
197 
198  switch (which)
199  {
200  case VL_API_TRACE_TX:
201  tp = am->tx_trace;
202  break;
203 
204  case VL_API_TRACE_RX:
205  tp = am->rx_trace;
206  break;
207 
208  default:
209  /* duh? */
210  return -1;
211  }
212 
213  /* Configured, data present? */
214  if (tp == 0 || tp->nitems == 0 || vec_len (tp->traces) == 0)
215  return -1;
216 
217  /* "Dare to be stupid" check */
218  if (fp == 0)
219  {
220  return -2;
221  }
222 
223  /* Write the file header */
224  fh.nitems = vec_len (tp->traces);
225  fh.endian = tp->endian;
226  fh.wrapped = tp->wrapped;
227 
228  if (fwrite (&fh, sizeof (fh), 1, fp) != 1)
229  {
230  return (-10);
231  }
232 
233  /* No-wrap case */
234  if (tp->wrapped == 0)
235  {
236  /*
237  * Note: vec_len return 0 when fed a NULL pointer.
238  * Unfortunately, the static analysis tool doesn't
239  * figure it out, hence the suppressed warnings.
240  * What a great use of my time.
241  */
242  for (i = 0; i < vec_len (tp->traces); i++)
243  {
244  u32 msg_length;
245  /*sa_ignore NO_NULL_CHK */
246  msg = tp->traces[i];
247  /*
248  * This retarded check required to pass
249  * [sic] SA-checking.
250  */
251  if (!msg)
252  continue;
253 
254  msg_length = clib_host_to_net_u32 (vec_len (msg));
255  if (fwrite (&msg_length, 1, sizeof (msg_length), fp)
256  != sizeof (msg_length))
257  {
258  return (-14);
259  }
260  if (fwrite (msg, 1, vec_len (msg), fp) != vec_len (msg))
261  {
262  return (-11);
263  }
264  }
265  }
266  else
267  {
268  /* Wrap case: write oldest -> end of buffer */
269  for (i = tp->curindex; i < vec_len (tp->traces); i++)
270  {
271  u32 msg_length;
272  msg = tp->traces[i];
273  /*
274  * This retarded check required to pass
275  * [sic] SA-checking
276  */
277  if (!msg)
278  continue;
279 
280  msg_length = clib_host_to_net_u32 (vec_len (msg));
281  if (fwrite (&msg_length, 1, sizeof (msg_length), fp)
282  != sizeof (msg_length))
283  {
284  return (-14);
285  }
286 
287  if (fwrite (msg, 1, vec_len (msg), fp) != vec_len (msg))
288  {
289  return (-12);
290  }
291  }
292  /* write beginning of buffer -> oldest-1 */
293  for (i = 0; i < tp->curindex; i++)
294  {
295  u32 msg_length;
296  /*sa_ignore NO_NULL_CHK */
297  msg = tp->traces[i];
298  /*
299  * This retarded check required to pass
300  * [sic] SA-checking
301  */
302  if (!msg)
303  continue;
304 
305  msg_length = clib_host_to_net_u32 (vec_len (msg));
306  if (fwrite (&msg_length, 1, sizeof (msg_length), fp)
307  != sizeof (msg_length))
308  {
309  return (-14);
310  }
311 
312  if (fwrite (msg, 1, vec_len (msg), fp) != vec_len (msg))
313  {
314  return (-13);
315  }
316  }
317  }
318  return 0;
319 }
320 
321 int
323  u32 nitems)
324 {
325  vl_api_trace_t *tp;
326  int was_on = 0;
327 
328  switch (which)
329  {
330  case VL_API_TRACE_TX:
331  tp = am->tx_trace;
332  if (tp == 0)
333  {
334  vec_validate (am->tx_trace, 0);
335  tp = am->tx_trace;
336  }
337  break;
338 
339  case VL_API_TRACE_RX:
340  tp = am->rx_trace;
341  if (tp == 0)
342  {
343  vec_validate (am->rx_trace, 0);
344  tp = am->rx_trace;
345  }
346 
347  break;
348 
349  default:
350  return -1;
351 
352  }
353 
354  if (tp->enabled)
355  {
356  was_on = vl_msg_api_trace_onoff (am, which, 0);
357  }
358  if (tp->traces)
359  {
360  vl_msg_api_trace_free (am, which);
361  }
362 
363  memset (tp, 0, sizeof (*tp));
364 
366  {
368  }
369  else
370  {
372  }
373 
374  tp->nitems = nitems;
375  if (was_on)
376  {
377  (void) vl_msg_api_trace_onoff (am, which, was_on);
378  }
379  return 0;
380 }
381 
382 void
384 {
385 }
386 
387 void
389 {
390 }
391 
392 always_inline void
394  void *the_msg, int trace_it, int do_it, int free_it)
395 {
396  u16 id = ntohs (*((u16 *) the_msg));
397  u8 *(*print_fp) (void *, void *);
398 
399  if (id < vec_len (am->msg_handlers) && am->msg_handlers[id])
400  {
401  if (trace_it)
402  vl_msg_api_trace (am, am->rx_trace, the_msg);
403 
404  if (am->msg_print_flag)
405  {
406  fformat (stdout, "[%d]: %s\n", id, am->msg_names[id]);
407  print_fp = (void *) am->msg_print_handlers[id];
408  if (print_fp == 0)
409  {
410  fformat (stdout, " [no registered print fn]\n");
411  }
412  else
413  {
414  (*print_fp) (the_msg, stdout);
415  }
416  }
417 
418  if (do_it)
419  {
420  if (!am->is_mp_safe[id])
422  (*am->msg_handlers[id]) (the_msg);
423  if (!am->is_mp_safe[id])
425  }
426  }
427  else
428  {
429  clib_warning ("no handler for msg id %d", id);
430  }
431 
432  if (free_it)
433  vl_msg_api_free (the_msg);
434 }
435 
436 /* set to 1 if you want before/after message handler event logging */
437 #define ELOG_API_MESSAGE_HANDLERS 0
438 
439 #if ELOG_API_MESSAGE_HANDLERS > 0
440 static u32
441 elog_id_for_msg_name (vlib_main_t * vm, char *msg_name)
442 {
443  uword *p, r;
444  static uword *h;
445  u8 *name_copy;
446 
447  if (!h)
448  h = hash_create_string (0, sizeof (uword));
449 
450  p = hash_get_mem (h, msg_name);
451  if (p)
452  return p[0];
453  r = elog_string (&vm->elog_main, "%s", msg_name);
454 
455  name_copy = format (0, "%s%c", msg_name, 0);
456 
457  hash_set_mem (h, name_copy, r);
458 
459  return r;
460 }
461 #endif
462 
463 /* This is only to be called from a vlib/vnet app */
464 void
466  void *the_msg, vlib_main_t * vm,
467  vlib_node_runtime_t * node)
468 {
469  u16 id = ntohs (*((u16 *) the_msg));
470  u8 *(*handler) (void *, void *, void *);
471 
472 #if ELOG_API_MESSAGE_HANDLERS > 0
473  {
474  /* *INDENT-OFF* */
475  ELOG_TYPE_DECLARE (e) =
476  {
477  .format = "api-msg: %s",
478  .format_args = "T4",
479  };
480  /* *INDENT-ON* */
481  struct
482  {
483  u32 c;
484  } *ed;
485  ed = ELOG_DATA (&vm->elog_main, e);
486  if (id < vec_len (am->msg_names))
487  ed->c = elog_id_for_msg_name (vm, am->msg_names[id]);
488  else
489  ed->c = elog_id_for_msg_name (vm, "BOGUS");
490  }
491 #endif
492 
493  if (id < vec_len (am->msg_handlers) && am->msg_handlers[id])
494  {
495  handler = (void *) am->msg_handlers[id];
496 
497  if (am->rx_trace && am->rx_trace->enabled)
498  vl_msg_api_trace (am, am->rx_trace, the_msg);
499 
500  if (!am->is_mp_safe[id])
502  (*handler) (the_msg, vm, node);
503  if (!am->is_mp_safe[id])
505  }
506  else
507  {
508  clib_warning ("no handler for msg id %d", id);
509  }
510 
511  /*
512  * Special-case, so we can e.g. bounce messages off the vnet
513  * main thread without copying them...
514  */
515  if (!(am->message_bounce[id]))
516  vl_msg_api_free (the_msg);
517 
518 #if ELOG_API_MESSAGE_HANDLERS > 0
519  {
520  /* *INDENT-OFF* */
521  ELOG_TYPE_DECLARE (e) = {
522  .format = "api-msg-done: %s",
523  .format_args = "T4",
524  };
525  /* *INDENT-ON* */
526 
527  struct
528  {
529  u32 c;
530  } *ed;
531  ed = ELOG_DATA (&vm->elog_main, e);
532  if (id < vec_len (am->msg_names))
533  ed->c = elog_id_for_msg_name (vm, am->msg_names[id]);
534  else
535  ed->c = elog_id_for_msg_name (vm, "BOGUS");
536  }
537 #endif
538 }
539 
540 void
541 vl_msg_api_handler (void *the_msg)
542 {
543  api_main_t *am = &api_main;
544 
545  msg_handler_internal (am, the_msg,
546  (am->rx_trace
547  && am->rx_trace->enabled) /* trace_it */ ,
548  1 /* do_it */ , 1 /* free_it */ );
549 }
550 
551 void
553 {
554  api_main_t *am = &api_main;
555  msg_handler_internal (am, the_msg,
556  (am->rx_trace
557  && am->rx_trace->enabled) /* trace_it */ ,
558  1 /* do_it */ , 0 /* free_it */ );
559 }
560 
561 void
563 {
564  api_main_t *am = &api_main;
565  msg_handler_internal (am, the_msg, 0 /* trace_it */ , 1 /* do_it */ ,
566  0 /* free_it */ );
567 }
568 
569 /*
570  * Add a trace record to the API message trace buffer, if
571  * API message tracing is enabled. Handy for adding sufficient
572  * data to the trace to reproduce autonomous state, as opposed to
573  * state downloaded via control-plane API messages. Example: the NAT
574  * application creates database entries based on packet traffic, not
575  * control-plane messages.
576  *
577  */
578 void
579 vl_msg_api_trace_only (void *the_msg)
580 {
581  api_main_t *am = &api_main;
582 
583  msg_handler_internal (am, the_msg,
584  (am->rx_trace
585  && am->rx_trace->enabled) /* trace_it */ ,
586  0 /* do_it */ , 0 /* free_it */ );
587 }
588 
589 void
591 {
592  api_main_t *am = &api_main;
593  u16 id = ntohs (*((u16 *) the_msg));
594 
595  if (PREDICT_FALSE (id >= vec_len (am->msg_cleanup_handlers)))
596  {
597  clib_warning ("_vl_msg_id too large: %d\n", id);
598  return;
599  }
600  if (am->msg_cleanup_handlers[id])
601  (*am->msg_cleanup_handlers[id]) (the_msg);
602 
603  vl_msg_api_free (the_msg);
604 }
605 
606 /*
607  * vl_msg_api_replay_handler
608  */
609 void
611 {
612  api_main_t *am = &api_main;
613 
614  u16 id = ntohs (*((u16 *) the_msg));
615 
616  if (PREDICT_FALSE (id >= vec_len (am->msg_handlers)))
617  {
618  clib_warning ("_vl_msg_id too large: %d\n", id);
619  return;
620  }
621  /* do NOT trace the message... */
622  if (am->msg_handlers[id])
623  (*am->msg_handlers[id]) (the_msg);
624  /* do NOT free the message buffer... */
625 }
626 
627 u32
629 {
630  return vl_msg_api_get_msg_length_inline (msg_arg);
631 }
632 
633 /*
634  * vl_msg_api_socket_handler
635  */
636 void
638 {
639  api_main_t *am = &api_main;
640 
641  msg_handler_internal (am, the_msg,
642  (am->rx_trace
643  && am->rx_trace->enabled) /* trace_it */ ,
644  1 /* do_it */ , 0 /* free_it */ );
645 }
646 
647 #define foreach_msg_api_vector \
648 _(msg_names) \
649 _(msg_handlers) \
650 _(msg_cleanup_handlers) \
651 _(msg_endian_handlers) \
652 _(msg_print_handlers) \
653 _(api_trace_cfg) \
654 _(message_bounce) \
655 _(is_mp_safe)
656 
657 void
659 {
660  api_main_t *am = &api_main;
661 
662  ASSERT (c->id > 0);
663 
664 #define _(a) vec_validate (am->a, c->id);
666 #undef _
667 
668  if (am->msg_names[c->id])
669  clib_warning ("BUG: multiple registrations of 'vl_api_%s_t_handler'",
670  c->name);
671 
672  am->msg_names[c->id] = c->name;
673  am->msg_handlers[c->id] = c->handler;
674  am->msg_cleanup_handlers[c->id] = c->cleanup;
675  am->msg_endian_handlers[c->id] = c->endian;
676  am->msg_print_handlers[c->id] = c->print;
677  am->message_bounce[c->id] = c->message_bounce;
678  am->is_mp_safe[c->id] = c->is_mp_safe;
679 
680  am->api_trace_cfg[c->id].size = c->size;
681  am->api_trace_cfg[c->id].trace_enable = c->traced;
682  am->api_trace_cfg[c->id].replay_enable = c->replay;
683 }
684 
685 /*
686  * vl_msg_api_set_handlers
687  * preserve the old API for a while
688  */
689 void
690 vl_msg_api_set_handlers (int id, char *name, void *handler, void *cleanup,
691  void *endian, void *print, int size, int traced)
692 {
694  vl_msg_api_msg_config_t *c = &cfg;
695 
696  memset (c, 0, sizeof (*c));
697 
698  c->id = id;
699  c->name = name;
700  c->handler = handler;
701  c->cleanup = cleanup;
702  c->endian = endian;
703  c->print = print;
704  c->traced = traced;
705  c->replay = 1;
706  c->message_bounce = 0;
707  c->is_mp_safe = 0;
708  vl_msg_api_config (c);
709 }
710 
711 void
712 vl_msg_api_set_cleanup_handler (int msg_id, void *fp)
713 {
714  api_main_t *am = &api_main;
715  ASSERT (msg_id > 0);
716 
717  vec_validate (am->msg_cleanup_handlers, msg_id);
718  am->msg_cleanup_handlers[msg_id] = fp;
719 }
720 
721 void
723 {
724  uword msg;
725 
726  while (!unix_shared_memory_queue_sub (q, (u8 *) & msg, 0))
727  vl_msg_api_handler ((void *) msg);
728 }
729 
732 {
733  switch (which)
734  {
735  case VL_API_TRACE_RX:
736  return am->rx_trace;
737  case VL_API_TRACE_TX:
738  return am->tx_trace;
739  default:
740  return 0;
741  }
742 }
743 
744 void
745 vl_noop_handler (void *mp)
746 {
747 }
748 
749 
751 
752 void
754 {
755  post_mortem_dump_enabled = enable;
756 }
757 
758 void
760 {
761  api_main_t *am = &api_main;
762  FILE *fp;
763  char filename[64];
764  int rv;
765 
766  if (post_mortem_dump_enabled == 0)
767  return;
768 
769  snprintf (filename, sizeof (filename), "/tmp/api_post_mortem.%d",
770  getpid ());
771 
772  fp = fopen (filename, "w");
773  if (fp == NULL)
774  {
775  rv = write (2, "Couldn't create ", 16);
776  rv = write (2, filename, strlen (filename));
777  rv = write (2, "\n", 1);
778  return;
779  }
780  rv = vl_msg_api_trace_save (am, VL_API_TRACE_RX, fp);
781  fclose (fp);
782  if (rv < 0)
783  {
784  rv = write (2, "Failed to save post-mortem API trace to ", 40);
785  rv = write (2, filename, strlen (filename));
786  rv = write (2, "\n", 1);
787  }
788 
789 }
790 
791 /* Layered message handling support */
792 
793 void
794 vl_msg_api_register_pd_handler (void *fp, u16 msg_id_host_byte_order)
795 {
796  api_main_t *am = &api_main;
797 
798  /* Mild idiot proofing */
799  if (msg_id_host_byte_order > 10000)
800  clib_warning ("msg_id_host_byte_order endian issue? %d arg vs %d",
801  msg_id_host_byte_order,
802  clib_net_to_host_u16 (msg_id_host_byte_order));
803  vec_validate (am->pd_msg_handlers, msg_id_host_byte_order);
804  am->pd_msg_handlers[msg_id_host_byte_order] = fp;
805 }
806 
807 int
808 vl_msg_api_pd_handler (void *mp, int rv)
809 {
810  api_main_t *am = &api_main;
811  int (*fp) (void *, int);
812  u16 msg_id;
813 
815  msg_id = clib_net_to_host_u16 (*((u16 *) mp));
816  else
817  msg_id = *((u16 *) mp);
818 
819  if (msg_id >= vec_len (am->pd_msg_handlers)
820  || am->pd_msg_handlers[msg_id] == 0)
821  return rv;
822 
823  fp = am->pd_msg_handlers[msg_id];
824  rv = (*fp) (mp, rv);
825  return rv;
826 }
827 
828 void
830 {
831  api_main_t *am = &api_main;
832 
833  am->first_available_msg_id = first_avail;
834 }
835 
836 u16
837 vl_msg_api_get_msg_ids (const char *name, int n)
838 {
839  api_main_t *am = &api_main;
840  u8 *name_copy;
841  vl_api_msg_range_t *rp;
842  uword *p;
843  u16 rv;
844 
845  if (am->msg_range_by_name == 0)
846  am->msg_range_by_name = hash_create_string (0, sizeof (uword));
847 
848  name_copy = format (0, "%s%c", name, 0);
849 
850  p = hash_get_mem (am->msg_range_by_name, name_copy);
851  if (p)
852  {
853  clib_warning ("WARNING: duplicate message range registration for '%s'",
854  name_copy);
855  vec_free (name_copy);
856  return ((u16) ~ 0);
857  }
858 
859  if (n < 0 || n > 1024)
860  {
862  ("WARNING: bad number of message-IDs (%d) requested by '%s'",
863  n, name_copy);
864  vec_free (name_copy);
865  return ((u16) ~ 0);
866  }
867 
868  vec_add2 (am->msg_ranges, rp, 1);
869 
870  rv = rp->first_msg_id = am->first_available_msg_id;
871  am->first_available_msg_id += n;
872  rp->last_msg_id = am->first_available_msg_id - 1;
873  rp->name = name_copy;
874 
875  hash_set_mem (am->msg_range_by_name, name_copy, rp - am->msg_ranges);
876 
877  return rv;
878 }
879 
880 void
881 vl_msg_api_add_msg_name_crc (api_main_t * am, const char *string, u32 id)
882 {
883  uword *p;
884 
885  if (am->msg_index_by_name_and_crc == 0)
887 
888  p = hash_get_mem (am->msg_index_by_name_and_crc, string);
889  if (p)
890  {
891  clib_warning ("attempt to redefine '%s' ignored...", string);
892  return;
893  }
894 
895  hash_set_mem (am->msg_index_by_name_and_crc, string, id);
896 }
897 
898 
899 /*
900  * fd.io coding-style-patch-verification: ON
901  *
902  * Local Variables:
903  * eval: (c-set-style "gnu")
904  * End:
905  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
void vl_msg_api_set_first_available_msg_id(u16 first_avail)
Definition: api_shared.c:829
int vl_msg_api_trace_onoff(api_main_t *am, vl_api_trace_which_t which, int onoff)
Definition: api_shared.c:112
int vl_msg_api_trace_save(api_main_t *am, vl_api_trace_which_t which, FILE *fp)
Definition: api_shared.c:191
void vl_msg_api_set_handlers(int id, char *name, void *handler, void *cleanup, void *endian, void *print, int size, int traced)
Definition: api_shared.c:690
int vl_msg_api_trace_free(api_main_t *am, vl_api_trace_which_t which)
Definition: api_shared.c:154
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
void vl_msg_api_set_cleanup_handler(int msg_id, void *fp)
Definition: api_shared.c:712
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:808
void vl_msg_api_handler(void *the_msg)
Definition: api_shared.c:541
static u64 do_it(pg_main_t *pg, pg_stream_t *s, u32 *buffers, u32 n_buffers, u32 lo_bit, u32 hi_bit, u64 v_min, u64 v_max, u64 v, pg_edit_type_t edit_type)
Definition: input.c:744
#define NULL
Definition: clib.h:55
static void msg_handler_internal(api_main_t *am, void *the_msg, int trace_it, int do_it, int free_it)
Definition: api_shared.c:393
u8 * message_bounce
Definition: api_common.h:176
static u8 post_mortem_dump_enabled
Definition: api_shared.c:750
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
vl_api_trace_t * vl_msg_api_trace_get(api_main_t *am, vl_api_trace_which_t which)
Definition: api_shared.c:731
u32 vl_msg_api_get_msg_length(void *msg_arg)
Definition: api_shared.c:628
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:561
#define hash_set_mem(h, key, value)
Definition: hash.h:274
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
int vl_msg_api_trace_configure(api_main_t *am, vl_api_trace_which_t which, u32 nitems)
Definition: api_shared.c:322
void(** msg_cleanup_handlers)(void *)
Definition: api_common.h:172
void vl_noop_handler(void *mp)
Definition: api_shared.c:745
trace_cfg_t * api_trace_cfg
Definition: api_common.h:185
void vl_msg_api_handler_no_trace_no_free(void *the_msg)
Definition: api_shared.c:562
void vl_msg_api_cleanup_handler(void *the_msg)
Definition: api_shared.c:590
vl_api_trace_t * rx_trace
Definition: api_common.h:182
#define always_inline
Definition: clib.h:84
void vl_msg_api_config(vl_msg_api_msg_config_t *c)
Definition: api_shared.c:658
void vl_msg_api_post_mortem_dump_enable_disable(int enable)
Definition: api_shared.c:753
#define clib_arch_is_little_endian
Definition: byte_order.h:54
int vl_msg_api_tx_trace_enabled(api_main_t *am)
Definition: api_shared.c:57
void vl_msg_api_trace_only(void *the_msg)
Definition: api_shared.c:579
#define hash_create_string(elts, value_bytes)
Definition: hash.h:652
void vl_msg_api_queue_handler(unix_shared_memory_queue_t *q)
Definition: api_shared.c:722
void vl_msg_api_handler_with_vm_node(api_main_t *am, void *the_msg, vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: api_shared.c:465
void vl_msg_api_add_msg_name_crc(api_main_t *am, const char *string, u32 id)
Definition: api_shared.c:881
int vl_msg_api_rx_trace_enabled(api_main_t *am)
Definition: api_shared.c:51
void(** msg_print_handlers)(void *, void *)
Definition: api_common.h:174
int replay_enable
Definition: api_common.h:71
void vl_msg_api_free(void *)
static void cleanup(void)
Definition: client.c:90
#define ELOG_DATA(em, f)
Definition: elog.h:481
#define PREDICT_FALSE(x)
Definition: clib.h:97
word fformat(FILE *f, char *fmt,...)
Definition: format.c:453
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define clib_arch_is_big_endian
Definition: byte_order.h:53
int unix_shared_memory_queue_sub(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
svmdb_client_t * c
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
void vl_msg_api_barrier_release(void)
Definition: api_shared.c:388
vl_api_msg_range_t * msg_ranges
Definition: api_common.h:201
void vl_msg_api_post_mortem_dump(void)
Definition: api_shared.c:759
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:69
elog_main_t elog_main
Definition: main.h:141
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:439
const char ** msg_names
Definition: api_common.h:175
void vl_msg_api_socket_handler(void *the_msg)
Definition: api_shared.c:637
#define VL_API_BIG_ENDIAN
Definition: api_common.h:95
api_main_t api_main
Definition: api_shared.c:35
vl_api_trace_t * tx_trace
Definition: api_common.h:183
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
#define VL_API_LITTLE_ENDIAN
Definition: api_common.h:94
static u32 elog_id_for_msg_name(mc_main_t *m, char *msg_name)
Definition: mc.c:46
u32 data_len
Definition: api_common.h:123
u64 size
Definition: vhost-user.h:75
void vl_msg_api_replay_handler(void *the_msg)
Definition: api_shared.c:610
void vl_msg_api_handler_no_free(void *the_msg)
Definition: api_shared.c:552
u64 uword
Definition: types.h:112
u32 missing_clients
Definition: api_common.h:181
void vl_msg_api_increment_missing_client_counter(void)
Definition: api_shared.c:44
unsigned short u16
Definition: types.h:57
void vl_msg_api_register_pd_handler(void *fp, u16 msg_id_host_byte_order)
Definition: api_shared.c:794
void(** msg_endian_handlers)(void *)
Definition: api_common.h:173
u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
Definition: elog.c:534
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static u32 vl_msg_api_get_msg_length_inline(void *msg_arg)
Definition: api.h:93
int(** pd_msg_handlers)(void *, int)
Definition: api_common.h:171
#define foreach_msg_api_vector
Definition: api_shared.c:647
#define hash_get_mem(h, key)
Definition: hash.h:268
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:837
u16 first_available_msg_id
Definition: api_common.h:195
void(** msg_handlers)(void *)
Definition: api_common.h:170
u8 * is_mp_safe
Definition: api_common.h:177
void vl_msg_api_trace(api_main_t *am, vl_api_trace_t *tp, void *msg)
Definition: api_shared.c:66
int trace_enable
Definition: api_common.h:70
int msg_print_flag
Definition: api_common.h:184
vl_api_trace_which_t
Definition: api_common.h:88
const char * region_name
Definition: api_common.h:246
uword * msg_index_by_name_and_crc
Definition: api_common.h:244
uword * msg_range_by_name
Definition: api_common.h:198
struct _unix_shared_memory_queue unix_shared_memory_queue_t
void vl_msg_api_barrier_sync(void)
Definition: api_shared.c:383