Type: refactor
Change-Id: I8785e4987e4f60361072440d0c3c6954c9c12394
Signed-off-by: Filip Varga <fivarga@cisco.com>
14 files changed:
add_vpp_library(nat
SOURCES
add_vpp_library(nat
SOURCES
lib/alloc.c
INSTALL_HEADERS
lib/alloc.c
INSTALL_HEADERS
in2out_ed.c
out2in.c
out2in_ed.c
in2out_ed.c
out2in.c
out2in_ed.c
nat_dpo.c
nat44_cli.c
nat44_handoff.c
nat_dpo.c
nat44_cli.c
nat44_handoff.c
INSTALL_HEADERS
nat_all_api_h.h
nat_msg_enum.h
INSTALL_HEADERS
nat_all_api_h.h
nat_msg_enum.h
#include <nat/lib/lib.h>
#include <nat/lib/inlines.h>
#include <nat/lib/lib.h>
#include <nat/lib/inlines.h>
+#include <nat/lib/ipfix_logging.h>
/* Session state */
#define foreach_det44_session_state \
/* Session state */
#define foreach_det44_session_state \
- // TODO:
- /*snat_ipfix_logging_max_entries_per_user (thread_index,
- DET44_SES_PER_USER,
- in_addr->as_u32); */
+ nat_ipfix_logging_max_entries_per_user (thread_index,
+ DET44_SES_PER_USER,
+ in_addr->as_u32);
#include <vnet/fib/ip4_fib.h>
#include <vnet/udp/udp.h>
#include <nat/nat.h>
#include <vnet/fib/ip4_fib.h>
#include <vnet/udp/udp.h>
#include <nat/nat.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
if (clib_bihash_add_del_8_8 (&tsm->out2in, &s_kv, 0))
nat_elog_warn ("out2in key del failed");
if (clib_bihash_add_del_8_8 (&tsm->out2in, &s_kv, 0))
nat_elog_warn ("out2in key del failed");
- snat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port,
- s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port,
+ s->in2out.fib_index);
nat_syslog_nat44_apmdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_syslog_nat44_apmdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_elog_notice ("out2in key add failed");
/* log NAT event */
nat_elog_notice ("out2in key add failed");
/* log NAT event */
- snat_ipfix_logging_nat44_ses_create (thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port, s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_create (thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port, s->in2out.fib_index);
nat_syslog_nat44_apmadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port, &s->out2in.addr,
nat_syslog_nat44_apmadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port, &s->out2in.addr,
#include <vnet/udp/udp.h>
#include <vppinfra/error.h>
#include <nat/nat.h>
#include <vnet/udp/udp.h>
#include <vppinfra/error.h>
#include <nat/nat.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
if (snat_is_unk_proto_session (s))
goto delete;
if (snat_is_unk_proto_session (s))
goto delete;
- snat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port,
- s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port,
+ s->in2out.fib_index);
nat_syslog_nat44_sdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_syslog_nat44_sdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
#undef _
/* Totally out of translations to use... */
#undef _
/* Totally out of translations to use... */
- snat_ipfix_logging_addresses_exhausted (thread_index, 0);
+ nat_ipfix_logging_addresses_exhausted (thread_index, 0);
*sessionp = s;
/* log NAT event */
*sessionp = s;
/* log NAT event */
- snat_ipfix_logging_nat44_ses_create (thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port, s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_create (thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port, s->in2out.fib_index);
nat_syslog_nat44_sadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_syslog_nat44_sadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
#include <vnet/ipfix-export/flow_report.h>
#include <vlibmemory/api.h>
#include <vnet/ipfix-export/flow_report.h>
#include <vlibmemory/api.h>
-#include <nat/nat_inlines.h>
-#include <nat/nat_ipfix_logging.h>
#include <vppinfra/atomics.h>
#include <vppinfra/atomics.h>
+#include <nat/lib/ipfix_logging.h>
+#include <nat/lib/inlines.h>
-vlib_node_registration_t snat_ipfix_flush_node;
-snat_ipfix_logging_main_t snat_ipfix_logging_main;
+vlib_node_registration_t nat_ipfix_flush_node;
+nat_ipfix_logging_main_t nat_ipfix_logging_main;
#define NAT44_SESSION_CREATE_LEN 26
#define NAT_ADDRESSES_EXHAUTED_LEN 13
#define NAT44_SESSION_CREATE_LEN 26
#define NAT_ADDRESSES_EXHAUTED_LEN 13
u16 src_port;
u16 nat_src_port;
u32 vrf_id;
u16 src_port;
u16 nat_src_port;
u32 vrf_id;
-} snat_ipfix_logging_nat44_ses_args_t;
+} nat_ipfix_logging_nat44_ses_args_t;
typedef struct
{
u32 pool_id;
typedef struct
{
u32 pool_id;
-} snat_ipfix_logging_addr_exhausted_args_t;
+} nat_ipfix_logging_addr_exhausted_args_t;
typedef struct
{
u32 limit;
u32 src_ip;
typedef struct
{
u32 limit;
u32 src_ip;
-} snat_ipfix_logging_max_entries_per_user_args_t;
+} nat_ipfix_logging_max_entries_per_user_args_t;
#define skip_if_disabled() \
do { \
#define skip_if_disabled() \
do { \
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main; \
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main; \
if (PREDICT_TRUE (!clib_atomic_fetch_or(&silm->enabled, 0))) \
return; \
} while (0)
if (PREDICT_TRUE (!clib_atomic_fetch_or(&silm->enabled, 0))) \
return; \
} while (0)
* @returns template packet
*/
static inline u8 *
* @returns template packet
*/
static inline u8 *
-snat_template_rewrite (flow_report_main_t * frm,
+nat_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)
{
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)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
ip4_header_t *ip;
udp_header_t *udp;
ipfix_message_header_t *h;
ip4_header_t *ip;
udp_header_t *udp;
ipfix_message_header_t *h;
-snat_template_rewrite_addr_exhausted (flow_report_main_t * frm,
+nat_template_rewrite_addr_exhausted (flow_report_main_t * frm,
flow_report_t * fr,
ip4_address_t * collector_address,
ip4_address_t * src_address,
flow_report_t * fr,
ip4_address_t * collector_address,
ip4_address_t * src_address,
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, NAT_ADDRESSES_EXHAUTED, 0);
}
u8 *
collector_port, NAT_ADDRESSES_EXHAUTED, 0);
}
u8 *
-snat_template_rewrite_nat44_session (flow_report_main_t * frm,
+nat_template_rewrite_nat44_session (flow_report_main_t * frm,
flow_report_t * fr,
ip4_address_t * collector_address,
ip4_address_t * src_address,
flow_report_t * fr,
ip4_address_t * collector_address,
ip4_address_t * src_address,
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, NAT44_SESSION_CREATE, 0);
}
u8 *
collector_port, NAT44_SESSION_CREATE, 0);
}
u8 *
-snat_template_rewrite_max_entries_per_usr (flow_report_main_t * frm,
+nat_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,
flow_report_t * fr,
ip4_address_t * collector_address,
ip4_address_t * src_address,
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, QUOTA_EXCEEDED,
MAX_ENTRIES_PER_USER);
}
collector_port, QUOTA_EXCEEDED,
MAX_ENTRIES_PER_USER);
}
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, QUOTA_EXCEEDED,
MAX_SESSION_ENTRIES);
}
collector_port, QUOTA_EXCEEDED,
MAX_SESSION_ENTRIES);
}
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, QUOTA_EXCEEDED,
MAX_BIB_ENTRIES);
}
collector_port, QUOTA_EXCEEDED,
MAX_BIB_ENTRIES);
}
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, NAT64_BIB_CREATE, 0);
}
collector_port, NAT64_BIB_CREATE, 0);
}
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
ipfix_report_element_t *elts,
u32 n_elts, u32 *stream_index)
{
- return snat_template_rewrite (frm, fr, collector_address, src_address,
+ return nat_template_rewrite (frm, fr, collector_address, src_address,
collector_port, NAT64_SESSION_CREATE, 0);
}
static inline void
collector_port, NAT64_SESSION_CREATE, 0);
}
static inline void
-snat_ipfix_header_create (flow_report_main_t * frm,
+nat_ipfix_header_create (flow_report_main_t * frm,
vlib_buffer_t * b0, u32 * offset)
{
vlib_buffer_t * b0, u32 * offset)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
flow_report_stream_t *stream;
ip4_ipfix_template_packet_t *tp;
ipfix_message_header_t *h = 0;
flow_report_stream_t *stream;
ip4_ipfix_template_packet_t *tp;
ipfix_message_header_t *h = 0;
-snat_ipfix_send (u32 thread_index, flow_report_main_t * frm,
+nat_ipfix_send (u32 thread_index, flow_report_main_t * frm,
vlib_frame_t * f, vlib_buffer_t * b0, u16 template_id)
{
ip4_ipfix_template_packet_t *tp;
vlib_frame_t * f, vlib_buffer_t * b0, u16 template_id)
{
ip4_ipfix_template_packet_t *tp;
-snat_ipfix_logging_nat44_ses (u32 thread_index, u8 nat_event, u32 src_ip,
+nat_ipfix_logging_nat44_ses (u32 thread_index, u8 nat_event, u32 src_ip,
u32 nat_src_ip, nat_protocol_t nat_proto,
u16 src_port, u16 nat_src_port, u32 vrf_id,
int do_flush)
{
u32 nat_src_ip, nat_protocol_t nat_proto,
u16 src_port, u16 nat_src_port, u32 vrf_id,
int do_flush)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->nat44_session_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->nat44_session_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->nat44_session_frame = 0;
sitd->nat44_session_buffer = 0;
offset = 0;
sitd->nat44_session_frame = 0;
sitd->nat44_session_buffer = 0;
offset = 0;
-snat_ipfix_logging_addr_exhausted (u32 thread_index, u32 pool_id, int do_flush)
+nat_ipfix_logging_addr_exhausted (u32 thread_index, u32 pool_id, int do_flush)
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->addr_exhausted_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->addr_exhausted_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->addr_exhausted_frame = 0;
sitd->addr_exhausted_buffer = 0;
offset = 0;
sitd->addr_exhausted_frame = 0;
sitd->addr_exhausted_buffer = 0;
offset = 0;
-snat_ipfix_logging_max_entries_per_usr (u32 thread_index,
+nat_ipfix_logging_max_entries_per_usr (u32 thread_index,
u32 limit, u32 src_ip, int do_flush)
{
u32 limit, u32 src_ip, int do_flush)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->max_entries_per_user_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->max_entries_per_user_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->max_entries_per_user_frame = 0;
sitd->max_entries_per_user_buffer = 0;
offset = 0;
sitd->max_entries_per_user_frame = 0;
sitd->max_entries_per_user_buffer = 0;
offset = 0;
static void
nat_ipfix_logging_max_ses (u32 thread_index, u32 limit, int do_flush)
{
static void
nat_ipfix_logging_max_ses (u32 thread_index, u32 limit, int do_flush)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->max_sessions_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->max_sessions_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->max_sessions_frame = 0;
sitd->max_sessions_buffer = 0;
offset = 0;
sitd->max_sessions_frame = 0;
sitd->max_sessions_buffer = 0;
offset = 0;
static void
nat_ipfix_logging_max_bib (u32 thread_index, u32 limit, int do_flush)
{
static void
nat_ipfix_logging_max_bib (u32 thread_index, u32 limit, int do_flush)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->max_bibs_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->max_bibs_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->max_bibs_frame = 0;
sitd->max_bibs_buffer = 0;
offset = 0;
sitd->max_bibs_frame = 0;
sitd->max_bibs_buffer = 0;
offset = 0;
u8 proto, u16 src_port, u16 nat_src_port,
u32 vrf_id, int do_flush)
{
u8 proto, u16 src_port, u16 nat_src_port,
u32 vrf_id, int do_flush)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->nat64_bib_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->nat64_bib_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->nat64_bib_frame = 0;
sitd->nat64_bib_buffer = 0;
offset = 0;
sitd->nat64_bib_frame = 0;
sitd->nat64_bib_buffer = 0;
offset = 0;
u16 dst_port, u16 nat_dst_port,
u32 vrf_id, int do_flush)
{
u16 dst_port, u16 nat_dst_port,
u32 vrf_id, int do_flush)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
- snat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
+ nat_ipfix_per_thread_data_t *sitd = &silm->per_thread_data[thread_index];
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
flow_report_main_t *frm = &flow_report_main;
vlib_frame_t *f;
vlib_buffer_t *b0 = 0;
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
{
- nat_elog_err ("can't allocate buffer for NAT IPFIX event");
+ //nat_elog_err ("can't allocate buffer for NAT IPFIX event");
}
if (PREDICT_FALSE (offset == 0))
}
if (PREDICT_FALSE (offset == 0))
- snat_ipfix_header_create (frm, b0, &offset);
+ nat_ipfix_header_create (frm, b0, &offset);
if (PREDICT_TRUE (do_flush == 0))
{
if (PREDICT_TRUE (do_flush == 0))
{
template_id = clib_atomic_fetch_or (
&silm->nat64_ses_template_id,
0);
template_id = clib_atomic_fetch_or (
&silm->nat64_ses_template_id,
0);
- snat_ipfix_send (thread_index, frm, f, b0, template_id);
+ nat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->nat64_ses_frame = 0;
sitd->nat64_ses_buffer = 0;
offset = 0;
sitd->nat64_ses_frame = 0;
sitd->nat64_ses_buffer = 0;
offset = 0;
-snat_ipfix_flush (u32 thread_index)
+nat_ipfix_flush (u32 thread_index)
- snat_ipfix_logging_nat44_ses (thread_index,
+ nat_ipfix_logging_nat44_ses (thread_index,
0, 0, 0, 0, 0, 0, 0, do_flush);
0, 0, 0, 0, 0, 0, 0, do_flush);
- snat_ipfix_logging_addr_exhausted (thread_index, 0, do_flush);
- snat_ipfix_logging_max_entries_per_usr (thread_index, 0, 0, do_flush);
+ nat_ipfix_logging_addr_exhausted (thread_index, 0, do_flush);
+ nat_ipfix_logging_max_entries_per_usr (thread_index, 0, 0, do_flush);
nat_ipfix_logging_max_ses (thread_index, 0, do_flush);
nat_ipfix_logging_max_bib (thread_index, 0, do_flush);
nat_ipfix_logging_nat64_bibe (thread_index,
nat_ipfix_logging_max_ses (thread_index, 0, do_flush);
nat_ipfix_logging_max_bib (thread_index, 0, do_flush);
nat_ipfix_logging_nat64_bibe (thread_index,
-snat_ipfix_flush_from_main (void)
+nat_ipfix_flush_from_main (void)
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
vlib_main_t *worker_vm;
int i;
vlib_main_t *worker_vm;
int i;
worker_vm = silm->worker_vms[i];
if (worker_vm)
vlib_node_set_interrupt_pending (worker_vm,
worker_vm = silm->worker_vms[i];
if (worker_vm)
vlib_node_set_interrupt_pending (worker_vm,
- snat_ipfix_flush_node.index);
+ nat_ipfix_flush_node.index);
}
/* Finally flush main thread */
}
/* Finally flush main thread */
* @param vrf_id VRF ID
*/
void
* @param vrf_id VRF ID
*/
void
-snat_ipfix_logging_nat44_ses_create (u32 thread_index,
+nat_ipfix_logging_nat44_ses_create (u32 thread_index,
u32 src_ip,
u32 nat_src_ip,
nat_protocol_t nat_proto,
u32 src_ip,
u32 nat_src_ip,
nat_protocol_t nat_proto,
- snat_ipfix_logging_nat44_ses (thread_index, NAT44_SESSION_CREATE, src_ip,
+ nat_ipfix_logging_nat44_ses (thread_index, NAT44_SESSION_CREATE, src_ip,
nat_src_ip, nat_proto, src_port, nat_src_port,
vrf_id, 0);
}
nat_src_ip, nat_proto, src_port, nat_src_port,
vrf_id, 0);
}
* @param vrf_id VRF ID
*/
void
* @param vrf_id VRF ID
*/
void
-snat_ipfix_logging_nat44_ses_delete (u32 thread_index,
+nat_ipfix_logging_nat44_ses_delete (u32 thread_index,
u32 src_ip,
u32 nat_src_ip,
nat_protocol_t nat_proto,
u32 src_ip,
u32 nat_src_ip,
nat_protocol_t nat_proto,
- snat_ipfix_logging_nat44_ses (thread_index, NAT44_SESSION_DELETE, src_ip,
+ nat_ipfix_logging_nat44_ses (thread_index, NAT44_SESSION_DELETE, src_ip,
nat_src_ip, nat_proto, src_port, nat_src_port,
vrf_id, 0);
}
nat_src_ip, nat_proto, src_port, nat_src_port,
vrf_id, 0);
}
* @param pool_id NAT pool ID
*/
void
* @param pool_id NAT pool ID
*/
void
-snat_ipfix_logging_addresses_exhausted (u32 thread_index, u32 pool_id)
+nat_ipfix_logging_addresses_exhausted (u32 thread_index, u32 pool_id)
{
//TODO: This event SHOULD be rate limited
skip_if_disabled ();
{
//TODO: This event SHOULD be rate limited
skip_if_disabled ();
- snat_ipfix_logging_addr_exhausted (thread_index, pool_id, 0);
+ nat_ipfix_logging_addr_exhausted (thread_index, pool_id, 0);
* @param src_ip source IPv4 address
*/
void
* @param src_ip source IPv4 address
*/
void
-snat_ipfix_logging_max_entries_per_user (u32 thread_index, u32 limit, u32 src_ip)
+nat_ipfix_logging_max_entries_per_user (u32 thread_index, u32 limit, u32 src_ip)
{
//TODO: This event SHOULD be rate limited
skip_if_disabled ();
{
//TODO: This event SHOULD be rate limited
skip_if_disabled ();
- snat_ipfix_logging_max_entries_per_usr (thread_index, limit, src_ip, 0);
+ nat_ipfix_logging_max_entries_per_usr (thread_index, limit, src_ip, 0);
vlib_frame_t * f,
u32 * to_next, u32 node_index)
{
vlib_frame_t * f,
u32 * to_next, u32 node_index)
{
- snat_ipfix_flush_from_main();
+ nat_ipfix_flush_from_main();
data_callback (flow_report_main_t * frm, flow_report_t * fr,
vlib_frame_t * f, u32 * to_next, u32 node_index)
{
data_callback (flow_report_main_t * frm, flow_report_t * fr,
vlib_frame_t * f, u32 * to_next, u32 node_index)
{
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
if (PREDICT_FALSE (++silm->call_counter >= vec_len (frm->reports)))
{
if (PREDICT_FALSE (++silm->call_counter >= vec_len (frm->reports)))
{
- snat_ipfix_flush_from_main();
+ nat_ipfix_flush_from_main();
silm->call_counter = 0;
}
silm->call_counter = 0;
}
* @returns 0 if success
*/
int
* @returns 0 if success
*/
int
-snat_ipfix_logging_enable_disable (int enable, u32 domain_id, u16 src_port)
+nat_ipfix_logging_enable_disable (int enable, u32 domain_id, u16 src_port)
- snat_main_t *sm = &snat_main;
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
flow_report_main_t *frm = &flow_report_main;
vnet_flow_report_add_del_args_t a;
int rv;
flow_report_main_t *frm = &flow_report_main;
vnet_flow_report_add_del_args_t a;
int rv;
a.src_port = src_port ? src_port : UDP_DST_PORT_ipfix;
a.flow_data_callback = data_callback;
a.src_port = src_port ? src_port : UDP_DST_PORT_ipfix;
a.flow_data_callback = data_callback;
- /* TODO: ipfix needs to be separated from NAT base plugin
- a.rewrite_callback = snat_template_rewrite_max_entries_per_usr;
+ a.rewrite_callback = nat_template_rewrite_nat44_session;
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
- */
- a.rewrite_callback = snat_template_rewrite_nat44_session;
-
- rv = vnet_flow_report_add_del (frm, &a, NULL);
- if (rv)
- {
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
- return -1;
- }
-
- a.rewrite_callback = snat_template_rewrite_addr_exhausted;
+ a.rewrite_callback = nat_template_rewrite_addr_exhausted;
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
return -1;
}
a.rewrite_callback = nat_template_rewrite_max_sessions;
return -1;
}
a.rewrite_callback = nat_template_rewrite_max_sessions;
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
return -1;
}
a.rewrite_callback = nat_template_rewrite_max_bibs;
return -1;
}
a.rewrite_callback = nat_template_rewrite_max_bibs;
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
return -1;
}
a.rewrite_callback = nat_template_rewrite_nat64_bib;
return -1;
}
a.rewrite_callback = nat_template_rewrite_nat64_bib;
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
return -1;
}
a.rewrite_callback = nat_template_rewrite_nat64_session;
return -1;
}
a.rewrite_callback = nat_template_rewrite_nat64_session;
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
rv = vnet_flow_report_add_del (frm, &a, NULL);
if (rv)
{
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
- if (sm->endpoint_dependent)
+ // if endpoint dependent per user max entries is also required
+ /*
+ a.rewrite_callback = nat_template_rewrite_max_entries_per_usr;
+ rv = vnet_flow_report_add_del (frm, &a, NULL);
+ if (rv)
- a.rewrite_callback = snat_template_rewrite_max_entries_per_usr;
-
- rv = vnet_flow_report_add_del (frm, &a, NULL);
- if (rv)
- {
- nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
- return -1;
- }
+ //nat_elog_warn_X1 ("vnet_flow_report_add_del returned %d", "i4", rv);
+ return -1;
* @param vm vlib main
*/
void
* @param vm vlib main
*/
void
-snat_ipfix_logging_init (vlib_main_t * vm)
+nat_ipfix_logging_init (vlib_main_t * vm)
- snat_ipfix_logging_main_t *silm = &snat_ipfix_logging_main;
+ nat_ipfix_logging_main_t *silm = &nat_ipfix_logging_main;
vlib_thread_main_t *tm = vlib_get_thread_main ();
silm->enabled = 0;
vlib_thread_main_t *tm = vlib_get_thread_main ();
silm->enabled = 0;
vlib_node_runtime_t *rt,
vlib_frame_t *f)
{
vlib_node_runtime_t *rt,
vlib_frame_t *f)
{
- snat_ipfix_flush(vm->thread_index);
+ nat_ipfix_flush(vm->thread_index);
return 0;
}
/* *INDENT-OFF* */
return 0;
}
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (snat_ipfix_flush_node) = {
+VLIB_REGISTER_NODE (nat_ipfix_flush_node) = {
.function = ipfix_flush_process,
.function = ipfix_flush_process,
- .name = "snat-ipfix-flush",
+ .name = "nat-ipfix-flush",
.type = VLIB_NODE_TYPE_INPUT,
.state = VLIB_NODE_STATE_INTERRUPT,
};
.type = VLIB_NODE_TYPE_INPUT,
.state = VLIB_NODE_STATE_INTERRUPT,
};
- * nat_ipfix_logging.h - NAT Events IPFIX logging
+ * ipfix_logging.h - NAT Events IPFIX logging
*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef __included_nat_ipfix_logging_h__
-#define __included_nat_ipfix_logging_h__
+#ifndef __included_nat_lib_ipfix_logging_h__
+#define __included_nat_lib_ipfix_logging_h__
+#include <vlib/buffer.h>
+#include <vlib/node.h>
+
+#include <nat/lib/lib.h>
typedef enum {
NAT_ADDRESSES_EXHAUTED = 3,
typedef enum {
NAT_ADDRESSES_EXHAUTED = 3,
u32 nat64_bib_next_record_offset;
u32 nat64_ses_next_record_offset;
u32 nat64_bib_next_record_offset;
u32 nat64_ses_next_record_offset;
-} snat_ipfix_per_thread_data_t;
+} nat_ipfix_per_thread_data_t;
typedef struct {
/** NAT plugin IPFIX logging enabled */
typedef struct {
/** NAT plugin IPFIX logging enabled */
f64 vlib_time_0;
/* Per thread data */
f64 vlib_time_0;
/* Per thread data */
- snat_ipfix_per_thread_data_t *per_thread_data;
+ nat_ipfix_per_thread_data_t *per_thread_data;
/** template IDs */
u16 nat44_session_template_id;
/** template IDs */
u16 nat44_session_template_id;
/** nat data callbacks call counter */
u16 call_counter;
/** nat data callbacks call counter */
u16 call_counter;
-} snat_ipfix_logging_main_t;
+} nat_ipfix_logging_main_t;
-extern snat_ipfix_logging_main_t snat_ipfix_logging_main;
+extern nat_ipfix_logging_main_t nat_ipfix_logging_main;
-void snat_ipfix_logging_init (vlib_main_t * vm);
-int snat_ipfix_logging_enable_disable (int enable, u32 domain_id, u16 src_port);
-void snat_ipfix_logging_nat44_ses_create (u32 thread_index, u32 src_ip,
+void nat_ipfix_logging_init (vlib_main_t * vm);
+int nat_ipfix_logging_enable_disable (int enable, u32 domain_id, u16 src_port);
+void nat_ipfix_logging_nat44_ses_create (u32 thread_index, u32 src_ip,
u32 nat_src_ip,
nat_protocol_t nat_proto,
u16 src_port, u16 nat_src_port,
u32 vrf_id);
u32 nat_src_ip,
nat_protocol_t nat_proto,
u16 src_port, u16 nat_src_port,
u32 vrf_id);
-void snat_ipfix_logging_nat44_ses_delete (u32 thread_index, u32 src_ip,
+void nat_ipfix_logging_nat44_ses_delete (u32 thread_index, u32 src_ip,
u32 nat_src_ip,
nat_protocol_t nat_proto,
u16 src_port, u16 nat_src_port,
u32 vrf_id);
u32 nat_src_ip,
nat_protocol_t nat_proto,
u16 src_port, u16 nat_src_port,
u32 vrf_id);
-void snat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id);
-void snat_ipfix_logging_max_entries_per_user(u32 thread_index,
+void nat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id);
+void nat_ipfix_logging_max_entries_per_user(u32 thread_index,
u32 limit, u32 src_ip);
void nat_ipfix_logging_max_sessions(u32 thread_index, u32 limit);
void nat_ipfix_logging_max_bibs(u32 thread_index, u32 limit);
u32 limit, u32 src_ip);
void nat_ipfix_logging_max_sessions(u32 thread_index, u32 limit);
void nat_ipfix_logging_max_bibs(u32 thread_index, u32 limit);
u16 src_port, u16 nat_src_port,
u32 vrf_id, u8 is_create);
u16 src_port, u16 nat_src_port,
u32 vrf_id, u8 is_create);
-#endif /* __included_nat_ipfix_logging_h__ */
+#endif /* __included_nat_lib_ipfix_logging_h__ */
#include <vnet/plugin/plugin.h>
#include <nat/nat.h>
#include <nat/nat_dpo.h>
#include <vnet/plugin/plugin.h>
#include <nat/nat.h>
#include <nat/nat_dpo.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_affinity.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_affinity.h>
if (!is_ha)
{
/* log NAT event */
if (!is_ha)
{
/* log NAT event */
- snat_ipfix_logging_nat44_ses_delete (thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port,
- s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_delete (thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port,
+ s->in2out.fib_index);
nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
s->ext_host_port, s->nat_proto, s->out2in.fib_index,
nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
s->ext_host_port, s->nat_proto, s->out2in.fib_index,
- snat_ipfix_logging_nat44_ses_delete (thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port,
- s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_delete (thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port,
+ s->in2out.fib_index);
nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
s->ext_host_port, s->nat_proto, s->out2in.fib_index,
thread_index);
nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
s->ext_host_port, s->nat_proto, s->out2in.fib_index,
thread_index);
sm->counters.hairpinning.stat_segment_name = "/nat44/hairpinning";
/* Init IPFIX logging */
sm->counters.hairpinning.stat_segment_name = "/nat44/hairpinning";
/* Init IPFIX logging */
- snat_ipfix_logging_init (vm);
+ nat_ipfix_logging_init (vm);
ip4_table_bind_callback_t cbt4 = {
.function = snat_ip4_table_bind,
ip4_table_bind_callback_t cbt4 = {
.function = snat_ip4_table_bind,
}
/* Totally out of translations to use... */
}
/* Totally out of translations to use... */
- snat_ipfix_logging_addresses_exhausted (thread_index, 0);
+ nat_ipfix_logging_addresses_exhausted (thread_index, 0);
exhausted:
/* Totally out of translations to use... */
exhausted:
/* Totally out of translations to use... */
- snat_ipfix_logging_addresses_exhausted (thread_index, 0);
+ nat_ipfix_logging_addresses_exhausted (thread_index, 0);
exhausted:
/* Totally out of translations to use... */
exhausted:
/* Totally out of translations to use... */
- snat_ipfix_logging_addresses_exhausted (thread_index, 0);
+ nat_ipfix_logging_addresses_exhausted (thread_index, 0);
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/lib/nat_inlines.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/lib/nat_inlines.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
{
- rv = snat_ipfix_logging_enable_disable (enable, domain_id,
- (u16) src_port);
+ rv = nat_ipfix_logging_enable_disable (enable, domain_id,
+ (u16) src_port);
if (rv)
return clib_error_return (0, "ipfix logging enable failed");
return 0;
if (rv)
return clib_error_return (0, "ipfix logging enable failed");
return 0;
- rv = snat_ipfix_logging_enable_disable (enable, domain_id, (u16) src_port);
+ rv = nat_ipfix_logging_enable_disable (enable, domain_id, (u16) src_port);
#include <vnet/plugin/plugin.h>
#include <vpp/app/version.h>
#include <vnet/plugin/plugin.h>
#include <vpp/app/version.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat64/nat64.h>
nat64_main_t nat64_main;
#include <nat/nat64/nat64.h>
nat64_main_t nat64_main;
nm->port_per_thread = (0xffff - 1024) / _vec_len (nm->workers);
}
nm->port_per_thread = (0xffff - 1024) / _vec_len (nm->workers);
}
- // TODO: ipfix needs to be separated from NAT base plugin
- //snat_ipfix_logging_init (vm);
+ nat_ipfix_logging_init (vm);
#define _(x) \
nm->counters.in2out.x.name = #x; \
#define _(x) \
nm->counters.in2out.x.name = #x; \
}
/* Totally out of translations to use... */
}
/* Totally out of translations to use... */
- //snat_ipfix_logging_addresses_exhausted (thread_index, 0);
+ nat_ipfix_logging_addresses_exhausted (thread_index, 0);
*/
#include <vnet/fib/fib_table.h>
*/
#include <vnet/fib/fib_table.h>
-//#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat_syslog.h>
#include <nat/lib/inlines.h>
#include <nat/nat64/nat64_db.h>
#include <nat/nat_syslog.h>
#include <nat/lib/inlines.h>
#include <nat/nat64/nat64_db.h>
kv.key[2] = bibe_key.as_u64[2];
clib_bihash_add_del_24_8 (&db->bib.out2in, &kv, 1);
kv.key[2] = bibe_key.as_u64[2];
clib_bihash_add_del_24_8 (&db->bib.out2in, &kv, 1);
- /*fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
- nat_ipfix_logging_nat64_bib (thread_index, in_addr, out_addr, proto,
- in_port, out_port, fib->ft_table_id, 1); */
+ fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
+ nat_ipfix_logging_nat64_bib (thread_index, in_addr, out_addr, proto,
+ in_port, out_port, fib->ft_table_id, 1);
if (!db->addr_free)
db->free_addr_port_cb (db, &bibe->out_addr, bibe->out_port, bibe->proto);
if (!db->addr_free)
db->free_addr_port_cb (db, &bibe->out_addr, bibe->out_port, bibe->proto);
- /*fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
- nat_ipfix_logging_nat64_bib (thread_index, &bibe->in_addr, &bibe->out_addr,
- bibe->proto, bibe->in_port, bibe->out_port,
- fib->ft_table_id, 0); */
+ fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
+ nat_ipfix_logging_nat64_bib (thread_index, &bibe->in_addr, &bibe->out_addr,
+ bibe->proto, bibe->in_port, bibe->out_port,
+ fib->ft_table_id, 0);
/* delete from pool */
pool_put (bib, bibe);
/* delete from pool */
pool_put (bib, bibe);
kv.key[5] = ste_key.as_u64[5];
clib_bihash_add_del_48_8 (&db->st.out2in, &kv, 1);
kv.key[5] = ste_key.as_u64[5];
clib_bihash_add_del_48_8 (&db->st.out2in, &kv, 1);
- /*fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
- nat_ipfix_logging_nat64_session (thread_index, &bibe->in_addr,
- &bibe->out_addr, bibe->proto,
- bibe->in_port, bibe->out_port,
- &ste->in_r_addr, &ste->out_r_addr,
- ste->r_port, ste->r_port, fib->ft_table_id,
- 1); */
+ fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
+ nat_ipfix_logging_nat64_session (thread_index, &bibe->in_addr,
+ &bibe->out_addr, bibe->proto,
+ bibe->in_port, bibe->out_port,
+ &ste->in_r_addr, &ste->out_r_addr,
+ ste->r_port, ste->r_port, fib->ft_table_id,
+ 1);
nat_syslog_nat64_sadd (bibe->fib_index, &bibe->in_addr, bibe->in_port,
&bibe->out_addr, bibe->out_port, &ste->out_r_addr,
ste->r_port, bibe->proto);
nat_syslog_nat64_sadd (bibe->fib_index, &bibe->in_addr, bibe->in_port,
&bibe->out_addr, bibe->out_port, &ste->out_r_addr,
ste->r_port, bibe->proto);
kv.key[5] = ste_key.as_u64[5];
clib_bihash_add_del_48_8 (&db->st.out2in, &kv, 0);
kv.key[5] = ste_key.as_u64[5];
clib_bihash_add_del_48_8 (&db->st.out2in, &kv, 0);
- /*fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
- nat_ipfix_logging_nat64_session (thread_index, &bibe->in_addr,
- &bibe->out_addr, bibe->proto,
- bibe->in_port, bibe->out_port,
- &ste->in_r_addr, &ste->out_r_addr,
- ste->r_port, ste->r_port, fib->ft_table_id,
- 0); */
+ fib_table_t *fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
+ nat_ipfix_logging_nat64_session (thread_index, &bibe->in_addr,
+ &bibe->out_addr, bibe->proto,
+ bibe->in_port, bibe->out_port,
+ &ste->in_r_addr, &ste->out_r_addr,
+ ste->r_port, ste->r_port, fib->ft_table_id,
+ 0);
nat_syslog_nat64_sdel (bibe->fib_index, &bibe->in_addr, bibe->in_port,
&bibe->out_addr, bibe->out_port, &ste->out_r_addr,
ste->r_port, bibe->proto);
nat_syslog_nat64_sdel (bibe->fib_index, &bibe->in_addr, bibe->in_port,
&bibe->out_addr, bibe->out_port, &ste->out_r_addr,
ste->r_port, bibe->proto);
#include <vnet/fib/fib_table.h>
#include <vnet/ip/ip_types_api.h>
#include <nat/nat44/ed_inlines.h>
#include <vnet/fib/fib_table.h>
#include <vnet/ip/ip_types_api.h>
#include <nat/nat44/ed_inlines.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#define vl_api_nat44_add_del_lb_static_mapping_t_endian vl_noop_handler
#define vl_api_nat44_nat44_lb_static_mapping_details_t_endian vl_noop_handler
#define vl_api_nat44_add_del_lb_static_mapping_t_endian vl_noop_handler
#define vl_api_nat44_nat44_lb_static_mapping_details_t_endian vl_noop_handler
vl_api_nat_ipfix_enable_disable_reply_t *rmp;
int rv = 0;
vl_api_nat_ipfix_enable_disable_reply_t *rmp;
int rv = 0;
- rv = snat_ipfix_logging_enable_disable (mp->enable,
- clib_host_to_net_u32
- (mp->domain_id),
- clib_host_to_net_u16
- (mp->src_port));
+ rv = nat_ipfix_logging_enable_disable (mp->enable,
+ clib_host_to_net_u32
+ (mp->domain_id),
+ clib_host_to_net_u16 (mp->src_port));
REPLY_MACRO (VL_API_NAT_IPFIX_ENABLE_DISABLE_REPLY);
}
REPLY_MACRO (VL_API_NAT_IPFIX_ENABLE_DISABLE_REPLY);
}
#include <vnet/ethernet/ethernet.h>
#include <vnet/fib/ip4_fib.h>
#include <nat/nat.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/fib/ip4_fib.h>
#include <nat/nat.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
if (clib_bihash_add_del_8_8 (&tsm->in2out, &s_kv, 0))
nat_elog_warn ("out2in key del failed");
if (clib_bihash_add_del_8_8 (&tsm->in2out, &s_kv, 0))
nat_elog_warn ("out2in key del failed");
- snat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port,
- s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port,
+ s->in2out.fib_index);
nat_syslog_nat44_apmdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_syslog_nat44_apmdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_elog_notice ("out2in key add failed");
/* log NAT event */
nat_elog_notice ("out2in key add failed");
/* log NAT event */
- snat_ipfix_logging_nat44_ses_create (thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port, s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_create (thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port, s->in2out.fib_index);
nat_syslog_nat44_apmadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port, &s->out2in.addr,
nat_syslog_nat44_apmadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port, &s->out2in.addr,
#include <vnet/udp/udp.h>
#include <vppinfra/error.h>
#include <nat/nat.h>
#include <vnet/udp/udp.h>
#include <vppinfra/error.h>
#include <nat/nat.h>
-#include <nat/nat_ipfix_logging.h>
+#include <nat/lib/ipfix_logging.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
#include <nat/nat_syslog.h>
if (snat_is_unk_proto_session (s))
goto delete;
if (snat_is_unk_proto_session (s))
goto delete;
- snat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port,
- s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_delete (ctx->thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port,
+ s->in2out.fib_index);
nat_syslog_nat44_sdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_syslog_nat44_sdel (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
}
/* Totally out of translations to use... */
}
/* Totally out of translations to use... */
- snat_ipfix_logging_addresses_exhausted (thread_index, 0);
+ nat_ipfix_logging_addresses_exhausted (thread_index, 0);
&ctx))
nat_elog_notice ("in2out-ed key add failed");
&ctx))
nat_elog_notice ("in2out-ed key add failed");
- snat_ipfix_logging_nat44_ses_create (thread_index,
- s->in2out.addr.as_u32,
- s->out2in.addr.as_u32,
- s->nat_proto,
- s->in2out.port,
- s->out2in.port, s->in2out.fib_index);
+ nat_ipfix_logging_nat44_ses_create (thread_index,
+ s->in2out.addr.as_u32,
+ s->out2in.addr.as_u32,
+ s->nat_proto,
+ s->in2out.port,
+ s->out2in.port, s->in2out.fib_index);
nat_syslog_nat44_sadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
nat_syslog_nat44_sadd (s->user_index, s->in2out.fib_index,
&s->in2out.addr, s->in2out.port,
self.assert_packet_checksums_valid(p)
return p
self.assert_packet_checksums_valid(p)
return p
- # TODO: ipfix needs to be separated from NAT base plugin
- @unittest.skipUnless(running_extended_tests, "part of extended tests")
def verify_ipfix_max_bibs(self, data, limit):
"""
Verify IPFIX maximum BIB entries exceeded event
def verify_ipfix_max_bibs(self, data, limit):
"""
Verify IPFIX maximum BIB entries exceeded event
# maxBIBEntries
self.assertEqual(struct.pack("I", limit), record[472])
# maxBIBEntries
self.assertEqual(struct.pack("I", limit), record[472])
- # TODO: ipfix needs to be separated from NAT base plugin
- @unittest.skipUnless(running_extended_tests, "part of extended tests")
def verify_ipfix_bib(self, data, is_create, src_addr):
"""
Verify IPFIX NAT64 BIB create and delete events
def verify_ipfix_bib(self, data, is_create, src_addr):
"""
Verify IPFIX NAT64 BIB create and delete events
# postNAPTSourceTransportPort
self.assertEqual(struct.pack("!H", self.tcp_port_out), record[227])
# postNAPTSourceTransportPort
self.assertEqual(struct.pack("!H", self.tcp_port_out), record[227])
- # TODO: ipfix needs to be separated from NAT base plugin
- @unittest.skipUnless(running_extended_tests, "part of extended tests")
def verify_ipfix_nat64_ses(self, data, is_create, src_addr, dst_addr,
dst_port):
"""
def verify_ipfix_nat64_ses(self, data, is_create, src_addr, dst_addr,
dst_port):
"""
packed_pref_n = b''.join([scapy.compat.chb(x) for x in pref_n])
return socket.inet_ntop(socket.AF_INET6, packed_pref_n)
packed_pref_n = b''.join([scapy.compat.chb(x) for x in pref_n])
return socket.inet_ntop(socket.AF_INET6, packed_pref_n)
- # TODO: ipfix needs to be separated from NAT base plugin
- @unittest.skipUnless(running_extended_tests, "part of extended tests")
def verify_ipfix_max_sessions(self, data, limit):
"""
Verify IPFIX maximum session entries exceeded event
def verify_ipfix_max_sessions(self, data, limit):
"""
Verify IPFIX maximum session entries exceeded event
addresses = self.vapi.nat64_pool_addr_dump()
self.assertEqual(0, len(addresses))
addresses = self.vapi.nat64_pool_addr_dump()
self.assertEqual(0, len(addresses))
- # TODO: ipfix needs to be separated from NAT base plugin
@unittest.skipUnless(running_extended_tests, "part of extended tests")
def test_ipfix_max_bibs_sessions(self):
""" IPFIX logging maximum session and BIB entries exceeded """
@unittest.skipUnless(running_extended_tests, "part of extended tests")
def test_ipfix_max_bibs_sessions(self):
""" IPFIX logging maximum session and BIB entries exceeded """
data = ipfix.decode_data_set(p.getlayer(Set))
self.verify_ipfix_max_bibs(data, max_bibs)
data = ipfix.decode_data_set(p.getlayer(Set))
self.verify_ipfix_max_bibs(data, max_bibs)
- # TODO: ipfix needs to be separated from NAT base plugin
- @unittest.skipUnless(running_extended_tests, "part of extended tests")
def test_ipfix_bib_ses(self):
""" IPFIX logging NAT64 BIB/session create and delete events """
self.tcp_port_in = random.randint(1025, 65535)
def test_ipfix_bib_ses(self):
""" IPFIX logging NAT64 BIB/session create and delete events """
self.tcp_port_in = random.randint(1025, 65535)