78 "FLOWPROBE[%s]: rx_sw_if_index %d, tx_sw_if_index %d, " 104 #define foreach_flowprobe_error \ 105 _(COLLISION, "Hash table collisions") \ 106 _(BUFFER, "Buffer allocation error") \ 107 _(EXPORTED_PACKETS, "Exported packets") \ 108 _(INPATH, "Exported packets in path") 112 #define _(sym,str) FLOWPROBE_ERROR_##sym, 119 #define _(sym,string) string, 131 #define FLOWPROBE_NEXT_NODES { \ 132 [FLOWPROBE_NEXT_DROP] = "error-drop", \ 133 [FLOWPROBE_NEXT_IP4_LOOKUP] = "ip4-lookup", \ 153 u32 rx_if = clib_host_to_net_u32 (e->
key.rx_sw_if_index);
155 offset +=
sizeof (rx_if);
158 u32 tx_if = clib_host_to_net_u32 (e->
key.tx_sw_if_index);
160 offset +=
sizeof (tx_if);
165 offset +=
sizeof (
u64);
167 return offset - start;
187 return offset - start;
206 to_b->
data[offset++] = e->
key.protocol;
211 offset +=
sizeof (
u64);
213 return offset - start;
232 to_b->
data[offset++] = e->
key.protocol;
237 offset +=
sizeof (
u64);
239 return offset - start;
255 return offset - start;
264 #ifdef clib_crc32c_uses_intrinsics 268 k->as_u32[0] ^ k->as_u32[1] ^ k->as_u32[2] ^ k->as_u32[3] ^ k->as_u32[4];
287 if (*poolindex != ~0)
293 if (memcmp (k, &e->
key, sizeof (flowprobe_key_t)))
322 (fm->timers_per_worker[my_cpu_number], *poolindex, 0,
331 u64 timestamp,
u16 length,
341 bool collect_ip4 =
false, collect_ip6 =
false;
344 u16 ethertype = clib_net_to_host_u16 (eth->
type);
346 flowprobe_key_t k = { {0} };
367 k.ethertype = ethertype;
369 if (collect_ip6 && ethertype == ETHERNET_TYPE_IP6)
384 if (collect_ip4 && ethertype == ETHERNET_TYPE_IP4)
394 octets = clib_net_to_host_u16 (ip4->
length);
396 if ((flags & FLOW_RECORD_L4) && udp &&
397 (k.protocol == IP_PROTOCOL_TCP || k.protocol == IP_PROTOCOL_UDP))
410 t->
src_address.ip4.as_u32 = k.src_address.ip4.as_u32;
411 t->
dst_address.ip4.as_u32 = k.dst_address.ip4.as_u32;
423 bool collision =
false;
433 FLOWPROBE_ERROR_COLLISION, 1);
491 for (i = 0; i < index; i++)
516 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix);
517 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix);
533 (sizeof (*ip) +
sizeof (*udp) +
536 (sizeof (*ip) +
sizeof (*udp)));
570 FLOWPROBE_ERROR_EXPORTED_PACKETS, 1);
597 FLOWPROBE_ERROR_BUFFER, 1);
628 bool collect_ip4 =
false, collect_ip6 =
false;
677 u32 n_left_from, *from, *to_next;
689 while (n_left_from > 0)
695 while (n_left_from >= 4 && n_left_to_next >= 2)
718 to_next[0] = bi0 = from[0];
719 to_next[1] = bi1 = from[1];
735 u16 ethertype0 = clib_net_to_host_u16 (eh0->
type);
745 u16 ethertype1 = clib_net_to_host_u16 (eh1->
type);
755 to_next, n_left_to_next,
756 bi0, bi1, next0, next1);
759 while (n_left_from > 0 && n_left_to_next > 0)
781 u16 ethertype0 = clib_net_to_host_u16 (eh0->
type);
798 to_next, n_left_to_next,
898 u32 *to_be_removed = 0, *
i;
907 tw_timer_expire_timers_2t_1w_2048sl (fm->timers_per_worker[cpu_index],
914 if (now > start_time + 100e-6
934 (fm->timers_per_worker[cpu_index], *
i, 0, delta);
960 .name =
"flowprobe-ip4",
961 .vector_size =
sizeof (
u32),
971 .name =
"flowprobe-ip6",
972 .vector_size =
sizeof (
u32),
982 .name =
"flowprobe-l2",
983 .vector_size =
sizeof (
u32),
993 .name =
"flowprobe-walker",
995 .state = VLIB_NODE_STATE_INTERRUPT,
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
flowprobe_protocol_context_t context[FLOW_N_VARIANTS]
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
u16 buffer_size
size of the buffer
sll srl srl sll sra u16x4 i
u32 ** expired_passive_per_worker
ip46_address_t src_address
L3 information.
#define FLOWPROBE_KEY_IN_U32
static u32 flowprobe_l4_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
u8 src_mac[6]
L2 information.
vlib_node_registration_t flowprobe_ip6_node
(constructor) VLIB_REGISTER_NODE (flowprobe_ip6_node)
static char * flowprobe_error_strings[]
static f64 vlib_time_now(vlib_main_t *vm)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
static u32 flowprobe_l3_ip6_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u64 clib_xxhash(u64 key)
struct _vlib_node_registration vlib_node_registration_t
static u32 flowprobe_l3_ip4_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
ip4_address_t src_address
flowprobe_entry_t * stateless_entry
u16 template_reports[FLOW_N_RECORDS]
static uword flowprobe_ip6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
ip46_address_t dst_address
static void flush_record(flowprobe_variant_t which)
ip4_address_t ipfix_collector
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
flowprobe_entry_t ** pool_per_worker
static u32 flowprobe_hash(flowprobe_key_t *k)
flow_report_stream_t * streams
flow-per-packet plugin header file
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
u8 * format_ethernet_address(u8 *s, va_list *args)
u64 timestamp
packet timestamp
vlib_frame_t ** frames_per_worker
frames containing ipfix buffers, per-worker thread
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
void flowprobe_flush_callback_ip6(void)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_node_registration_t flowprobe_walker_node
(constructor) VLIB_REGISTER_NODE (flowprobe_walker_node)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
u64 nanosecond_time_0
Time reference pair.
static uword flowprobe_ip4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u8 ht_log2len
Per CPU flow-state.
uword flowprobe_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, flowprobe_variant_t which)
flow_report_main_t flow_report_main
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
#define FLOWPROBE_NEXT_NODES
static void flowprobe_export_send(vlib_main_t *vm, vlib_buffer_t *b0, flowprobe_variant_t which)
static u32 flowprobe_common_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
#define VLIB_BUFFER_FLOW_REPORT
u16 src_port
L4 information.
static char * flowprobe_variant_strings[]
u32 node_index
Node index.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
static_always_inline void vnet_feature_next(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
static vlib_buffer_t * flowprobe_get_buffer(vlib_main_t *vm, flowprobe_variant_t which)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static u32 version_length(u16 length)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static u32 flowprobe_l2_add(vlib_buffer_t *to_b, flowprobe_entry_t *e, u16 offset)
#define foreach_flowprobe_error
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
#define VLIB_BUFFER_IS_TRACED
flowprobe_entry_t * flowprobe_lookup(u32 my_cpu_number, flowprobe_key_t *k, u32 *poolindex, bool *collision)
static u8 * format_flowprobe_trace(u8 *s, va_list *args)
#define clib_memcpy(a, b, c)
void flowprobe_flush_callback_l2(void)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define pool_put_index(p, i)
Free pool element with given index.
u32 rx_sw_if_index
interface handle
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
void flowprobe_flush_callback_ip4(void)
#define VLIB_NODE_FLAG_TRACE
#define FLOW_MAXIMUM_EXPORT_ENTRIES
static vlib_main_t * vlib_get_main(void)
flowprobe_main_t flowprobe_main
vlib_node_registration_t flowprobe_ip4_node
(constructor) VLIB_REGISTER_NODE (flowprobe_ip4_node)
static uword flowprobe_walker_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
flowprobe_variant_t which
template key/value backing page structure
static u32 ipfix_set_id_length(u16 set_id, u16 length)
vlib_buffer_t ** buffers_per_worker
ipfix buffers under construction, per-worker thread
static void flowprobe_export_entry(vlib_main_t *vm, flowprobe_entry_t *e)
vlib_node_registration_t flowprobe_l2_node
(constructor) VLIB_REGISTER_NODE (flowprobe_l2_node)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
u16 template_size[FLOW_N_RECORDS]
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static_always_inline uword os_get_thread_index(void)
struct clib_bihash_value offset
template key/value backing page structure
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
#define VLIB_REGISTER_NODE(x,...)
#define vec_foreach(var, vec)
Vector iterator.
static flowprobe_variant_t flowprobe_get_variant(flowprobe_variant_t which, flowprobe_record_t flags, u16 ethertype)
u16 flags
Copy of main node flags.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
u16 * next_record_offset_per_worker
next record offset, per worker thread
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
flowprobe_entry_t * flowprobe_create(u32 my_cpu_number, flowprobe_key_t *k, u32 *poolindex)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static void add_to_flow_record_state(vlib_main_t *vm, vlib_node_runtime_t *node, flowprobe_main_t *fm, vlib_buffer_t *b, u64 timestamp, u16 length, flowprobe_variant_t which, flowprobe_trace_t *t)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static void flowprobe_delete_by_index(u32 my_cpu_number, u32 poolindex)
static u16 flowprobe_get_headersize(void)
static uword flowprobe_l2_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)