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