FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
node.c
Go to the documentation of this file.
1 /*
2  * node.c - ipfix probe graph node
3  *
4  * Copyright (c) 2017 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include <vlib/vlib.h>
18 #include <vnet/vnet.h>
19 #include <vppinfra/crc32.h>
20 #include <vppinfra/error.h>
21 #include <flowprobe/flowprobe.h>
22 #include <vnet/ip/ip6_packet.h>
23 #include <vnet/udp/udp_local.h>
24 #include <vlibmemory/api.h>
25 
27 
28 /**
29  * @file node.c
30  * flow record generator graph node
31  */
32 
33 typedef struct
34 {
35  /** interface handle */
38  /** packet timestamp */
40  /** size of the buffer */
42 
43  /** L2 information */
44  u8 src_mac[6];
45  u8 dst_mac[6];
46  /** Ethertype */
48 
49  /** L3 information */
50  ip46_address_t src_address;
51  ip46_address_t dst_address;
54 
55  /** L4 information */
58 
61 
62 static char *flowprobe_variant_strings[] = {
63  [FLOW_VARIANT_IP4] = "IP4",
64  [FLOW_VARIANT_IP6] = "IP6",
65  [FLOW_VARIANT_L2] = "L2",
66  [FLOW_VARIANT_L2_IP4] = "L2-IP4",
67  [FLOW_VARIANT_L2_IP6] = "L2-IP6",
68 };
69 
70 /* packet trace format function */
71 static u8 *
72 format_flowprobe_trace (u8 * s, va_list * args)
73 {
74  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
75  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
76  flowprobe_trace_t *t = va_arg (*args, flowprobe_trace_t *);
77  u32 indent = format_get_indent (s);
78 
79  s = format (s,
80  "FLOWPROBE[%s]: rx_sw_if_index %d, tx_sw_if_index %d, "
81  "timestamp %lld, size %d", flowprobe_variant_strings[t->which],
83  t->timestamp, t->buffer_size);
84 
85  if (t->which == FLOW_VARIANT_L2)
86  s = format (s, "\n%U -> %U", format_white_space, indent,
89 
90  if (t->protocol > 0
93  s =
94  format (s, "\n%U%U: %U -> %U", format_white_space, indent,
98  return s;
99 }
100 
104 
105 /* No counters at the moment */
106 #define foreach_flowprobe_error \
107 _(COLLISION, "Hash table collisions") \
108 _(BUFFER, "Buffer allocation error") \
109 _(EXPORTED_PACKETS, "Exported packets") \
110 _(INPATH, "Exported packets in path")
111 
112 typedef enum
113 {
114 #define _(sym,str) FLOWPROBE_ERROR_##sym,
116 #undef _
119 
120 static char *flowprobe_error_strings[] = {
121 #define _(sym,string) string,
123 #undef _
124 };
125 
126 typedef enum
127 {
132 
133 #define FLOWPROBE_NEXT_NODES { \
134  [FLOWPROBE_NEXT_DROP] = "error-drop", \
135  [FLOWPROBE_NEXT_IP4_LOOKUP] = "ip4-lookup", \
136 }
137 
138 static inline flowprobe_variant_t
140  flowprobe_record_t flags, u16 ethertype)
141 {
142  if (which == FLOW_VARIANT_L2
144  return ethertype == ETHERNET_TYPE_IP6 ? FLOW_VARIANT_L2_IP6 : ethertype ==
145  ETHERNET_TYPE_IP4 ? FLOW_VARIANT_L2_IP4 : FLOW_VARIANT_L2;
146  return which;
147 }
148 
149 /*
150  * NTP rfc868 : 2 208 988 800 corresponds to 00:00 1 Jan 1970 GMT
151  */
152 #define NTP_TIMESTAMP 2208988800LU
153 
154 static inline u32
156 {
157  u16 start = offset;
158 
159  /* Ingress interface */
160  u32 rx_if = clib_host_to_net_u32 (e->key.rx_sw_if_index);
161  clib_memcpy_fast (to_b->data + offset, &rx_if, sizeof (rx_if));
162  offset += sizeof (rx_if);
163 
164  /* Egress interface */
165  u32 tx_if = clib_host_to_net_u32 (e->key.tx_sw_if_index);
166  clib_memcpy_fast (to_b->data + offset, &tx_if, sizeof (tx_if));
167  offset += sizeof (tx_if);
168 
169  /* packet delta count */
170  u64 packetdelta = clib_host_to_net_u64 (e->packetcount);
171  clib_memcpy_fast (to_b->data + offset, &packetdelta, sizeof (u64));
172  offset += sizeof (u64);
173 
174  /* flowStartNanoseconds */
175  u32 t = clib_host_to_net_u32 (e->flow_start.sec + NTP_TIMESTAMP);
176  clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
177  offset += sizeof (u32);
178  t = clib_host_to_net_u32 (e->flow_start.nsec);
179  clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
180  offset += sizeof (u32);
181 
182  /* flowEndNanoseconds */
183  t = clib_host_to_net_u32 (e->flow_end.sec + NTP_TIMESTAMP);
184  clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
185  offset += sizeof (u32);
186  t = clib_host_to_net_u32 (e->flow_end.nsec);
187  clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
188  offset += sizeof (u32);
189 
190  return offset - start;
191 }
192 
193 static inline u32
195 {
196  u16 start = offset;
197 
198  /* src mac address */
199  clib_memcpy_fast (to_b->data + offset, &e->key.src_mac, 6);
200  offset += 6;
201 
202  /* dst mac address */
203  clib_memcpy_fast (to_b->data + offset, &e->key.dst_mac, 6);
204  offset += 6;
205 
206  /* ethertype */
207  clib_memcpy_fast (to_b->data + offset, &e->key.ethertype, 2);
208  offset += 2;
209 
210  return offset - start;
211 }
212 
213 static inline u32
215 {
216  u16 start = offset;
217 
218  /* ip6 src address */
220  sizeof (ip6_address_t));
221  offset += sizeof (ip6_address_t);
222 
223  /* ip6 dst address */
225  sizeof (ip6_address_t));
226  offset += sizeof (ip6_address_t);
227 
228  /* Protocol */
229  to_b->data[offset++] = e->key.protocol;
230 
231  /* octetDeltaCount */
232  u64 octetdelta = clib_host_to_net_u64 (e->octetcount);
233  clib_memcpy_fast (to_b->data + offset, &octetdelta, sizeof (u64));
234  offset += sizeof (u64);
235 
236  return offset - start;
237 }
238 
239 static inline u32
241 {
242  u16 start = offset;
243 
244  /* ip4 src address */
245  clib_memcpy_fast (to_b->data + offset, &e->key.src_address.ip4,
246  sizeof (ip4_address_t));
247  offset += sizeof (ip4_address_t);
248 
249  /* ip4 dst address */
250  clib_memcpy_fast (to_b->data + offset, &e->key.dst_address.ip4,
251  sizeof (ip4_address_t));
252  offset += sizeof (ip4_address_t);
253 
254  /* Protocol */
255  to_b->data[offset++] = e->key.protocol;
256 
257  /* octetDeltaCount */
258  u64 octetdelta = clib_host_to_net_u64 (e->octetcount);
259  clib_memcpy_fast (to_b->data + offset, &octetdelta, sizeof (u64));
260  offset += sizeof (u64);
261 
262  return offset - start;
263 }
264 
265 static inline u32
267 {
268  u16 start = offset;
269 
270  /* src port */
271  clib_memcpy_fast (to_b->data + offset, &e->key.src_port, 2);
272  offset += 2;
273 
274  /* dst port */
275  clib_memcpy_fast (to_b->data + offset, &e->key.dst_port, 2);
276  offset += 2;
277 
278  /* tcp control bits */
279  u16 control_bits = htons (e->prot.tcp.flags);
280  clib_memcpy_fast (to_b->data + offset, &control_bits, 2);
281  offset += 2;
282 
283  return offset - start;
284 }
285 
286 static inline u32
288 {
290  u32 h = 0;
291 
292 #ifdef clib_crc32c_uses_intrinsics
293  h = clib_crc32c ((u8 *) k, sizeof (*k));
294 #else
295  int i;
296  u64 tmp = 0;
297  for (i = 0; i < sizeof (*k) / 8; i++)
298  tmp ^= ((u64 *) k)[i];
299 
300  h = clib_xxhash (tmp);
301 #endif
302 
303  return h >> (32 - fm->ht_log2len);
304 }
305 
307 flowprobe_lookup (u32 my_cpu_number, flowprobe_key_t * k, u32 * poolindex,
308  bool * collision)
309 {
312  u32 h;
313 
314  h = (fm->active_timer) ? flowprobe_hash (k) : 0;
315 
316  /* Lookup in the flow state pool */
317  *poolindex = fm->hash_per_worker[my_cpu_number][h];
318  if (*poolindex != ~0)
319  {
320  e = pool_elt_at_index (fm->pool_per_worker[my_cpu_number], *poolindex);
321  if (e)
322  {
323  /* Verify key or report collision */
324  if (memcmp (k, &e->key, sizeof (flowprobe_key_t)))
325  *collision = true;
326  return e;
327  }
328  }
329 
330  return 0;
331 }
332 
334 flowprobe_create (u32 my_cpu_number, flowprobe_key_t * k, u32 * poolindex)
335 {
337  u32 h;
338 
340 
341  /* Get my index */
342  h = (fm->active_timer) ? flowprobe_hash (k) : 0;
343 
344  pool_get (fm->pool_per_worker[my_cpu_number], e);
345  *poolindex = e - fm->pool_per_worker[my_cpu_number];
346  fm->hash_per_worker[my_cpu_number][h] = *poolindex;
347 
348  e->key = *k;
349 
350  if (fm->passive_timer > 0)
351  {
352  e->passive_timer_handle = tw_timer_start_2t_1w_2048sl
353  (fm->timers_per_worker[my_cpu_number], *poolindex, 0,
354  fm->passive_timer);
355  }
356  return e;
357 }
358 
359 static inline void
364 {
365  if (fm->disabled)
366  return;
367 
368  u32 my_cpu_number = vm->thread_index;
369  u16 octets = 0;
370 
371  flowprobe_record_t flags = fm->context[which].flags;
372  bool collect_ip4 = false, collect_ip6 = false;
373  ASSERT (b);
375  u16 ethertype = clib_net_to_host_u16 (eth->type);
376  /* *INDENT-OFF* */
377  flowprobe_key_t k = {};
378  /* *INDENT-ON* */
379  ip4_header_t *ip4 = 0;
380  ip6_header_t *ip6 = 0;
381  udp_header_t *udp = 0;
382  tcp_header_t *tcp = 0;
383  u8 tcp_flags = 0;
384 
386  {
387  collect_ip4 = which == FLOW_VARIANT_L2_IP4 || which == FLOW_VARIANT_IP4;
388  collect_ip6 = which == FLOW_VARIANT_L2_IP6 || which == FLOW_VARIANT_IP6;
389  }
390 
391  k.rx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
392  k.tx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
393 
394  k.which = which;
395 
396  if (flags & FLOW_RECORD_L2)
397  {
398  clib_memcpy_fast (k.src_mac, eth->src_address, 6);
399  clib_memcpy_fast (k.dst_mac, eth->dst_address, 6);
400  k.ethertype = ethertype;
401  }
402  if (collect_ip6 && ethertype == ETHERNET_TYPE_IP6)
403  {
404  ip6 = (ip6_header_t *) (eth + 1);
405  if (flags & FLOW_RECORD_L3)
406  {
407  k.src_address.as_u64[0] = ip6->src_address.as_u64[0];
408  k.src_address.as_u64[1] = ip6->src_address.as_u64[1];
409  k.dst_address.as_u64[0] = ip6->dst_address.as_u64[0];
410  k.dst_address.as_u64[1] = ip6->dst_address.as_u64[1];
411  }
412  k.protocol = ip6->protocol;
413  if (k.protocol == IP_PROTOCOL_UDP)
414  udp = (udp_header_t *) (ip6 + 1);
415  else if (k.protocol == IP_PROTOCOL_TCP)
416  tcp = (tcp_header_t *) (ip6 + 1);
417 
418  octets = clib_net_to_host_u16 (ip6->payload_length)
419  + sizeof (ip6_header_t);
420  }
421  if (collect_ip4 && ethertype == ETHERNET_TYPE_IP4)
422  {
423  ip4 = (ip4_header_t *) (eth + 1);
424  if (flags & FLOW_RECORD_L3)
425  {
426  k.src_address.ip4.as_u32 = ip4->src_address.as_u32;
427  k.dst_address.ip4.as_u32 = ip4->dst_address.as_u32;
428  }
429  k.protocol = ip4->protocol;
430  if ((flags & FLOW_RECORD_L4) && k.protocol == IP_PROTOCOL_UDP)
431  udp = (udp_header_t *) (ip4 + 1);
432  else if ((flags & FLOW_RECORD_L4) && k.protocol == IP_PROTOCOL_TCP)
433  tcp = (tcp_header_t *) (ip4 + 1);
434 
435  octets = clib_net_to_host_u16 (ip4->length);
436  }
437 
438  if (udp)
439  {
440  k.src_port = udp->src_port;
441  k.dst_port = udp->dst_port;
442  }
443  else if (tcp)
444  {
445  k.src_port = tcp->src_port;
446  k.dst_port = tcp->dst_port;
447  tcp_flags = tcp->flags;
448  }
449 
450  if (t)
451  {
454  clib_memcpy_fast (t->src_mac, k.src_mac, 6);
455  clib_memcpy_fast (t->dst_mac, k.dst_mac, 6);
456  t->ethertype = k.ethertype;
457  t->src_address.ip4.as_u32 = k.src_address.ip4.as_u32;
458  t->dst_address.ip4.as_u32 = k.dst_address.ip4.as_u32;
459  t->protocol = k.protocol;
460  t->src_port = k.src_port;
461  t->dst_port = k.dst_port;
462  t->which = k.which;
463  }
464 
465  flowprobe_entry_t *e = 0;
466  f64 now = vlib_time_now (vm);
467  if (fm->active_timer > 0)
468  {
469  u32 poolindex = ~0;
470  bool collision = false;
471 
472  e = flowprobe_lookup (my_cpu_number, &k, &poolindex, &collision);
473  if (collision)
474  {
475  /* Flush data and clean up entry for reuse. */
476  if (e->packetcount)
478  e->key = k;
479  e->flow_start = timestamp;
480  vlib_node_increment_counter (vm, node->node_index,
481  FLOWPROBE_ERROR_COLLISION, 1);
482  }
483  if (!e) /* Create new entry */
484  {
485  e = flowprobe_create (my_cpu_number, &k, &poolindex);
486  e->last_exported = now;
487  e->flow_start = timestamp;
488  }
489  }
490  else
491  {
492  e = &fm->stateless_entry[my_cpu_number];
493  e->key = k;
494  }
495 
496  if (e)
497  {
498  /* Updating entry */
499  e->packetcount++;
500  e->octetcount += octets;
501  e->last_updated = now;
502  e->flow_end = timestamp;
503  e->prot.tcp.flags |= tcp_flags;
504  if (fm->active_timer == 0
505  || (now > e->last_exported + fm->active_timer))
507  }
508 }
509 
510 static u16
512 {
513  return sizeof (ip4_header_t) + sizeof (udp_header_t) +
514  sizeof (ipfix_message_header_t) + sizeof (ipfix_set_header_t);
515 }
516 
517 static void
520 {
523  vlib_frame_t *f;
527  ip4_header_t *ip;
528  udp_header_t *udp;
529  flowprobe_record_t flags = fm->context[which].flags;
530  u32 my_cpu_number = vm->thread_index;
531 
532  /* Fill in header */
533  flow_report_stream_t *stream;
534 
535  /* Nothing to send */
536  if (fm->context[which].next_record_offset_per_worker[my_cpu_number] <=
538  return;
539 
540  u32 i, index = vec_len (frm->streams);
541  for (i = 0; i < index; i++)
542  if (frm->streams[i].domain_id == 1)
543  {
544  index = i;
545  break;
546  }
547  if (i == vec_len (frm->streams))
548  {
549  vec_validate (frm->streams, index);
550  frm->streams[index].domain_id = 1;
551  }
552  stream = &frm->streams[index];
553 
554  tp = vlib_buffer_get_current (b0);
555  ip = (ip4_header_t *) & tp->ip4;
556  udp = (udp_header_t *) (ip + 1);
557  h = (ipfix_message_header_t *) (udp + 1);
558  s = (ipfix_set_header_t *) (h + 1);
559 
560  ip->ip_version_and_header_length = 0x45;
561  ip->ttl = 254;
562  ip->protocol = IP_PROTOCOL_UDP;
563  ip->flags_and_fragment_offset = 0;
564  ip->src_address.as_u32 = frm->src_address.as_u32;
565  ip->dst_address.as_u32 = frm->ipfix_collector.as_u32;
566  udp->src_port = clib_host_to_net_u16 (stream->src_port);
567  udp->dst_port = clib_host_to_net_u16 (frm->collector_port);
568  udp->checksum = 0;
569 
570  /* FIXUP: message header export_time */
571  h->export_time = (u32)
572  (((f64) frm->unix_time_0) +
573  (vlib_time_now (frm->vlib_main) - frm->vlib_time_0));
574  h->export_time = clib_host_to_net_u32 (h->export_time);
575  h->domain_id = clib_host_to_net_u32 (stream->domain_id);
576 
577  /* FIXUP: message header sequence_number */
578  h->sequence_number = stream->sequence_number++;
579  h->sequence_number = clib_host_to_net_u32 (h->sequence_number);
580 
581  s->set_id_length = ipfix_set_id_length (fm->template_reports[flags],
582  b0->current_length -
583  (sizeof (*ip) + sizeof (*udp) +
584  sizeof (*h)));
585  h->version_length = version_length (b0->current_length -
586  (sizeof (*ip) + sizeof (*udp)));
587 
588  ip->length = clib_host_to_net_u16 (b0->current_length);
589 
590  ip->checksum = ip4_header_checksum (ip);
591  udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip));
592 
593  if (frm->udp_checksum)
594  {
595  /* RFC 7011 section 10.3.2. */
597  if (udp->checksum == 0)
598  udp->checksum = 0xffff;
599  }
600 
602 
603  /* Find or allocate a frame */
604  f = fm->context[which].frames_per_worker[my_cpu_number];
605  if (PREDICT_FALSE (f == 0))
606  {
607  u32 *to_next;
609  fm->context[which].frames_per_worker[my_cpu_number] = f;
610  u32 bi0 = vlib_get_buffer_index (vm, b0);
611 
612  /* Enqueue the buffer */
613  to_next = vlib_frame_vector_args (f);
614  to_next[0] = bi0;
615  f->n_vectors = 1;
616  }
617 
620  FLOWPROBE_ERROR_EXPORTED_PACKETS, 1);
621 
622  fm->context[which].frames_per_worker[my_cpu_number] = 0;
623  fm->context[which].buffers_per_worker[my_cpu_number] = 0;
624  fm->context[which].next_record_offset_per_worker[my_cpu_number] =
626 }
627 
628 static vlib_buffer_t *
630 {
633  vlib_buffer_t *b0;
634  u32 bi0;
635  u32 my_cpu_number = vm->thread_index;
636 
637  /* Find or allocate a buffer */
638  b0 = fm->context[which].buffers_per_worker[my_cpu_number];
639 
640  /* Need to allocate a buffer? */
641  if (PREDICT_FALSE (b0 == 0))
642  {
643  if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
644  {
646  FLOWPROBE_ERROR_BUFFER, 1);
647  return 0;
648  }
649 
650  /* Initialize the buffer */
651  b0 = fm->context[which].buffers_per_worker[my_cpu_number] =
652  vlib_get_buffer (vm, bi0);
653 
654  b0->current_data = 0;
656  b0->flags |=
657  (VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_FLOW_REPORT);
658  vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0;
659  vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index;
660  fm->context[which].next_record_offset_per_worker[my_cpu_number] =
661  b0->current_length;
662  }
663 
664  return b0;
665 }
666 
667 static void
669 {
670  u32 my_cpu_number = vm->thread_index;
673  vlib_buffer_t *b0;
674  bool collect_ip4 = false, collect_ip6 = false;
676  flowprobe_record_t flags = fm->context[which].flags;
677  u16 offset =
678  fm->context[which].next_record_offset_per_worker[my_cpu_number];
679 
682 
683  b0 = flowprobe_get_buffer (vm, which);
684  /* No available buffer, what to do... */
685  if (b0 == 0)
686  return;
687 
688  if (flags & FLOW_RECORD_L3)
689  {
690  collect_ip4 = which == FLOW_VARIANT_L2_IP4 || which == FLOW_VARIANT_IP4;
691  collect_ip6 = which == FLOW_VARIANT_L2_IP6 || which == FLOW_VARIANT_IP6;
692  }
693 
694  offset += flowprobe_common_add (b0, e, offset);
695 
696  if (flags & FLOW_RECORD_L2)
697  offset += flowprobe_l2_add (b0, e, offset);
698  if (collect_ip6)
699  offset += flowprobe_l3_ip6_add (b0, e, offset);
700  if (collect_ip4)
701  offset += flowprobe_l3_ip4_add (b0, e, offset);
702  if (flags & FLOW_RECORD_L4)
703  offset += flowprobe_l4_add (b0, e, offset);
704 
705  /* Reset per flow-export counters */
706  e->packetcount = 0;
707  e->octetcount = 0;
709 
710  b0->current_length = offset;
711 
712  fm->context[which].next_record_offset_per_worker[my_cpu_number] = offset;
713  /* Time to flush the buffer? */
714  if (offset + fm->template_size[flags] > frm->path_mtu)
716 }
717 
718 uword
722 {
723  u32 n_left_from, *from, *to_next;
727 
729 
731  n_left_from = frame->n_vectors;
732  next_index = node->cached_next_index;
733 
734  while (n_left_from > 0)
735  {
736  u32 n_left_to_next;
737 
738  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
739 
740  while (n_left_from >= 4 && n_left_to_next >= 2)
741  {
742  u32 next0 = FLOWPROBE_NEXT_DROP;
743  u32 next1 = FLOWPROBE_NEXT_DROP;
744  u16 len0, len1;
745  u32 bi0, bi1;
746  vlib_buffer_t *b0, *b1;
747 
748  /* Prefetch next iteration. */
749  {
750  vlib_buffer_t *p2, *p3;
751 
752  p2 = vlib_get_buffer (vm, from[2]);
753  p3 = vlib_get_buffer (vm, from[3]);
754 
755  vlib_prefetch_buffer_header (p2, LOAD);
756  vlib_prefetch_buffer_header (p3, LOAD);
757 
760  }
761 
762  /* speculatively enqueue b0 and b1 to the current next frame */
763  to_next[0] = bi0 = from[0];
764  to_next[1] = bi1 = from[1];
765  from += 2;
766  to_next += 2;
767  n_left_from -= 2;
768  n_left_to_next -= 2;
769 
770  b0 = vlib_get_buffer (vm, bi0);
771  b1 = vlib_get_buffer (vm, bi1);
772 
773  vnet_feature_next (&next0, b0);
774  vnet_feature_next (&next1, b1);
775 
776  len0 = vlib_buffer_length_in_chain (vm, b0);
778  u16 ethertype0 = clib_net_to_host_u16 (eh0->type);
779 
780  if (PREDICT_TRUE ((b0->flags & VNET_BUFFER_F_FLOW_REPORT) == 0))
783  (which, fm->context[which].flags,
784  ethertype0), 0);
785 
786  len1 = vlib_buffer_length_in_chain (vm, b1);
788  u16 ethertype1 = clib_net_to_host_u16 (eh1->type);
789 
790  if (PREDICT_TRUE ((b1->flags & VNET_BUFFER_F_FLOW_REPORT) == 0))
793  (which, fm->context[which].flags,
794  ethertype1), 0);
795 
796  /* verify speculative enqueues, maybe switch current next frame */
798  to_next, n_left_to_next,
799  bi0, bi1, next0, next1);
800  }
801 
802  while (n_left_from > 0 && n_left_to_next > 0)
803  {
804  u32 bi0;
805  vlib_buffer_t *b0;
806  u32 next0 = FLOWPROBE_NEXT_DROP;
807  u16 len0;
808 
809  /* speculatively enqueue b0 to the current next frame */
810  bi0 = from[0];
811  to_next[0] = bi0;
812  from += 1;
813  to_next += 1;
814  n_left_from -= 1;
815  n_left_to_next -= 1;
816 
817  b0 = vlib_get_buffer (vm, bi0);
818 
819  vnet_feature_next (&next0, b0);
820 
821  len0 = vlib_buffer_length_in_chain (vm, b0);
823  u16 ethertype0 = clib_net_to_host_u16 (eh0->type);
824 
825  if (PREDICT_TRUE ((b0->flags & VNET_BUFFER_F_FLOW_REPORT) == 0))
826  {
827  flowprobe_trace_t *t = 0;
828  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
829  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
830  t = vlib_add_trace (vm, node, b0, sizeof (*t));
831 
834  (which, fm->context[which].flags,
835  ethertype0), t);
836  }
837 
838  /* verify speculative enqueue, maybe switch current next frame */
840  to_next, n_left_to_next,
841  bi0, next0);
842  }
843 
844  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
845  }
846  return frame->n_vectors;
847 }
848 
849 static uword
852 {
854 }
855 
856 static uword
859 {
861 }
862 
863 static uword
866 {
868 }
869 
870 static inline void
872 {
875  if (b)
877 }
878 
879 void
881 {
883 }
884 
885 void
887 {
889 }
890 
891 void
893 {
897 }
898 
899 
900 static void
901 flowprobe_delete_by_index (u32 my_cpu_number, u32 poolindex)
902 {
905  u32 h;
906 
907  e = pool_elt_at_index (fm->pool_per_worker[my_cpu_number], poolindex);
908 
909  /* Get my index */
910  h = flowprobe_hash (&e->key);
911 
912  /* Reset hash */
913  fm->hash_per_worker[my_cpu_number][h] = ~0;
914 
915  pool_put_index (fm->pool_per_worker[my_cpu_number], poolindex);
916 }
917 
918 
919 /* Per worker process processing the active/passive expired entries */
920 static uword
923 {
927 
928  /*
929  * $$$$ Remove this check from here and track FRM status and disable
930  * this process if required.
931  */
932  if (frm->ipfix_collector.as_u32 == 0 || frm->src_address.as_u32 == 0)
933  {
934  fm->disabled = true;
935  return 0;
936  }
937  fm->disabled = false;
938 
939  u32 cpu_index = os_get_thread_index ();
940  u32 *to_be_removed = 0, *i;
941 
942  /*
943  * Tick the timer when required and process the vector of expired
944  * timers
945  */
946  f64 start_time = vlib_time_now (vm);
947  u32 count = 0;
948 
949  tw_timer_expire_timers_2t_1w_2048sl (fm->timers_per_worker[cpu_index],
950  start_time);
951 
952  vec_foreach (i, fm->expired_passive_per_worker[cpu_index])
953  {
954  u32 exported = 0;
955  f64 now = vlib_time_now (vm);
956  if (now > start_time + 100e-6
957  || exported > FLOW_MAXIMUM_EXPORT_ENTRIES - 1)
958  break;
959 
960  if (pool_is_free_index (fm->pool_per_worker[cpu_index], *i))
961  {
962  clib_warning ("Element is %d is freed already\n", *i);
963  continue;
964  }
965  else
966  e = pool_elt_at_index (fm->pool_per_worker[cpu_index], *i);
967 
968  /* Check last update timestamp. If it is longer than passive time nuke
969  * entry. Otherwise restart timer with what's left
970  * Premature passive timer by more than 10%
971  */
972  if ((now - e->last_updated) < (u64) (fm->passive_timer * 0.9))
973  {
974  u64 delta = fm->passive_timer - (now - e->last_updated);
975  e->passive_timer_handle = tw_timer_start_2t_1w_2048sl
976  (fm->timers_per_worker[cpu_index], *i, 0, delta);
977  }
978  else /* Nuke entry */
979  {
980  vec_add1 (to_be_removed, *i);
981  }
982  /* If anything to report send it to the exporter */
983  if (e->packetcount && now > e->last_exported + fm->active_timer)
984  {
985  exported++;
987  }
988  count++;
989  }
990  if (count)
991  vec_delete (fm->expired_passive_per_worker[cpu_index], count, 0);
992 
993  vec_foreach (i, to_be_removed) flowprobe_delete_by_index (cpu_index, *i);
994  vec_free (to_be_removed);
995 
996  return 0;
997 }
998 
999 /* *INDENT-OFF* */
1001  .function = flowprobe_ip4_node_fn,
1002  .name = "flowprobe-ip4",
1003  .vector_size = sizeof (u32),
1004  .format_trace = format_flowprobe_trace,
1006  .n_errors = ARRAY_LEN(flowprobe_error_strings),
1007  .error_strings = flowprobe_error_strings,
1008  .n_next_nodes = FLOWPROBE_N_NEXT,
1009  .next_nodes = FLOWPROBE_NEXT_NODES,
1010 };
1012  .function = flowprobe_ip6_node_fn,
1013  .name = "flowprobe-ip6",
1014  .vector_size = sizeof (u32),
1015  .format_trace = format_flowprobe_trace,
1017  .n_errors = ARRAY_LEN(flowprobe_error_strings),
1018  .error_strings = flowprobe_error_strings,
1019  .n_next_nodes = FLOWPROBE_N_NEXT,
1020  .next_nodes = FLOWPROBE_NEXT_NODES,
1021 };
1023  .function = flowprobe_l2_node_fn,
1024  .name = "flowprobe-l2",
1025  .vector_size = sizeof (u32),
1026  .format_trace = format_flowprobe_trace,
1028  .n_errors = ARRAY_LEN(flowprobe_error_strings),
1029  .error_strings = flowprobe_error_strings,
1030  .n_next_nodes = FLOWPROBE_N_NEXT,
1031  .next_nodes = FLOWPROBE_NEXT_NODES,
1032 };
1034  .function = flowprobe_walker_process,
1035  .name = "flowprobe-walker",
1036  .type = VLIB_NODE_TYPE_INPUT,
1037  .state = VLIB_NODE_STATE_INTERRUPT,
1038 };
1039 /* *INDENT-ON* */
1040 
1041 /*
1042  * fd.io coding-style-patch-verification: ON
1043  *
1044  * Local Variables:
1045  * eval: (c-set-style "gnu")
1046  * End:
1047  */
flowprobe_flush_callback_l2
void flowprobe_flush_callback_l2(void)
Definition: node.c:892
vlib.h
flowprobe_variant_strings
static char * flowprobe_variant_strings[]
Definition: node.c:62
tmp
u32 * tmp
Definition: interface_output.c:1078
flush_record
static void flush_record(flowprobe_variant_t which)
Definition: node.c:871
flowprobe_main
flowprobe_main_t flowprobe_main
Definition: flowprobe.c:39
ip4_lookup_node
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
Definition: ip4_forward.c:104
vlib_frame_t::n_vectors
u16 n_vectors
Definition: node.h:387
flowprobe_key_t::dst_mac
u8 dst_mac[6]
Definition: flowprobe.h:80
flow_report_stream_t::sequence_number
u32 sequence_number
Definition: flow_report.h:80
flowprobe_walker_node
vlib_node_registration_t flowprobe_walker_node
(constructor) VLIB_REGISTER_NODE (flowprobe_walker_node)
Definition: node.c:1033
udp_header_t::src_port
u16 src_port
Definition: udp_packet.h:48
flowprobe_trace_t::dst_mac
u8 dst_mac[6]
Definition: node.c:45
udp_header_t::length
u16 length
Definition: udp_packet.h:51
api.h
flowprobe_trace_t::dst_port
u16 dst_port
Definition: node.c:57
flow_report_main
flow_report_main_t flow_report_main
Definition: flow_report.c:22
vlib_prefetch_buffer_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:231
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
flow_report_main::udp_checksum
u8 udp_checksum
Definition: flow_report.h:129
flow_report_main::vlib_main
vlib_main_t * vlib_main
Definition: flow_report.h:136
flowprobe_node_fn
uword flowprobe_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, flowprobe_variant_t which)
Definition: node.c:719
flowprobe_key_t::rx_sw_if_index
u32 rx_sw_if_index
Definition: flowprobe.h:77
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
flowprobe_create
flowprobe_entry_t * flowprobe_create(u32 my_cpu_number, flowprobe_key_t *k, u32 *poolindex)
Definition: node.c:334
src_mac
vl_api_mac_address_t src_mac
Definition: acl_types.api:94
NTP_TIMESTAMP
#define NTP_TIMESTAMP
Definition: node.c:152
flowprobe_trace_t::dst_address
ip46_address_t dst_address
Definition: node.c:51
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:1080
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
FLOWPROBE_N_ERROR
@ FLOWPROBE_N_ERROR
Definition: node.c:117
ipfix_set_header_t
Definition: ipfix_packet.h:115
tcp_header_t
struct _tcp_header tcp_header_t
format_ethernet_address
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
ip4_header_checksum_is_valid
static uword ip4_header_checksum_is_valid(ip4_header_t *i)
Definition: ip4_packet.h:396
ethernet_header_t::dst_address
u8 dst_address[6]
Definition: packet.h:55
ethernet_header_t::src_address
u8 src_address[6]
Definition: packet.h:56
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
flowprobe_error_strings
static char * flowprobe_error_strings[]
Definition: node.c:120
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
timestamp_nsec_t::sec
u32 sec
Definition: flowprobe.h:93
add_to_flow_record_state
static void add_to_flow_record_state(vlib_main_t *vm, vlib_node_runtime_t *node, flowprobe_main_t *fm, vlib_buffer_t *b, timestamp_nsec_t timestamp, u16 length, flowprobe_variant_t which, flowprobe_trace_t *t)
Definition: node.c:360
flowprobe_key_t::src_address
ip46_address_t src_address
Definition: flowprobe.h:82
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
flowprobe_common_add
static u32 flowprobe_common_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
Definition: node.c:155
VLIB_NODE_TYPE_INPUT
@ VLIB_NODE_TYPE_INPUT
Definition: node.h:76
flow_report_stream_t::domain_id
u32 domain_id
Definition: flow_report.h:79
flowprobe_trace_t::src_mac
u8 src_mac[6]
L2 information.
Definition: node.c:44
flowprobe_flush_callback_ip6
void flowprobe_flush_callback_ip6(void)
Definition: node.c:886
timestamp_nsec_t::nsec
u32 nsec
Definition: flowprobe.h:94
u16
unsigned short u16
Definition: types.h:57
flowprobe_trace_t::tx_sw_if_index
u32 tx_sw_if_index
Definition: node.c:37
flowprobe_trace_t::protocol
u8 protocol
Definition: node.c:52
ethernet_header_t::type
u16 type
Definition: packet.h:59
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vec_delete
#define vec_delete(V, N, M)
Delete N elements starting at element M.
Definition: vec.h:875
fm
vnet_feature_main_t * fm
Definition: nat44_ei_hairpinning.c:589
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
flowprobe_delete_by_index
static void flowprobe_delete_by_index(u32 my_cpu_number, u32 poolindex)
Definition: node.c:901
flowprobe_key_t::protocol
u8 protocol
Definition: flowprobe.h:84
flowprobe_main_t
Definition: flowprobe.h:120
flowprobe_ip4_node_fn
static uword flowprobe_ip4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: node.c:850
flow_report_main::fib_index
u32 fib_index
Definition: flow_report.h:120
FLOWPROBE_NEXT_DROP
@ FLOWPROBE_NEXT_DROP
Definition: node.c:128
vlib_frame_t
Definition: node.h:372
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
vlib_buffer_length_in_chain
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:433
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
pool_put_index
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:337
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
h
h
Definition: flowhash_template.h:372
flowprobe_entry_t::flow_start
timestamp_nsec_t flow_start
Definition: flowprobe.h:102
flowprobe_get_headersize
static u16 flowprobe_get_headersize(void)
Definition: node.c:511
flowprobe_entry_t::tcp
struct flowprobe_entry_t::@56::@57 tcp
ip4_ipfix_template_packet_t
Definition: flow_report.h:42
flowprobe_trace_t::rx_sw_if_index
u32 rx_sw_if_index
interface handle
Definition: node.c:36
flowprobe_trace_t::src_port
u16 src_port
L4 information.
Definition: node.c:56
ip6_packet.h
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
flowprobe_l2_node
vlib_node_registration_t flowprobe_l2_node
(constructor) VLIB_REGISTER_NODE (flowprobe_l2_node)
Definition: node.c:103
FLOWPROBE_NEXT_IP4_LOOKUP
@ FLOWPROBE_NEXT_IP4_LOOKUP
Definition: node.c:129
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
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
flowprobe_l2_add
static u32 flowprobe_l2_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
Definition: node.c:194
flowprobe_entry_t::flow_end
timestamp_nsec_t flow_end
Definition: flowprobe.h:103
count
u8 count
Definition: dhcp.api:208
which
int which
Definition: cJSON.h:234
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
error.h
foreach_flowprobe_error
#define foreach_flowprobe_error
Definition: node.c:106
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
flowprobe_key_t::dst_port
u16 dst_port
Definition: flowprobe.h:86
flowprobe_key_t::tx_sw_if_index
u32 tx_sw_if_index
Definition: flowprobe.h:78
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:708
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
flow_report_stream_t::src_port
u16 src_port
Definition: flow_report.h:81
flowprobe_entry_t::last_exported
f64 last_exported
Definition: flowprobe.h:105
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
flowprobe_entry_t
Definition: flowprobe.h:97
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
offset
struct clib_bihash_value offset
template key/value backing page structure
flowprobe_key_t::dst_address
ip46_address_t dst_address
Definition: flowprobe.h:83
flowprobe_get_variant
static flowprobe_variant_t flowprobe_get_variant(flowprobe_variant_t which, flowprobe_record_t flags, u16 ethertype)
Definition: node.c:139
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vnet_feature_next
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:322
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_get_buffer_index
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:324
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
ip4_tcp_udp_compute_checksum
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
Definition: pnat_test_stubs.h:59
flowprobe_hash
static u32 flowprobe_hash(flowprobe_key_t *k)
Definition: node.c:287
flowprobe_trace_t::timestamp
u64 timestamp
packet timestamp
Definition: node.c:39
flowprobe_flush_callback_ip4
void flowprobe_flush_callback_ip4(void)
Definition: node.c:880
flow_report_main::ipfix_collector
ip4_address_t ipfix_collector
Definition: flow_report.h:117
udp_local.h
uword
u64 uword
Definition: types.h:112
format_ip_protocol
format_function_t format_ip_protocol
Definition: format.h:45
crc32.h
ethernet_header_t
Definition: packet.h:52
flowprobe_key_t::ethertype
u16 ethertype
Definition: flowprobe.h:81
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:213
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
flowprobe_entry_t::packetcount
u64 packetcount
Definition: flowprobe.h:100
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
flowprobe_entry_t::key
flowprobe_key_t key
Definition: flowprobe.h:99
flowprobe_key_t
Definition: flowprobe.h:76
clib_xxhash
static u64 clib_xxhash(u64 key)
Definition: xxhash.h:58
flow_report_main
Definition: flow_report.h:111
flowprobe_trace_t
Definition: node.c:33
ip4_address_t
Definition: ip4_packet.h:50
version_length
static u32 version_length(u16 length)
Definition: ipfix_packet.h:33
flow_report_main::streams
flow_report_stream_t * streams
Definition: flow_report.h:114
flowprobe.h
flow-per-packet plugin header file
timestamp_nsec_t
Definition: flowprobe.h:91
flowprobe_entry_t::octetcount
u64 octetcount
Definition: flowprobe.h:101
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
ipfix_message_header_t
Definition: ipfix_packet.h:24
flowprobe_l3_ip6_add
static u32 flowprobe_l3_ip6_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
Definition: node.c:214
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
os_get_thread_index
static_always_inline uword os_get_thread_index(void)
Definition: os.h:63
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
flowprobe_key_t::src_port
u16 src_port
Definition: flowprobe.h:85
flow_report_main::collector_port
u16 collector_port
Definition: flow_report.h:118
flowprobe_l3_ip4_add
static u32 flowprobe_l3_ip4_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
Definition: node.c:240
flow_report_main::path_mtu
u32 path_mtu
Definition: flow_report.h:123
flowprobe_trace_t::src_address
ip46_address_t src_address
L3 information.
Definition: node.c:50
flowprobe_variant_t
flowprobe_variant_t
Definition: flowprobe.h:46
udp_header_t::checksum
u16 checksum
Definition: udp_packet.h:55
FLOW_MAXIMUM_EXPORT_ENTRIES
#define FLOW_MAXIMUM_EXPORT_ENTRIES
Definition: flowprobe.h:61
flowprobe_record_t
flowprobe_record_t
Definition: flowprobe.h:35
FLOW_VARIANT_L2
@ FLOW_VARIANT_L2
Definition: flowprobe.h:50
unix_time_now_nsec_fraction
static void unix_time_now_nsec_fraction(u32 *sec, u32 *nsec)
Definition: time.h:282
FLOWPROBE_N_NEXT
@ FLOWPROBE_N_NEXT
Definition: node.c:130
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vlib_validate_buffer_enqueue_x1
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:224
index
u32 index
Definition: flow_types.api:221
flow_report_main::src_address
ip4_address_t src_address
Definition: flow_report.h:119
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
ip4_ipfix_template_packet_t::ip4
ip4_header_t ip4
Definition: flow_report.h:44
u64
unsigned long u64
Definition: types.h:89
flowprobe_entry_t::last_updated
f64 last_updated
Definition: flowprobe.h:104
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
format_get_indent
static u32 format_get_indent(u8 *s)
Definition: format.h:72
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
format_ip46_address
format_function_t format_ip46_address
Definition: ip46_address.h:50
u32
unsigned int u32
Definition: types.h:88
FLOW_RECORD_L3
@ FLOW_RECORD_L3
Definition: flowprobe.h:38
flowprobe_trace_t::buffer_size
u16 buffer_size
size of the buffer
Definition: node.c:41
flowprobe_ip4_node
vlib_node_registration_t flowprobe_ip4_node
(constructor) VLIB_REGISTER_NODE (flowprobe_ip4_node)
Definition: node.c:101
udp_header_t::dst_port
u16 dst_port
Definition: udp_packet.h:48
flow_report_stream_t
Definition: flow_report.h:77
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
FLOW_VARIANT_L2_IP4
@ FLOW_VARIANT_L2_IP4
Definition: flowprobe.h:51
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
flow_report_main::unix_time_0
u32 unix_time_0
Definition: flow_report.h:132
FLOW_VARIANT_IP6
@ FLOW_VARIANT_IP6
Definition: flowprobe.h:49
FLOW_VARIANT_L2_IP6
@ FLOW_VARIANT_L2_IP6
Definition: flowprobe.h:52
flowprobe_error_t
flowprobe_error_t
Definition: node.c:112
ip6_header_t
Definition: ip6_packet.h:294
flowprobe_key_t::which
flowprobe_variant_t which
Definition: flowprobe.h:87
now
f64 now
Definition: nat44_ei_out2in.c:710
length
char const int length
Definition: cJSON.h:163
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
flowprobe_walker_process
static uword flowprobe_walker_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: node.c:921
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
flowprobe_next_t
flowprobe_next_t
Definition: node.c:126
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
format_flowprobe_trace
static u8 * format_flowprobe_trace(u8 *s, va_list *args)
Definition: node.c:72
flowprobe_trace_t::ethertype
u16 ethertype
Ethertype.
Definition: node.c:47
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:399
flowprobe_trace_t::which
flowprobe_variant_t which
Definition: node.c:59
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
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
ipfix_set_id_length
static u32 ipfix_set_id_length(u16 set_id, u16 length)
Definition: ipfix_packet.h:121
FLOW_RECORD_L2
@ FLOW_RECORD_L2
Definition: flowprobe.h:37
flowprobe_trace_t::tos
u8 tos
Definition: node.c:53
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
FLOW_VARIANT_IP4
@ FLOW_VARIANT_IP4
Definition: flowprobe.h:48
flowprobe_key_t::src_mac
u8 src_mac[6]
Definition: flowprobe.h:79
flowprobe_l4_add
static u32 flowprobe_l4_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
Definition: node.c:266
flow_report_main::vlib_time_0
f64 vlib_time_0
Definition: flow_report.h:133
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
vlib_validate_buffer_enqueue_x2
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
Definition: buffer_node.h:70
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
flowprobe_get_buffer
static vlib_buffer_t * flowprobe_get_buffer(vlib_main_t *vm, flowprobe_variant_t which)
Definition: node.c:629
vnet.h
flowprobe_lookup
flowprobe_entry_t * flowprobe_lookup(u32 my_cpu_number, flowprobe_key_t *k, u32 *poolindex, bool *collision)
Definition: node.c:307
vlib_node_runtime_t
Definition: node.h:454
flowprobe_export_entry
static void flowprobe_export_entry(vlib_main_t *vm, flowprobe_entry_t *e)
Definition: node.c:668
from
from
Definition: nat44_ei_hairpinning.c:415
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
vlib_get_next_frame
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:395
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
FLOW_RECORD_L4
@ FLOW_RECORD_L4
Definition: flowprobe.h:39
timestamp
f64 timestamp
Definition: vpe_types.api:28
ipfix_set_header_t::set_id_length
u32 set_id_length
Definition: ipfix_packet.h:117
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
flowprobe_entry_t::prot
union flowprobe_entry_t::@56 prot
flowprobe_entry_t::passive_timer_handle
u32 passive_timer_handle
Definition: flowprobe.h:106
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
flowprobe_ip6_node_fn
static uword flowprobe_ip6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: node.c:857
FLOWPROBE_NEXT_NODES
#define FLOWPROBE_NEXT_NODES
Definition: node.c:133
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
flowprobe_export_send
static void flowprobe_export_send(vlib_main_t *vm, vlib_buffer_t *b0, flowprobe_variant_t which)
Definition: node.c:518
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
flowprobe_l2_node_fn
static uword flowprobe_l2_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: node.c:864
flowprobe_ip6_node
vlib_node_registration_t flowprobe_ip6_node
(constructor) VLIB_REGISTER_NODE (flowprobe_ip6_node)
Definition: node.c:102
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105