Line data Source code
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/xxhash.h>
21 : #include <vppinfra/error.h>
22 : #include <flowprobe/flowprobe.h>
23 : #include <vnet/ip/ip6_packet.h>
24 : #include <vnet/udp/udp_local.h>
25 : #include <vlibmemory/api.h>
26 :
27 : static void flowprobe_export_entry (vlib_main_t * vm, flowprobe_entry_t * e);
28 :
29 : /**
30 : * @file node.c
31 : * flow record generator graph node
32 : */
33 :
34 : typedef struct
35 : {
36 : /** interface handle */
37 : u32 rx_sw_if_index;
38 : u32 tx_sw_if_index;
39 : /** packet timestamp */
40 : u64 timestamp;
41 : /** size of the buffer */
42 : u16 buffer_size;
43 :
44 : /** L2 information */
45 : u8 src_mac[6];
46 : u8 dst_mac[6];
47 : /** Ethertype */
48 : u16 ethertype;
49 :
50 : /** L3 information */
51 : ip46_address_t src_address;
52 : ip46_address_t dst_address;
53 : u8 protocol;
54 : u8 tos;
55 :
56 : /** L4 information */
57 : u16 src_port;
58 : u16 dst_port;
59 :
60 : flowprobe_variant_t which;
61 : } flowprobe_trace_t;
62 :
63 : static char *flowprobe_variant_strings[] = {
64 : [FLOW_VARIANT_IP4] = "IP4",
65 : [FLOW_VARIANT_IP6] = "IP6",
66 : [FLOW_VARIANT_L2] = "L2",
67 : [FLOW_VARIANT_L2_IP4] = "L2-IP4",
68 : [FLOW_VARIANT_L2_IP6] = "L2-IP6",
69 : };
70 :
71 : /* packet trace format function */
72 : static u8 *
73 35 : format_flowprobe_trace (u8 * s, va_list * args)
74 : {
75 35 : CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
76 35 : CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
77 35 : flowprobe_trace_t *t = va_arg (*args, flowprobe_trace_t *);
78 35 : u32 indent = format_get_indent (s);
79 :
80 35 : s = format (s,
81 : "FLOWPROBE[%s]: rx_sw_if_index %d, tx_sw_if_index %d, "
82 35 : "timestamp %lld, size %d", flowprobe_variant_strings[t->which],
83 : t->rx_sw_if_index, t->tx_sw_if_index,
84 35 : t->timestamp, t->buffer_size);
85 :
86 35 : if (t->which == FLOW_VARIANT_L2)
87 2 : s = format (s, "\n%U -> %U", format_white_space, indent,
88 : format_ethernet_address, &t->src_mac,
89 : format_ethernet_address, &t->dst_mac);
90 :
91 35 : if (t->protocol > 0
92 29 : && (t->which == FLOW_VARIANT_L2_IP4 || t->which == FLOW_VARIANT_IP4
93 4 : || t->which == FLOW_VARIANT_L2_IP6 || t->which == FLOW_VARIANT_IP6))
94 : s =
95 29 : format (s, "\n%U%U: %U -> %U", format_white_space, indent,
96 29 : format_ip_protocol, t->protocol, format_ip46_address,
97 : &t->src_address, IP46_TYPE_ANY, format_ip46_address,
98 : &t->dst_address, IP46_TYPE_ANY);
99 35 : return s;
100 : }
101 :
102 : vlib_node_registration_t flowprobe_input_ip4_node;
103 : vlib_node_registration_t flowprobe_input_ip6_node;
104 : vlib_node_registration_t flowprobe_input_l2_node;
105 : vlib_node_registration_t flowprobe_output_ip4_node;
106 : vlib_node_registration_t flowprobe_output_ip6_node;
107 : vlib_node_registration_t flowprobe_output_l2_node;
108 :
109 : /* No counters at the moment */
110 : #define foreach_flowprobe_error \
111 : _(COLLISION, "Hash table collisions") \
112 : _(BUFFER, "Buffer allocation error") \
113 : _(EXPORTED_PACKETS, "Exported packets") \
114 : _(INPATH, "Exported packets in path")
115 :
116 : typedef enum
117 : {
118 : #define _(sym,str) FLOWPROBE_ERROR_##sym,
119 : foreach_flowprobe_error
120 : #undef _
121 : FLOWPROBE_N_ERROR,
122 : } flowprobe_error_t;
123 :
124 : static char *flowprobe_error_strings[] = {
125 : #define _(sym,string) string,
126 : foreach_flowprobe_error
127 : #undef _
128 : };
129 :
130 : typedef enum
131 : {
132 : FLOWPROBE_NEXT_DROP,
133 : FLOWPROBE_NEXT_IP4_LOOKUP,
134 : FLOWPROBE_N_NEXT,
135 : } flowprobe_next_t;
136 :
137 : #define FLOWPROBE_NEXT_NODES { \
138 : [FLOWPROBE_NEXT_DROP] = "error-drop", \
139 : [FLOWPROBE_NEXT_IP4_LOOKUP] = "ip4-lookup", \
140 : }
141 :
142 : static inline flowprobe_variant_t
143 55 : flowprobe_get_variant (flowprobe_variant_t which,
144 : flowprobe_record_t flags, u16 ethertype)
145 : {
146 55 : if (which == FLOW_VARIANT_L2
147 42 : && (flags & FLOW_RECORD_L3 || flags & FLOW_RECORD_L4))
148 40 : return ethertype == ETHERNET_TYPE_IP6 ? FLOW_VARIANT_L2_IP6 : ethertype ==
149 : ETHERNET_TYPE_IP4 ? FLOW_VARIANT_L2_IP4 : FLOW_VARIANT_L2;
150 15 : return which;
151 : }
152 :
153 : /*
154 : * NTP rfc868 : 2 208 988 800 corresponds to 00:00 1 Jan 1970 GMT
155 : */
156 : #define NTP_TIMESTAMP 2208988800LU
157 :
158 : static inline u32
159 53 : flowprobe_common_add (vlib_buffer_t * to_b, flowprobe_entry_t * e, u16 offset)
160 : {
161 53 : u16 start = offset;
162 :
163 : /* Ingress interface */
164 53 : u32 rx_if = clib_host_to_net_u32 (e->key.rx_sw_if_index);
165 53 : clib_memcpy_fast (to_b->data + offset, &rx_if, sizeof (rx_if));
166 53 : offset += sizeof (rx_if);
167 :
168 : /* Egress interface */
169 53 : u32 tx_if = clib_host_to_net_u32 (e->key.tx_sw_if_index);
170 53 : clib_memcpy_fast (to_b->data + offset, &tx_if, sizeof (tx_if));
171 53 : offset += sizeof (tx_if);
172 :
173 : /* Flow direction
174 : 0x00: ingress flow
175 : 0x01: egress flow */
176 53 : to_b->data[offset++] = (e->key.direction == FLOW_DIRECTION_TX);
177 :
178 : /* packet delta count */
179 53 : u64 packetdelta = clib_host_to_net_u64 (e->packetcount);
180 53 : clib_memcpy_fast (to_b->data + offset, &packetdelta, sizeof (u64));
181 53 : offset += sizeof (u64);
182 :
183 : /* flowStartNanoseconds */
184 53 : u32 t = clib_host_to_net_u32 (e->flow_start.sec + NTP_TIMESTAMP);
185 53 : clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
186 53 : offset += sizeof (u32);
187 53 : t = clib_host_to_net_u32 (e->flow_start.nsec);
188 53 : clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
189 53 : offset += sizeof (u32);
190 :
191 : /* flowEndNanoseconds */
192 53 : t = clib_host_to_net_u32 (e->flow_end.sec + NTP_TIMESTAMP);
193 53 : clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
194 53 : offset += sizeof (u32);
195 53 : t = clib_host_to_net_u32 (e->flow_end.nsec);
196 53 : clib_memcpy_fast (to_b->data + offset, &t, sizeof (u32));
197 53 : offset += sizeof (u32);
198 :
199 53 : return offset - start;
200 : }
201 :
202 : static inline u32
203 41 : flowprobe_l2_add (vlib_buffer_t * to_b, flowprobe_entry_t * e, u16 offset)
204 : {
205 41 : u16 start = offset;
206 :
207 : /* src mac address */
208 41 : clib_memcpy_fast (to_b->data + offset, &e->key.src_mac, 6);
209 41 : offset += 6;
210 :
211 : /* dst mac address */
212 41 : clib_memcpy_fast (to_b->data + offset, &e->key.dst_mac, 6);
213 41 : offset += 6;
214 :
215 : /* ethertype */
216 41 : clib_memcpy_fast (to_b->data + offset, &e->key.ethertype, 2);
217 41 : offset += 2;
218 :
219 41 : return offset - start;
220 : }
221 :
222 : static inline u32
223 2 : flowprobe_l3_ip6_add (vlib_buffer_t * to_b, flowprobe_entry_t * e, u16 offset)
224 : {
225 2 : u16 start = offset;
226 :
227 : /* ip6 src address */
228 2 : clib_memcpy_fast (to_b->data + offset, &e->key.src_address,
229 : sizeof (ip6_address_t));
230 2 : offset += sizeof (ip6_address_t);
231 :
232 : /* ip6 dst address */
233 2 : clib_memcpy_fast (to_b->data + offset, &e->key.dst_address,
234 : sizeof (ip6_address_t));
235 2 : offset += sizeof (ip6_address_t);
236 :
237 : /* Protocol */
238 2 : to_b->data[offset++] = e->key.protocol;
239 :
240 : /* octetDeltaCount */
241 2 : u64 octetdelta = clib_host_to_net_u64 (e->octetcount);
242 2 : clib_memcpy_fast (to_b->data + offset, &octetdelta, sizeof (u64));
243 2 : offset += sizeof (u64);
244 :
245 2 : return offset - start;
246 : }
247 :
248 : static inline u32
249 39 : flowprobe_l3_ip4_add (vlib_buffer_t * to_b, flowprobe_entry_t * e, u16 offset)
250 : {
251 39 : u16 start = offset;
252 :
253 : /* ip4 src address */
254 39 : clib_memcpy_fast (to_b->data + offset, &e->key.src_address.ip4,
255 : sizeof (ip4_address_t));
256 39 : offset += sizeof (ip4_address_t);
257 :
258 : /* ip4 dst address */
259 39 : clib_memcpy_fast (to_b->data + offset, &e->key.dst_address.ip4,
260 : sizeof (ip4_address_t));
261 39 : offset += sizeof (ip4_address_t);
262 :
263 : /* Protocol */
264 39 : to_b->data[offset++] = e->key.protocol;
265 :
266 : /* octetDeltaCount */
267 39 : u64 octetdelta = clib_host_to_net_u64 (e->octetcount);
268 39 : clib_memcpy_fast (to_b->data + offset, &octetdelta, sizeof (u64));
269 39 : offset += sizeof (u64);
270 :
271 39 : return offset - start;
272 : }
273 :
274 : static inline u32
275 41 : flowprobe_l4_add (vlib_buffer_t * to_b, flowprobe_entry_t * e, u16 offset)
276 : {
277 41 : u16 start = offset;
278 :
279 : /* src port */
280 41 : clib_memcpy_fast (to_b->data + offset, &e->key.src_port, 2);
281 41 : offset += 2;
282 :
283 : /* dst port */
284 41 : clib_memcpy_fast (to_b->data + offset, &e->key.dst_port, 2);
285 41 : offset += 2;
286 :
287 : /* tcp control bits */
288 41 : u16 control_bits = htons (e->prot.tcp.flags);
289 41 : clib_memcpy_fast (to_b->data + offset, &control_bits, 2);
290 41 : offset += 2;
291 :
292 41 : return offset - start;
293 : }
294 :
295 : static inline u32
296 17 : flowprobe_hash (flowprobe_key_t * k)
297 : {
298 17 : flowprobe_main_t *fm = &flowprobe_main;
299 17 : u32 h = 0;
300 :
301 : #ifdef clib_crc32c_uses_intrinsics
302 17 : h = clib_crc32c ((u8 *) k, sizeof (*k));
303 : #else
304 : int i;
305 : u64 tmp = 0;
306 : for (i = 0; i < sizeof (*k) / 8; i++)
307 : tmp ^= ((u64 *) k)[i];
308 :
309 : h = clib_xxhash (tmp);
310 : #endif
311 :
312 17 : return h >> (32 - fm->ht_log2len);
313 : }
314 :
315 : flowprobe_entry_t *
316 7 : flowprobe_lookup (u32 my_cpu_number, flowprobe_key_t * k, u32 * poolindex,
317 : bool * collision)
318 : {
319 7 : flowprobe_main_t *fm = &flowprobe_main;
320 : flowprobe_entry_t *e;
321 : u32 h;
322 :
323 7 : h = (fm->active_timer) ? flowprobe_hash (k) : 0;
324 :
325 : /* Lookup in the flow state pool */
326 7 : *poolindex = fm->hash_per_worker[my_cpu_number][h];
327 7 : if (*poolindex != ~0)
328 : {
329 2 : e = pool_elt_at_index (fm->pool_per_worker[my_cpu_number], *poolindex);
330 2 : if (e)
331 : {
332 : /* Verify key or report collision */
333 2 : if (memcmp (k, &e->key, sizeof (flowprobe_key_t)))
334 0 : *collision = true;
335 2 : return e;
336 : }
337 : }
338 :
339 5 : return 0;
340 : }
341 :
342 : flowprobe_entry_t *
343 5 : flowprobe_create (u32 my_cpu_number, flowprobe_key_t * k, u32 * poolindex)
344 : {
345 5 : flowprobe_main_t *fm = &flowprobe_main;
346 : u32 h;
347 :
348 : flowprobe_entry_t *e;
349 :
350 : /* Get my index */
351 5 : h = (fm->active_timer) ? flowprobe_hash (k) : 0;
352 :
353 5 : pool_get (fm->pool_per_worker[my_cpu_number], e);
354 5 : *poolindex = e - fm->pool_per_worker[my_cpu_number];
355 5 : fm->hash_per_worker[my_cpu_number][h] = *poolindex;
356 :
357 5 : e->key = *k;
358 :
359 5 : if (fm->passive_timer > 0)
360 : {
361 5 : e->passive_timer_handle = tw_timer_start_2t_1w_2048sl
362 5 : (fm->timers_per_worker[my_cpu_number], *poolindex, 0,
363 5 : fm->passive_timer);
364 : }
365 5 : return e;
366 : }
367 :
368 : static inline void
369 55 : add_to_flow_record_state (vlib_main_t *vm, vlib_node_runtime_t *node,
370 : flowprobe_main_t *fm, vlib_buffer_t *b,
371 : timestamp_nsec_t timestamp, u16 length,
372 : flowprobe_variant_t which,
373 : flowprobe_direction_t direction,
374 : flowprobe_trace_t *t)
375 : {
376 55 : if (fm->disabled)
377 0 : return;
378 :
379 55 : ASSERT (direction == FLOW_DIRECTION_RX || direction == FLOW_DIRECTION_TX);
380 :
381 55 : u32 my_cpu_number = vm->thread_index;
382 55 : u16 octets = 0;
383 :
384 55 : flowprobe_record_t flags = fm->context[which].flags;
385 55 : bool collect_ip4 = false, collect_ip6 = false;
386 55 : ASSERT (b);
387 55 : ethernet_header_t *eth = ethernet_buffer_get_header (b);
388 55 : u16 ethertype = clib_net_to_host_u16 (eth->type);
389 55 : u16 l2_hdr_sz = sizeof (ethernet_header_t);
390 : /* *INDENT-OFF* */
391 55 : flowprobe_key_t k = {};
392 : /* *INDENT-ON* */
393 55 : ip4_header_t *ip4 = 0;
394 55 : ip6_header_t *ip6 = 0;
395 55 : udp_header_t *udp = 0;
396 55 : tcp_header_t *tcp = 0;
397 55 : u8 tcp_flags = 0;
398 :
399 55 : if (flags & FLOW_RECORD_L3 || flags & FLOW_RECORD_L4)
400 : {
401 49 : collect_ip4 = which == FLOW_VARIANT_L2_IP4 || which == FLOW_VARIANT_IP4;
402 49 : collect_ip6 = which == FLOW_VARIANT_L2_IP6 || which == FLOW_VARIANT_IP6;
403 : }
404 :
405 55 : k.rx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
406 55 : k.tx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
407 :
408 55 : k.which = which;
409 55 : k.direction = direction;
410 :
411 55 : if (flags & FLOW_RECORD_L2)
412 : {
413 43 : clib_memcpy_fast (k.src_mac, eth->src_address, 6);
414 43 : clib_memcpy_fast (k.dst_mac, eth->dst_address, 6);
415 43 : k.ethertype = ethertype;
416 : }
417 55 : if (ethertype == ETHERNET_TYPE_VLAN)
418 : {
419 : /*VLAN TAG*/
420 0 : ethernet_vlan_header_tv_t *ethv =
421 : (ethernet_vlan_header_tv_t *) (&(eth->type));
422 : /*Q in Q possibility */
423 0 : while (clib_net_to_host_u16 (ethv->type) == ETHERNET_TYPE_VLAN)
424 : {
425 0 : ethv++;
426 0 : l2_hdr_sz += sizeof (ethernet_vlan_header_tv_t);
427 : }
428 0 : k.ethertype = ethertype = clib_net_to_host_u16 ((ethv)->type);
429 : }
430 55 : if (collect_ip6 && ethertype == ETHERNET_TYPE_IP6)
431 : {
432 4 : ip6 = (ip6_header_t *) (b->data + l2_hdr_sz);
433 4 : if (flags & FLOW_RECORD_L3)
434 : {
435 2 : k.src_address.as_u64[0] = ip6->src_address.as_u64[0];
436 2 : k.src_address.as_u64[1] = ip6->src_address.as_u64[1];
437 2 : k.dst_address.as_u64[0] = ip6->dst_address.as_u64[0];
438 2 : k.dst_address.as_u64[1] = ip6->dst_address.as_u64[1];
439 : }
440 4 : k.protocol = ip6->protocol;
441 4 : if (k.protocol == IP_PROTOCOL_UDP)
442 4 : udp = (udp_header_t *) (ip6 + 1);
443 0 : else if (k.protocol == IP_PROTOCOL_TCP)
444 0 : tcp = (tcp_header_t *) (ip6 + 1);
445 :
446 4 : octets = clib_net_to_host_u16 (ip6->payload_length)
447 : + sizeof (ip6_header_t);
448 : }
449 55 : if (collect_ip4 && ethertype == ETHERNET_TYPE_IP4)
450 : {
451 45 : ip4 = (ip4_header_t *) (b->data + l2_hdr_sz);
452 45 : if (flags & FLOW_RECORD_L3)
453 : {
454 41 : k.src_address.ip4.as_u32 = ip4->src_address.as_u32;
455 41 : k.dst_address.ip4.as_u32 = ip4->dst_address.as_u32;
456 : }
457 45 : k.protocol = ip4->protocol;
458 45 : if ((flags & FLOW_RECORD_L4) && k.protocol == IP_PROTOCOL_UDP)
459 40 : udp = (udp_header_t *) (ip4 + 1);
460 5 : else if ((flags & FLOW_RECORD_L4) && k.protocol == IP_PROTOCOL_TCP)
461 1 : tcp = (tcp_header_t *) (ip4 + 1);
462 :
463 45 : octets = clib_net_to_host_u16 (ip4->length);
464 : }
465 :
466 55 : if (udp)
467 : {
468 44 : k.src_port = udp->src_port;
469 44 : k.dst_port = udp->dst_port;
470 : }
471 11 : else if (tcp)
472 : {
473 1 : k.src_port = tcp->src_port;
474 1 : k.dst_port = tcp->dst_port;
475 1 : tcp_flags = tcp->flags;
476 : }
477 :
478 55 : if (t)
479 : {
480 35 : t->rx_sw_if_index = k.rx_sw_if_index;
481 35 : t->tx_sw_if_index = k.tx_sw_if_index;
482 35 : clib_memcpy_fast (t->src_mac, k.src_mac, 6);
483 35 : clib_memcpy_fast (t->dst_mac, k.dst_mac, 6);
484 35 : t->ethertype = k.ethertype;
485 35 : t->src_address.ip4.as_u32 = k.src_address.ip4.as_u32;
486 35 : t->dst_address.ip4.as_u32 = k.dst_address.ip4.as_u32;
487 35 : t->protocol = k.protocol;
488 35 : t->src_port = k.src_port;
489 35 : t->dst_port = k.dst_port;
490 35 : t->which = k.which;
491 : }
492 :
493 55 : flowprobe_entry_t *e = 0;
494 55 : f64 now = vlib_time_now (vm);
495 55 : if (fm->active_timer > 0)
496 : {
497 7 : u32 poolindex = ~0;
498 7 : bool collision = false;
499 :
500 7 : e = flowprobe_lookup (my_cpu_number, &k, &poolindex, &collision);
501 7 : if (collision)
502 : {
503 : /* Flush data and clean up entry for reuse. */
504 0 : if (e->packetcount)
505 0 : flowprobe_export_entry (vm, e);
506 0 : e->key = k;
507 0 : e->flow_start = timestamp;
508 0 : vlib_node_increment_counter (vm, node->node_index,
509 : FLOWPROBE_ERROR_COLLISION, 1);
510 : }
511 7 : if (!e) /* Create new entry */
512 : {
513 5 : e = flowprobe_create (my_cpu_number, &k, &poolindex);
514 5 : e->last_exported = now;
515 5 : e->flow_start = timestamp;
516 : }
517 : }
518 : else
519 : {
520 48 : e = &fm->stateless_entry[my_cpu_number];
521 48 : e->key = k;
522 : }
523 :
524 55 : if (e)
525 : {
526 : /* Updating entry */
527 55 : e->packetcount++;
528 55 : e->octetcount += octets;
529 55 : e->last_updated = now;
530 55 : e->flow_end = timestamp;
531 55 : e->prot.tcp.flags |= tcp_flags;
532 55 : if (fm->active_timer == 0
533 7 : || (now > e->last_exported + fm->active_timer))
534 48 : flowprobe_export_entry (vm, e);
535 : }
536 : }
537 :
538 : static u16
539 487 : flowprobe_get_headersize (void)
540 : {
541 487 : return sizeof (ip4_header_t) + sizeof (udp_header_t) +
542 : sizeof (ipfix_message_header_t) + sizeof (ipfix_set_header_t);
543 : }
544 :
545 : static void
546 360 : flowprobe_export_send (vlib_main_t * vm, vlib_buffer_t * b0,
547 : flowprobe_variant_t which)
548 : {
549 360 : flowprobe_main_t *fm = &flowprobe_main;
550 360 : flow_report_main_t *frm = &flow_report_main;
551 360 : ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0);
552 : vlib_frame_t *f;
553 : ip4_ipfix_template_packet_t *tp;
554 : ipfix_set_header_t *s;
555 : ipfix_message_header_t *h;
556 : ip4_header_t *ip;
557 : udp_header_t *udp;
558 360 : flowprobe_record_t flags = fm->context[which].flags;
559 360 : u32 my_cpu_number = vm->thread_index;
560 :
561 : /* Fill in header */
562 : flow_report_stream_t *stream;
563 :
564 : /* Nothing to send */
565 360 : if (fm->context[which].next_record_offset_per_worker[my_cpu_number] <=
566 360 : flowprobe_get_headersize ())
567 331 : return;
568 :
569 29 : u32 i, index = vec_len (exp->streams);
570 29 : for (i = 0; i < index; i++)
571 29 : if (exp->streams[i].domain_id == 1)
572 : {
573 29 : index = i;
574 29 : break;
575 : }
576 29 : if (i == vec_len (exp->streams))
577 : {
578 0 : vec_validate (exp->streams, index);
579 0 : exp->streams[index].domain_id = 1;
580 : }
581 29 : stream = &exp->streams[index];
582 :
583 29 : tp = vlib_buffer_get_current (b0);
584 29 : ip = (ip4_header_t *) & tp->ip4;
585 29 : udp = (udp_header_t *) (ip + 1);
586 29 : h = (ipfix_message_header_t *) (udp + 1);
587 29 : s = (ipfix_set_header_t *) (h + 1);
588 :
589 29 : ip->ip_version_and_header_length = 0x45;
590 29 : ip->ttl = 254;
591 29 : ip->protocol = IP_PROTOCOL_UDP;
592 29 : ip->flags_and_fragment_offset = 0;
593 29 : ip->src_address.as_u32 = exp->src_address.ip.ip4.as_u32;
594 29 : ip->dst_address.as_u32 = exp->ipfix_collector.ip.ip4.as_u32;
595 29 : udp->src_port = clib_host_to_net_u16 (stream->src_port);
596 29 : udp->dst_port = clib_host_to_net_u16 (exp->collector_port);
597 29 : udp->checksum = 0;
598 :
599 : /* FIXUP: message header export_time */
600 29 : h->export_time = (u32)
601 58 : (((f64) frm->unix_time_0) +
602 29 : (vlib_time_now (frm->vlib_main) - frm->vlib_time_0));
603 29 : h->export_time = clib_host_to_net_u32 (h->export_time);
604 29 : h->domain_id = clib_host_to_net_u32 (stream->domain_id);
605 :
606 : /* FIXUP: message header sequence_number */
607 29 : h->sequence_number = stream->sequence_number++;
608 29 : h->sequence_number = clib_host_to_net_u32 (h->sequence_number);
609 :
610 58 : s->set_id_length = ipfix_set_id_length (fm->template_reports[flags],
611 29 : b0->current_length -
612 : (sizeof (*ip) + sizeof (*udp) +
613 : sizeof (*h)));
614 29 : h->version_length = version_length (b0->current_length -
615 : (sizeof (*ip) + sizeof (*udp)));
616 :
617 29 : ip->length = clib_host_to_net_u16 (b0->current_length);
618 :
619 29 : ip->checksum = ip4_header_checksum (ip);
620 29 : udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip));
621 :
622 29 : if (exp->udp_checksum)
623 : {
624 : /* RFC 7011 section 10.3.2. */
625 0 : udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip);
626 0 : if (udp->checksum == 0)
627 0 : udp->checksum = 0xffff;
628 : }
629 :
630 29 : ASSERT (ip4_header_checksum_is_valid (ip));
631 :
632 : /* Find or allocate a frame */
633 29 : f = fm->context[which].frames_per_worker[my_cpu_number];
634 29 : if (PREDICT_FALSE (f == 0))
635 : {
636 : u32 *to_next;
637 29 : f = vlib_get_frame_to_node (vm, ip4_lookup_node.index);
638 29 : fm->context[which].frames_per_worker[my_cpu_number] = f;
639 29 : u32 bi0 = vlib_get_buffer_index (vm, b0);
640 :
641 : /* Enqueue the buffer */
642 29 : to_next = vlib_frame_vector_args (f);
643 29 : to_next[0] = bi0;
644 29 : f->n_vectors = 1;
645 : }
646 :
647 29 : vlib_put_frame_to_node (vm, ip4_lookup_node.index, f);
648 29 : vlib_node_increment_counter (vm, flowprobe_output_l2_node.index,
649 : FLOWPROBE_ERROR_EXPORTED_PACKETS, 1);
650 :
651 29 : fm->context[which].frames_per_worker[my_cpu_number] = 0;
652 29 : fm->context[which].buffers_per_worker[my_cpu_number] = 0;
653 29 : fm->context[which].next_record_offset_per_worker[my_cpu_number] =
654 29 : flowprobe_get_headersize ();
655 : }
656 :
657 : static vlib_buffer_t *
658 409 : flowprobe_get_buffer (vlib_main_t * vm, flowprobe_variant_t which)
659 : {
660 409 : flowprobe_main_t *fm = &flowprobe_main;
661 409 : ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0);
662 : vlib_buffer_t *b0;
663 : u32 bi0;
664 409 : u32 my_cpu_number = vm->thread_index;
665 :
666 : /* Find or allocate a buffer */
667 409 : b0 = fm->context[which].buffers_per_worker[my_cpu_number];
668 :
669 : /* Need to allocate a buffer? */
670 409 : if (PREDICT_FALSE (b0 == 0))
671 : {
672 45 : if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
673 : {
674 0 : vlib_node_increment_counter (vm, flowprobe_output_l2_node.index,
675 : FLOWPROBE_ERROR_BUFFER, 1);
676 0 : return 0;
677 : }
678 :
679 : /* Initialize the buffer */
680 90 : b0 = fm->context[which].buffers_per_worker[my_cpu_number] =
681 45 : vlib_get_buffer (vm, bi0);
682 :
683 45 : b0->current_data = 0;
684 45 : b0->current_length = flowprobe_get_headersize ();
685 45 : b0->flags |=
686 : (VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_FLOW_REPORT);
687 45 : vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0;
688 45 : vnet_buffer (b0)->sw_if_index[VLIB_TX] = exp->fib_index;
689 45 : fm->context[which].next_record_offset_per_worker[my_cpu_number] =
690 45 : b0->current_length;
691 : }
692 :
693 409 : return b0;
694 : }
695 :
696 : static void
697 53 : flowprobe_export_entry (vlib_main_t * vm, flowprobe_entry_t * e)
698 : {
699 53 : u32 my_cpu_number = vm->thread_index;
700 53 : flowprobe_main_t *fm = &flowprobe_main;
701 53 : ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0);
702 : vlib_buffer_t *b0;
703 53 : bool collect_ip4 = false, collect_ip6 = false;
704 53 : flowprobe_variant_t which = e->key.which;
705 53 : flowprobe_record_t flags = fm->context[which].flags;
706 53 : u16 offset =
707 53 : fm->context[which].next_record_offset_per_worker[my_cpu_number];
708 :
709 53 : if (offset < flowprobe_get_headersize ())
710 0 : offset = flowprobe_get_headersize ();
711 :
712 53 : b0 = flowprobe_get_buffer (vm, which);
713 : /* No available buffer, what to do... */
714 53 : if (b0 == 0)
715 0 : return;
716 :
717 53 : if (flags & FLOW_RECORD_L3)
718 : {
719 41 : collect_ip4 = which == FLOW_VARIANT_L2_IP4 || which == FLOW_VARIANT_IP4;
720 41 : collect_ip6 = which == FLOW_VARIANT_L2_IP6 || which == FLOW_VARIANT_IP6;
721 : }
722 :
723 53 : offset += flowprobe_common_add (b0, e, offset);
724 :
725 53 : if (flags & FLOW_RECORD_L2)
726 41 : offset += flowprobe_l2_add (b0, e, offset);
727 53 : if (collect_ip6)
728 2 : offset += flowprobe_l3_ip6_add (b0, e, offset);
729 53 : if (collect_ip4)
730 39 : offset += flowprobe_l3_ip4_add (b0, e, offset);
731 53 : if (flags & FLOW_RECORD_L4)
732 41 : offset += flowprobe_l4_add (b0, e, offset);
733 :
734 : /* Reset per flow-export counters */
735 53 : e->packetcount = 0;
736 53 : e->octetcount = 0;
737 53 : e->last_exported = vlib_time_now (vm);
738 :
739 53 : b0->current_length = offset;
740 :
741 53 : fm->context[which].next_record_offset_per_worker[my_cpu_number] = offset;
742 : /* Time to flush the buffer? */
743 53 : if (offset + fm->template_size[flags] > exp->path_mtu)
744 4 : flowprobe_export_send (vm, b0, which);
745 : }
746 :
747 : uword
748 27 : flowprobe_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
749 : vlib_frame_t *frame, flowprobe_variant_t which,
750 : flowprobe_direction_t direction)
751 : {
752 : u32 n_left_from, *from, *to_next;
753 : flowprobe_next_t next_index;
754 27 : flowprobe_main_t *fm = &flowprobe_main;
755 : timestamp_nsec_t timestamp;
756 :
757 27 : unix_time_now_nsec_fraction (×tamp.sec, ×tamp.nsec);
758 :
759 27 : from = vlib_frame_vector_args (frame);
760 27 : n_left_from = frame->n_vectors;
761 27 : next_index = node->cached_next_index;
762 :
763 54 : while (n_left_from > 0)
764 : {
765 : u32 n_left_to_next;
766 :
767 27 : vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
768 :
769 37 : while (n_left_from >= 4 && n_left_to_next >= 2)
770 : {
771 10 : u32 next0 = FLOWPROBE_NEXT_DROP;
772 10 : u32 next1 = FLOWPROBE_NEXT_DROP;
773 : u16 len0, len1;
774 : u32 bi0, bi1;
775 : vlib_buffer_t *b0, *b1;
776 :
777 : /* Prefetch next iteration. */
778 : {
779 : vlib_buffer_t *p2, *p3;
780 :
781 10 : p2 = vlib_get_buffer (vm, from[2]);
782 10 : p3 = vlib_get_buffer (vm, from[3]);
783 :
784 10 : vlib_prefetch_buffer_header (p2, LOAD);
785 10 : vlib_prefetch_buffer_header (p3, LOAD);
786 :
787 10 : clib_prefetch_store (p2->data);
788 10 : clib_prefetch_store (p3->data);
789 : }
790 :
791 : /* speculatively enqueue b0 and b1 to the current next frame */
792 10 : to_next[0] = bi0 = from[0];
793 10 : to_next[1] = bi1 = from[1];
794 10 : from += 2;
795 10 : to_next += 2;
796 10 : n_left_from -= 2;
797 10 : n_left_to_next -= 2;
798 :
799 10 : b0 = vlib_get_buffer (vm, bi0);
800 10 : b1 = vlib_get_buffer (vm, bi1);
801 :
802 10 : vnet_feature_next (&next0, b0);
803 10 : vnet_feature_next (&next1, b1);
804 :
805 10 : len0 = vlib_buffer_length_in_chain (vm, b0);
806 10 : ethernet_header_t *eh0 = vlib_buffer_get_current (b0);
807 10 : u16 ethertype0 = clib_net_to_host_u16 (eh0->type);
808 :
809 10 : if (PREDICT_TRUE ((b0->flags & VNET_BUFFER_F_FLOW_REPORT) == 0))
810 10 : add_to_flow_record_state (
811 : vm, node, fm, b0, timestamp, len0,
812 10 : flowprobe_get_variant (which, fm->context[which].flags,
813 : ethertype0),
814 : direction, 0);
815 :
816 10 : len1 = vlib_buffer_length_in_chain (vm, b1);
817 10 : ethernet_header_t *eh1 = vlib_buffer_get_current (b1);
818 10 : u16 ethertype1 = clib_net_to_host_u16 (eh1->type);
819 :
820 10 : if (PREDICT_TRUE ((b1->flags & VNET_BUFFER_F_FLOW_REPORT) == 0))
821 10 : add_to_flow_record_state (
822 : vm, node, fm, b1, timestamp, len1,
823 10 : flowprobe_get_variant (which, fm->context[which].flags,
824 : ethertype1),
825 : direction, 0);
826 :
827 : /* verify speculative enqueues, maybe switch current next frame */
828 10 : vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
829 : to_next, n_left_to_next,
830 : bi0, bi1, next0, next1);
831 : }
832 :
833 62 : while (n_left_from > 0 && n_left_to_next > 0)
834 : {
835 : u32 bi0;
836 : vlib_buffer_t *b0;
837 35 : u32 next0 = FLOWPROBE_NEXT_DROP;
838 : u16 len0;
839 :
840 : /* speculatively enqueue b0 to the current next frame */
841 35 : bi0 = from[0];
842 35 : to_next[0] = bi0;
843 35 : from += 1;
844 35 : to_next += 1;
845 35 : n_left_from -= 1;
846 35 : n_left_to_next -= 1;
847 :
848 35 : b0 = vlib_get_buffer (vm, bi0);
849 :
850 35 : vnet_feature_next (&next0, b0);
851 :
852 35 : len0 = vlib_buffer_length_in_chain (vm, b0);
853 35 : ethernet_header_t *eh0 = vlib_buffer_get_current (b0);
854 35 : u16 ethertype0 = clib_net_to_host_u16 (eh0->type);
855 :
856 35 : if (PREDICT_TRUE ((b0->flags & VNET_BUFFER_F_FLOW_REPORT) == 0))
857 : {
858 35 : flowprobe_trace_t *t = 0;
859 35 : if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
860 : && (b0->flags & VLIB_BUFFER_IS_TRACED)))
861 35 : t = vlib_add_trace (vm, node, b0, sizeof (*t));
862 :
863 35 : add_to_flow_record_state (
864 : vm, node, fm, b0, timestamp, len0,
865 35 : flowprobe_get_variant (which, fm->context[which].flags,
866 : ethertype0),
867 : direction, t);
868 : }
869 :
870 : /* verify speculative enqueue, maybe switch current next frame */
871 35 : vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
872 : to_next, n_left_to_next,
873 : bi0, next0);
874 : }
875 :
876 27 : vlib_put_next_frame (vm, node, next_index, n_left_to_next);
877 : }
878 27 : return frame->n_vectors;
879 : }
880 :
881 : static uword
882 3 : flowprobe_input_ip4_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
883 : vlib_frame_t *frame)
884 : {
885 3 : return flowprobe_node_fn (vm, node, frame, FLOW_VARIANT_IP4,
886 : FLOW_DIRECTION_RX);
887 : }
888 :
889 : static uword
890 3 : flowprobe_input_ip6_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
891 : vlib_frame_t *frame)
892 : {
893 3 : return flowprobe_node_fn (vm, node, frame, FLOW_VARIANT_IP6,
894 : FLOW_DIRECTION_RX);
895 : }
896 :
897 : static uword
898 5 : flowprobe_input_l2_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
899 : vlib_frame_t *frame)
900 : {
901 5 : return flowprobe_node_fn (vm, node, frame, FLOW_VARIANT_L2,
902 : FLOW_DIRECTION_RX);
903 : }
904 :
905 : static uword
906 4 : flowprobe_output_ip4_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
907 : vlib_frame_t *frame)
908 : {
909 4 : return flowprobe_node_fn (vm, node, frame, FLOW_VARIANT_IP4,
910 : FLOW_DIRECTION_TX);
911 : }
912 :
913 : static uword
914 3 : flowprobe_output_ip6_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
915 : vlib_frame_t *frame)
916 : {
917 3 : return flowprobe_node_fn (vm, node, frame, FLOW_VARIANT_IP6,
918 : FLOW_DIRECTION_TX);
919 : }
920 :
921 : static uword
922 9 : flowprobe_output_l2_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
923 : vlib_frame_t *frame)
924 : {
925 9 : return flowprobe_node_fn (vm, node, frame, FLOW_VARIANT_L2,
926 : FLOW_DIRECTION_TX);
927 : }
928 :
929 : static inline void
930 356 : flush_record (flowprobe_variant_t which)
931 : {
932 356 : vlib_main_t *vm = vlib_get_main ();
933 356 : vlib_buffer_t *b = flowprobe_get_buffer (vm, which);
934 356 : if (b)
935 356 : flowprobe_export_send (vm, b, which);
936 356 : }
937 :
938 : void
939 18 : flowprobe_flush_callback_ip4 (void)
940 : {
941 18 : flush_record (FLOW_VARIANT_IP4);
942 18 : }
943 :
944 : void
945 14 : flowprobe_flush_callback_ip6 (void)
946 : {
947 14 : flush_record (FLOW_VARIANT_IP6);
948 14 : }
949 :
950 : void
951 108 : flowprobe_flush_callback_l2 (void)
952 : {
953 108 : flush_record (FLOW_VARIANT_L2);
954 108 : flush_record (FLOW_VARIANT_L2_IP4);
955 108 : flush_record (FLOW_VARIANT_L2_IP6);
956 108 : }
957 :
958 :
959 : static void
960 5 : flowprobe_delete_by_index (u32 my_cpu_number, u32 poolindex)
961 : {
962 5 : flowprobe_main_t *fm = &flowprobe_main;
963 : flowprobe_entry_t *e;
964 : u32 h;
965 :
966 5 : e = pool_elt_at_index (fm->pool_per_worker[my_cpu_number], poolindex);
967 :
968 : /* Get my index */
969 5 : h = flowprobe_hash (&e->key);
970 :
971 : /* Reset hash */
972 5 : fm->hash_per_worker[my_cpu_number][h] = ~0;
973 :
974 5 : pool_put_index (fm->pool_per_worker[my_cpu_number], poolindex);
975 5 : }
976 :
977 :
978 : /* Per worker process processing the active/passive expired entries */
979 : static uword
980 242708 : flowprobe_walker_process (vlib_main_t * vm,
981 : vlib_node_runtime_t * rt, vlib_frame_t * f)
982 : {
983 242708 : flowprobe_main_t *fm = &flowprobe_main;
984 : flowprobe_entry_t *e;
985 242708 : ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0);
986 :
987 : /*
988 : * $$$$ Remove this check from here and track FRM status and disable
989 : * this process if required.
990 : */
991 439736 : if (ip_address_is_zero (&exp->ipfix_collector) ||
992 197028 : ip_address_is_zero (&exp->src_address))
993 : {
994 45680 : fm->disabled = true;
995 45680 : return 0;
996 : }
997 197028 : fm->disabled = false;
998 :
999 197028 : u32 cpu_index = os_get_thread_index ();
1000 197028 : u32 *to_be_removed = 0, *i;
1001 :
1002 : /*
1003 : * Tick the timer when required and process the vector of expired
1004 : * timers
1005 : */
1006 197028 : f64 start_time = vlib_time_now (vm);
1007 197028 : u32 count = 0;
1008 :
1009 197028 : tw_timer_expire_timers_2t_1w_2048sl (fm->timers_per_worker[cpu_index],
1010 : start_time);
1011 :
1012 197033 : vec_foreach (i, fm->expired_passive_per_worker[cpu_index])
1013 : {
1014 5 : u32 exported = 0;
1015 5 : f64 now = vlib_time_now (vm);
1016 5 : if (now > start_time + 100e-6
1017 5 : || exported > FLOW_MAXIMUM_EXPORT_ENTRIES - 1)
1018 : break;
1019 :
1020 5 : if (pool_is_free_index (fm->pool_per_worker[cpu_index], *i))
1021 : {
1022 0 : clib_warning ("Element is %d is freed already\n", *i);
1023 0 : continue;
1024 : }
1025 : else
1026 5 : e = pool_elt_at_index (fm->pool_per_worker[cpu_index], *i);
1027 :
1028 : /* Check last update timestamp. If it is longer than passive time nuke
1029 : * entry. Otherwise restart timer with what's left
1030 : * Premature passive timer by more than 10%
1031 : */
1032 5 : if ((now - e->last_updated) < (u64) (fm->passive_timer * 0.9))
1033 : {
1034 0 : u64 delta = fm->passive_timer - (now - e->last_updated);
1035 0 : e->passive_timer_handle = tw_timer_start_2t_1w_2048sl
1036 0 : (fm->timers_per_worker[cpu_index], *i, 0, delta);
1037 : }
1038 : else /* Nuke entry */
1039 : {
1040 5 : vec_add1 (to_be_removed, *i);
1041 : }
1042 : /* If anything to report send it to the exporter */
1043 5 : if (e->packetcount && now > e->last_exported + fm->active_timer)
1044 : {
1045 5 : exported++;
1046 5 : flowprobe_export_entry (vm, e);
1047 : }
1048 5 : count++;
1049 : }
1050 197028 : if (count)
1051 5 : vec_delete (fm->expired_passive_per_worker[cpu_index], count, 0);
1052 :
1053 197033 : vec_foreach (i, to_be_removed) flowprobe_delete_by_index (cpu_index, *i);
1054 197028 : vec_free (to_be_removed);
1055 :
1056 197028 : return 0;
1057 : }
1058 :
1059 : /* *INDENT-OFF* */
1060 139480 : VLIB_REGISTER_NODE (flowprobe_input_ip4_node) = {
1061 : .function = flowprobe_input_ip4_node_fn,
1062 : .name = "flowprobe-input-ip4",
1063 : .vector_size = sizeof (u32),
1064 : .format_trace = format_flowprobe_trace,
1065 : .type = VLIB_NODE_TYPE_INTERNAL,
1066 : .n_errors = ARRAY_LEN (flowprobe_error_strings),
1067 : .error_strings = flowprobe_error_strings,
1068 : .n_next_nodes = FLOWPROBE_N_NEXT,
1069 : .next_nodes = FLOWPROBE_NEXT_NODES,
1070 : };
1071 139480 : VLIB_REGISTER_NODE (flowprobe_input_ip6_node) = {
1072 : .function = flowprobe_input_ip6_node_fn,
1073 : .name = "flowprobe-input-ip6",
1074 : .vector_size = sizeof (u32),
1075 : .format_trace = format_flowprobe_trace,
1076 : .type = VLIB_NODE_TYPE_INTERNAL,
1077 : .n_errors = ARRAY_LEN (flowprobe_error_strings),
1078 : .error_strings = flowprobe_error_strings,
1079 : .n_next_nodes = FLOWPROBE_N_NEXT,
1080 : .next_nodes = FLOWPROBE_NEXT_NODES,
1081 : };
1082 139480 : VLIB_REGISTER_NODE (flowprobe_input_l2_node) = {
1083 : .function = flowprobe_input_l2_node_fn,
1084 : .name = "flowprobe-input-l2",
1085 : .vector_size = sizeof (u32),
1086 : .format_trace = format_flowprobe_trace,
1087 : .type = VLIB_NODE_TYPE_INTERNAL,
1088 : .n_errors = ARRAY_LEN (flowprobe_error_strings),
1089 : .error_strings = flowprobe_error_strings,
1090 : .n_next_nodes = FLOWPROBE_N_NEXT,
1091 : .next_nodes = FLOWPROBE_NEXT_NODES,
1092 : };
1093 139480 : VLIB_REGISTER_NODE (flowprobe_output_ip4_node) = {
1094 : .function = flowprobe_output_ip4_node_fn,
1095 : .name = "flowprobe-output-ip4",
1096 : .vector_size = sizeof (u32),
1097 : .format_trace = format_flowprobe_trace,
1098 : .type = VLIB_NODE_TYPE_INTERNAL,
1099 : .n_errors = ARRAY_LEN (flowprobe_error_strings),
1100 : .error_strings = flowprobe_error_strings,
1101 : .n_next_nodes = FLOWPROBE_N_NEXT,
1102 : .next_nodes = FLOWPROBE_NEXT_NODES,
1103 : };
1104 139480 : VLIB_REGISTER_NODE (flowprobe_output_ip6_node) = {
1105 : .function = flowprobe_output_ip6_node_fn,
1106 : .name = "flowprobe-output-ip6",
1107 : .vector_size = sizeof (u32),
1108 : .format_trace = format_flowprobe_trace,
1109 : .type = VLIB_NODE_TYPE_INTERNAL,
1110 : .n_errors = ARRAY_LEN (flowprobe_error_strings),
1111 : .error_strings = flowprobe_error_strings,
1112 : .n_next_nodes = FLOWPROBE_N_NEXT,
1113 : .next_nodes = FLOWPROBE_NEXT_NODES,
1114 : };
1115 139480 : VLIB_REGISTER_NODE (flowprobe_output_l2_node) = {
1116 : .function = flowprobe_output_l2_node_fn,
1117 : .name = "flowprobe-output-l2",
1118 : .vector_size = sizeof (u32),
1119 : .format_trace = format_flowprobe_trace,
1120 : .type = VLIB_NODE_TYPE_INTERNAL,
1121 : .n_errors = ARRAY_LEN (flowprobe_error_strings),
1122 : .error_strings = flowprobe_error_strings,
1123 : .n_next_nodes = FLOWPROBE_N_NEXT,
1124 : .next_nodes = FLOWPROBE_NEXT_NODES,
1125 : };
1126 139480 : VLIB_REGISTER_NODE (flowprobe_walker_node) = {
1127 : .function = flowprobe_walker_process,
1128 : .name = "flowprobe-walker",
1129 : .type = VLIB_NODE_TYPE_INPUT,
1130 : .state = VLIB_NODE_STATE_INTERRUPT,
1131 : };
1132 : /* *INDENT-ON* */
1133 :
1134 : /*
1135 : * fd.io coding-style-patch-verification: ON
1136 : *
1137 : * Local Variables:
1138 : * eval: (c-set-style "gnu")
1139 : * End:
1140 : */
|