59 #define _(field,mask,item,length) \ 60 if ((field) == (mask)) \ 64 fr->fields_to_send = clib_bitmap_set (fr->fields_to_send, \ 90 ip->ip_version_and_header_length = 0x45;
92 ip->protocol = IP_PROTOCOL_UDP;
93 ip->src_address.as_u32 = src_address->
as_u32;
94 ip->dst_address.as_u32 = collector_address->
as_u32;
95 udp->src_port = clib_host_to_net_u16 (fr->
src_port);
96 udp->dst_port = clib_host_to_net_u16 (collector_port);
97 udp->length = clib_host_to_net_u16 (
vec_len(rewrite) -
sizeof (*ip));
101 h->domain_id = clib_host_to_net_u32 (fr->
domain_id);
106 #define _(field,mask,item,length) \ 107 if ((field) == (mask)) \ 109 f->e_id_length = ipfix_e_id_length (0 , \ 134 ip->length = clib_host_to_net_u16 ((
u8 *)f - (
u8 *)ip);
151 vnet_classify_entry_t * v, * save_v;
154 u32 record_offset = 0;
164 u32 records_this_buffer;
169 while (__sync_lock_test_and_set (t->writer_lock, 1))
172 for (i = 0; i < t->nbuckets; i++)
181 for (k = 0; k < t->entries_per_page; k++)
184 (t, save_v, j*t->entries_per_page + k);
222 next_offset = (
u32) (((
u8 *)(s+1)) - (
u8 *)tp);
223 record_offset = next_offset;
224 records_this_buffer = 0;
232 #define _(field,mask,item,length) \ 233 if (clib_bitmap_get (fr->fields_to_send, field_index)) \ 235 clib_memcpy (b0->data + next_offset, &field, \ 237 next_offset += length; \ 245 u64 packets = clib_host_to_net_u64 (v->hits);
247 next_offset +=
sizeof (packets);
249 records_this_buffer++;
253 u32 next_record_size = next_offset - record_offset;
254 record_offset = next_offset;
256 if (next_offset + next_record_size > frm->
path_mtu)
260 (
sizeof (*ip) +
sizeof (*udp) +
263 (
sizeof (*ip) +
sizeof (*udp)));
274 clib_host_to_net_u16 ((
u16)next_offset);
309 (
sizeof (*ip) +
sizeof (*udp) +
312 (
sizeof (*ip) +
sizeof (*udp)));
322 new_l0 = clib_host_to_net_u16 ((
u16)next_offset);
340 *(t->writer_lock) = 0;
356 u32 src_port = UDP_DST_PORT_ipfix;
360 memset (&args, 0,
sizeof (args));
365 else if (
unformat (input,
"domain %d", &domain_id))
367 else if (
unformat (input,
"src-port %d", &src_port))
379 args.
opaque = (
void *) fcm;
392 case VNET_API_ERROR_NO_SUCH_ENTRY:
402 .path =
"flow classify",
403 .short_help =
"flow classify",
sll srl srl sll sra u16x4 i
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
static f64 vlib_time_now(vlib_main_t *vm)
static u8 * template_rewrite(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_flow_rewrite_callback_t * rewrite_callback
#define vlib_call_init_function(vm, x)
static int vnet_classify_entry_is_free(vnet_classify_entry_t *e)
flow_report_main_t flow_report_main
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
flow_report_classify_main_t flow_report_classify_main
u16 current_length
Nbytes between current data and the end of this buffer.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static vlib_frame_t * send_flows(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
static u32 version_length(u16 length)
static vnet_classify_entry_t * vnet_classify_entry_at_index(vnet_classify_table_t *t, vnet_classify_entry_t *e, u32 index)
static u32 ipfix_id_count(u16 id, u16 count)
#define clib_memcpy(a, b, c)
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
struct _vnet_classify_main vnet_classify_main_t
vnet_classify_main_t vnet_classify_main
u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
#define foreach_ipfix_field
static u32 ipfix_set_id_length(u16 set_id, u16 length)
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
vnet_flow_data_callback_t * flow_data_callback
static clib_error_t * flow_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_error_return(e, args...)
static clib_error_t * flow_report_classify_init(vlib_main_t *vm)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
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 clib_error_t * flow_report_init(vlib_main_t *vm)
static u16 ip_csum_fold(ip_csum_t c)
static vnet_classify_entry_t * vnet_classify_get_entry(vnet_classify_table_t *t, uword offset)
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a)