FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
memory_client.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * memory_client.c - API message handling, client code.
4  *
5  * Copyright (c) 2010 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 <setjmp.h>
21 
22 #include <svm/svm.h>
23 #include <svm/ssvm.h>
24 #include <vppinfra/serialize.h>
25 #include <vppinfra/hash.h>
27 #include <vlibapi/api_common.h>
28 
29 /* A hack. vl_client_get_first_plugin_msg_id depends on it */
31 
33 
34 #define vl_typedefs /* define message structures */
36 #undef vl_typedefs
37 
38 #define vl_endianfun /* define message structures */
40 #undef vl_endianfun
41 
42 /* instantiate all the print functions we know about */
43 #define vl_print(handle, ...) clib_warning (__VA_ARGS__)
44 #define vl_printfun
46 #undef vl_printfun
47 
50 
51 typedef struct rx_thread_fn_arg
52 {
56 
57 static void *
58 rx_thread_fn (void *arg)
59 {
62  svm_queue_t *q;
63 
64  vlibapi_set_main (a->am);
66  free (a);
67 
70 
71  /* So we can make the rx thread terminate cleanly */
72  if (setjmp (mm->rx_thread_jmpbuf) == 0)
73  {
74  mm->rx_thread_jmpbuf_valid = 1;
76  while (1)
78  }
79  pthread_exit (0);
80 }
81 
82 static void
84 {
86  if (mm->rx_thread_jmpbuf_valid)
87  longjmp (mm->rx_thread_jmpbuf, 1);
88 }
89 
90 static void
92 {
94  int i;
95  u8 **keys = 0;
96  hash_pair_t *hp;
97 
98  if (!am->msg_index_by_name_and_crc)
99  return;
100 
101  /* *INDENT-OFF* */
102  hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
103  ({
104  vec_add1 (keys, (u8 *) hp->key);
105  }));
106  /* *INDENT-ON* */
107  for (i = 0; i < vec_len (keys); i++)
108  vec_free (keys[i]);
109  vec_free (keys);
110  hash_free (am->msg_index_by_name_and_crc);
111 }
112 
113 CLIB_NOSANITIZE_ADDR static void
114 VL_API_VEC_UNPOISON (const void *v)
115 {
116  const vec_header_t *vh = &((vec_header_t *) v)[-1];
117  CLIB_MEM_UNPOISON (vh, sizeof (*vh) + vec_len (v));
118 }
119 
120 static void
122 {
123  serialize_main_t _sm, *sm = &_sm;
125  u8 *tblv;
126  u32 nmsgs;
127  int i;
128  u8 *name_and_crc;
129  u32 msg_index;
130 
131  am->my_client_index = mp->index;
132  am->my_registration = (vl_api_registration_t *) (uword) mp->handle;
133 
134  /* Clean out any previous hash table (unlikely) */
136 
137  am->msg_index_by_name_and_crc = hash_create_string (0, sizeof (uword));
138 
139  /* Recreate the vnet-side API message handler table */
140  tblv = uword_to_pointer (mp->message_table, u8 *);
141  unserialize_open_data (sm, tblv, vec_len (tblv));
142  unserialize_integer (sm, &nmsgs, sizeof (u32));
143 
144  VL_API_VEC_UNPOISON (tblv);
145 
146  for (i = 0; i < nmsgs; i++)
147  {
149  unserialize_cstring (sm, (char **) &name_and_crc);
150  hash_set_mem (am->msg_index_by_name_and_crc, name_and_crc, msg_index);
151  }
152 }
153 
154 static void
155 noop_handler (void *notused)
156 {
157 }
158 
159 void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem);
160 int
161 vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
162 {
165  svm_queue_t *vl_input_queue;
166  vl_shmem_hdr_t *shmem_hdr;
167  int rv = 0;
168  void *oldheap;
170 
171  if (am->my_registration)
172  {
173  clib_warning ("client %s already connected...", name);
174  return -1;
175  }
176 
177  if (am->vlib_rp == 0)
178  {
179  clib_warning ("am->vlib_rp NULL");
180  return -1;
181  }
182 
183  shmem_hdr = am->shmem_hdr;
184 
185  if (shmem_hdr == 0 || shmem_hdr->vl_input_queue == 0)
186  {
187  clib_warning ("shmem_hdr / input queue NULL");
188  return -1;
189  }
190 
191  CLIB_MEM_UNPOISON (shmem_hdr, sizeof (*shmem_hdr));
193 
194  oldheap = vl_msg_push_heap ();
195  vl_input_queue = svm_queue_alloc_and_init (input_queue_size, sizeof (uword),
196  getpid ());
197  vl_msg_pop_heap (oldheap);
198 
199  am->my_client_index = ~0;
200  am->my_registration = 0;
201  am->vl_input_queue = vl_input_queue;
202 
204  clib_memset (mp, 0, sizeof (*mp));
205  mp->_vl_msg_id = ntohs (VL_API_MEMCLNT_CREATE);
206  mp->ctx_quota = ctx_quota;
207  mp->input_queue = (uword) vl_input_queue;
208  strncpy ((char *) mp->name, name, sizeof (mp->name) - 1);
209 
210  vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & mp);
211 
212  while (1)
213  {
214  int qstatus;
215  struct timespec ts, tsrem;
216  int i;
217 
218  /* Wait up to 10 seconds */
219  for (i = 0; i < 1000; i++)
220  {
221  qstatus = svm_queue_sub (vl_input_queue, (u8 *) & rp,
222  SVM_Q_NOWAIT, 0);
223  if (qstatus == 0)
224  goto read_one_msg;
225  ts.tv_sec = 0;
226  ts.tv_nsec = 10000 * 1000; /* 10 ms */
227  while (nanosleep (&ts, &tsrem) < 0)
228  ts = tsrem;
229  }
230  /* Timeout... */
231  clib_warning ("memclnt_create_reply timeout");
232  return -1;
233 
234  read_one_msg:
235  VL_MSG_API_UNPOISON (rp);
236  if (ntohs (rp->_vl_msg_id) != VL_API_MEMCLNT_CREATE_REPLY)
237  {
238  clib_warning ("unexpected reply: id %d", ntohs (rp->_vl_msg_id));
239  continue;
240  }
241  rv = clib_net_to_host_u32 (rp->response);
242 
243  vl_msg_api_handler ((void *) rp);
244  break;
245  }
246  return (rv);
247 }
248 
249 static void
251 {
252  void *oldheap;
254 
255  oldheap = vl_msg_push_heap ();
256  svm_queue_free (am->vl_input_queue);
257  vl_msg_pop_heap (oldheap);
258 
259  am->my_client_index = ~0;
260  am->my_registration = 0;
261  am->vl_input_queue = 0;
262 }
263 
264 void
266 {
268  vl_shmem_hdr_t *shmem_hdr;
270 
271  ASSERT (am->vlib_rp);
272  shmem_hdr = am->shmem_hdr;
273  ASSERT (shmem_hdr && shmem_hdr->vl_input_queue);
274 
276  clib_memset (mp, 0, sizeof (*mp));
277  mp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE);
278  mp->index = am->my_client_index;
279  mp->handle = (uword) am->my_registration;
280  mp->do_cleanup = do_cleanup;
281 
282  vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & mp);
283 }
284 
285 int
287 {
289  svm_queue_t *vl_input_queue;
291  time_t begin;
292 
293  vl_input_queue = am->vl_input_queue;
294  vl_client_send_disconnect (0 /* wait for reply */ );
295 
296  /*
297  * Have to be careful here, in case the client is disconnecting
298  * because e.g. the vlib process died, or is unresponsive.
299  */
300  begin = time (0);
301  while (1)
302  {
303  time_t now;
304 
305  now = time (0);
306 
307  if (now >= (begin + 2))
308  {
309  clib_warning ("peer unresponsive, give up");
310  am->my_client_index = ~0;
311  am->my_registration = 0;
312  am->shmem_hdr = 0;
313  return -1;
314  }
315  if (svm_queue_sub (vl_input_queue, (u8 *) & rp, SVM_Q_NOWAIT, 0) < 0)
316  continue;
317 
318  VL_MSG_API_UNPOISON (rp);
319 
320  /* drain the queue */
321  if (ntohs (rp->_vl_msg_id) != VL_API_MEMCLNT_DELETE_REPLY)
322  {
323  clib_warning ("queue drain: %d", ntohs (rp->_vl_msg_id));
324  vl_msg_api_handler ((void *) rp);
325  continue;
326  }
327  vl_msg_api_handler ((void *) rp);
328  break;
329  }
330 
332  return 0;
333 }
334 
335 /**
336  * Stave off the binary API dead client reaper
337  * Only sent to inactive clients
338  */
339 static void
341 {
342  vl_api_memclnt_keepalive_reply_t *rmp;
343  api_main_t *am;
344  vl_shmem_hdr_t *shmem_hdr;
345 
346  am = vlibapi_get_main ();
347  shmem_hdr = am->shmem_hdr;
348 
349  rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
350  clib_memset (rmp, 0, sizeof (*rmp));
351  rmp->_vl_msg_id = ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
352  rmp->context = mp->context;
353  vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & rmp);
354 }
355 
356 #define foreach_api_msg \
357 _(RX_THREAD_EXIT, rx_thread_exit) \
358 _(MEMCLNT_CREATE_REPLY, memclnt_create_reply) \
359 _(MEMCLNT_DELETE_REPLY, memclnt_delete_reply) \
360 _(MEMCLNT_KEEPALIVE, memclnt_keepalive)
361 
362 void
364 {
365 
366 #define _(N,n) \
367  vl_msg_api_set_handlers(VL_API_##N, #n, \
368  vl_api_##n##_t_handler, \
369  noop_handler, \
370  vl_api_##n##_t_endian, \
371  vl_api_##n##_t_print, \
372  sizeof(vl_api_##n##_t), 1);
374 #undef _
375 }
376 
377 int
378 vl_client_api_map (const char *region_name)
379 {
380  int rv;
381 
382  if ((rv = vl_map_shmem (region_name, 0 /* is_vlib */ )) < 0)
383  return rv;
384 
386  return 0;
387 }
388 
389 void
391 {
393 }
394 
395 u8
397 {
399 }
400 
401 static int
402 connect_to_vlib_internal (const char *svm_name,
403  const char *client_name,
404  int rx_queue_size, void *(*thread_fn) (void *),
405  void *thread_fn_arg, int do_map)
406 {
407  int rv = 0;
410 
411  if (do_map && (rv = vl_client_api_map (svm_name)))
412  {
413  clib_warning ("vl_client_api map rv %d", rv);
414  return rv;
415  }
416 
417  if (vl_client_connect (client_name, 0 /* punt quota */ ,
418  rx_queue_size /* input queue */ ) < 0)
419  {
421  return -1;
422  }
423 
424  /* Start the rx queue thread */
425 
426  if (thread_fn)
427  {
428  if (thread_fn == rx_thread_fn)
429  {
430  rx_thread_fn_arg_t *arg;
431  arg = malloc (sizeof (*arg));
432  arg->am = vlibapi_get_main ();
434  thread_fn_arg = (void *) arg;
435  }
436 
437  rv = pthread_create (&mm->rx_thread_handle,
438  NULL /*attr */ , thread_fn, thread_fn_arg);
439  if (rv)
440  {
441  clib_warning ("pthread_create returned %d", rv);
442  am->rx_thread_handle = 0;
443  }
444  else
445  {
446  am->rx_thread_handle = mm->rx_thread_handle;
447  }
448  }
449 
450  mm->connected_to_vlib = 1;
451  return 0;
452 }
453 
454 int
455 vl_client_connect_to_vlib (const char *svm_name,
456  const char *client_name, int rx_queue_size)
457 {
458  return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
459  rx_thread_fn, 0 /* thread fn arg */ ,
460  1 /* do map */ );
461 }
462 
463 int
465  const char *client_name,
466  int rx_queue_size)
467 {
468  return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
469  0 /* no rx_thread_fn */ ,
470  0 /* no thread fn arg */ ,
471  1 /* do map */ );
472 }
473 
474 int
475 vl_client_connect_to_vlib_no_map (const char *svm_name,
476  const char *client_name, int rx_queue_size)
477 {
478  return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
479  rx_thread_fn, 0 /* no thread fn arg */ ,
480  0 /* dont map */ );
481 }
482 
483 int
485  const char *client_name,
486  int rx_queue_size)
487 {
488  return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
489  0 /* no thread_fn */ ,
490  0 /* no thread fn arg */ ,
491  0 /* dont map */ );
492 }
493 
494 int
496  const char *client_name,
497  int rx_queue_size,
498  void *(*thread_fn) (void *), void *arg)
499 {
500  return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
501  thread_fn, arg, 1 /* do map */ );
502 }
503 
504 
505 static void
507 {
510  uword junk;
511 
512  if (mm->rx_thread_jmpbuf_valid)
513  {
515  ep = vl_msg_api_alloc (sizeof (*ep));
516  ep->_vl_msg_id = ntohs (VL_API_RX_THREAD_EXIT);
517  vl_msg_api_send_shmem (am->vl_input_queue, (u8 *) & ep);
518  pthread_join (mm->rx_thread_handle, (void **) &junk);
519  }
520  if (mm->connected_to_vlib)
521  {
523  if (do_unmap)
525  }
526  clib_memset (mm, 0, sizeof (*mm));
527 }
528 
529 void
531 {
533 }
534 
535 void
537 {
539 }
540 
543 {
545  i32 retval = ntohl (mp->retval);
546 
547  mm->first_msg_id_reply = (retval >= 0) ? ntohs (mp->first_msg_id) : ~0;
548  mm->first_msg_id_reply_ready = 1;
549 }
550 
551 u16
552 vl_client_get_first_plugin_msg_id (const char *plugin_name)
553 {
557  f64 timeout;
558  void *old_handler;
559  clib_time_t clib_time;
560  u16 rv = ~0;
561 
562  if (strlen (plugin_name) + 1 > sizeof (mp->name))
563  return (rv);
564 
565  clib_memset (&clib_time, 0, sizeof (clib_time));
566  clib_time_init (&clib_time);
567 
568  /* Push this plugin's first_msg_id_reply handler */
569  old_handler = am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY];
570  am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = (void *)
572 
573  /* Ask the data-plane for the message-ID base of the indicated plugin */
574  mm->first_msg_id_reply_ready = 0;
575 
576  /* Not using shm client */
577  if (!am->my_registration)
578  {
579  mp = vl_socket_client_msg_alloc (sizeof (*mp));
580  clib_memset (mp, 0, sizeof (*mp));
581  mp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID);
582  mp->client_index = am->my_client_index;
583  strncpy ((char *) mp->name, plugin_name, sizeof (mp->name) - 1);
584 
585  if (vl_socket_client_write () <= 0)
586  goto sock_err;
587  if (vl_socket_client_read (1))
588  goto sock_err;
589 
590  if (mm->first_msg_id_reply_ready == 1)
591  {
592  rv = mm->first_msg_id_reply;
593  goto result;
594  }
595 
596  sock_err:
597  /* Restore old handler */
598  am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler;
599 
600  return -1;
601  }
602  else
603  {
604  mp = vl_msg_api_alloc (sizeof (*mp));
605  clib_memset (mp, 0, sizeof (*mp));
606  mp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID);
607  mp->client_index = am->my_client_index;
608  strncpy ((char *) mp->name, plugin_name, sizeof (mp->name) - 1);
609 
610  vl_msg_api_send_shmem (am->shmem_hdr->vl_input_queue, (u8 *) & mp);
611 
612  /* Synchronously wait for the answer */
613  timeout = clib_time_now (&clib_time) + 1.0;
614  while (clib_time_now (&clib_time) < timeout)
615  {
616  if (mm->first_msg_id_reply_ready == 1)
617  {
618  rv = mm->first_msg_id_reply;
619  goto result;
620  }
621  }
622  /* Restore old handler */
623  am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler;
624 
625  return rv;
626  }
627 
628 result:
629 
630  /* Restore the old handler */
631  am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler;
632 
633  if (rv == (u16) ~ 0)
634  clib_warning ("plugin '%s' not registered", plugin_name);
635 
636  return rv;
637 }
638 
639 /*
640  * fd.io coding-style-patch-verification: ON
641  *
642  * Local Variables:
643  * eval: (c-set-style "gnu")
644  * End:
645  */
memory_client.h
noop_handler
static void noop_handler(void *notused)
Definition: memory_client.c:155
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
foreach_api_msg
#define foreach_api_msg
Definition: memory_client.c:356
vlibapi_set_memory_client_main
static void vlibapi_set_memory_client_main(memory_client_main_t *mm)
Definition: memory_client.h:74
hash_free
#define hash_free(h)
Definition: hash.h:310
vl_client_api_unmap
void vl_client_api_unmap(void)
Definition: memory_client.c:390
memory_client_main_t::rx_thread_jmpbuf
jmp_buf rx_thread_jmpbuf
Definition: memory_client.h:31
vl_msg_api_queue_handler
void vl_msg_api_queue_handler(svm_queue_t *q)
Definition: api_shared.c:917
vl_api_memclnt_create_t::ctx_quota
i32 ctx_quota
Definition: memclnt.api:35
vl_map_shmem
int vl_map_shmem(const char *region_name, int is_vlib)
Definition: memory_shared.c:534
vl_api_memclnt_create_reply_t::index
u32 index
Definition: memclnt.api:45
hash_foreach_pair
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:373
name
string name[64]
Definition: fib.api:25
keys
vl_api_ikev2_keys_t keys
Definition: ikev2_types.api:125
vl_api_name_and_crc_free
static void vl_api_name_and_crc_free(void)
Definition: memory_client.c:91
vl_client_connect_to_vlib_no_map
int vl_client_connect_to_vlib_no_map(const char *svm_name, const char *client_name, int rx_queue_size)
Definition: memory_client.c:475
vl_socket_client_read
int vl_socket_client_read(int wait)
Definition: socket_client.c:157
vl_api_memclnt_delete_t
Definition: memclnt.api:53
vl_client_connect_to_vlib_no_rx_pthread
int vl_client_connect_to_vlib_no_rx_pthread(const char *svm_name, const char *client_name, int rx_queue_size)
Definition: memory_client.c:464
hash_create_string
#define hash_create_string(elts, value_bytes)
Definition: hash.h:689
svm_queue_t
struct _svm_queue svm_queue_t
VL_API_VEC_UNPOISON
static CLIB_NOSANITIZE_ADDR void VL_API_VEC_UNPOISON(const void *v)
Definition: memory_client.c:114
u16
unsigned short u16
Definition: types.h:57
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
SVM_Q_NOWAIT
@ SVM_Q_NOWAIT
non-blocking call - works with both condvar and eventfd signaling
Definition: queue.h:44
am
app_main_t * am
Definition: application.c:489
vl_api_memclnt_delete_reply_t_handler
static void vl_api_memclnt_delete_reply_t_handler(vl_api_memclnt_delete_reply_t *mp)
Definition: memory_client.c:250
vl_client_disconnect_from_vlib
void vl_client_disconnect_from_vlib(void)
Definition: memory_client.c:530
vl_api_memclnt_create_t::name
string name[64]
Definition: memclnt.api:37
vl_api_rx_thread_exit_t
Definition: memclnt.api:67
vl_client_send_disconnect
void vl_client_send_disconnect(u8 do_cleanup)
Definition: memory_client.c:265
serialize_main_t
Definition: serialize.h:144
clib_mem_set_thread_index
static void clib_mem_set_thread_index(void)
Definition: mem.h:196
vl_api_get_first_msg_id_t::client_index
u32 client_index
Definition: memclnt.api:103
vl_shmem_hdr_
Definition: memory_shared.h:76
vl_msg_api_alloc_as_if_client
void * vl_msg_api_alloc_as_if_client(int nbytes)
Definition: memory_shared.c:236
vl_api_memclnt_create_reply_t
Definition: memclnt.api:41
api_main_t::vl_input_queue
svm_queue_t * vl_input_queue
Peer input queue pointer.
Definition: api_common.h:333
vl_client_disconnect
int vl_client_disconnect(void)
Definition: memory_client.c:286
clib_time_init
__clib_export void clib_time_init(clib_time_t *c)
Definition: time.c:207
i32
signed int i32
Definition: types.h:77
vl_api_memclnt_create_reply_t::message_table
u64 message_table
Definition: memclnt.api:46
vl_api_memclnt_create_t
Definition: memclnt.api:33
vl_socket_client_msg_alloc
void * vl_socket_client_msg_alloc(int nbytes)
Definition: socket_client.c:228
vl_api_memclnt_delete_reply_t
Definition: memclnt.api:59
disconnect_from_vlib_internal
static void disconnect_from_vlib_internal(u8 do_unmap)
Definition: memory_client.c:506
VL_MSG_API_UNPOISON
static CLIB_NOSANITIZE_ADDR void VL_MSG_API_UNPOISON(const void *a)
Definition: api_common.h:149
vl_client_api_map
int vl_client_api_map(const char *region_name)
Definition: memory_client.c:378
memory_client_main_t
Definition: memory_client.h:27
hash.h
svm_queue_free
void svm_queue_free(svm_queue_t *q)
Definition: queue.c:91
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vl_api_memclnt_keepalive_t_handler
static void vl_api_memclnt_keepalive_t_handler(vl_api_memclnt_keepalive_t *mp)
Stave off the binary API dead client reaper Only sent to inactive clients.
Definition: memory_client.c:340
my_memory_client_main
__thread memory_client_main_t * my_memory_client_main
Definition: memory_client.c:49
svm.h
CLIB_NOSANITIZE_ADDR
#define CLIB_NOSANITIZE_ADDR
Definition: sanitizer.h:112
vlibapi_get_memory_client_main
static memory_client_main_t * vlibapi_get_memory_client_main(void)
Definition: memory_client.h:67
vl_client_get_first_plugin_msg_id
u16 vl_client_get_first_plugin_msg_id(const char *plugin_name)
Definition: memory_client.c:552
vl_api_get_first_msg_id_reply_t::retval
i32 retval
Definition: memclnt.api:110
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
rx_thread_fn_arg::am
api_main_t * am
Definition: memory_client.c:53
vl_api_get_first_msg_id_t::name
string name[64]
Definition: memclnt.api:105
unserialize_integer
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
Definition: serialize.h:201
vl_shmem_hdr_::vl_input_queue
svm_queue_t * vl_input_queue
Definition: memory_shared.h:84
uword
u64 uword
Definition: types.h:112
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
vl_api_memclnt_create_reply_t::handle
u64 handle
Definition: memclnt.api:44
socket_client.h
f64
double f64
Definition: types.h:142
vl_api_get_first_msg_id_reply_t_handler
static void vl_api_get_first_msg_id_reply_t_handler(vl_api_get_first_msg_id_reply_t *mp)
Definition: memory_client.c:542
clib_time_now
static f64 clib_time_now(clib_time_t *c)
Definition: time.h:230
connect_to_vlib_internal
static int connect_to_vlib_internal(const char *svm_name, const char *client_name, int rx_queue_size, void *(*thread_fn)(void *), void *thread_fn_arg, int do_map)
Definition: memory_client.c:402
memory_client_main
memory_client_main_t memory_client_main
Definition: memory_client.c:48
memory_client_main_t::rx_thread_jmpbuf_valid
u8 rx_thread_jmpbuf_valid
Definition: memory_client.h:29
unserialize_open_data
__clib_export void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
Definition: serialize.c:891
memory_client_main_t::first_msg_id_reply
u16 first_msg_id_reply
Definition: memory_client.h:35
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
vl_client_disconnect_from_vlib_no_unmap
void vl_client_disconnect_from_vlib_no_unmap(void)
Definition: memory_client.c:536
unserialize_cstring
__clib_export void unserialize_cstring(serialize_main_t *m, char **s)
Definition: serialize.c:178
vl_api_memclnt_keepalive_t::context
u32 context
Definition: memclnt.api:210
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vl_msg_api_handler
void vl_msg_api_handler(void *the_msg)
Definition: api_shared.c:704
vl_api_memclnt_delete_t::do_cleanup
bool do_cleanup
Definition: memclnt.api:56
clib_time_t
Definition: time.h:44
vl_client_install_client_message_handlers
void vl_client_install_client_message_handlers(void)
Definition: memory_client.c:363
vl_api_get_first_msg_id_reply_t::first_msg_id
u16 first_msg_id
Definition: memclnt.api:111
vl_api_get_first_msg_id_reply_t
Definition: memclnt.api:108
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vl_api_memclnt_delete_t::index
u32 index
Definition: memclnt.api:54
vl_mem_client_is_connected
u8 vl_mem_client_is_connected(void)
Definition: memory_client.c:396
u32
unsigned int u32
Definition: types.h:88
vl_msg_push_heap
void * vl_msg_push_heap(void)
Definition: cli.c:745
rx_thread_fn_arg
Definition: memory_client.c:51
CLIB_MEM_UNPOISON
#define CLIB_MEM_UNPOISON(a, s)
Definition: sanitizer.h:114
vl_api_get_first_msg_id_t
Definition: memclnt.api:102
vl_api_memclnt_keepalive_t
Definition: memclnt.api:207
vl_api_memclnt_create_reply_t_handler
static void vl_api_memclnt_create_reply_t_handler(vl_api_memclnt_create_reply_t *mp)
Definition: memory_client.c:121
memory_client_main_t::first_msg_id_reply_ready
volatile u8 first_msg_id_reply_ready
Definition: memory_client.h:34
now
f64 now
Definition: nat44_ei_out2in.c:710
vec_header_t
vector header structure
Definition: vec_bootstrap.h:55
vl_unmap_shmem_client
void vl_unmap_shmem_client(void)
Definition: memory_shared.c:747
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
memory_client_main_t::rx_thread_handle
pthread_t rx_thread_handle
Definition: memory_client.h:32
u8
unsigned char u8
Definition: types.h:56
serialize.h
a
a
Definition: bitmap.h:525
vl_msg_api_send_shmem
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
Definition: memory_shared.c:753
vl_api_memclnt_create_t::input_queue
u64 input_queue
Definition: memclnt.api:36
uword_to_pointer
#define uword_to_pointer(u, type)
Definition: types.h:136
rx_thread_fn_arg::mm
memory_client_main_t * mm
Definition: memory_client.c:54
vl_api_memclnt_delete_t::handle
u64 handle
Definition: memclnt.api:55
i
int i
Definition: flowhash_template.h:376
free
void free(void *p)
Definition: mem.c:42
VL_MSG_API_SVM_QUEUE_UNPOISON
static CLIB_NOSANITIZE_ADDR void VL_MSG_API_SVM_QUEUE_UNPOISON(const svm_queue_t *q)
Definition: api_common.h:156
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
malloc
void * malloc(size_t size)
Definition: mem.c:33
unserialize_likely_small_unsigned_integer
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
Definition: serialize.h:254
svm_queue_sub
int svm_queue_sub(svm_queue_t *q, u8 *elem, svm_q_conditional_wait_t cond, u32 time)
Definition: queue.c:369
vl_socket_client_write
int vl_socket_client_write(void)
Definition: socket_client.c:203
api_common.h
rv
int __clib_unused rv
Definition: application.c:491
rx_thread_fn_arg_t
struct rx_thread_fn_arg rx_thread_fn_arg_t
vl_memory_api_h.h
rx_thread_fn
static void * rx_thread_fn(void *arg)
Definition: memory_client.c:58
vl_client_connect_to_vlib_no_rx_pthread_no_map
int vl_client_connect_to_vlib_no_rx_pthread_no_map(const char *svm_name, const char *client_name, int rx_queue_size)
Definition: memory_client.c:484
ssvm.h
vl_client_connect_to_vlib
int vl_client_connect_to_vlib(const char *svm_name, const char *client_name, int rx_queue_size)
Definition: memory_client.c:455
vl_msg_pop_heap
void vl_msg_pop_heap(void *oldheap)
Definition: cli.c:752
vl_api_memclnt_create_reply_t::response
i32 response
Definition: memclnt.api:43
svm_queue_alloc_and_init
svm_queue_t * svm_queue_alloc_and_init(int nels, int elsize, int consumer_pid)
Allocate and initialize svm queue.
Definition: queue.c:74
vl_client_connect_to_vlib_thread_fn
int vl_client_connect_to_vlib_thread_fn(const char *svm_name, const char *client_name, int rx_queue_size, void *(*thread_fn)(void *), void *arg)
Definition: memory_client.c:495
vl_api_rx_thread_exit_t_handler
static void vl_api_rx_thread_exit_t_handler(vl_api_rx_thread_exit_t *mp)
Definition: memory_client.c:83
vl_memory_msg_enum.h
vlibapi_set_main
static void vlibapi_set_main(api_main_t *am)
Definition: api_common.h:396
vl_client_connect
int vl_client_connect(const char *name, int ctx_quota, int input_queue_size)
Definition: memory_client.c:161
memory_client_main_t::connected_to_vlib
u8 connected_to_vlib
Definition: memory_client.h:30
hash_pair_t
Definition: hash.h:159
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199