FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
flow_report.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 /*
16  * flow_report.c
17  */
19 #include <vnet/api_errno.h>
20 #include <vnet/udp/udp.h>
21 
23 
26 {
28  return index < vec_len (frm->streams) &&
29  frm->streams[index].domain_id != ~0;
30 }
31 
33 add_stream (void)
34 {
36  u32 i;
37  for (i = 0; i < vec_len (frm->streams); i++)
38  if (!stream_index_valid (i))
39  return &frm->streams[i];
40  u32 index = vec_len (frm->streams);
41  vec_validate (frm->streams, index);
42  return &frm->streams[index];
43 }
44 
47 {
49  ASSERT (index < vec_len (frm->streams));
50  ASSERT (frm->streams[index].domain_id != ~0);
51  frm->streams[index].domain_id = ~0;
52 }
53 
54 static i32
56 {
58  flow_report_stream_t *stream;
59  u32 i;
60  for (i = 0; i < vec_len (frm->streams); i++)
61  if (stream_index_valid (i))
62  {
63  stream = &frm->streams[i];
64  if (domain_id == stream->domain_id)
65  {
66  if (src_port != stream->src_port)
67  return -2;
68  return i;
69  }
70  else if (src_port == stream->src_port)
71  {
72  return -2;
73  }
74  }
75  return -1;
76 }
77 
78 int
80  flow_report_t * fr, u32 * buffer_indexp)
81 {
82  u32 bi0;
83  vlib_buffer_t *b0;
87  udp_header_t *udp;
88  vlib_main_t *vm = frm->vlib_main;
89  flow_report_stream_t *stream;
90 
91  ASSERT (buffer_indexp);
92 
93  if (fr->update_rewrite || fr->rewrite == 0)
94  {
95  if (frm->ipfix_collector.as_u32 == 0 || frm->src_address.as_u32 == 0)
96  {
98  VLIB_NODE_STATE_DISABLED);
99  return -1;
100  }
101  vec_free (fr->rewrite);
102  fr->update_rewrite = 1;
103  }
104 
105  if (fr->update_rewrite)
106  {
107  fr->rewrite = fr->rewrite_callback (frm, fr,
108  &frm->ipfix_collector,
109  &frm->src_address,
110  frm->collector_port,
111  fr->report_elements,
112  fr->n_report_elements,
113  fr->stream_indexp);
114  fr->update_rewrite = 0;
115  }
116 
117  if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
118  return -1;
119 
120  b0 = vlib_get_buffer (vm, bi0);
121 
123 
124  clib_memcpy_fast (b0->data, fr->rewrite, vec_len (fr->rewrite));
125  b0->current_data = 0;
126  b0->current_length = vec_len (fr->rewrite);
127  b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_FLOW_REPORT);
128  vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0;
129  vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index;
130 
131  tp = vlib_buffer_get_current (b0);
132  ip = (ip4_header_t *) & tp->ip4;
133  udp = (udp_header_t *) (ip + 1);
134  h = (ipfix_message_header_t *) (udp + 1);
135 
136  /* FIXUP: message header export_time */
137  h->export_time = (u32)
138  (((f64) frm->unix_time_0) +
139  (vlib_time_now (frm->vlib_main) - frm->vlib_time_0));
140  h->export_time = clib_host_to_net_u32 (h->export_time);
141 
142  stream = &frm->streams[fr->stream_index];
143 
144  /* FIXUP: message header sequence_number. Templates do not increase it */
145  h->sequence_number = clib_host_to_net_u32 (stream->sequence_number);
146 
147  /* FIXUP: udp length */
148  udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip));
149 
150  if (frm->udp_checksum)
151  {
152  /* RFC 7011 section 10.3.2. */
154  if (udp->checksum == 0)
155  udp->checksum = 0xffff;
156  }
157 
158  *buffer_indexp = bi0;
159 
161 
162  return 0;
163 }
164 
165 u8 *
167  flow_report_t * fr,
168  ip4_address_t * collector_address,
170  u16 collector_port,
171  ipfix_report_element_t * report_elts,
172  u32 n_elts, u32 * stream_indexp)
173 {
174  ip4_header_t *ip;
175  udp_header_t *udp;
180  ipfix_field_specifier_t *first_field;
181  u8 *rewrite = 0;
183  flow_report_stream_t *stream;
184  int i;
186 
187  ASSERT (stream_indexp);
188  ASSERT (n_elts);
189  ASSERT (report_elts);
190 
191  stream = &frm->streams[fr->stream_index];
192  *stream_indexp = fr->stream_index;
193 
194  /* allocate rewrite space */
197  + n_elts * sizeof (ipfix_field_specifier_t) - 1,
199 
200  /* create the packet rewrite string */
202  ip = (ip4_header_t *) & tp->ip4;
203  udp = (udp_header_t *) (ip + 1);
204  h = (ipfix_message_header_t *) (udp + 1);
205  s = (ipfix_set_header_t *) (h + 1);
206  t = (ipfix_template_header_t *) (s + 1);
207  first_field = f = (ipfix_field_specifier_t *) (t + 1);
208 
209  ip->ip_version_and_header_length = 0x45;
210  ip->ttl = 254;
211  ip->protocol = IP_PROTOCOL_UDP;
212  ip->src_address.as_u32 = src_address->as_u32;
213  ip->dst_address.as_u32 = collector_address->as_u32;
214  udp->src_port = clib_host_to_net_u16 (stream->src_port);
215  udp->dst_port = clib_host_to_net_u16 (collector_port);
216  udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip));
217 
218  /* FIXUP LATER: message header export_time */
219  h->domain_id = clib_host_to_net_u32 (stream->domain_id);
220 
221  ep = report_elts;
222 
223  for (i = 0; i < n_elts; i++)
224  {
225  f->e_id_length = ipfix_e_id_length (0, ep->info_element, ep->size);
226  f++;
227  ep++;
228  }
229 
230  /* Back to the template packet... */
231  ip = (ip4_header_t *) & tp->ip4;
232  udp = (udp_header_t *) (ip + 1);
233 
234  ASSERT (f - first_field);
235  /* Field count in this template */
236  t->id_count = ipfix_id_count (fr->template_id, f - first_field);
237 
238  /* set length in octets */
239  s->set_id_length =
240  ipfix_set_id_length (2 /* set_id */ , (u8 *) f - (u8 *) s);
241 
242  /* message length in octets */
243  h->version_length = version_length ((u8 *) f - (u8 *) h);
244 
245  ip->length = clib_host_to_net_u16 ((u8 *) f - (u8 *) ip);
246  ip->checksum = ip4_header_checksum (ip);
247 
248  return rewrite;
249 }
250 
251 static uword
254 {
256  flow_report_t *fr;
257  u32 ip4_lookup_node_index;
259  vlib_frame_t *nf = 0;
260  u32 template_bi;
261  u32 *to_next;
262  int send_template;
263  f64 now, wait_time;
264  f64 def_wait_time = 5.0;
265  int rv;
266  uword event_type;
267  uword *event_data = 0;
268 
269  /* Wait for Godot... */
271  event_type = vlib_process_get_events (vm, &event_data);
272  if (event_type != 1)
273  clib_warning ("bogus kickoff event received, %d", event_type);
274  vec_reset_length (event_data);
275 
276  /* Enqueue pkts to ip4-lookup */
277  ip4_lookup_node = vlib_get_node_by_name (vm, (u8 *) "ip4-lookup");
278  ip4_lookup_node_index = ip4_lookup_node->index;
279 
280  wait_time = def_wait_time;
281 
282  while (1)
283  {
285  event_type = vlib_process_get_events (vm, &event_data);
286  vec_reset_length (event_data);
287 
288  /* 5s delay by default, possibly reduced by template intervals */
289  wait_time = def_wait_time;
290 
291  vec_foreach (fr, frm->reports)
292  {
293  f64 next_template;
294  now = vlib_time_now (vm);
295 
296  /* Need to send a template packet? */
297  send_template =
299  send_template += fr->last_template_sent == 0;
300  template_bi = ~0;
301  rv = 0;
302 
303  if (send_template)
304  rv = send_template_packet (frm, fr, &template_bi);
305 
306  if (rv < 0)
307  continue;
308 
309  /* decide if template should be sent sooner than current wait time */
310  next_template =
312  wait_time = clib_min (wait_time, next_template);
313 
314  nf = vlib_get_frame_to_node (vm, ip4_lookup_node_index);
315  nf->n_vectors = 0;
316  to_next = vlib_frame_vector_args (nf);
317 
318  if (template_bi != ~0)
319  {
320  to_next[0] = template_bi;
321  to_next++;
322  nf->n_vectors++;
323  }
324 
325  nf = fr->flow_data_callback (frm, fr,
326  nf, to_next, ip4_lookup_node_index);
327  if (nf)
328  vlib_put_frame_to_node (vm, ip4_lookup_node_index, nf);
329  }
330  }
331 
332  return 0; /* not so much */
333 }
334 
335 /* *INDENT-OFF* */
337  .function = flow_report_process,
338  .type = VLIB_NODE_TYPE_PROCESS,
339  .name = "flow-report-process",
340 };
341 /* *INDENT-ON* */
342 
343 int
346  u16 * template_id)
347 {
348  int i;
349  int found_index = ~0;
350  flow_report_t *fr;
351  flow_report_stream_t *stream;
352  u32 si;
353 
354  si = find_stream (a->domain_id, a->src_port);
355  if (si == -2)
356  return VNET_API_ERROR_INVALID_VALUE;
357  if (si == -1 && a->is_add == 0)
358  return VNET_API_ERROR_NO_SUCH_ENTRY;
359 
360  for (i = 0; i < vec_len (frm->reports); i++)
361  {
362  fr = vec_elt_at_index (frm->reports, i);
363  if (fr->opaque.as_uword == a->opaque.as_uword
364  && fr->rewrite_callback == a->rewrite_callback
365  && fr->flow_data_callback == a->flow_data_callback)
366  {
367  found_index = i;
368  if (template_id)
369  *template_id = fr->template_id;
370  break;
371  }
372  }
373 
374  if (a->is_add == 0)
375  {
376  if (found_index != ~0)
377  {
378  vec_delete (frm->reports, 1, found_index);
379  stream = &frm->streams[si];
380  stream->n_reports--;
381  if (stream->n_reports == 0)
382  delete_stream (si);
383  return 0;
384  }
385  return VNET_API_ERROR_NO_SUCH_ENTRY;
386  }
387 
388  if (found_index != ~0)
389  return VNET_API_ERROR_VALUE_EXIST;
390 
391  if (si == -1)
392  {
393  stream = add_stream ();
394  stream->domain_id = a->domain_id;
395  stream->src_port = a->src_port;
396  stream->sequence_number = 0;
397  stream->n_reports = 0;
398  si = stream - frm->streams;
399  }
400  else
401  stream = &frm->streams[si];
402 
403  stream->n_reports++;
404 
405  vec_add2 (frm->reports, fr, 1);
406 
407  fr->stream_index = si;
408  fr->template_id = 256 + stream->next_template_no;
409  stream->next_template_no = (stream->next_template_no + 1) % (65536 - 256);
410  fr->update_rewrite = 1;
411  fr->opaque = a->opaque;
412  fr->rewrite_callback = a->rewrite_callback;
413  fr->flow_data_callback = a->flow_data_callback;
414  fr->report_elements = a->report_elements;
415  fr->n_report_elements = a->n_report_elements;
416  fr->stream_indexp = a->stream_indexp;
417  if (template_id)
418  *template_id = fr->template_id;
419 
420  return 0;
421 }
422 
423 clib_error_t *
425 {
426  switch (error)
427  {
428  case 0:
429  return 0;
430  case VNET_API_ERROR_NO_SUCH_ENTRY:
431  return clib_error_return (0, "Flow report not found");
432  case VNET_API_ERROR_VALUE_EXIST:
433  return clib_error_return (0, "Flow report already exists");
434  case VNET_API_ERROR_INVALID_VALUE:
435  return clib_error_return (0, "Expecting either still unused values "
436  "for both domain_id and src_port "
437  "or already used values for both fields");
438  default:
439  return clib_error_return (0, "vnet_flow_report_add_del returned %d",
440  error);
441  }
442 }
443 
444 void
446 {
447  flow_report_t *fr;
448  u32 i;
449 
450  for (i = 0; i < vec_len (frm->streams); i++)
451  if (stream_index_valid (i))
452  frm->streams[i].sequence_number = 0;
453 
454  vec_foreach (fr, frm->reports)
455  {
456  fr->update_rewrite = 1;
457  fr->last_template_sent = 0;
458  }
459 }
460 
461 void
463 {
464  flow_report_t *fr;
465 
466  frm->streams[stream_index].sequence_number = 0;
467 
468  vec_foreach (fr, frm->reports)
469  if (frm->reports->stream_index == stream_index)
470  {
471  fr->update_rewrite = 1;
472  fr->last_template_sent = 0;
473  }
474 }
475 
476 int
478  u32 old_domain_id, u16 old_src_port,
479  u32 new_domain_id, u16 new_src_port)
480 {
481  i32 stream_index = find_stream (old_domain_id, old_src_port);
482  if (stream_index < 0)
483  return 1;
484  flow_report_stream_t *stream = &frm->streams[stream_index];
485  stream->domain_id = new_domain_id;
486  stream->src_port = new_src_port;
487  if (old_domain_id != new_domain_id || old_src_port != new_src_port)
488  vnet_stream_reset (frm, stream_index);
489  return 0;
490 }
491 
492 static clib_error_t *
494  unformat_input_t * input,
495  vlib_cli_command_t * cmd)
496 {
498  ip4_address_t collector, src;
499  u16 collector_port = UDP_DST_PORT_ipfix;
500  u32 fib_id;
501  u32 fib_index = ~0;
502 
503  collector.as_u32 = 0;
504  src.as_u32 = 0;
505  u32 path_mtu = 512; // RFC 7011 section 10.3.3.
506  u32 template_interval = 20;
507  u8 udp_checksum = 0;
508 
510  {
511  if (unformat (input, "collector %U", unformat_ip4_address, &collector))
512  ;
513  else if (unformat (input, "port %U", unformat_udp_port,
514  &collector_port))
515  ;
516  else if (unformat (input, "src %U", unformat_ip4_address, &src))
517  ;
518  else if (unformat (input, "fib-id %u", &fib_id))
519  {
520  ip4_main_t *im = &ip4_main;
521  uword *p = hash_get (im->fib_index_by_table_id, fib_id);
522  if (!p)
523  return clib_error_return (0, "fib ID %d doesn't exist\n", fib_id);
524  fib_index = p[0];
525  }
526  else if (unformat (input, "path-mtu %u", &path_mtu))
527  ;
528  else if (unformat (input, "template-interval %u", &template_interval))
529  ;
530  else if (unformat (input, "udp-checksum"))
531  udp_checksum = 1;
532  else
533  break;
534  }
535 
536  if (collector.as_u32 != 0 && src.as_u32 == 0)
537  return clib_error_return (0, "src address required");
538 
539  if (path_mtu > 1450 /* vpp does not support fragmentation */ )
540  return clib_error_return (0, "too big path-mtu value, maximum is 1450");
541 
542  if (path_mtu < 68)
543  return clib_error_return (0, "too small path-mtu value, minimum is 68");
544 
545  /* Reset report streams if we are reconfiguring IP addresses */
546  if (frm->ipfix_collector.as_u32 != collector.as_u32 ||
547  frm->src_address.as_u32 != src.as_u32 ||
548  frm->collector_port != collector_port)
550 
551  frm->ipfix_collector.as_u32 = collector.as_u32;
552  frm->collector_port = collector_port;
553  frm->src_address.as_u32 = src.as_u32;
554  frm->fib_index = fib_index;
555  frm->path_mtu = path_mtu;
556  frm->template_interval = template_interval;
557  frm->udp_checksum = udp_checksum;
558 
559  if (collector.as_u32)
560  vlib_cli_output (vm, "Collector %U, src address %U, "
561  "fib index %d, path MTU %u, "
562  "template resend interval %us, "
563  "udp checksum %s",
566  fib_index, path_mtu, template_interval,
567  udp_checksum ? "enabled" : "disabled");
568  else
569  vlib_cli_output (vm, "IPFIX Collector is disabled");
570 
571  /* Turn on the flow reporting process */
573  return 0;
574 }
575 
576 /* *INDENT-OFF* */
578  .path = "set ipfix exporter",
579  .short_help = "set ipfix exporter "
580  "collector <ip4-address> [port <port>] "
581  "src <ip4-address> [fib-id <fib-id>] "
582  "[path-mtu <path-mtu>] "
583  "[template-interval <template-interval>] "
584  "[udp-checksum]",
585  .function = set_ipfix_exporter_command_fn,
586 };
587 /* *INDENT-ON* */
588 
589 
590 static clib_error_t *
592  unformat_input_t * input, vlib_cli_command_t * cmd)
593 {
594  /* poke the flow reporting process */
596  return 0;
597 }
598 
599 /* *INDENT-OFF* */
601  .path = "ipfix flush",
602  .short_help = "flush the current ipfix data [for make test]",
603  .function = ipfix_flush_command_fn,
604 };
605 /* *INDENT-ON* */
606 
607 static clib_error_t *
609 {
611 
612  frm->vlib_main = vm;
613  frm->vnet_main = vnet_get_main ();
614  frm->unix_time_0 = time (0);
615  frm->vlib_time_0 = vlib_time_now (frm->vlib_main);
616  frm->fib_index = ~0;
617 
618  return 0;
619 }
620 
622 /*
623  * fd.io coding-style-patch-verification: ON
624  *
625  * Local Variables:
626  * eval: (c-set-style "gnu")
627  * End:
628  */
stream_index_valid
static_always_inline u8 stream_index_valid(u32 index)
Definition: flow_report.c:25
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
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
flow_report_stream_t::sequence_number
u32 sequence_number
Definition: flow_report.h:80
im
vnet_interface_main_t * im
Definition: interface_output.c:395
udp_header_t::src_port
u16 src_port
Definition: udp_packet.h:48
udp_header_t::length
u16 length
Definition: udp_packet.h:51
flow_report_main
flow_report_main_t flow_report_main
Definition: flow_report.c:22
ipfix_e_id_length
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
Definition: ipfix_packet.h:77
flow_report_main::udp_checksum
u8 udp_checksum
Definition: flow_report.h:129
flow_report_stream_t::n_reports
u16 n_reports
Definition: flow_report.h:82
flow_report_main::vlib_main
vlib_main_t * vlib_main
Definition: flow_report.h:136
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
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
vlib_node_set_state
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:175
ipfix_set_header_t
Definition: ipfix_packet.h:115
flow_report::stream_index
u32 stream_index
Definition: flow_report.h:91
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
opaque_t::as_uword
uword as_uword
Definition: flow_report.h:74
vnet_stream_change
int vnet_stream_change(flow_report_main_t *frm, u32 old_domain_id, u16 old_src_port, u32 new_domain_id, u16 new_src_port)
Definition: flow_report.c:477
flow_report_stream_t::domain_id
u32 domain_id
Definition: flow_report.h:79
flow_report
Definition: flow_report.h:86
u16
unsigned short u16
Definition: types.h:57
flow_report::stream_indexp
u32 * stream_indexp
Definition: flow_report.h:105
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
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
flow_report_main::template_interval
u32 template_interval
Definition: flow_report.h:126
flow_report_main::fib_index
u32 fib_index
Definition: flow_report.h:120
unformat_input_t
struct _unformat_input_t unformat_input_t
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_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
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
h
h
Definition: flowhash_template.h:372
error
Definition: cJSON.c:88
ip4_ipfix_template_packet_t
Definition: flow_report.h:42
i32
signed int i32
Definition: types.h:77
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
flow_report::last_template_sent
f64 last_template_sent
Definition: flow_report.h:92
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
delete_stream
static_always_inline void delete_stream(u32 index)
Definition: flow_report.c:46
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
vnet_flow_reports_reset
void vnet_flow_reports_reset(flow_report_main_t *frm)
Definition: flow_report.c:445
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
set_ipfix_exporter_command_fn
static clib_error_t * set_ipfix_exporter_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: flow_report.c:493
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
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
flow_report_stream_t::src_port
u16 src_port
Definition: flow_report.h:81
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vnet_flow_rewrite_generic_callback
u8 * vnet_flow_rewrite_generic_callback(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port, ipfix_report_element_t *report_elts, u32 n_elts, u32 *stream_indexp)
Definition: flow_report.c:166
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
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
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
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
static_always_inline
#define static_always_inline
Definition: clib.h:112
flow_report_main::ipfix_collector
ip4_address_t ipfix_collector
Definition: flow_report.h:117
unformat_udp_port
unformat_function_t unformat_udp_port
Definition: udp.h:238
uword
u64 uword
Definition: types.h:112
hash_get
#define hash_get(h, key)
Definition: hash.h:249
ipfix_report_element_t
Definition: flow_report.h:35
src_port
vl_api_ip_port_and_mask_t src_port
Definition: flow_types.api:91
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
vnet_stream_reset
void vnet_stream_reset(flow_report_main_t *frm, u32 stream_index)
Definition: flow_report.c:462
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
src
vl_api_address_t src
Definition: gre.api:54
flow_report_main
Definition: flow_report.h:111
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
clib_min
#define clib_min(x, y)
Definition: clib.h:342
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
ipfix_message_header_t
Definition: ipfix_packet.h:24
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
ipfix_flush_command
static vlib_cli_command_t ipfix_flush_command
(constructor) VLIB_CLI_COMMAND (ipfix_flush_command)
Definition: flow_report.c:600
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
flow_report::update_rewrite
int update_rewrite
Definition: flow_report.h:93
flow_report.h
flow_report_main::collector_port
u16 collector_port
Definition: flow_report.h:118
flow_report_main::path_mtu
u32 path_mtu
Definition: flow_report.h:123
find_stream
static i32 find_stream(u32 domain_id, u16 src_port)
Definition: flow_report.c:55
udp_header_t::checksum
u16 checksum
Definition: udp_packet.h:55
flow_report_init
static clib_error_t * flow_report_init(vlib_main_t *vm)
Definition: flow_report.c:608
ipfix_report_element_t::info_element
u32 info_element
Definition: flow_report.h:37
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
ipfix_id_count
static u32 ipfix_id_count(u16 id, u16 count)
Definition: ipfix_packet.h:184
index
u32 index
Definition: flow_types.api:221
flow_report_main::src_address
ip4_address_t src_address
Definition: flow_report.h:119
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
ip4_ipfix_template_packet_t::ip4
ip4_header_t ip4
Definition: flow_report.h:44
flow_report_add_del_error_to_clib_error
clib_error_t * flow_report_add_del_error_to_clib_error(int error)
Definition: flow_report.c:424
flow_report::template_id
u16 template_id
Definition: flow_report.h:90
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
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
flow_report::rewrite_callback
vnet_flow_rewrite_callback_t * rewrite_callback
Definition: flow_report.h:102
vlib_buffer_get_default_data_size
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:122
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
udp_header_t::dst_port
u16 dst_port
Definition: udp_packet.h:48
flow_report_stream_t
Definition: flow_report.h:77
vnet_flow_report_add_del_args_t
Definition: flow_report.h:146
ipfix_report_element_t::size
u32 size
Definition: flow_report.h:38
si
vnet_sw_interface_t * si
Definition: interface_output.c:398
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
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
udp.h
flow_report::report_elements
ipfix_report_element_t * report_elements
Definition: flow_report.h:103
now
f64 now
Definition: nat44_ei_out2in.c:710
ipfix_template_header_t
Definition: ipfix_packet.h:178
vlib_main_t
Definition: main.h:102
ipfix_flush_command_fn
static clib_error_t * ipfix_flush_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: flow_report.c:591
vlib_node_t
Definition: node.h:247
ipfix_field_specifier_t
Definition: ipfix_packet.h:71
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:544
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
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_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
flow_report_process_node
vlib_node_registration_t flow_report_process_node
(constructor) VLIB_REGISTER_NODE (flow_report_process_node)
Definition: flow_report.c:336
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
flow_report_main::reports
flow_report_t * reports
Definition: flow_report.h:113
ipfix_set_id_length
static u32 ipfix_set_id_length(u16 set_id, u16 length)
Definition: ipfix_packet.h:121
flow_report_main::vnet_main
vnet_main_t * vnet_main
Definition: flow_report.h:137
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
flow_report_main::vlib_time_0
f64 vlib_time_0
Definition: flow_report.h:133
rv
int __clib_unused rv
Definition: application.c:491
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
send_template_packet
int send_template_packet(flow_report_main_t *frm, flow_report_t *fr, u32 *buffer_indexp)
Definition: flow_report.c:79
vnet_flow_report_add_del
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a, u16 *template_id)
Definition: flow_report.c:344
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
flow_report::n_report_elements
u32 n_report_elements
Definition: flow_report.h:104
api_errno.h
vlib_node_runtime_t
Definition: node.h:454
udp_checksum
u16 udp_checksum(udp_header_t *uh, u32 udp_len, void *ih, u8 version)
Definition: packets.c:116
src_address
vl_api_address_union_t src_address
Definition: ip_types.api:122
vlib_cli_command_t
Definition: cli.h:92
path_mtu
u16 path_mtu
Definition: ip.api:783
add_stream
static_always_inline flow_report_stream_t * add_stream(void)
Definition: flow_report.c:33
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
set_ipfix_exporter_command
static vlib_cli_command_t set_ipfix_exporter_command
(constructor) VLIB_CLI_COMMAND (set_ipfix_exporter_command)
Definition: flow_report.c:577
rewrite
rewrite
Definition: pnat.api:158
flow_report::rewrite
u8 * rewrite
Definition: flow_report.h:89
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
flow_report::flow_data_callback
vnet_flow_data_callback_t * flow_data_callback
Definition: flow_report.h:108
ipfix_set_header_t::set_id_length
u32 set_id_length
Definition: ipfix_packet.h:117
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
flow_report::opaque
opaque_t opaque
Definition: flow_report.h:99
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
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
ipfix_template_header_t::id_count
u32 id_count
Definition: ipfix_packet.h:180
flow_report_stream_t::next_template_no
u16 next_template_no
Definition: flow_report.h:83
flow_report_process
static uword flow_report_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: flow_report.c:252