FD.io VPP  v21.01.1
Vector Packet Processing
nat.h File Reference
+ Include dependency graph for nat.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  nat44_config_t
 
struct  nat_pre_trace_t
 
struct  snat_user_key_t
 
struct  snat_user_t
 
struct  snat_address_t
 
struct  nat_fib_t
 
struct  nat_outside_fib_t
 
struct  nat44_lb_addr_port_t
 
struct  snat_static_mapping_t
 
struct  snat_interface_t
 
struct  snat_static_map_resolve_t
 
struct  snat_main_per_thread_data_t
 
struct  snat_main_s
 
struct  nat44_is_idle_session_ctx_t
 
struct  snat_runtime_t
 
struct  icmp_echo_header_t
 
struct  tcp_udp_header_t
 

Macros

#define NAT_FQ_NELTS   64
 
#define SNAT_FLAG_HAIRPINNING   (1 << 0)
 
#define foreach_nat44_config_flag
 
#define foreach_nat_addr_and_port_alloc_alg
 
#define foreach_snat_session_state
 
#define foreach_nat_in2out_ed_error
 
#define foreach_nat44_handoff_error
 
#define foreach_nat_out2in_ed_error
 
#define NAT44_SES_I2O_FIN   1
 
#define NAT44_SES_O2I_FIN   2
 
#define NAT44_SES_I2O_FIN_ACK   4
 
#define NAT44_SES_O2I_FIN_ACK   8
 
#define NAT44_SES_I2O_SYN   16
 
#define NAT44_SES_O2I_SYN   32
 
#define NAT44_SES_RST   64
 
#define SNAT_SESSION_FLAG_STATIC_MAPPING   1
 
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO   2
 
#define SNAT_SESSION_FLAG_LOAD_BALANCING   4
 
#define SNAT_SESSION_FLAG_TWICE_NAT   8
 
#define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT   16
 
#define SNAT_SESSION_FLAG_FWD_BYPASS   32
 
#define SNAT_SESSION_FLAG_AFFINITY   64
 
#define SNAT_SESSION_FLAG_EXACT_ADDRESS   128
 
#define NAT_INTERFACE_FLAG_IS_INSIDE   1
 
#define NAT_INTERFACE_FLAG_IS_OUTSIDE   2
 
#define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY   1
 
#define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY   2
 
#define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT   4
 
#define NAT_STATIC_MAPPING_FLAG_LB   8
 
#define NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS   16
 
#define foreach_nat_counter   _ (tcp) _ (udp) _ (icmp) _ (other) _ (drops)
 
#define snat_is_session_static(s)   (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING)
 Check if SNAT session is created from static mapping. More...
 
#define snat_is_unk_proto_session(s)   (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO)
 Check if SNAT session for unknown protocol. More...
 
#define is_twice_nat_session(s)   (s->flags & SNAT_SESSION_FLAG_TWICE_NAT)
 Check if NAT session is twice NAT. More...
 
#define is_lb_session(s)   (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING)
 Check if NAT session is load-balancing. More...
 
#define is_fwd_bypass_session(s)   (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS)
 Check if NAT session is forwarding bypass. More...
 
#define is_ed_session(s)   (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT)
 Check if NAT session is endpoint dependent. More...
 
#define is_affinity_sessions(s)   (s->flags & SNAT_SESSION_FLAG_AFFINITY)
 Check if NAT session has affinity record. More...
 
#define is_exact_address_session(s)   (s->flags & SNAT_SESSION_FLAG_EXACT_ADDRESS)
 Check if exact pool address should be used. More...
 
#define nat_interface_is_inside(i)   i->flags & NAT_INTERFACE_FLAG_IS_INSIDE
 Check if NAT interface is inside. More...
 
#define nat_interface_is_outside(i)   i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE
 Check if NAT interface is outside. More...
 
#define nat44_is_ses_closed(s)   s->state == 0xf
 Check if NAT44 endpoint-dependent TCP session is closed. More...
 
#define is_addr_only_static_mapping(sm)   (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY)
 Check if NAT static mapping is address only (1:1NAT). More...
 
#define is_out2in_only_static_mapping(sm)   (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY)
 Check if NAT static mapping match only out2in direction. More...
 
#define is_identity_static_mapping(sm)   (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT)
 Check if NAT static mapping is identity NAT. More...
 
#define is_lb_static_mapping(sm)   (sm->flags & NAT_STATIC_MAPPING_FLAG_LB)
 Check if NAT static mapping is load-balancing. More...
 
#define is_exact_address(s)   (s->flags & NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS)
 Check if exact pool address should be used. More...
 
#define nat_log_err(...)   vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)
 
#define nat_log_warn(...)   vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__)
 
#define nat_log_notice(...)   vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__)
 
#define nat_log_info(...)   vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__)
 
#define nat_log_debug(...)   vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__)
 
#define foreach_nat_log_level
 
#define nat_elog(_level, _str)
 
#define nat_elog_addr(_level, _str, _addr)
 
#define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst)
 
#define nat_elog_debug_handoff_v2(_str, _prt, _fib, _src, _dst)
 
#define nat_elog_X1(_level, _fmt, _arg, _val1)
 
#define nat_elog_notice(nat_elog_str)   nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str)
 
#define nat_elog_warn(nat_elog_str)   nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str)
 
#define nat_elog_err(nat_elog_str)   nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str)
 
#define nat_elog_debug(nat_elog_str)   nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str)
 
#define nat_elog_info(nat_elog_str)   nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str)
 
#define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)   nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
 
#define nat_elog_warn_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)   nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
 
#define nat_elog_err_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)   nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
 
#define nat_elog_debug_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)   nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
 
#define nat_elog_info_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)   nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
 

Typedefs

typedef enum nat44_config_flags_t_ nat44_config_flags_t
 
typedef u32() snat_icmp_match_function_t(struct snat_main_s *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 
typedef u32() snat_get_worker_in2out_function_t(ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
 
typedef u32() snat_get_worker_out2in_function_t(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
 
typedef int() nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
 
typedef struct snat_main_s snat_main_t
 
typedef enum nat_log_level_t_ nat_log_level_t
 

Enumerations

enum  nat44_config_flags_t_ { foreach_nat44_config_flag }
 
enum  nat_next_t {
  NAT_NEXT_DROP, NAT_NEXT_ICMP_ERROR, NAT_NEXT_IN2OUT_ED_FAST_PATH, NAT_NEXT_IN2OUT_ED_SLOW_PATH,
  NAT_NEXT_IN2OUT_ED_OUTPUT_FAST_PATH, NAT_NEXT_IN2OUT_ED_OUTPUT_SLOW_PATH, NAT_NEXT_OUT2IN_ED_FAST_PATH, NAT_NEXT_OUT2IN_ED_SLOW_PATH,
  NAT_NEXT_OUT2IN_ED_HANDOFF, NAT_NEXT_IN2OUT_CLASSIFY, NAT_NEXT_OUT2IN_CLASSIFY, NAT_N_NEXT
}
 
enum  nat_addr_and_port_alloc_alg_t { foreach_nat_addr_and_port_alloc_alg }
 
enum  snat_session_state_t { foreach_snat_session_state }
 
enum  nat_in2out_ed_error_t { NAT_IN2OUT_ED_N_ERROR }
 
enum  nat44_handoff_error_t { NAT44_HANDOFF_N_ERROR }
 
enum  nat_out2in_ed_error_t { NAT_OUT2IN_ED_N_ERROR }
 
enum  twice_nat_type_t { TWICE_NAT_DISABLED, TWICE_NAT, TWICE_NAT_SELF }
 
enum  lb_nat_type_t { NO_LB_NAT, LB_NAT, AFFINITY_LB_NAT }
 
enum  nat_log_level_t_ { foreach_nat_log_level }
 

Functions

typedef CLIB_PACKED (struct { u32 ses_count;u32 rx_fib_index;u32 tx_fib_index;u8 expired;}) per_vrf_sessions_t
 
typedef CLIB_PACKED (struct { struct { ip4_address_t addr;u32 fib_index;u16 port;} out2in;struct { ip4_address_t addr;u32 fib_index;u16 port;} in2out;nat_protocol_t nat_proto;u32 flags;u32 per_user_index;u32 per_user_list_head_index;u32 lru_head_index;u32 lru_index;f64 last_lru_update;f64 last_heard;f64 ha_last_refreshed;u64 total_bytes;u32 total_pkts;ip4_address_t ext_host_addr;u16 ext_host_port;ip4_address_t ext_host_nat_addr;u16 ext_host_nat_port;u8 state;u32 i2o_fin_seq;u32 o2i_fin_seq;u64 tcp_closed_timestamp;u32 user_index;u32 per_vrf_sessions_index;}) snat_session_t
 
static bool tcp_flags_is_init (u8 f)
 Check if client initiating TCP connection (received SYN from client) More...
 
u32 icmp_match_in2out_fast (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 Get address and port values to be used for ICMP packet translation. More...
 
u32 icmp_match_in2out_slow (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 Get address and port values to be used for ICMP packet translation and create session if needed. More...
 
u32 icmp_match_out2in_fast (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 Get address and port values to be used for ICMP packet translation. More...
 
u32 icmp_match_out2in_slow (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 Get address and port values to be used for ICMP packet translation and create session if needed. More...
 
u32 icmp_match_out2in_ed (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 
u32 icmp_match_in2out_ed (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 
u32 icmp_in2out (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
 
u32 icmp_out2in (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
 
u32 snat_icmp_hairpinning (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
 
void nat_hairpinning_sm_unknown_proto (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
 
void nat44_ed_hairpinning_unknown_proto (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
 
int snat_hairpinning (vlib_main_t *vm, vlib_node_runtime_t *node, snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0, int is_ed, int do_trace)
 
int nat44_i2o_ed_is_idle_session_cb (clib_bihash_kv_16_8_t *kv, void *arg)
 
int nat44_o2i_ed_is_idle_session_cb (clib_bihash_kv_16_8_t *kv, void *arg)
 
int nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t *kv, void *arg)
 
int nat44_o2i_is_idle_session_cb (clib_bihash_kv_8_8_t *kv, void *arg)
 
int nat44_plugin_enable (nat44_config_t c)
 Enable NAT44 plugin. More...
 
int nat44_plugin_disable ()
 Disable NAT44 plugin. More...
 
int snat_add_address (snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
 Add external address to NAT44 pool. More...
 
int snat_del_address (snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
 Delete external address from NAT44 pool. More...
 
void nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add)
 Add/delete external address to FIB DPO (out2in DPO mode) More...
 
int snat_add_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, u32 sw_if_index, nat_protocol_t proto, int is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat, ip4_address_t pool_addr, int exact)
 Add/delete NAT44 static mapping. More...
 
int nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u32 affinity)
 Add/delete static mapping with load-balancing (multiple backends) More...
 
int nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port, ip4_address_t l_addr, u16 l_port, nat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add)
 
clib_error_tnat44_api_hookup (vlib_main_t *vm)
 
int snat_set_workers (uword *bitmap)
 Set NAT plugin workers. More...
 
int snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del)
 Enable/disable NAT44 feature on the interface. More...
 
int snat_interface_add_del_output_feature (u32 sw_if_index, u8 is_inside, int is_del)
 Enable/disable NAT44 output feature on the interface (postrouting NAT) More...
 
int snat_add_interface_address (snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
 Add/delete NAT44 pool address from specific interface. More...
 
int nat44_del_session (snat_main_t *sm, ip4_address_t *addr, u16 port, nat_protocol_t proto, u32 vrf_id, int is_in)
 Delete NAT44 session. More...
 
int nat44_del_ed_session (snat_main_t *sm, ip4_address_t *addr, u16 port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 vrf_id, int is_in)
 Delete NAT44 endpoint-dependent session. More...
 
void nat_free_session_data (snat_main_t *sm, snat_session_t *s, u32 thread_index, u8 is_ha)
 Free NAT44 session data (lookup keys, external address port) More...
 
int nat44_set_session_limit (u32 session_limit, u32 vrf_id)
 Set NAT44 session limit (session limit, vrf id) More...
 
int nat44_update_session_limit (u32 session_limit, u32 vrf_id)
 Update NAT44 session limit flushing all data (session limit, vrf id) More...
 
void nat44_db_init (snat_main_per_thread_data_t *tsm)
 Initialize NAT44 data. More...
 
void nat44_db_free (snat_main_per_thread_data_t *tsm)
 Free NAT44 data. More...
 
int nat44_ei_user_del (ip4_address_t *addr, u32 fib_index)
 Delete specific NAT44 EI user and his sessions. More...
 
void nat44_sessions_clear ()
 Free all NAT44 sessions. More...
 
snat_user_tnat_user_get_or_create (snat_main_t *sm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
 Find or create NAT user. More...
 
snat_session_t * nat_session_alloc_or_recycle (snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
 Allocate new NAT session or recycle last used. More...
 
void nat_set_alloc_addr_and_port_mape (u16 psid, u16 psid_offset, u16 psid_length)
 Set address and port assignment algorithm for MAP-E CE. More...
 
void nat_set_alloc_addr_and_port_range (u16 start_port, u16 end_port)
 Set address and port assignment algorithm for port range. More...
 
void nat_set_alloc_addr_and_port_default (void)
 Set address and port assignment algorithm to default/standard. More...
 
void snat_free_outside_address_and_port (snat_address_t *addresses, u32 thread_index, ip4_address_t *addr, u16 port, nat_protocol_t protocol)
 Free outside address and port pair. More...
 
int snat_alloc_outside_address_and_port (snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
 Alloc outside address and port. More...
 
void expire_per_vrf_sessions (u32 fib_index)
 
int snat_static_mapping_match (snat_main_t *sm, ip4_address_t match_addr, u16 match_port, u32 match_fib_index, nat_protocol_t match_protocol, ip4_address_t *mapping_addr, u16 *mapping_port, u32 *mapping_fib_index, u8 by_external, u8 *is_addr_only, twice_nat_type_t *twice_nat, lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_nat, snat_static_mapping_t **out)
 Match NAT44 static mapping. More...
 
void snat_add_del_addr_to_fib (ip4_address_t *addr, u8 p_len, u32 sw_if_index, int is_add)
 Add/del NAT address to FIB. More...
 
void nat_ha_sadd_cb (ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
 
void nat_ha_sdel_cb (ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 ti)
 
void nat_ha_sref_cb (ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
 
void nat_ha_sadd_ed_cb (ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
 
void nat_ha_sdel_ed_cb (ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 ti)
 
void nat_ha_sref_ed_cb (ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
 
u8format_user_kvp (u8 *s, va_list *args)
 

Variables

snat_main_t snat_main
 
vlib_node_registration_t nat_default_node
 (constructor) VLIB_REGISTER_NODE (nat_default_node) More...
 
vlib_node_registration_t nat_pre_in2out_node
 (constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node) More...
 
vlib_node_registration_t nat_pre_out2in_node
 (constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node) More...
 
vlib_node_registration_t snat_in2out_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_node) More...
 
vlib_node_registration_t snat_in2out_output_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_output_node) More...
 
vlib_node_registration_t snat_out2in_node
 (constructor) VLIB_REGISTER_NODE (snat_out2in_node) More...
 
vlib_node_registration_t snat_in2out_worker_handoff_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node) More...
 
vlib_node_registration_t snat_in2out_output_worker_handoff_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node) More...
 
vlib_node_registration_t snat_out2in_worker_handoff_node
 (constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node) More...
 
vlib_node_registration_t nat44_ed_in2out_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node) More...
 
vlib_node_registration_t nat44_ed_in2out_output_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node) More...
 
vlib_node_registration_t nat44_ed_out2in_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node) More...
 
fib_source_t nat_fib_src_hi
 
fib_source_t nat_fib_src_low
 
format_function_t format_snat_user
 
format_function_t format_snat_static_mapping
 
format_function_t format_snat_static_map_to_resolve
 
format_function_t format_snat_session
 
format_function_t format_snat_key
 
format_function_t format_static_mapping_key
 
format_function_t format_nat_protocol
 
format_function_t format_nat_addr_and_port_alloc_alg
 
unformat_function_t unformat_nat_protocol
 

Macro Definition Documentation

◆ foreach_nat44_config_flag

#define foreach_nat44_config_flag
Value:
_(0x00, IS_ENDPOINT_INDEPENDENT) \
_(0x01, IS_ENDPOINT_DEPENDENT) \
_(0x02, IS_STATIC_MAPPING_ONLY) \
_(0x04, IS_CONNECTION_TRACKING) \
_(0x08, IS_OUT2IN_DPO)

Definition at line 46 of file nat.h.

◆ foreach_nat44_handoff_error

#define foreach_nat44_handoff_error
Value:
_(CONGESTION_DROP, "congestion drop") \
_(SAME_WORKER, "same worker") \
_(DO_HANDOFF, "do handoff")

Definition at line 166 of file nat.h.

◆ foreach_nat_addr_and_port_alloc_alg

#define foreach_nat_addr_and_port_alloc_alg
Value:
_(0, DEFAULT, "default") \
_(1, MAPE, "map-e") \
_(2, RANGE, "port-range")

Definition at line 118 of file nat.h.

◆ foreach_nat_counter

#define foreach_nat_counter   _ (tcp) _ (udp) _ (icmp) _ (other) _ (drops)

Definition at line 512 of file nat.h.

◆ foreach_nat_in2out_ed_error

#define foreach_nat_in2out_ed_error
Value:
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_(OUT_OF_PORTS, "out of ports") \
_(BAD_ICMP_TYPE, "unsupported ICMP type") \
_(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
_(NON_SYN, "non-SYN packet try to create session") \
_(TCP_CLOSED, "drops due to TCP in transitory timeout")

Definition at line 150 of file nat.h.

◆ foreach_nat_log_level

#define foreach_nat_log_level
Value:
_(0x00, LOG_NONE) \
_(0x01, LOG_ERROR) \
_(0x02, LOG_WARNING) \
_(0x03, LOG_NOTICE) \
_(0x04, LOG_INFO) \
_(0x05, LOG_DEBUG)

Definition at line 901 of file nat.h.

◆ foreach_nat_out2in_ed_error

#define foreach_nat_out2in_ed_error
Value:
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_(OUT_OF_PORTS, "out of ports") \
_(BAD_ICMP_TYPE, "unsupported ICMP type") \
_(NO_TRANSLATION, "no translation") \
_(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
_(MAX_USER_SESS_EXCEEDED, "max user sessions exceeded") \
_(CANNOT_CREATE_USER, "cannot create NAT user") \
_(NON_SYN, "non-SYN packet try to create session") \
_(TCP_CLOSED, "drops due to TCP in transitory timeout")

Definition at line 179 of file nat.h.

◆ foreach_snat_session_state

#define foreach_snat_session_state
Value:
_(0, UNKNOWN, "unknown") \
_(1, UDP_ACTIVE, "udp-active") \
_(2, TCP_SYN_SENT, "tcp-syn-sent") \
_(3, TCP_ESTABLISHED, "tcp-established") \
_(4, TCP_FIN_WAIT, "tcp-fin-wait") \
_(5, TCP_CLOSE_WAIT, "tcp-close-wait") \
_(6, TCP_CLOSING, "tcp-closing") \
_(7, TCP_LAST_ACK, "tcp-last-ack") \
_(8, TCP_CLOSED, "tcp-closed") \
_(9, ICMP_ACTIVE, "icmp-active")

Definition at line 131 of file nat.h.

◆ is_addr_only_static_mapping

#define is_addr_only_static_mapping (   sm)    (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY)

Check if NAT static mapping is address only (1:1NAT).

Parameters
smNAT static mapping
Returns
1 if 1:1NAT, 0 if 1:1NAPT

Definition at line 852 of file nat.h.

◆ is_affinity_sessions

#define is_affinity_sessions (   s)    (s->flags & SNAT_SESSION_FLAG_AFFINITY)

Check if NAT session has affinity record.

Parameters
sNAT session
Returns
1 if NAT session has affinity record

Definition at line 822 of file nat.h.

◆ is_ed_session

#define is_ed_session (   s)    (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT)

Check if NAT session is endpoint dependent.

Parameters
sNAT session
Returns
1 if NAT session is endpoint dependent

Definition at line 816 of file nat.h.

◆ is_exact_address

#define is_exact_address (   s)    (s->flags & NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS)

Check if exact pool address should be used.

Parameters
sSNAT session
Returns
1 if exact pool address or 0

Definition at line 876 of file nat.h.

◆ is_exact_address_session

#define is_exact_address_session (   s)    (s->flags & SNAT_SESSION_FLAG_EXACT_ADDRESS)

Check if exact pool address should be used.

Parameters
sSNAT session
Returns
1 if exact pool address or 0

Definition at line 828 of file nat.h.

◆ is_fwd_bypass_session

#define is_fwd_bypass_session (   s)    (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS)

Check if NAT session is forwarding bypass.

Parameters
sNAT session
Returns
1 if NAT session is load-balancing

Definition at line 810 of file nat.h.

◆ is_identity_static_mapping

#define is_identity_static_mapping (   sm)    (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT)

Check if NAT static mapping is identity NAT.

Parameters
smNAT static mapping
Returns
1 if identity NAT

Definition at line 864 of file nat.h.

◆ is_lb_session

#define is_lb_session (   s)    (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING)

Check if NAT session is load-balancing.

Parameters
sNAT session
Returns
1 if NAT session is load-balancing

Definition at line 804 of file nat.h.

◆ is_lb_static_mapping

#define is_lb_static_mapping (   sm)    (sm->flags & NAT_STATIC_MAPPING_FLAG_LB)

Check if NAT static mapping is load-balancing.

Parameters
smNAT static mapping
Returns
1 if load-balancing

Definition at line 870 of file nat.h.

◆ is_out2in_only_static_mapping

#define is_out2in_only_static_mapping (   sm)    (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY)

Check if NAT static mapping match only out2in direction.

Parameters
smNAT static mapping
Returns
1 if rule match only out2in direction

Definition at line 858 of file nat.h.

◆ is_twice_nat_session

#define is_twice_nat_session (   s)    (s->flags & SNAT_SESSION_FLAG_TWICE_NAT)

Check if NAT session is twice NAT.

Parameters
sNAT session
Returns
1 if NAT session is twice NAT

Definition at line 798 of file nat.h.

◆ nat44_is_ses_closed

#define nat44_is_ses_closed (   s)    s->state == 0xf

Check if NAT44 endpoint-dependent TCP session is closed.

Parameters
sNAT session
Returns
1 if session is closed

Definition at line 846 of file nat.h.

◆ NAT44_SES_I2O_FIN

#define NAT44_SES_I2O_FIN   1

Definition at line 200 of file nat.h.

◆ NAT44_SES_I2O_FIN_ACK

#define NAT44_SES_I2O_FIN_ACK   4

Definition at line 202 of file nat.h.

◆ NAT44_SES_I2O_SYN

#define NAT44_SES_I2O_SYN   16

Definition at line 204 of file nat.h.

◆ NAT44_SES_O2I_FIN

#define NAT44_SES_O2I_FIN   2

Definition at line 201 of file nat.h.

◆ NAT44_SES_O2I_FIN_ACK

#define NAT44_SES_O2I_FIN_ACK   8

Definition at line 203 of file nat.h.

◆ NAT44_SES_O2I_SYN

#define NAT44_SES_O2I_SYN   32

Definition at line 205 of file nat.h.

◆ NAT44_SES_RST

#define NAT44_SES_RST   64

Definition at line 206 of file nat.h.

◆ nat_elog

#define nat_elog (   _level,
  _str 
)
Value:
do \
{ \
snat_main_t *sm = &snat_main; \
if (PREDICT_FALSE (sm->log_level >= _level)) \
{ \
ELOG_TYPE_DECLARE (e) = \
{ \
.format = "nat-msg " _str, \
.format_args = "", \
}; \
ELOG_DATA (&vlib_global_main.elog_main, e); \
} \
} while (0);
vlib_main_t vlib_global_main
Definition: main.c:2041
#define PREDICT_FALSE(x)
Definition: clib.h:121
snat_main_t snat_main
Definition: nat.c:39
elog_main_t elog_main
Definition: main.h:224

Definition at line 916 of file nat.h.

◆ nat_elog_addr

#define nat_elog_addr (   _level,
  _str,
  _addr 
)
Value:
do \
{ \
if (PREDICT_FALSE (sm->log_level >= _level)) \
{ \
ELOG_TYPE_DECLARE (e) = \
{ \
.format = "nat-msg " _str " %d.%d.%d.%d", \
.format_args = "i1i1i1i1", \
}; \
CLIB_PACKED(struct \
{ \
u8 oct1; \
u8 oct2; \
u8 oct3; \
u8 oct4; \
}) *ed; \
ed->oct4 = _addr >> 24; \
ed->oct3 = _addr >> 16; \
ed->oct2 = _addr >> 8; \
ed->oct1 = _addr; \
} \
} while (0);
vlib_main_t vlib_global_main
Definition: main.c:2041
#define ELOG_DATA(em, f)
Definition: elog.h:484
#define PREDICT_FALSE(x)
Definition: clib.h:121
elog_main_t elog_main
Definition: main.h:224

Definition at line 931 of file nat.h.

◆ nat_elog_debug

#define nat_elog_debug (   nat_elog_str)    nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str)

Definition at line 1062 of file nat.h.

◆ nat_elog_debug_handoff

#define nat_elog_debug_handoff (   _str,
  _tid,
  _fib,
  _src,
  _dst 
)
Value:
do \
{ \
if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \
{ \
ELOG_TYPE_DECLARE (e) = \
{ \
.format = "nat-msg " _str " ip src: %d.%d.%d.%d dst: %d.%d.%d.%d" \
" tid from: %d to: %d fib: %d", \
.format_args = "i1i1i1i1i1i1i1i1i4i4i4", \
}; \
CLIB_PACKED(struct \
{ \
u8 src_oct1; \
u8 src_oct2; \
u8 src_oct3; \
u8 src_oct4; \
u8 dst_oct1; \
u8 dst_oct2; \
u8 dst_oct3; \
u8 dst_oct4; \
u32 ftid; \
u32 ttid; \
u32 fib; \
}) *ed; \
ed->src_oct1 = _src >> 24; \
ed->src_oct2 = _src >> 16; \
ed->src_oct3 = _src >> 8; \
ed->src_oct4 = _src; \
ed->dst_oct1 = _dst >> 24; \
ed->dst_oct2 = _dst >> 16; \
ed->dst_oct3 = _dst >> 8; \
ed->dst_oct4 = _dst; \
ed->ftid = vlib_get_thread_index (); \
ed->ttid = _tid; \
ed->fib = _fib; \
} \
} while (0);
vlib_main_t vlib_global_main
Definition: main.c:2041
#define ELOG_DATA(em, f)
Definition: elog.h:484
#define PREDICT_FALSE(x)
Definition: clib.h:121
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:219
elog_main_t elog_main
Definition: main.h:224

Definition at line 956 of file nat.h.

◆ nat_elog_debug_handoff_v2

#define nat_elog_debug_handoff_v2 (   _str,
  _prt,
  _fib,
  _src,
  _dst 
)
Value:
do \
{ \
if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \
{ \
ELOG_TYPE_DECLARE (e) = \
{ \
.format = "nat-msg " _str " ip_src:%d.%d.%d.%d ip_dst:%d.%d.%d.%d" \
" tid:%d prt:%d fib:%d", \
.format_args = "i1i1i1i1i1i1i1i1i4i4i4", \
}; \
CLIB_PACKED(struct \
{ \
u8 src_oct1; \
u8 src_oct2; \
u8 src_oct3; \
u8 src_oct4; \
u8 dst_oct1; \
u8 dst_oct2; \
u8 dst_oct3; \
u8 dst_oct4; \
u32 tid; \
u32 prt; \
u32 fib; \
}) *ed; \
ed->src_oct1 = _src >> 24; \
ed->src_oct2 = _src >> 16; \
ed->src_oct3 = _src >> 8; \
ed->src_oct4 = _src; \
ed->dst_oct1 = _dst >> 24; \
ed->dst_oct2 = _dst >> 16; \
ed->dst_oct3 = _dst >> 8; \
ed->dst_oct4 = _dst; \
ed->tid = vlib_get_thread_index (); \
ed->prt = _prt; \
ed->fib = _fib; \
} \
} while (0);
vlib_main_t vlib_global_main
Definition: main.c:2041
#define ELOG_DATA(em, f)
Definition: elog.h:484
#define PREDICT_FALSE(x)
Definition: clib.h:121
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:219
elog_main_t elog_main
Definition: main.h:224

Definition at line 996 of file nat.h.

◆ nat_elog_debug_X1

#define nat_elog_debug_X1 (   nat_elog_fmt_str,
  nat_elog_fmt_arg,
  nat_elog_val1 
)    nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)

Definition at line 1073 of file nat.h.

◆ nat_elog_err

#define nat_elog_err (   nat_elog_str)    nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str)

Definition at line 1060 of file nat.h.

◆ nat_elog_err_X1

#define nat_elog_err_X1 (   nat_elog_fmt_str,
  nat_elog_fmt_arg,
  nat_elog_val1 
)    nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)

Definition at line 1071 of file nat.h.

◆ nat_elog_info

#define nat_elog_info (   nat_elog_str)    nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str)

Definition at line 1064 of file nat.h.

◆ nat_elog_info_X1

#define nat_elog_info_X1 (   nat_elog_fmt_str,
  nat_elog_fmt_arg,
  nat_elog_val1 
)    nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)

Definition at line 1075 of file nat.h.

◆ nat_elog_notice

#define nat_elog_notice (   nat_elog_str)    nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str)

Definition at line 1056 of file nat.h.

◆ nat_elog_notice_X1

#define nat_elog_notice_X1 (   nat_elog_fmt_str,
  nat_elog_fmt_arg,
  nat_elog_val1 
)    nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)

Definition at line 1067 of file nat.h.

◆ nat_elog_warn

#define nat_elog_warn (   nat_elog_str)    nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str)

Definition at line 1058 of file nat.h.

◆ nat_elog_warn_X1

#define nat_elog_warn_X1 (   nat_elog_fmt_str,
  nat_elog_fmt_arg,
  nat_elog_val1 
)    nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)

Definition at line 1069 of file nat.h.

◆ nat_elog_X1

#define nat_elog_X1 (   _level,
  _fmt,
  _arg,
  _val1 
)
Value:
do \
{ \
snat_main_t *sm = &snat_main; \
if (PREDICT_FALSE (sm->log_level >= _level)) \
{ \
ELOG_TYPE_DECLARE (e) = \
{ \
.format = "nat-msg " _fmt, \
.format_args = _arg, \
}; \
CLIB_PACKED(struct \
{ \
typeof (_val1) val1; \
}) *ed; \
ed->val1 = _val1; \
} \
} while (0);
vlib_main_t vlib_global_main
Definition: main.c:2041
#define ELOG_DATA(em, f)
Definition: elog.h:484
#define PREDICT_FALSE(x)
Definition: clib.h:121
snat_main_t snat_main
Definition: nat.c:39
elog_main_t elog_main
Definition: main.h:224

Definition at line 1036 of file nat.h.

◆ NAT_FQ_NELTS

#define NAT_FQ_NELTS   64

Definition at line 40 of file nat.h.

◆ NAT_INTERFACE_FLAG_IS_INSIDE

#define NAT_INTERFACE_FLAG_IS_INSIDE   1

Definition at line 219 of file nat.h.

◆ NAT_INTERFACE_FLAG_IS_OUTSIDE

#define NAT_INTERFACE_FLAG_IS_OUTSIDE   2

Definition at line 220 of file nat.h.

◆ nat_interface_is_inside

#define nat_interface_is_inside (   i)    i->flags & NAT_INTERFACE_FLAG_IS_INSIDE

Check if NAT interface is inside.

Parameters
iNAT interface
Returns
1 if inside interface

Definition at line 834 of file nat.h.

◆ nat_interface_is_outside

#define nat_interface_is_outside (   i)    i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE

Check if NAT interface is outside.

Parameters
iNAT interface
Returns
1 if outside interface

Definition at line 840 of file nat.h.

◆ nat_log_debug

#define nat_log_debug (   ...)    vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__)

Definition at line 897 of file nat.h.

◆ nat_log_err

#define nat_log_err (   ...)    vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)

Definition at line 889 of file nat.h.

◆ nat_log_info

#define nat_log_info (   ...)    vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__)

Definition at line 895 of file nat.h.

◆ nat_log_notice

#define nat_log_notice (   ...)    vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__)

Definition at line 893 of file nat.h.

◆ nat_log_warn

#define nat_log_warn (   ...)    vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__)

Definition at line 891 of file nat.h.

◆ NAT_STATIC_MAPPING_FLAG_ADDR_ONLY

#define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY   1

Definition at line 223 of file nat.h.

◆ NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS

#define NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS   16

Definition at line 227 of file nat.h.

◆ NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT

#define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT   4

Definition at line 225 of file nat.h.

◆ NAT_STATIC_MAPPING_FLAG_LB

#define NAT_STATIC_MAPPING_FLAG_LB   8

Definition at line 226 of file nat.h.

◆ NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY

#define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY   2

Definition at line 224 of file nat.h.

◆ SNAT_FLAG_HAIRPINNING

#define SNAT_FLAG_HAIRPINNING   (1 << 0)

Definition at line 43 of file nat.h.

◆ snat_is_session_static

#define snat_is_session_static (   s)    (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING)

Check if SNAT session is created from static mapping.

Parameters
sSNAT session
Returns
1 if SNAT session is created from static mapping otherwise 0

Definition at line 786 of file nat.h.

◆ snat_is_unk_proto_session

#define snat_is_unk_proto_session (   s)    (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO)

Check if SNAT session for unknown protocol.

Parameters
sSNAT session
Returns
1 if SNAT session for unknown protocol otherwise 0

Definition at line 792 of file nat.h.

◆ SNAT_SESSION_FLAG_AFFINITY

#define SNAT_SESSION_FLAG_AFFINITY   64

Definition at line 215 of file nat.h.

◆ SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT

#define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT   16

Definition at line 213 of file nat.h.

◆ SNAT_SESSION_FLAG_EXACT_ADDRESS

#define SNAT_SESSION_FLAG_EXACT_ADDRESS   128

Definition at line 216 of file nat.h.

◆ SNAT_SESSION_FLAG_FWD_BYPASS

#define SNAT_SESSION_FLAG_FWD_BYPASS   32

Definition at line 214 of file nat.h.

◆ SNAT_SESSION_FLAG_LOAD_BALANCING

#define SNAT_SESSION_FLAG_LOAD_BALANCING   4

Definition at line 211 of file nat.h.

◆ SNAT_SESSION_FLAG_STATIC_MAPPING

#define SNAT_SESSION_FLAG_STATIC_MAPPING   1

Definition at line 209 of file nat.h.

◆ SNAT_SESSION_FLAG_TWICE_NAT

#define SNAT_SESSION_FLAG_TWICE_NAT   8

Definition at line 212 of file nat.h.

◆ SNAT_SESSION_FLAG_UNKNOWN_PROTO

#define SNAT_SESSION_FLAG_UNKNOWN_PROTO   2

Definition at line 210 of file nat.h.

Typedef Documentation

◆ nat44_config_flags_t

◆ nat_alloc_out_addr_and_port_function_t

typedef int() nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)

Definition at line 502 of file nat.h.

◆ nat_log_level_t

◆ snat_get_worker_in2out_function_t

typedef u32() snat_get_worker_in2out_function_t(ip4_header_t *ip, u32 rx_fib_index, u8 is_output)

Definition at line 492 of file nat.h.

◆ snat_get_worker_out2in_function_t

typedef u32() snat_get_worker_out2in_function_t(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)

Definition at line 496 of file nat.h.

◆ snat_icmp_match_function_t

typedef u32() snat_icmp_match_function_t(struct snat_main_s *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)

Definition at line 479 of file nat.h.

◆ snat_main_t

typedef struct snat_main_s snat_main_t

Enumeration Type Documentation

◆ lb_nat_type_t

Enumerator
NO_LB_NAT 
LB_NAT 
AFFINITY_LB_NAT 

Definition at line 369 of file nat.h.

◆ nat44_config_flags_t_

Enumerator
foreach_nat44_config_flag 

Definition at line 53 of file nat.h.

◆ nat44_handoff_error_t

Enumerator
NAT44_HANDOFF_N_ERROR 

Definition at line 171 of file nat.h.

◆ nat_addr_and_port_alloc_alg_t

Enumerator
foreach_nat_addr_and_port_alloc_alg 

Definition at line 123 of file nat.h.

◆ nat_in2out_ed_error_t

Enumerator
NAT_IN2OUT_ED_N_ERROR 

Definition at line 158 of file nat.h.

◆ nat_log_level_t_

Enumerator
foreach_nat_log_level 

Definition at line 909 of file nat.h.

◆ nat_next_t

enum nat_next_t
Enumerator
NAT_NEXT_DROP 
NAT_NEXT_ICMP_ERROR 
NAT_NEXT_IN2OUT_ED_FAST_PATH 
NAT_NEXT_IN2OUT_ED_SLOW_PATH 
NAT_NEXT_IN2OUT_ED_OUTPUT_FAST_PATH 
NAT_NEXT_IN2OUT_ED_OUTPUT_SLOW_PATH 
NAT_NEXT_OUT2IN_ED_FAST_PATH 
NAT_NEXT_OUT2IN_ED_SLOW_PATH 
NAT_NEXT_OUT2IN_ED_HANDOFF 
NAT_NEXT_IN2OUT_CLASSIFY 
NAT_NEXT_OUT2IN_CLASSIFY 
NAT_N_NEXT 

Definition at line 81 of file nat.h.

◆ nat_out2in_ed_error_t

Enumerator
NAT_OUT2IN_ED_N_ERROR 

Definition at line 190 of file nat.h.

◆ snat_session_state_t

Enumerator
foreach_snat_session_state 

Definition at line 143 of file nat.h.

◆ twice_nat_type_t

Enumerator
TWICE_NAT_DISABLED 
TWICE_NAT 
TWICE_NAT_SELF 

Definition at line 359 of file nat.h.

Function Documentation

◆ CLIB_PACKED() [1/2]

typedef CLIB_PACKED ( struct { u32 ses_count;u32 rx_fib_index;u32 tx_fib_index;u8 expired;}  )

◆ CLIB_PACKED() [2/2]

typedef CLIB_PACKED ( struct { struct { ip4_address_t addr;u32 fib_index;u16 port;} out2in;struct { ip4_address_t addr;u32 fib_index;u16 port;} in2out;nat_protocol_t nat_proto;u32 flags;u32 per_user_index;u32 per_user_list_head_index;u32 lru_head_index;u32 lru_index;f64 last_lru_update;f64 last_heard;f64 ha_last_refreshed;u64 total_bytes;u32 total_pkts;ip4_address_t ext_host_addr;u16 ext_host_port;ip4_address_t ext_host_nat_addr;u16 ext_host_nat_port;u8 state;u32 i2o_fin_seq;u32 o2i_fin_seq;u64 tcp_closed_timestamp;u32 user_index;u32 per_vrf_sessions_index;}  )

◆ expire_per_vrf_sessions()

void expire_per_vrf_sessions ( u32  fib_index)

Definition at line 1917 of file nat.c.

+ Here is the caller graph for this function:

◆ format_user_kvp()

u8* format_user_kvp ( u8 s,
va_list *  args 
)

Definition at line 222 of file nat.c.

+ Here is the caller graph for this function:

◆ icmp_in2out()

u32 icmp_in2out ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
icmp46_header_t *  icmp0,
u32  sw_if_index0,
u32  rx_fib_index0,
vlib_node_runtime_t node,
u32  next0,
u32  thread_index,
void *  d,
void *  e 
)

Definition at line 642 of file in2out.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_match_in2out_ed()

u32 icmp_match_in2out_ed ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

Definition at line 646 of file in2out_ed.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_match_in2out_fast()

u32 icmp_match_in2out_fast ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

Get address and port values to be used for ICMP packet translation.

Parameters
[in]smNAT main
[in,out]nodeNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[in,out]ip0ip header
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 572 of file in2out.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_match_in2out_slow()

u32 icmp_match_in2out_slow ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

Get address and port values to be used for ICMP packet translation and create session if needed.

Parameters
[in,out]smNAT main
[in,out]nodeNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[in,out]ip0ip header
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 453 of file in2out.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_match_out2in_ed()

u32 icmp_match_out2in_ed ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

Definition at line 543 of file out2in_ed.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_match_out2in_fast()

u32 icmp_match_out2in_fast ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t mapping_addr,
u16 mapping_port,
u32 mapping_fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

Get address and port values to be used for ICMP packet translation.

Parameters
[in]smNAT main
[in,out]nodeNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[in,out]ip0ip header
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 459 of file out2in.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_match_out2in_slow()

u32 icmp_match_out2in_slow ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

Get address and port values to be used for ICMP packet translation and create session if needed.

Parameters
[in,out]smNAT main
[in,out]nodeNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[in,out]ip0ip header
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 318 of file out2in.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icmp_out2in()

u32 icmp_out2in ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
icmp46_header_t *  icmp0,
u32  sw_if_index0,
u32  rx_fib_index0,
vlib_node_runtime_t node,
u32  next0,
u32  thread_index,
void *  d,
void *  e 
)

Definition at line 519 of file out2in.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_add_del_address_dpo()

void nat44_add_del_address_dpo ( ip4_address_t  addr,
u8  is_add 
)

Add/delete external address to FIB DPO (out2in DPO mode)

Parameters
addrIPv4 address
is_add1 = add, 0 = delete
Returns
0 on success, non-zero value otherwise

Definition at line 3545 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_add_del_lb_static_mapping()

int nat44_add_del_lb_static_mapping ( ip4_address_t  e_addr,
u16  e_port,
nat_protocol_t  proto,
nat44_lb_addr_port_t locals,
u8  is_add,
twice_nat_type_t  twice_nat,
u8  out2in_only,
u8 tag,
u32  affinity 
)

Add/delete static mapping with load-balancing (multiple backends)

Parameters
e_addrexternal IPv4 address
e_portexternal port number
protoL4 protocol
localslist of local backends
is_add1 = add, 0 = delete
twice_nattwice-nat mode
out2in_onlyif 1 rule match only out2in direction
tagopaque string tag
affinity0 = disabled, otherwise client IP affinity sticky time
Returns
0 on success, non-zero value otherwise

Definition at line 1365 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_api_hookup()

clib_error_t* nat44_api_hookup ( vlib_main_t vm)

Definition at line 1706 of file nat44_api.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_db_free()

void nat44_db_free ( snat_main_per_thread_data_t tsm)

Free NAT44 data.

Parameters
tsmper thread data

Definition at line 4347 of file nat.c.

+ Here is the caller graph for this function:

◆ nat44_db_init()

void nat44_db_init ( snat_main_per_thread_data_t tsm)

Initialize NAT44 data.

Parameters
tsmper thread data

Definition at line 4288 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_del_ed_session()

int nat44_del_ed_session ( snat_main_t sm,
ip4_address_t addr,
u16  port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  vrf_id,
int  is_in 
)

Delete NAT44 endpoint-dependent session.

Parameters
smsnat global configuration data
addrIPv4 address
portL4 port number
protoL4 protocol
vrf_idVRF ID
is_in1 = inside network address and port pair, 0 = outside
Returns
0 on success, non-zero value otherwise

Definition at line 4660 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_del_session()

int nat44_del_session ( snat_main_t sm,
ip4_address_t addr,
u16  port,
nat_protocol_t  proto,
u32  vrf_id,
int  is_in 
)

Delete NAT44 session.

Parameters
addrIPv4 address
portL4 port number
protoL4 protocol
vrf_idVRF ID
is_in1 = inside network address and port pair, 0 = outside
Returns
0 on success, non-zero value otherwise

Definition at line 4622 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_ed_hairpinning_unknown_proto()

void nat44_ed_hairpinning_unknown_proto ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip 
)

Definition at line 412 of file nat44_hairpinning.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_ei_user_del()

int nat44_ei_user_del ( ip4_address_t addr,
u32  fib_index 
)

Delete specific NAT44 EI user and his sessions.

Parameters
addrIPv4 address
fib_indexFIB table index

Definition at line 328 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_i2o_ed_is_idle_session_cb()

int nat44_i2o_ed_is_idle_session_cb ( clib_bihash_kv_16_8_t kv,
void *  arg 
)

Definition at line 75 of file in2out_ed.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_i2o_is_idle_session_cb()

int nat44_i2o_is_idle_session_cb ( clib_bihash_kv_8_8_t kv,
void *  arg 
)

Definition at line 188 of file in2out.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_lb_static_mapping_add_del_local()

int nat44_lb_static_mapping_add_del_local ( ip4_address_t  e_addr,
u16  e_port,
ip4_address_t  l_addr,
u16  l_port,
nat_protocol_t  proto,
u32  vrf_id,
u8  probability,
u8  is_add 
)

Definition at line 1599 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_o2i_ed_is_idle_session_cb()

int nat44_o2i_ed_is_idle_session_cb ( clib_bihash_kv_16_8_t kv,
void *  arg 
)

Definition at line 98 of file out2in_ed.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_o2i_is_idle_session_cb()

int nat44_o2i_is_idle_session_cb ( clib_bihash_kv_8_8_t kv,
void *  arg 
)

Definition at line 104 of file out2in.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_plugin_disable()

int nat44_plugin_disable ( )

Disable NAT44 plugin.

Returns
0 on success, non-zero value otherwise

Definition at line 3009 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_plugin_enable()

int nat44_plugin_enable ( nat44_config_t  c)

Enable NAT44 plugin.

Parameters
cnat44_config_t
Returns
0 on success, non-zero value otherwise

Definition at line 2843 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_sessions_clear()

void nat44_sessions_clear ( )

Free all NAT44 sessions.

Definition at line 4372 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_set_session_limit()

int nat44_set_session_limit ( u32  session_limit,
u32  vrf_id 
)

Set NAT44 session limit (session limit, vrf id)

Parameters
session_limitSession limit
vrf_idVRF id
Returns
0 on success, non-zero value otherwise

Definition at line 4253 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat44_update_session_limit()

int nat44_update_session_limit ( u32  session_limit,
u32  vrf_id 
)

Update NAT44 session limit flushing all data (session limit, vrf id)

Parameters
session_limitSession limit
vrf_idVRF id
Returns
0 on success, non-zero value otherwise

Definition at line 4272 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_free_session_data()

void nat_free_session_data ( snat_main_t sm,
snat_session_t *  s,
u32  thread_index,
u8  is_ha 
)

Free NAT44 session data (lookup keys, external address port)

Parameters
smsnat global configuration data
sNAT session
thread_indexthread index
is_hais HA event

Definition at line 376 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_ha_sadd_cb()

void nat_ha_sadd_cb ( ip4_address_t in_addr,
u16  in_port,
ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
ip4_address_t ehn_addr,
u16  ehn_port,
u8  proto,
u32  fib_index,
u16  flags,
u32  thread_index 
)

Definition at line 3932 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_ha_sadd_ed_cb()

void nat_ha_sadd_ed_cb ( ip4_address_t in_addr,
u16  in_port,
ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
ip4_address_t ehn_addr,
u16  ehn_port,
u8  proto,
u32  fib_index,
u16  flags,
u32  thread_index 
)

Definition at line 4071 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_ha_sdel_cb()

void nat_ha_sdel_cb ( ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  fib_index,
u32  ti 
)

Definition at line 4021 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_ha_sdel_ed_cb()

void nat_ha_sdel_ed_cb ( ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  fib_index,
u32  ti 
)

Definition at line 4168 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_ha_sref_cb()

void nat_ha_sref_cb ( ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  fib_index,
u32  total_pkts,
u64  total_bytes,
u32  thread_index 
)

Definition at line 4050 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_ha_sref_ed_cb()

void nat_ha_sref_ed_cb ( ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  fib_index,
u32  total_pkts,
u64  total_bytes,
u32  thread_index 
)

Definition at line 4197 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_hairpinning_sm_unknown_proto()

void nat_hairpinning_sm_unknown_proto ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip 
)

Definition at line 385 of file nat44_hairpinning.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_session_alloc_or_recycle()

snat_session_t* nat_session_alloc_or_recycle ( snat_main_t sm,
snat_user_t u,
u32  thread_index,
f64  now 
)

Allocate new NAT session or recycle last used.

Parameters
smsnat global configuration data
uNAT user
thread_indexthread index
nowtime now
Returns
session data structure on success otherwise zero value

Definition at line 574 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_set_alloc_addr_and_port_default()

void nat_set_alloc_addr_and_port_default ( void  )

Set address and port assignment algorithm to default/standard.

Definition at line 4721 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_set_alloc_addr_and_port_mape()

void nat_set_alloc_addr_and_port_mape ( u16  psid,
u16  psid_offset,
u16  psid_length 
)

Set address and port assignment algorithm for MAP-E CE.

Parameters
psidPort Set Identifier value
psid_offsetnumber of offset bits
psid_lengthlength of PSID

Definition at line 4698 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_set_alloc_addr_and_port_range()

void nat_set_alloc_addr_and_port_range ( u16  start_port,
u16  end_port 
)

Set address and port assignment algorithm for port range.

Parameters
start_portbeginning of the port range
end_portend of the port range

Definition at line 4710 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat_user_get_or_create()

snat_user_t* nat_user_get_or_create ( snat_main_t sm,
ip4_address_t addr,
u32  fib_index,
u32  thread_index 
)

Find or create NAT user.

Parameters
smsnat global configuration data
addrIPv4 address
fib_indexFIB table index
thread_indexthread index
Returns
NAT user data structure on success otherwise zero value

Definition at line 514 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_add_address()

int snat_add_address ( snat_main_t sm,
ip4_address_t addr,
u32  vrf_id,
u8  twice_nat 
)

Add external address to NAT44 pool.

Parameters
smsnat global configuration data
addrIPv4 address
vrf_idVRF id of tenant, ~0 means independent of VRF
twice_nat1 if twice NAT address
Returns
0 on success, non-zero value otherwise

Definition at line 680 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_add_del_addr_to_fib()

void snat_add_del_addr_to_fib ( ip4_address_t addr,
u8  p_len,
u32  sw_if_index,
int  is_add 
)

Add/del NAT address to FIB.

Add the external NAT address to the FIB as receive entries. This ensures that VPP will reply to ARP for this address and we don't need to enable proxy ARP on the outside interface.

Parameters
addrIPv4 address
plenaddress prefix length
sw_if_indexsoftware index of the outside interface
is_add0 = delete, 1 = add.

Definition at line 651 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_add_interface_address()

int snat_add_interface_address ( snat_main_t sm,
u32  sw_if_index,
int  is_del,
u8  twice_nat 
)

Add/delete NAT44 pool address from specific interface.

Parameters
sw_if_indexsoftware index of the interface
is_del1 = delete, 0 = add
twice_nat1 = twice NAT address for external hosts
Returns
0 on success, non-zero value otherwise

Definition at line 4554 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_add_static_mapping()

int snat_add_static_mapping ( ip4_address_t  l_addr,
ip4_address_t  e_addr,
u16  l_port,
u16  e_port,
u32  vrf_id,
int  addr_only,
u32  sw_if_index,
nat_protocol_t  proto,
int  is_add,
twice_nat_type_t  twice_nat,
u8  out2in_only,
u8 tag,
u8  identity_nat,
ip4_address_t  pool_addr,
int  exact 
)

Add/delete NAT44 static mapping.

Parameters
l_addrlocal IPv4 address
e_addrexternal IPv4 address
l_portlocal port number
e_portexternal port number
vrf_idlocal VRF ID
addr_only1 = 1:1NAT, 0 = 1:1NAPT
sw_if_indexuse interface address as external IPv4 address
protoL4 protocol
is_add1 = add, 0 = delete
twice_nattwice-nat mode
out2in_onlyif 1 rule match only out2in direction
tagopaque string tag
identity_natidentity NAT
pool_addrpool IPv4 address
exact1 = exact pool address
Returns
0 on success, non-zero value otherwise

Definition at line 920 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_alloc_outside_address_and_port()

int snat_alloc_outside_address_and_port ( snat_address_t addresses,
u32  fib_index,
u32  thread_index,
nat_protocol_t  proto,
ip4_address_t addr,
u16 port,
u16  port_per_thread,
u32  snat_thread_index 
)

Alloc outside address and port.

Parameters
addressesvector of outside addresses
fib_indexFIB table index
thread_indexthread index
port_per_threadnumber of ports per thread
snat_thread_indexNAT thread index
Returns
0 on success, non-zero value otherwise

Definition at line 3343 of file nat.c.

+ Here is the caller graph for this function:

◆ snat_del_address()

int snat_del_address ( snat_main_t sm,
ip4_address_t  addr,
u8  delete_sm,
u8  twice_nat 
)

Delete external address from NAT44 pool.

Parameters
smsnat global configuration data
addrIPv4 address
delete_sm1 if delete static mapping using address
twice_nat1 if twice NAT address
Returns
0 on success, non-zero value otherwise

Definition at line 1750 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_free_outside_address_and_port()

void snat_free_outside_address_and_port ( snat_address_t addresses,
u32  thread_index,
ip4_address_t addr,
u16  port,
nat_protocol_t  protocol 
)

Free outside address and port pair.

Parameters
addressesvector of outside addresses
thread_indexthread index
keyaddress, port and protocol

Definition at line 3108 of file nat.c.

+ Here is the caller graph for this function:

◆ snat_hairpinning()

int snat_hairpinning ( vlib_main_t vm,
vlib_node_runtime_t node,
snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
udp_header_t udp0,
tcp_header_t tcp0,
u32  proto0,
int  is_ed,
int  do_trace 
)

Definition at line 97 of file nat44_hairpinning.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_icmp_hairpinning()

u32 snat_icmp_hairpinning ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
icmp46_header_t *  icmp0,
int  is_ed 
)

Definition at line 240 of file nat44_hairpinning.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_interface_add_del()

int snat_interface_add_del ( u32  sw_if_index,
u8  is_inside,
int  is_del 
)

Enable/disable NAT44 feature on the interface.

Parameters
sw_if_indexsoftware index of the interface
is_inside1 = inside, 0 = outside
is_del1 = delete, 0 = add
Returns
0 on success, non-zero value otherwise

Definition at line 1976 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_interface_add_del_output_feature()

int snat_interface_add_del_output_feature ( u32  sw_if_index,
u8  is_inside,
int  is_del 
)

Enable/disable NAT44 output feature on the interface (postrouting NAT)

Parameters
sw_if_indexsoftware index of the interface
is_inside1 = inside, 0 = outside
is_del1 = delete, 0 = add
Returns
0 on success, non-zero value otherwise

Definition at line 2242 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_set_workers()

int snat_set_workers ( uword bitmap)

Set NAT plugin workers.

Parameters
bitmapNAT workers bitmap
Returns
0 on success, non-zero value otherwise

Definition at line 2457 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snat_static_mapping_match()

int snat_static_mapping_match ( snat_main_t sm,
ip4_address_t  match_addr,
u16  match_port,
u32  match_fib_index,
nat_protocol_t  match_protocol,
ip4_address_t mapping_addr,
u16 mapping_port,
u32 mapping_fib_index,
u8  by_external,
u8 is_addr_only,
twice_nat_type_t twice_nat,
lb_nat_type_t lb,
ip4_address_t ext_host_addr,
u8 is_identity_nat,
snat_static_mapping_t **  out 
)

Match NAT44 static mapping.

Parameters
keyaddress and port to match
addrexternal/local address of the matched mapping
portport of the matched mapping
fib_indexfib index of the matched mapping
by_externalif 0 match by local address otherwise match by external address
is_addr_only1 if matched mapping is address only
twice_natmatched mapping is twice NAT type
lb1 if matched mapping is load-balanced
ext_host_addrexternal host address
is_identity_nat1 if indentity mapping
outif !=0 set to pointer of the mapping structure
Returns
0 if match found otherwise 1.

Definition at line 3183 of file nat.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_flags_is_init()

static bool tcp_flags_is_init ( u8  f)
inlinestatic

Check if client initiating TCP connection (received SYN from client)

Parameters
tTCP header
Returns
1 if client initiating TCP connection

Definition at line 883 of file nat.h.

+ Here is the caller graph for this function:

Variable Documentation

◆ format_nat_addr_and_port_alloc_alg

format_function_t format_nat_addr_and_port_alloc_alg

Definition at line 778 of file nat.h.

◆ format_nat_protocol

format_function_t format_nat_protocol

Definition at line 777 of file nat.h.

◆ format_snat_key

format_function_t format_snat_key

Definition at line 775 of file nat.h.

◆ format_snat_session

format_function_t format_snat_session

Definition at line 774 of file nat.h.

◆ format_snat_static_map_to_resolve

format_function_t format_snat_static_map_to_resolve

Definition at line 773 of file nat.h.

◆ format_snat_static_mapping

format_function_t format_snat_static_mapping

Definition at line 772 of file nat.h.

◆ format_snat_user

format_function_t format_snat_user

Definition at line 771 of file nat.h.

◆ format_static_mapping_key

format_function_t format_static_mapping_key

Definition at line 776 of file nat.h.

◆ nat44_ed_in2out_node

vlib_node_registration_t nat44_ed_in2out_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)

Definition at line 1496 of file in2out_ed.c.

◆ nat44_ed_in2out_output_node

vlib_node_registration_t nat44_ed_in2out_output_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)

Definition at line 1516 of file in2out_ed.c.

◆ nat44_ed_out2in_node

vlib_node_registration_t nat44_ed_out2in_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)

Definition at line 1511 of file out2in_ed.c.

◆ nat_default_node

vlib_node_registration_t nat_default_node

(constructor) VLIB_REGISTER_NODE (nat_default_node)

Definition at line 4737 of file nat.c.

◆ nat_fib_src_hi

fib_source_t nat_fib_src_hi

Definition at line 22 of file dslite.c.

◆ nat_fib_src_low

fib_source_t nat_fib_src_low

◆ nat_pre_in2out_node

vlib_node_registration_t nat_pre_in2out_node

(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)

Definition at line 1594 of file in2out_ed.c.

◆ nat_pre_out2in_node

vlib_node_registration_t nat_pre_out2in_node

(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)

Definition at line 1591 of file out2in_ed.c.

◆ snat_in2out_node

vlib_node_registration_t snat_in2out_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_node)

Definition at line 1642 of file in2out.c.

◆ snat_in2out_output_node

vlib_node_registration_t snat_in2out_output_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)

Definition at line 1674 of file in2out.c.

◆ snat_in2out_output_worker_handoff_node

vlib_node_registration_t snat_in2out_output_worker_handoff_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)

Definition at line 294 of file nat44_handoff.c.

◆ snat_in2out_worker_handoff_node

vlib_node_registration_t snat_in2out_worker_handoff_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)

Definition at line 274 of file nat44_handoff.c.

◆ snat_main

snat_main_t snat_main

Definition at line 39 of file nat.c.

◆ snat_out2in_node

vlib_node_registration_t snat_out2in_node

(constructor) VLIB_REGISTER_NODE (snat_out2in_node)

Definition at line 1374 of file out2in.c.

◆ snat_out2in_worker_handoff_node

vlib_node_registration_t snat_out2in_worker_handoff_node

(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)

Definition at line 313 of file nat44_handoff.c.

◆ unformat_nat_protocol

unformat_function_t unformat_nat_protocol

Definition at line 780 of file nat.h.