FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ioam_export.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __included_ioam_export_h__
16 #define __included_ioam_export_h__
17 
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/ip/ip_packet.h>
21 #include <vnet/ip/ip4_packet.h>
22 #include <vnet/ip/ip6_packet.h>
23 #include <vnet/ip/ip6_hop_by_hop.h>
24 #include <vnet/udp/udp_local.h>
25 #include <vnet/udp/udp_packet.h>
27 
28 #include <vppinfra/pool.h>
29 #include <vppinfra/hash.h>
30 #include <vppinfra/error.h>
31 #include <vppinfra/elog.h>
32 #include <vppinfra/lock.h>
33 
34 #include <vlib/threads.h>
35 
36 typedef struct ioam_export_buffer
37 {
38  /** Required for pool_get_aligned */
39  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
40  /* Allocated buffer */
45 
46 
47 typedef struct
48 {
49  /* API message ID base */
52 
53  /* TODO: to support multiple collectors all this has to be grouped and create a vector here */
57 
58  /* ipfix collector, our ip address */
61 
62  /* Pool of ioam_export_buffer_t */
64  /* Vector of per thread ioam_export_buffer_t to buffer pool index */
66  /* Lock per thread to swap buffers between worker and timer process */
68 
69  /* time scale transform */
72 
73  /* convenience */
78 
82 
83 
84 #define DEFAULT_EXPORT_SIZE (3 * CLIB_CACHE_LINE_BYTES)
85 /*
86  * Number of records in a buffer
87  * ~(MTU (1500) - [ip hdr(40) + UDP(8) + ipfix (24)]) / DEFAULT_EXPORT_SIZE
88  */
89 #define DEFAULT_EXPORT_RECORDS 7
90 
91 inline static void
93 {
94  vlib_node_t *next_node;
95 
96  next_node = vlib_get_node_by_name (em->vlib_main, next_node_name);
97  em->next_node_index = next_node->index;
98 }
99 
100 inline static void
102 {
103  vlib_node_t *next_node;
104 
105  next_node = vlib_get_node_by_name (em->vlib_main, (u8 *) "ip4-lookup");
106  em->next_node_index = next_node->index;
107 }
108 
111 {
112 
113  if (vec_len (em->buffer_per_thread) > thread_id)
114  return (pool_elt_at_index
115  (em->buffer_pool, em->buffer_per_thread[thread_id]));
116  return (0);
117 }
118 
119 inline static int
121 {
123  b0->current_data = 0;
125  b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
126  return (1);
127 }
128 
129 inline static int
132 {
133  vlib_buffer_t *b = 0;
134 
135  if (!eb)
136  return (-1);
137  /* TODO: Perhaps buffer init from template here */
138  if (vlib_buffer_alloc (vm, &(eb->buffer_index), 1) != 1)
139  return (-2);
140  eb->records_in_this_buffer = 0;
141  eb->touched_at = vlib_time_now (vm);
142  b = vlib_get_buffer (vm, eb->buffer_index);
143  (void) ioam_export_buffer_add_header (em, b);
144  vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
145  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
146  return (1);
147 }
148 
149 inline static void
151 {
152  vlib_main_t *vm = em->vlib_main;
153  ioam_export_buffer_t *eb = 0;
154  int i;
155  for (i = 0; i < vec_len (em->buffer_per_thread); i++)
156  {
158  if (eb)
159  vlib_buffer_free (vm, &(eb->buffer_index), 1);
160  }
161  for (i = 0; i < vec_len (em->lockp); i++)
162  clib_mem_free ((void *) em->lockp[i]);
164  pool_free (em->buffer_pool);
165  vec_free (em->lockp);
166  em->buffer_per_thread = 0;
167  em->buffer_pool = 0;
168  em->lockp = 0;
169 }
170 
171 inline static int
173 {
174  int no_of_threads = vec_len (vlib_worker_threads);
175  int i;
176  ioam_export_buffer_t *eb = 0;
177 
179  no_of_threads - 1, CLIB_CACHE_LINE_BYTES);
181  no_of_threads - 1, CLIB_CACHE_LINE_BYTES);
182  vec_validate_aligned (em->lockp, no_of_threads - 1, CLIB_CACHE_LINE_BYTES);
183 
184  if (!em->buffer_per_thread || !em->buffer_pool || !em->lockp)
185  {
186  return (-1);
187  }
188  for (i = 0; i < no_of_threads; i++)
189  {
190  eb = 0;
192  clib_memset (eb, 0, sizeof (*eb));
193  em->buffer_per_thread[i] = eb - em->buffer_pool;
194  if (ioam_export_init_buffer (em, vm, eb) != 1)
195  {
197  return (-2);
198  }
199  clib_spinlock_init (&em->lockp[i]);
200  }
201  return (1);
202 }
203 
204 #define IPFIX_IOAM_EXPORT_ID 272
205 #define IPFIX_VXLAN_IOAM_EXPORT_ID 273
206 
207 /* Used to build the rewrite */
208 /* data set packet */
209 typedef struct
210 {
214 
215 typedef struct
216 {
221 
222 
223 inline static void
225  ip4_address_t * collector_address,
227 {
228  vec_free (em->record_header);
229  em->record_header = 0;
230 }
231 
232 inline static int
234  ip4_address_t * collector_address,
236 {
237  ip4_header_t *ip;
238  udp_header_t *udp;
241  u8 *rewrite = 0;
243 
244 
245  /* allocate rewrite space */
247  sizeof (ip4_ipfix_data_packet_t) - 1,
249 
251  ip = (ip4_header_t *) & tp->ip4;
252  udp = (udp_header_t *) (ip + 1);
253  h = (ipfix_message_header_t *) (udp + 1);
254  s = (ipfix_set_header_t *) (h + 1);
255 
256  ip->ip_version_and_header_length = 0x45;
257  ip->ttl = 254;
258  ip->protocol = IP_PROTOCOL_UDP;
259  ip->src_address.as_u32 = src_address->as_u32;
260  ip->dst_address.as_u32 = collector_address->as_u32;
261  udp->src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix);
262  udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix);
263  /* FIXUP: UDP length */
264  udp->length = clib_host_to_net_u16 (vec_len (rewrite) +
266  DEFAULT_EXPORT_SIZE) - sizeof (*ip));
267 
268  /* FIXUP: message header export_time */
269  /* FIXUP: message header sequence_number */
270  h->domain_id = clib_host_to_net_u32 (em->domain_id);
271 
272  /*FIXUP: Setid length in octets if records exported are not default */
274  (sizeof (*s) +
277 
278  /* FIXUP: h version and length length in octets if records exported are not default */
279  h->version_length = version_length (sizeof (*h) +
280  (sizeof (*s) +
283 
284  /* FIXUP: ip length if records exported are not default */
285  /* FIXUP: ip checksum if records exported are not default */
286  ip->length = clib_host_to_net_u16 (vec_len (rewrite) +
289  ip->checksum = ip4_header_checksum (ip);
290  _vec_len (rewrite) = sizeof (ip4_ipfix_data_packet_t);
291  em->record_header = rewrite;
292  return (1);
293 }
294 
295 inline static int
298 {
299  ip4_header_t *ip;
300  udp_header_t *udp;
304  vlib_buffer_t *b0;
305  u16 new_l0, old_l0;
306  ip_csum_t sum0;
307  vlib_frame_t *nf = 0;
308  u32 *to_next;
309 
310  b0 = vlib_get_buffer (vm, eb->buffer_index);
311  tp = vlib_buffer_get_current (b0);
312  ip = (ip4_header_t *) & tp->ip4;
313  udp = (udp_header_t *) (ip + 1);
314  h = (ipfix_message_header_t *) (udp + 1);
315  s = (ipfix_set_header_t *) (h + 1);
316 
317  /* FIXUP: message header export_time */
318  h->export_time = clib_host_to_net_u32 ((u32)
319  (((f64) em->unix_time_0) +
320  (vlib_time_now (em->vlib_main) -
321  em->vlib_time_0)));
322 
323  /* FIXUP: message header sequence_number */
324  h->sequence_number = clib_host_to_net_u32 (em->sequence_number++);
325 
326  /* FIXUP: lengths if different from default */
328  {
329  s->set_id_length = ipfix_set_id_length (em->set_id /* set_id */ ,
330  b0->current_length -
331  (sizeof (*ip) + sizeof (*udp) +
332  sizeof (*h)));
333  h->version_length =
334  version_length (b0->current_length - (sizeof (*ip) + sizeof (*udp)));
335  sum0 = ip->checksum;
336  old_l0 = ip->length;
337  new_l0 = clib_host_to_net_u16 ((u16) b0->current_length);
338  sum0 = ip_csum_update (sum0, old_l0, new_l0, ip4_header_t,
339  length /* changed member */ );
340  ip->checksum = ip_csum_fold (sum0);
341  ip->length = new_l0;
342  udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip));
343  }
344 
345  /* Enqueue pkts to ip4-lookup */
346 
348  nf->n_vectors = 0;
349  to_next = vlib_frame_vector_args (nf);
350  nf->n_vectors = 1;
351  to_next[0] = eb->buffer_index;
353  return (1);
354 
355 }
356 
357 #define EXPORT_TIMEOUT (20.0)
358 #define THREAD_PERIOD (30.0)
359 inline static uword
362  u32 index)
363 {
364  f64 now;
365  f64 timeout = 30.0;
366  uword event_type;
367  uword *event_data = 0;
368  int i;
369  ioam_export_buffer_t *eb = 0, *new_eb = 0;
370  u32 *vec_buffer_indices = 0;
371  u32 *vec_buffer_to_be_sent = 0;
372  u32 *thread_index = 0;
373  u32 new_pool_index = 0;
374 
376  /* Wait for Godot... */
378  event_type = vlib_process_get_events (vm, &event_data);
379  if (event_type != 1)
380  clib_warning ("bogus kickoff event received, %d", event_type);
381  vec_reset_length (event_data);
382 
383  while (1)
384  {
386  event_type = vlib_process_get_events (vm, &event_data);
387  switch (event_type)
388  {
389  case 2: /* Stop and Wait for kickoff again */
390  timeout = 1e9;
391  break;
392  case 1: /* kickoff : Check for unsent buffers */
393  timeout = THREAD_PERIOD;
394  break;
395  case ~0: /* timeout */
396  break;
397  }
398  vec_reset_length (event_data);
399  now = vlib_time_now (vm);
400  /*
401  * Create buffers for threads that are not active enough
402  * to send out the export records
403  */
404  for (i = 0; i < vec_len (em->buffer_per_thread); i++)
405  {
406  /* If the worker thread is processing export records ignore further checks */
407  if (CLIB_SPINLOCK_IS_LOCKED (&em->lockp[i]))
408  continue;
410  if (eb->records_in_this_buffer > 0
411  && now > (eb->touched_at + EXPORT_TIMEOUT))
412  {
413  pool_get_aligned (em->buffer_pool, new_eb,
415  clib_memset (new_eb, 0, sizeof (*new_eb));
416  if (ioam_export_init_buffer (em, vm, new_eb) == 1)
417  {
418  new_pool_index = new_eb - em->buffer_pool;
419  vec_add (vec_buffer_indices, &new_pool_index, 1);
420  vec_add (vec_buffer_to_be_sent, &em->buffer_per_thread[i],
421  1);
422  vec_add (thread_index, &i, 1);
423  }
424  else
425  {
426  pool_put (em->buffer_pool, new_eb);
427  /*Give up */
428  goto CLEANUP;
429  }
430  }
431  }
432  if (vec_len (thread_index) != 0)
433  {
434  /*
435  * Now swap the buffers out
436  */
437  for (i = 0; i < vec_len (thread_index); i++)
438  {
441  vec_pop (vec_buffer_indices);
443  }
444 
445  /* Send the buffers */
446  for (i = 0; i < vec_len (vec_buffer_to_be_sent); i++)
447  {
448  eb =
449  pool_elt_at_index (em->buffer_pool, vec_buffer_to_be_sent[i]);
450  ioam_export_send_buffer (em, vm, eb);
451  pool_put (em->buffer_pool, eb);
452  }
453  }
454 
455  CLEANUP:
456  /* Free any leftover/unused buffers and everything that was allocated */
457  for (i = 0; i < vec_len (vec_buffer_indices); i++)
458  {
459  new_eb = pool_elt_at_index (em->buffer_pool, vec_buffer_indices[i]);
460  vlib_buffer_free (vm, &new_eb->buffer_index, 1);
461  pool_put (em->buffer_pool, new_eb);
462  }
463  vec_free (vec_buffer_indices);
464  vec_free (vec_buffer_to_be_sent);
466  }
467  return 0; /* not so much */
468 }
469 
470 #define ioam_export_node_common(EM, VM, N, F, HTYPE, L, V, NEXT, FIXUP_FUNC) \
471 do { \
472  u32 n_left_from, *from, *to_next; \
473  export_next_t next_index; \
474  u32 pkts_recorded = 0; \
475  ioam_export_buffer_t *my_buf = 0; \
476  vlib_buffer_t *eb0 = 0; \
477  u32 ebi0 = 0; \
478  from = vlib_frame_vector_args (F); \
479  n_left_from = (F)->n_vectors; \
480  next_index = (N)->cached_next_index; \
481  clib_spinlock_lock (&(EM)->lockp[(VM)->thread_index]); \
482  my_buf = ioam_export_get_my_buffer (EM, (VM)->thread_index); \
483  my_buf->touched_at = vlib_time_now (VM); \
484  while (n_left_from > 0) \
485  { \
486  u32 n_left_to_next; \
487  vlib_get_next_frame (VM, N, next_index, to_next, n_left_to_next); \
488  while (n_left_from >= 4 && n_left_to_next >= 2) \
489  { \
490  u32 next0 = NEXT; \
491  u32 next1 = NEXT; \
492  u32 bi0, bi1; \
493  HTYPE *ip0, *ip1; \
494  vlib_buffer_t *p0, *p1; \
495  u32 ip_len0, ip_len1; \
496  { \
497  vlib_buffer_t *p2, *p3; \
498  p2 = vlib_get_buffer (VM, from[2]); \
499  p3 = vlib_get_buffer (VM, from[3]); \
500  vlib_prefetch_buffer_header (p2, LOAD); \
501  vlib_prefetch_buffer_header (p3, LOAD); \
502  CLIB_PREFETCH (p2->data, 3 * CLIB_CACHE_LINE_BYTES, LOAD); \
503  CLIB_PREFETCH (p3->data, 3 * CLIB_CACHE_LINE_BYTES, LOAD); \
504  } \
505  to_next[0] = bi0 = from[0]; \
506  to_next[1] = bi1 = from[1]; \
507  from += 2; \
508  to_next += 2; \
509  n_left_from -= 2; \
510  n_left_to_next -= 2; \
511  p0 = vlib_get_buffer (VM, bi0); \
512  p1 = vlib_get_buffer (VM, bi1); \
513  ip0 = vlib_buffer_get_current (p0); \
514  ip1 = vlib_buffer_get_current (p1); \
515  ip_len0 = \
516  clib_net_to_host_u16 (ip0->L) + sizeof (HTYPE); \
517  ip_len1 = \
518  clib_net_to_host_u16 (ip1->L) + sizeof (HTYPE); \
519  ebi0 = my_buf->buffer_index; \
520  eb0 = vlib_get_buffer (VM, ebi0); \
521  if (PREDICT_FALSE (eb0 == 0)) \
522  goto NO_BUFFER1; \
523  ip_len0 = \
524  ip_len0 > DEFAULT_EXPORT_SIZE ? DEFAULT_EXPORT_SIZE : ip_len0; \
525  ip_len1 = \
526  ip_len1 > DEFAULT_EXPORT_SIZE ? DEFAULT_EXPORT_SIZE : ip_len1; \
527  copy3cachelines (eb0->data + eb0->current_length, ip0, ip_len0); \
528  FIXUP_FUNC(eb0, p0); \
529  eb0->current_length += DEFAULT_EXPORT_SIZE; \
530  my_buf->records_in_this_buffer++; \
531  if (my_buf->records_in_this_buffer >= DEFAULT_EXPORT_RECORDS) \
532  { \
533  ioam_export_send_buffer (EM, VM, my_buf); \
534  ioam_export_init_buffer (EM, VM, my_buf); \
535  } \
536  ebi0 = my_buf->buffer_index; \
537  eb0 = vlib_get_buffer (VM, ebi0); \
538  if (PREDICT_FALSE (eb0 == 0)) \
539  goto NO_BUFFER1; \
540  copy3cachelines (eb0->data + eb0->current_length, ip1, ip_len1); \
541  FIXUP_FUNC(eb0, p1); \
542  eb0->current_length += DEFAULT_EXPORT_SIZE; \
543  my_buf->records_in_this_buffer++; \
544  if (my_buf->records_in_this_buffer >= DEFAULT_EXPORT_RECORDS) \
545  { \
546  ioam_export_send_buffer (EM, VM, my_buf); \
547  ioam_export_init_buffer (EM, VM, my_buf); \
548  } \
549  pkts_recorded += 2; \
550  if (PREDICT_FALSE (((node)->flags & VLIB_NODE_FLAG_TRACE))) \
551  { \
552  if (p0->flags & VLIB_BUFFER_IS_TRACED) \
553  { \
554  export_trace_t *t = \
555  vlib_add_trace (VM, node, p0, sizeof (*t)); \
556  t->flow_label = \
557  clib_net_to_host_u32 (ip0->V); \
558  t->next_index = next0; \
559  } \
560  if (p1->flags & VLIB_BUFFER_IS_TRACED) \
561  { \
562  export_trace_t *t = \
563  vlib_add_trace (VM, N, p1, sizeof (*t)); \
564  t->flow_label = \
565  clib_net_to_host_u32 (ip1->V); \
566  t->next_index = next1; \
567  } \
568  } \
569  NO_BUFFER1: \
570  vlib_validate_buffer_enqueue_x2 (VM, N, next_index, \
571  to_next, n_left_to_next, \
572  bi0, bi1, next0, next1); \
573  } \
574  while (n_left_from > 0 && n_left_to_next > 0) \
575  { \
576  u32 bi0; \
577  vlib_buffer_t *p0; \
578  u32 next0 = NEXT; \
579  HTYPE *ip0; \
580  u32 ip_len0; \
581  bi0 = from[0]; \
582  to_next[0] = bi0; \
583  from += 1; \
584  to_next += 1; \
585  n_left_from -= 1; \
586  n_left_to_next -= 1; \
587  p0 = vlib_get_buffer (VM, bi0); \
588  ip0 = vlib_buffer_get_current (p0); \
589  ip_len0 = \
590  clib_net_to_host_u16 (ip0->L) + sizeof (HTYPE); \
591  ebi0 = my_buf->buffer_index; \
592  eb0 = vlib_get_buffer (VM, ebi0); \
593  if (PREDICT_FALSE (eb0 == 0)) \
594  goto NO_BUFFER; \
595  ip_len0 = \
596  ip_len0 > DEFAULT_EXPORT_SIZE ? DEFAULT_EXPORT_SIZE : ip_len0; \
597  copy3cachelines (eb0->data + eb0->current_length, ip0, ip_len0); \
598  FIXUP_FUNC(eb0, p0); \
599  eb0->current_length += DEFAULT_EXPORT_SIZE; \
600  my_buf->records_in_this_buffer++; \
601  if (my_buf->records_in_this_buffer >= DEFAULT_EXPORT_RECORDS) \
602  { \
603  ioam_export_send_buffer (EM, VM, my_buf); \
604  ioam_export_init_buffer (EM, VM, my_buf); \
605  } \
606  if (PREDICT_FALSE (((N)->flags & VLIB_NODE_FLAG_TRACE) \
607  && (p0->flags & VLIB_BUFFER_IS_TRACED))) \
608  { \
609  export_trace_t *t = vlib_add_trace (VM, (N), p0, sizeof (*t)); \
610  t->flow_label = \
611  clib_net_to_host_u32 (ip0->V); \
612  t->next_index = next0; \
613  } \
614  pkts_recorded += 1; \
615  NO_BUFFER: \
616  vlib_validate_buffer_enqueue_x1 (VM, N, next_index, \
617  to_next, n_left_to_next, \
618  bi0, next0); \
619  } \
620  vlib_put_next_frame (VM, N, next_index, n_left_to_next); \
621  } \
622  vlib_node_increment_counter (VM, export_node.index, \
623  EXPORT_ERROR_RECORDED, pkts_recorded); \
624  clib_spinlock_unlock (&(EM)->lockp[(VM)->thread_index]); \
625 } while(0)
626 
627 #endif /* __included_ioam_export_h__ */
628 
629 /*
630  * fd.io coding-style-patch-verification: ON
631  *
632  * Local Variables:
633  * eval: (c-set-style "gnu")
634  * End:
635  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
ioam_export_main_t::lockp
clib_spinlock_t * lockp
Definition: ioam_export.h:67
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
ioam_export_buffer::buffer_index
u32 buffer_index
Definition: ioam_export.h:41
ioam_export_buffer::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
Required for pool_get_aligned.
vlib_frame_t::n_vectors
u16 n_vectors
Definition: node.h:387
vlib_buffer_free
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:979
udp_header_t::src_port
u16 src_port
Definition: udp_packet.h:48
udp_header_t::length
u16 length
Definition: udp_packet.h:51
vec_add
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:688
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
ip4_ipfix_data_packet_t::ip4
ip4_header_t ip4
Definition: ioam_export.h:217
ioam_export_process_common
static uword ioam_export_process_common(ioam_export_main_t *em, vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f, u32 index)
Definition: ioam_export.h:360
elog.h
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
f
vlib_frame_t * f
Definition: interface_output.c:1098
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
ipfix_set_header_t
Definition: ipfix_packet.h:115
pool_get_aligned
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:249
ioam_export_buffer::touched_at
u64 touched_at
Definition: ioam_export.h:42
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
threads.h
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
ioam_export_buffer_t
struct ioam_export_buffer ioam_export_buffer_t
u16
unsigned short u16
Definition: types.h:57
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
ip_packet.h
vlib_frame_t
Definition: node.h:372
vlib_worker_threads
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
vlib_get_frame_to_node
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
Definition: main.c:184
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
ioam_export_main_t::vlib_time_0
f64 vlib_time_0
Definition: ioam_export.h:71
h
h
Definition: flowhash_template.h:372
ip4_ipfix_data_packet_t
Definition: ioam_export.h:215
ioam_export_main_t::domain_id
u32 domain_id
Definition: ioam_export.h:56
ip6_packet.h
vlib_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
vlib_put_frame_to_node
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
Definition: main.c:218
ioam_export_main_t::next_node_index
u32 next_node_index
Definition: ioam_export.h:77
hash.h
ioam_export_main_t::unix_time_0
u32 unix_time_0
Definition: ioam_export.h:70
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_node_t::index
u32 index
Definition: node.h:269
error.h
ip6_hop_by_hop.h
ethernet_main_t_
Definition: ethernet.h:288
vlib_buffer_alloc
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:702
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
lock.h
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
clib_spinlock_lock
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:82
ioam_export_main_t::msg_id_base
u16 msg_id_base
Definition: ioam_export.h:50
clib_spinlock_s
Definition: lock.h:51
udp_local.h
ipfix_packet.h
udp_packet.h
uword
u64 uword
Definition: types.h:112
ipfix_data_packet_t::s
ipfix_set_header_t s
Definition: ioam_export.h:212
pool.h
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
DEFAULT_EXPORT_SIZE
#define DEFAULT_EXPORT_SIZE
Definition: ioam_export.h:84
DEFAULT_EXPORT_RECORDS
#define DEFAULT_EXPORT_RECORDS
Definition: ioam_export.h:89
ioam_export_send_buffer
static int ioam_export_send_buffer(ioam_export_main_t *em, vlib_main_t *vm, ioam_export_buffer_t *eb)
Definition: ioam_export.h:296
ip4_ipfix_data_packet_t::udp
udp_header_t udp
Definition: ioam_export.h:218
f64
double f64
Definition: types.h:142
ioam_export_thread_buffer_init
static int ioam_export_thread_buffer_init(ioam_export_main_t *em, vlib_main_t *vm)
Definition: ioam_export.h:172
ioam_export_buffer
Definition: ioam_export.h:36
ioam_export_main_t::ethernet_main
ethernet_main_t * ethernet_main
Definition: ioam_export.h:76
ip4_address_t
Definition: ip4_packet.h:50
version_length
static u32 version_length(u16 length)
Definition: ipfix_packet.h:33
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vec_pop
#define vec_pop(V)
Returns last element of a vector and decrements its length.
Definition: vec.h:705
ipfix_message_header_t
Definition: ipfix_packet.h:24
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
ioam_export_main_t::export_process_node_index
u32 export_process_node_index
Definition: ioam_export.h:80
ipfix_data_packet_t
Definition: ioam_export.h:209
pool_alloc_aligned
#define pool_alloc_aligned(P, N, A)
Allocate N more free elements to pool (general version).
Definition: pool.h:344
ip4_packet.h
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
CLIB_SPINLOCK_IS_LOCKED
#define CLIB_SPINLOCK_IS_LOCKED(_p)
Definition: lock.h:48
index
u32 index
Definition: flow_types.api:221
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
ioam_export_buffer_add_header
static int ioam_export_buffer_add_header(ioam_export_main_t *em, vlib_buffer_t *b0)
Definition: ioam_export.h:120
ioam_export_main_t::buffer_pool
ioam_export_buffer_t * buffer_pool
Definition: ioam_export.h:63
u64
unsigned long u64
Definition: types.h:89
vlib_process_wait_for_event_or_clock
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:755
ioam_export_reset_next_node
static void ioam_export_reset_next_node(ioam_export_main_t *em)
Definition: ioam_export.h:101
ip.h
u32
unsigned int u32
Definition: types.h:88
udp_header_t::dst_port
u16 dst_port
Definition: udp_packet.h:48
ioam_export_main_t::sequence_number
u32 sequence_number
Definition: ioam_export.h:55
ipfix_data_packet_t::h
ipfix_message_header_t h
Definition: ioam_export.h:211
ioam_export_main_t
Definition: ioam_export.h:47
ioam_export_main_t::my_hbh_slot
uword my_hbh_slot
Definition: ioam_export.h:79
ip4_ipfix_data_packet_t::ipfix
ipfix_data_packet_t ipfix
Definition: ioam_export.h:219
clib_spinlock_unlock
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:121
ioam_export_main_t::vlib_main
vlib_main_t * vlib_main
Definition: ioam_export.h:74
ioam_export_main_t::record_header
u8 * record_header
Definition: ioam_export.h:54
now
f64 now
Definition: nat44_ei_out2in.c:710
length
char const int length
Definition: cJSON.h:163
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
ip_csum_update
#define ip_csum_update(sum, old, new, type, field)
Definition: ip_packet.h:295
vlib_node_t
Definition: node.h:247
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
ioam_export_main_t::vnet_main
vnet_main_t * vnet_main
Definition: ioam_export.h:75
u8
unsigned char u8
Definition: types.h:56
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
ip
vl_api_address_t ip
Definition: l2.api:558
ip4_header_checksum
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:314
THREAD_PERIOD
#define THREAD_PERIOD
Definition: ioam_export.h:358
ip_csum_t
uword ip_csum_t
Definition: ip_packet.h:245
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
i
int i
Definition: flowhash_template.h:376
pool_free
#define pool_free(p)
Free a pool.
Definition: pool.h:447
ipfix_set_id_length
static u32 ipfix_set_id_length(u16 set_id, u16 length)
Definition: ipfix_packet.h:121
ioam_export_header_create
static int ioam_export_header_create(ioam_export_main_t *em, ip4_address_t *collector_address, ip4_address_t *src_address)
Definition: ioam_export.h:233
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
ioam_export_set_next_node
static void ioam_export_set_next_node(ioam_export_main_t *em, u8 *next_node_name)
Definition: ioam_export.h:92
ioam_export_header_cleanup
static void ioam_export_header_cleanup(ioam_export_main_t *em, ip4_address_t *collector_address, ip4_address_t *src_address)
Definition: ioam_export.h:224
ioam_export_thread_buffer_free
static void ioam_export_thread_buffer_free(ioam_export_main_t *em)
Definition: ioam_export.h:150
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
vnet.h
ioam_export_main_t::src_address
ip4_address_t src_address
Definition: ioam_export.h:60
vlib_node_runtime_t
Definition: node.h:454
ioam_export_get_my_buffer
static ioam_export_buffer_t * ioam_export_get_my_buffer(ioam_export_main_t *em, u32 thread_id)
Definition: ioam_export.h:110
ioam_export_buffer::records_in_this_buffer
u8 records_in_this_buffer
Definition: ioam_export.h:43
src_address
vl_api_address_union_t src_address
Definition: ip_types.api:122
ioam_export_main_t::ipfix_collector
ip4_address_t ipfix_collector
Definition: ioam_export.h:59
rewrite
rewrite
Definition: pnat.api:158
ioam_export_main_t::set_id
u16 set_id
Definition: ioam_export.h:51
ip_csum_fold
static u16 ip_csum_fold(ip_csum_t c)
Definition: ip_packet.h:301
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
ipfix_set_header_t::set_id_length
u32 set_id_length
Definition: ipfix_packet.h:117
ioam_export_main_t::buffer_per_thread
u32 * buffer_per_thread
Definition: ioam_export.h:65
ioam_export_init_buffer
static int ioam_export_init_buffer(ioam_export_main_t *em, vlib_main_t *vm, ioam_export_buffer_t *eb)
Definition: ioam_export.h:130
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
EXPORT_TIMEOUT
#define EXPORT_TIMEOUT
Definition: ioam_export.h:357
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111