25 #define NAT44_SESSION_CREATE_LEN 26 26 #define NAT_ADDRESSES_EXHAUTED_LEN 13 27 #define MAX_ENTRIES_PER_USER_LEN 21 28 #define MAX_SESSIONS_LEN 17 29 #define MAX_BIBS_LEN 17 30 #define MAX_FRAGMENTS_IP4_LEN 21 31 #define MAX_FRAGMENTS_IP6_LEN 33 32 #define NAT64_BIB_LEN 38 33 #define NAT64_SES_LEN 62 35 #define NAT44_SESSION_CREATE_FIELD_COUNT 8 36 #define NAT_ADDRESSES_EXHAUTED_FIELD_COUNT 3 37 #define MAX_ENTRIES_PER_USER_FIELD_COUNT 5 38 #define MAX_SESSIONS_FIELD_COUNT 4 39 #define MAX_BIBS_FIELD_COUNT 4 40 #define MAX_FRAGMENTS_FIELD_COUNT 5 41 #define NAT64_BIB_FIELD_COUNT 8 42 #define NAT64_SES_FIELD_COUNT 12 114 #define skip_if_disabled() \ 116 snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main; \ 117 if (PREDICT_TRUE (!silm->enabled)) \ 227 udp->
dst_port = clib_host_to_net_u16 (collector_port);
228 udp->
length = clib_host_to_net_u16 (
vec_len (rewrite) -
sizeof (*ip));
396 ip->
length = clib_host_to_net_u16 ((
u8 *) f - (
u8 *) ip);
409 u32 n_elts,
u32 *stream_index)
422 u32 n_elts,
u32 *stream_index)
435 u32 n_elts,
u32 *stream_index)
449 u32 n_elts,
u32 *stream_index)
463 u32 n_elts,
u32 *stream_index)
477 u32 n_elts,
u32 *stream_index)
491 u32 n_elts,
u32 *stream_index)
505 u32 n_elts,
u32 *stream_index)
518 u32 n_elts,
u32 *stream_index)
541 b0->
flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_FLOW_REPORT);
567 *offset = (
u32) (((
u8 *) (s + 1)) - (
u8 *) tp);
589 (sizeof (*ip) +
sizeof (*udp) +
592 (sizeof (*ip) +
sizeof (*udp)));
613 u16 nat_src_port,
u32 vrf_id,
int do_flush)
643 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
676 u64 time_stamp = clib_host_to_net_u64 (now);
678 offset +=
sizeof (time_stamp);
681 offset +=
sizeof (nat_event);
684 offset +=
sizeof (
src_ip);
687 offset +=
sizeof (nat_src_ip);
690 offset +=
sizeof (proto);
696 offset +=
sizeof (nat_src_port);
699 offset +=
sizeof (vrf_id);
744 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
777 u64 time_stamp = clib_host_to_net_u64 (now);
779 offset +=
sizeof (time_stamp);
782 offset +=
sizeof (nat_event);
785 offset +=
sizeof (pool_id);
831 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
864 u64 time_stamp = clib_host_to_net_u64 (now);
866 offset +=
sizeof (time_stamp);
869 offset +=
sizeof (nat_event);
872 offset +=
sizeof (quota_event);
875 offset +=
sizeof (limit);
878 offset +=
sizeof (
src_ip);
924 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
957 u64 time_stamp = clib_host_to_net_u64 (now);
959 offset +=
sizeof (time_stamp);
962 offset +=
sizeof (nat_event);
965 offset +=
sizeof (quota_event);
968 offset +=
sizeof (limit);
1014 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
1047 u64 time_stamp = clib_host_to_net_u64 (now);
1049 offset +=
sizeof (time_stamp);
1052 offset +=
sizeof (nat_event);
1055 offset +=
sizeof (quota_event);
1058 offset +=
sizeof (limit);
1104 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
1137 u64 time_stamp = clib_host_to_net_u64 (now);
1139 offset +=
sizeof (time_stamp);
1142 offset +=
sizeof (nat_event);
1145 offset +=
sizeof (quota_event);
1148 offset +=
sizeof (limit);
1151 offset +=
sizeof (
src);
1197 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
1230 u64 time_stamp = clib_host_to_net_u64 (now);
1232 offset +=
sizeof (time_stamp);
1235 offset +=
sizeof (nat_event);
1238 offset +=
sizeof (quota_event);
1241 offset +=
sizeof (limit);
1263 u16 nat_src_port,
u32 vrf_id,
int do_flush)
1290 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
1323 u64 time_stamp = clib_host_to_net_u64 (now);
1325 offset +=
sizeof (time_stamp);
1328 offset +=
sizeof (nat_event);
1334 offset +=
sizeof (nat_src_ip);
1337 offset +=
sizeof (proto);
1343 offset +=
sizeof (nat_src_port);
1346 offset +=
sizeof (vrf_id);
1367 u32 vrf_id,
int do_flush)
1394 nat_log_err (
"can't allocate buffer for NAT IPFIX event");
1427 u64 time_stamp = clib_host_to_net_u64 (now);
1429 offset +=
sizeof (time_stamp);
1432 offset +=
sizeof (nat_event);
1438 offset +=
sizeof (nat_src_ip);
1441 offset +=
sizeof (proto);
1447 offset +=
sizeof (nat_src_port);
1453 offset +=
sizeof (nat_dst_ip);
1459 offset +=
sizeof (nat_dst_port);
1462 offset +=
sizeof (vrf_id);
1501 u16 nat_src_port,
u32 vrf_id)
1516 (
u8 *) & a,
sizeof (a));
1534 u16 nat_src_port,
u32 vrf_id)
1549 (
u8 *) & a,
sizeof (a));
1556 u32 * to_next,
u32 node_index)
1585 (
u8 *) & a,
sizeof (a));
1592 u32 * to_next,
u32 node_index)
1623 (
u8 *) & a,
sizeof (a));
1630 u32 * to_next,
u32 node_index)
1658 (
u8 *) & a,
sizeof (a));
1665 u32 * to_next,
u32 node_index)
1693 (
u8 *) & a,
sizeof (a));
1700 u32 * to_next,
u32 node_index)
1730 (
u8 *) & a,
sizeof (a));
1737 u32 * to_next,
u32 node_index)
1771 (
u8 *) & a,
sizeof (a));
1778 u32 * to_next,
u32 node_index)
1826 (
u8 *) & a,
sizeof (a));
1833 u32 * to_next,
u32 node_index)
1874 u16 nat_dst_port,
u32 vrf_id,
u8 is_create)
1895 (
u8 *) & a,
sizeof (a));
1902 u32 * to_next,
u32 node_index)
1904 nat_ipfix_logging_nat64_ses (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
1925 u8 e = enable ? 1 : 0;
1934 a.
domain_id = domain_id ? domain_id : 1;
1945 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
1957 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
1967 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
1977 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
1987 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
1997 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
2007 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
2017 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
2027 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
2039 nat_log_warn (
"vnet_flow_report_add_del returned %d", rv);
void nat_ipfix_logging_max_sessions(u32 limit)
Generate maximum session entries exceeded event.
vlib_frame_t * max_frags_ip4_frame
u32 max_entries_per_user_next_record_offset
static void nat_ipfix_logging_nat64_ses(u8 nat_event, ip6_address_t *src_ip, u32 nat_src_ip, u8 proto, u16 src_port, u16 nat_src_port, ip6_address_t *dst_ip, u32 nat_dst_ip, u16 dst_port, u16 nat_dst_port, u32 vrf_id, int do_flush)
static void nat_ipfix_logging_max_frag_ip6(u32 limit, ip6_address_t *src, int do_flush)
u16 max_frags_ip4_template_id
u8 * snat_template_rewrite_addr_exhausted(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)
vlib_frame_t * max_entries_per_user_frame
static void snat_ipfix_logging_max_entries_per_usr_rpc_cb(snat_ipfix_logging_max_entries_per_user_args_t *a)
u16 max_frags_ip6_template_id
#define MAX_FRAGMENTS_IP6_LEN
u16 nat64_ses_template_id
u32 nat64_ses_next_record_offset
u8 * nat_template_rewrite_max_sessions(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 void nat_ipfix_logging_nat64_bib_rpc_cb(nat_ipfix_logging_nat64_bib_args_t *a)
static void nat_ipfix_logging_max_frag_ip6_rpc_cb(nat_ipfix_logging_max_frags_ip6_args_t *a)
vlib_frame_t * addr_exhausted_frame
#define clib_memcpy_fast(a, b, c)
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_frame_t * nat_data_callback_max_frags_ip4(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
static f64 vlib_time_now(vlib_main_t *vm)
#define NAT44_SESSION_CREATE_FIELD_COUNT
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a, u16 *template_id)
u8 * nat_template_rewrite_max_bibs(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)
#define nat_log_warn(...)
u16 addr_exhausted_template_id
ip4_address_t src_address
static void snat_ipfix_logging_nat44_ses_rpc_cb(snat_ipfix_logging_nat44_ses_args_t *a)
u8 enabled
NAT plugin IPFIX logging enabled.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
void nat_ipfix_logging_max_fragments_ip6(u32 limit, ip6_address_t *src)
Generate maximum IPv6 fragments pending reassembly exceeded event.
static void nat_ipfix_logging_max_ses_rpc_cb(nat_ipfix_logging_max_sessions_args_t *a)
#define MAX_SESSIONS_FIELD_COUNT
static void snat_ipfix_logging_max_entries_per_usr(u32 limit, u32 src_ip, int do_flush)
ip4_address_t ipfix_collector
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
u8 * snat_template_rewrite_nat44_session(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_stream_t * streams
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
void nat_ipfix_logging_nat64_bib(ip6_address_t *src_ip, ip4_address_t *nat_src_ip, u8 proto, u16 src_port, u16 nat_src_port, u32 vrf_id, u8 is_create)
Generate NAT64 BIB create and delete events.
static void nat_ipfix_logging_max_frag_ip4(u32 limit, u32 src, int do_flush)
vnet_flow_rewrite_callback_t * rewrite_callback
snat_ipfix_logging_main_t snat_ipfix_logging_main
static void nat_ipfix_logging_max_frag_ip4_rpc_cb(nat_ipfix_logging_max_frags_ip4_args_t *a)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static void nat_ipfix_logging_nat64_ses_rpc_cb(nat_ipfix_logging_nat64_ses_args_t *a)
static void snat_ipfix_logging_addr_exhausted(u32 pool_id, int do_flush)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
void snat_ipfix_logging_init(vlib_main_t *vm)
Initialize NAT plugin IPFIX logging.
int snat_ipfix_logging_enable_disable(int enable, u32 domain_id, u16 src_port)
Enable/disable NAT plugin IPFIX logging.
vlib_frame_t * nat_data_callback_max_bibs(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
u32 addr_exhausted_next_record_offset
#define NAT44_SESSION_CREATE_LEN
u8 * snat_template_rewrite_max_entries_per_usr(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 u8 * snat_template_rewrite(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port, nat_event_t event, quota_exceed_event_t quota_event)
Create an IPFIX template packet rewrite string.
static void snat_ipfix_logging_nat44_ses(u8 nat_event, u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id, int do_flush)
static void snat_ipfix_send(flow_report_main_t *frm, vlib_frame_t *f, vlib_buffer_t *b0, u16 template_id)
vlib_buffer_t * nat64_ses_buffer
u32 max_bibs_next_record_offset
#define MAX_FRAGMENTS_FIELD_COUNT
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
u16 nat64_bib_template_id
flow_report_main_t flow_report_main
vlib_frame_t * max_frags_ip6_frame
u16 current_length
Nbytes between current data and the end of this buffer.
vlib_frame_t * nat44_session_frame
frames containing ipfix buffers
#define NAT_ADDRESSES_EXHAUTED_LEN
vlib_frame_t * max_bibs_frame
vlib_buffer_t * max_sessions_buffer
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void snat_ipfix_logging_nat44_ses_delete(u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session delete event.
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
void snat_ipfix_logging_nat44_ses_create(u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session create event.
vl_api_address_union_t src_address
u32 stream_index
stream index
static u32 version_length(u16 length)
static void nat_ipfix_logging_max_bib_rpc_cb(nat_ipfix_logging_max_bibs_args_t *a)
u64 milisecond_time_0
Time reference pair.
vlib_frame_t * nat_data_callback_max_sessions(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
u16 max_entries_per_user_template_id
vlib_frame_t * snat_data_callback_max_entries_per_usr(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
void nat_ipfix_logging_max_bibs(u32 limit)
Generate maximum BIB entries exceeded event.
static void nat_ipfix_logging_max_ses(u32 limit, int do_flush)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
vlib_frame_t * nat64_bib_frame
vlib_buffer_t * max_frags_ip6_buffer
vlib_buffer_t * nat44_session_buffer
ipfix buffers under construction
static u32 ipfix_id_count(u16 id, u16 count)
vlib_frame_t * nat_data_callback_nat64_bib(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
static u64 unix_time_now_nsec(void)
static void nat_ipfix_logging_max_bib(u32 limit, int do_flush)
u16 nat44_session_template_id
template IDs
u8 * nat_template_rewrite_nat64_session(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)
u16 max_sessions_template_id
#define MAX_BIBS_FIELD_COUNT
vlib_buffer_t * max_bibs_buffer
void nat_ipfix_logging_max_fragments_ip4(u32 limit, ip4_address_t *src)
Generate maximum IPv4 fragments pending reassembly exceeded event.
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
#define MAX_FRAGMENTS_IP4_LEN
vlib_buffer_t * addr_exhausted_buffer
void snat_ipfix_logging_max_entries_per_user(u32 limit, u32 src_ip)
Generate maximum entries per user exceeded event.
u32 max_sessions_next_record_offset
u8 * nat_template_rewrite_nat64_bib(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)
snat_protocol_t snat_proto
u32 max_frags_ip6_next_record_offset
vlib_frame_t * nat_data_callback_nat64_session(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
vlib_frame_t * max_sessions_frame
template key/value backing page structure
static u32 ipfix_set_id_length(u16 set_id, u16 length)
u8 * nat_template_rewrite_max_frags_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)
vlib_buffer_t * nat64_bib_buffer
vlib_frame_t * snat_data_callback_nat44_session(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
#define MAX_ENTRIES_PER_USER_LEN
#define MAX_ENTRIES_PER_USER_FIELD_COUNT
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_buffer_t * max_frags_ip4_buffer
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
void snat_ipfix_logging_addresses_exhausted(u32 pool_id)
Generate NAT addresses exhausted event.
#define skip_if_disabled()
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u32 max_frags_ip4_next_record_offset
vnet_flow_data_callback_t * flow_data_callback
struct clib_bihash_value offset
template key/value backing page structure
vlib_buffer_t * max_entries_per_user_buffer
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
#define NAT_ADDRESSES_EXHAUTED_FIELD_COUNT
#define NAT64_SES_FIELD_COUNT
static void snat_ipfix_header_create(flow_report_main_t *frm, vlib_buffer_t *b0, u32 *offset)
static void nat_ipfix_logging_nat64_bibe(u8 nat_event, ip6_address_t *src_ip, u32 nat_src_ip, u8 proto, u16 src_port, u16 nat_src_port, u32 vrf_id, int do_flush)
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, vlib_buffer_free_list_index_t free_list_index)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
u8 * nat_template_rewrite_max_frags_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)
vlib_frame_t * nat64_ses_frame
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
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)
u32 nat64_bib_next_record_offset
static void snat_ipfix_logging_addr_exhausted_rpc_cb(snat_ipfix_logging_addr_exhausted_args_t *a)
u32 nat44_session_next_record_offset
next record offset
#define NAT64_BIB_FIELD_COUNT
vlib_frame_t * nat_data_callback_max_frags_ip6(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
vlib_frame_t * snat_data_callback_addr_exhausted(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
void nat_ipfix_logging_nat64_session(ip6_address_t *src_ip, ip4_address_t *nat_src_ip, u8 proto, u16 src_port, u16 nat_src_port, ip6_address_t *dst_ip, ip4_address_t *nat_dst_ip, u16 dst_port, u16 nat_dst_port, u32 vrf_id, u8 is_create)
Generate NAT64 session create and delete events.