|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
27 #include <vpp/app/version.h>
36 #include <flowprobe/flowprobe.api_enum.h>
37 #include <flowprobe/flowprobe.api_types.h>
44 #define REPLY_MSG_ID_BASE fm->msg_id_base
51 .arc_name =
"ip4-output",
52 .node_name =
"flowprobe-ip4",
58 .arc_name =
"ip6-output",
59 .node_name =
"flowprobe-ip6",
64 .arc_name =
"interface-output",
65 .node_name =
"flowprobe-l2",
71 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
74 vl_print (handle, (char *)s); \
81 #define flowprobe_template_ip4_field_count() 4
84 sourceIPv4Address, 4);
88 destinationIPv4Address, 4);
92 protocolIdentifier, 1);
104 #define flowprobe_template_ip6_field_count() 4
107 sourceIPv6Address, 16);
111 destinationIPv6Address, 16);
115 protocolIdentifier, 1);
127 #define flowprobe_template_l2_field_count() 3
130 sourceMacAddress, 6);
134 destinationMacAddress, 6);
146 #define flowprobe_template_common_field_count() 5
149 ingressInterface, 4);
159 packetDeltaCount, 8);
164 flowStartNanoseconds, 8);
169 flowEndNanoseconds, 8);
178 #define flowprobe_template_l4_field_count() 3
181 sourceTransportPort, 2);
185 destinationTransportPort, 2);
225 bool collect_ip4 =
false, collect_ip6 =
false;
263 ip->ip_version_and_header_length = 0x45;
265 ip->protocol = IP_PROTOCOL_UDP;
267 ip->dst_address.as_u32 = collector_address->
as_u32;
269 udp->
dst_port = clib_host_to_net_u16 (collector_port);
274 h->domain_id = clib_host_to_net_u32 (stream->
domain_id);
305 ip->length = clib_host_to_net_u16 ((
u8 *)
f - (
u8 *)
ip);
318 u32 n_elts,
u32 * stream_index)
321 (frm, fr, collector_address,
src_address, collector_port,
332 u32 n_elts,
u32 * stream_index)
335 (frm, fr, collector_address,
src_address, collector_port,
346 u32 n_elts,
u32 * stream_index)
349 (frm, fr, collector_address,
src_address, collector_port,
360 u32 n_elts,
u32 * stream_index)
363 (frm, fr, collector_address,
src_address, collector_port,
374 u32 n_elts,
u32 * stream_index)
377 (frm, fr, collector_address,
src_address, collector_port,
423 bool is_add,
u16 * template_id)
427 .rewrite_callback = rewrite_callback,
428 .flow_data_callback = flow_data_callback,
430 .domain_id = domain_id,
432 .opaque.as_uword =
flags,
446 for (
i = 0;
i <
vec_len (expired_timers);
i++)
448 poolindex = expired_timers[
i] & 0x7FFFFFFF;
449 vec_add1 (
fm->expired_passive_per_worker[my_cpu_number], poolindex);
477 for (
i = 0;
i < num_threads;
i++)
482 for (j = 0; j < (1 <<
fm->ht_log2len); j++)
483 fm->hash_per_worker[
i][j] = ~0;
484 fm->timers_per_worker[
i] =
486 tw_timer_wheel_init_2t_1w_2048sl (
fm->timers_per_worker[
i],
496 for (
i = 0;
i < num_threads;
i++)
497 fm->stateless_entry[
i].last_exported =
now;
498 fm->disabled =
false;
500 fm->initialized =
true;
536 fm->template_per_flow[
which] += (is_add) ? 1 : -1;
537 if (is_add &&
fm->template_per_flow[
which] > 1)
538 template_id =
fm->template_reports[
flags];
540 if ((is_add &&
fm->template_per_flow[
which] == 1) ||
541 (!is_add &&
fm->template_per_flow[
which] == 0))
550 is_add, &template_id);
557 is_add, &template_id);
559 (is_add) ? template_id : 0;
564 is_add, &template_id);
566 (is_add) ? template_id : 0;
574 fm->template_reports[
flags] = template_id;
581 is_add, &template_id);
586 is_add, &template_id);
588 if (
rv &&
rv != VNET_API_ERROR_VALUE_EXIST)
597 fm->template_reports[
flags] = (is_add) ? template_id : 0;
611 if (is_add && !
fm->initialized)
614 if (
fm->active_timer)
629 vl_api_flowprobe_tx_interface_add_del_reply_t *rmp;
637 clib_warning (
"Please specify flowprobe params record first...");
638 rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
645 rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
655 REPLY_MACRO (VL_API_FLOWPROBE_TX_INTERFACE_ADD_DEL_REPLY);
658 #define vec_neg_search(v,E) \
661 while (_v(i) < vec_len(v) && v[_v(i)] == E) \
665 if (_v(i) == vec_len(v)) \
672 u8 record_l3,
u8 record_l4,
673 u32 active_timer,
u32 passive_timer)
704 vl_api_flowprobe_params_reply_t *rmp;
720 .version = VPP_BUILD_VER,
721 .description =
"Flow per Packet",
733 s =
format (s,
" %U -> %U",
761 u32 active_timer = va_arg (*args,
u32);
762 u32 passive_timer = va_arg (*args,
u32);
771 if (active_timer != (
u32) ~ 0)
772 s =
format (s,
" active: %d", active_timer);
774 if (passive_timer != (
u32) ~ 0)
775 s =
format (s,
" passive: %d", passive_timer);
853 "Please specify flowprobe params record first...");
863 "Datapath is already enabled for given interface...");
867 "Interface has enable different datapath ...");
876 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
878 (0,
"Invalid interface, only works on physical ports");
881 case VNET_API_ERROR_UNIMPLEMENTED:
920 bool record_l2 =
false, record_l3 =
false, record_l4 =
false;
921 u32 active_timer = ~0;
922 u32 passive_timer = ~0;
926 if (
unformat (input,
"active %d", &active_timer))
928 else if (
unformat (input,
"passive %d", &passive_timer))
930 else if (
unformat (input,
"record"))
946 if (passive_timer > 0 && active_timer > passive_timer)
948 "Passive timer has to be greater than active one...");
951 active_timer, passive_timer))
953 "Couldn't change flowperpacket params when feature is enabled on some interface ...");
964 u32 active_timer =
fm->active_timer;
965 u32 passive_timer =
fm->passive_timer;
988 .path =
"flowprobe feature add-del",
990 "flowprobe feature add-del <interface-name> <l2|ip4|ip6> disable",
994 .path =
"flowprobe params",
996 "flowprobe params record <[l2] [l3] [l4]> [active <timer> passive <timer>]",
1001 .path =
"show flowprobe feature",
1003 "show flowprobe feature",
1007 .path =
"show flowprobe params",
1009 "show flowprobe params",
1013 .path =
"show flowprobe table",
1014 .short_help =
"show flowprobe table",
1018 .path =
"show flowprobe statistics",
1019 .short_help =
"show flowprobe statistics",
1031 uword *event_data = 0;
1038 if (event_type != 1)
1039 clib_warning (
"bogus kickoff event received, %d", event_type);
1054 f64 sleep_duration = 0.1;
1059 sleep_duration = 0.1;
1062 worker_vm = worker_vms[
i];
1068 (
fm->expired_passive_per_worker[
i] > 0) ? 1e-4 : 0.1;
1079 .name =
"flowprobe-timer-process",
1084 #include <flowprobe/flowprobe.api.c>
1111 clib_memset (
fm->template_per_flow, 0, sizeof (
fm->template_per_flow));
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
flowprobe_main_t flowprobe_main
vl_api_flowprobe_which_flags_t which
#define VALIDATE_SW_IF_INDEX(mp)
static u8 * flowprobe_template_rewrite_ip6(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 *elts, u32 n_elts, u32 *stream_index)
flow_report_main_t flow_report_main
static clib_error_t * flowprobe_init(vlib_main_t *vm)
Set up the API message handling tables.
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
static ipfix_field_specifier_t * flowprobe_template_ip6_fields(ipfix_field_specifier_t *f)
static vlib_cli_command_t flowprobe_show_stats_command
(constructor) VLIB_CLI_COMMAND (flowprobe_show_stats_command)
static ipfix_field_specifier_t * flowprobe_template_l4_fields(ipfix_field_specifier_t *f)
static clib_error_t * flowprobe_show_table_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cm)
static ipfix_field_specifier_t * flowprobe_template_l2_fields(ipfix_field_specifier_t *f)
@ FLOWPROBE_RECORD_FLAG_L2
static ipfix_field_specifier_t * flowprobe_template_ip4_fields(ipfix_field_specifier_t *f)
u8 * format_ethernet_address(u8 *s, va_list *args)
static int flowprobe_tx_interface_add_del_feature(flowprobe_main_t *fm, u32 sw_if_index, u8 which, int is_add)
configure / deconfigure the IPFIX flow-per-packet
static vlib_cli_command_t flowprobe_params_command
(constructor) VLIB_CLI_COMMAND (flowprobe_params_command)
#define clib_error_return(e, args...)
ip46_address_t src_address
void vl_api_flowprobe_tx_interface_add_del_t_handler(vl_api_flowprobe_tx_interface_add_del_t *mp)
API message handler.
static u8 * flowprobe_template_rewrite_inline(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port, flowprobe_variant_t which)
Create an IPFIX template packet rewrite string.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static clib_error_t * flowprobe_show_params_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_registration_t flowprobe_walker_node
(constructor) VLIB_REGISTER_NODE (flowprobe_walker_node)
u8 *() vnet_flow_rewrite_callback_t(struct flow_report_main *, struct flow_report *, ip4_address_t *, ip4_address_t *, u16, ipfix_report_element_t *elts, u32 n_elts, u32 *stream_index)
static uword timer_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
VNET_FEATURE_INIT(flow_perpacket_ip4, static)
#define flowprobe_template_ip4_field_count()
static u8 * flowprobe_template_rewrite_l2_ip4(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 *elts, u32 n_elts, u32 *stream_index)
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,...
static vlib_cli_command_t flowprobe_show_params_command
(constructor) VLIB_CLI_COMMAND (flowprobe_show_params_command)
static void flowprobe_expired_timer_callback(u32 *expired_timers)
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define FLOWPROBE_TIMER_PASSIVE
#define flowprobe_template_l4_field_count()
u8 * format_flowprobe_feature(u8 *s, va_list *args)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vl_api_flowprobe_record_flags_t record_flags
vnet_main_t * vnet_get_main(void)
ip46_address_t dst_address
static void setup_message_id_table(api_main_t *am)
static clib_error_t * flowprobe_show_stats_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cm)
static int flowprobe_params(flowprobe_main_t *fm, u8 record_l2, u8 record_l3, u8 record_l4, u32 active_timer, u32 passive_timer)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static int validate_feature_on_interface(flowprobe_main_t *fm, u32 sw_if_index, u8 which)
static vlib_cli_command_t flowprobe_enable_disable_command
(constructor) VLIB_CLI_COMMAND (flowprobe_enable_disable_command)
static u8 * flowprobe_template_rewrite_l2_ip6(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 *elts, u32 n_elts, u32 *stream_index)
void flowprobe_flush_callback_l2(void)
vlib_frame_t *() vnet_flow_data_callback_t(struct flow_report_main *, struct flow_report *, vlib_frame_t *, u32 *, u32)
static u64 unix_time_now_nsec(void)
vlib_frame_t * flowprobe_data_callback_ip4(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
Flush accumulated data.
vlib_thread_main_t vlib_thread_main
u8 * format_flowprobe_params(u8 *s, va_list *args)
vl_api_ip_port_and_mask_t src_port
#define flowprobe_template_ip6_field_count()
static clib_error_t * flowprobe_params_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_feature_config_main_t * cm
static int flowprobe_template_add_del(u32 domain_id, u16 src_port, flowprobe_record_t flags, vnet_flow_data_callback_t *flow_data_callback, vnet_flow_rewrite_callback_t *rewrite_callback, bool is_add, u16 *template_id)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
static clib_error_t * flowprobe_create_state_tables(u32 active_timer)
#define VLIB_CLI_COMMAND(x,...)
u8 * format_flowprobe_entry(u8 *s, va_list *args)
static u32 version_length(u16 length)
flow_report_stream_t * streams
flow-per-packet plugin header file
#define vec_neg_search(v, E)
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static ipfix_field_specifier_t * flowprobe_template_common_fields(ipfix_field_specifier_t *f)
void flowprobe_flush_callback_ip6(void)
static clib_error_t * flowprobe_tx_interface_add_del_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define BAD_SW_IF_INDEX_LABEL
static u32 ipfix_id_count(u16 id, u16 count)
static u8 * flowprobe_template_rewrite_ip4(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 *elts, u32 n_elts, u32 *stream_index)
format_function_t format_vnet_sw_if_index_name
unformat_function_t unformat_vnet_sw_interface
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...
description fragment has unexpected format
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
format_function_t format_ip46_address
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
#define VLIB_INIT_FUNCTION(x)
static vlib_node_registration_t flowprobe_timer_node
(constructor) VLIB_REGISTER_NODE (flowprobe_timer_node)
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
#define vec_foreach(var, vec)
Vector iterator.
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
static uword pool_elts(void *v)
Number of active elements in a pool.
@ FLOWPROBE_RECORD_FLAG_L4
static vlib_cli_command_t flowprobe_show_feature_command
(constructor) VLIB_CLI_COMMAND (flowprobe_show_feature_command)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
static vlib_cli_command_t flowprobe_show_table_command
(constructor) VLIB_CLI_COMMAND (flowprobe_show_table_command)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void flowprobe_flush_callback_ip4(void)
static u32 vlib_get_n_threads()
static vlib_main_t * vlib_get_main(void)
#define VNET_FEATURES(...)
#define FLOWPROBE_LOG2_HASHSIZE
vnet_interface_output_runtime_t * rt
static u16 ip4_header_checksum(ip4_header_t *i)
void vl_api_flowprobe_params_t_handler(vl_api_flowprobe_params_t *mp)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
static u32 ipfix_set_id_length(u16 set_id, u16 length)
Enable / disable per-packet IPFIX recording on an interface.
#define flowprobe_template_l2_field_count()
#define clib_warning(format, args...)
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
uword flowprobe_walker_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a, u16 *template_id)
static f64 vlib_time_now(vlib_main_t *vm)
#define FLOWPROBE_TIMER_ACTIVE
vl_api_address_union_t src_address
@ FLOWPROBE_RECORD_FLAG_L3
vl_api_interface_index_t sw_if_index
#define flowprobe_template_common_field_count()
vlib_frame_t * flowprobe_data_callback_l2(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
static void * clib_mem_alloc(uword size)
vlib_frame_t * flowprobe_data_callback_ip6(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
vl_api_interface_index_t sw_if_index
static clib_error_t * flowprobe_show_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_REGISTER_NODE(x,...)
static u8 * flowprobe_template_rewrite_l2(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 *elts, u32 n_elts, u32 *stream_index)
vl_api_wireguard_peer_flags_t flags