FD.io VPP  v18.07.1-19-g511ce25
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  snat_session_key_t
 
struct  nat_ed_ses_key_t
 
struct  snat_det_out_key_t
 
struct  snat_user_key_t
 
struct  snat_user_t
 
struct  snat_address_t
 
struct  nat_outside_fib_t
 
struct  snat_det_session_t
 
struct  snat_det_map_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  snat_runtime_t
 
struct  icmp_echo_header_t
 
struct  tcp_udp_header_t
 

Macros

#define SNAT_UDP_TIMEOUT   300
 
#define SNAT_UDP_TIMEOUT_MIN   120
 
#define SNAT_TCP_TRANSITORY_TIMEOUT   240
 
#define SNAT_TCP_ESTABLISHED_TIMEOUT   7440
 
#define SNAT_TCP_INCOMING_SYN   6
 
#define SNAT_ICMP_TIMEOUT   60
 
#define NAT_FQ_NELTS   64
 
#define SNAT_FLAG_HAIRPINNING   (1 << 0)
 
#define foreach_snat_protocol
 
#define foreach_snat_session_state
 
#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_is_ses_closed(s)   s->state == 0xf
 
#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 NAT_INTERFACE_FLAG_IS_INSIDE   1
 
#define NAT_INTERFACE_FLAG_IS_OUTSIDE   2
 
#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 nat_interface_is_inside(i)   i->flags & NAT_INTERFACE_FLAG_IS_INSIDE
 
#define nat_interface_is_outside(i)   i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE
 
#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__)
 

Typedefs

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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 
typedef u32snat_get_worker_function_t) (ip4_header_t *ip, u32 rx_fib_index)
 
typedef int nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp, u16 port_per_thread, u32 snat_thread_index)
 
typedef struct snat_main_s snat_main_t
 

Enumerations

enum  snat_protocol_t { foreach_snat_protocol }
 
enum  snat_session_state_t { foreach_snat_session_state }
 
enum  twice_nat_type_t { TWICE_NAT_DISABLED, TWICE_NAT, TWICE_NAT_SELF }
 

Functions

typedef CLIB_PACKED (struct{snat_session_key_t out2in;snat_session_key_t in2out;u32 flags;u32 per_user_index;u32 per_user_list_head_index;f64 last_heard;u64 total_bytes;u32 total_pkts;u32 outside_address_index;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;}) snat_session_t
 
void snat_free_outside_address_and_port (snat_address_t *addresses, u32 thread_index, snat_session_key_t *k)
 
int snat_alloc_outside_address_and_port (snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp, u16 port_per_thread, u32 snat_thread_index)
 
int snat_static_mapping_match (snat_main_t *sm, snat_session_key_t match, snat_session_key_t *mapping, u8 by_external, u8 *is_addr_only, twice_nat_type_t *twice_nat, u8 *lb)
 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...
 
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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 Get address and port values to be used for ICMP packet translation and create session if needed. More...
 
u32 icmp_match_in2out_det (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 Get address and port values to be used for ICMP packet translation and create session if needed. More...
 
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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 
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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 Get address and port values to be used for ICMP packet translation and create session if needed. More...
 
u32 icmp_match_out2in_det (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 
void increment_v4_address (ip4_address_t *a)
 
int snat_add_address (snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
 
int snat_del_address (snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
 
void nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add)
 
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, snat_protocol_t proto, int is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag)
 Add static mapping. More...
 
clib_error_tsnat_api_init (vlib_main_t *vm, snat_main_t *sm)
 
int snat_set_workers (uword *bitmap)
 
int snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del)
 
int snat_interface_add_del_output_feature (u32 sw_if_index, u8 is_inside, int is_del)
 
int snat_add_interface_address (snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
 
uword unformat_snat_protocol (unformat_input_t *input, va_list *args)
 
u8format_snat_protocol (u8 *s, va_list *args)
 
int nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port, snat_protocol_t proto, u32 vrf_id, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag)
 
int nat44_del_session (snat_main_t *sm, ip4_address_t *addr, u16 port, snat_protocol_t proto, u32 vrf_id, int is_in)
 
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)
 
void nat_free_session_data (snat_main_t *sm, snat_session_t *s, u32 thread_index)
 
snat_user_tnat_user_get_or_create (snat_main_t *sm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
 
snat_session_t * nat_session_alloc_or_recycle (snat_main_t *sm, snat_user_t *u, u32 thread_index)
 
void nat_set_alloc_addr_and_port_mape (u16 psid, u16 psid_offset, u16 psid_length)
 
void nat_set_alloc_addr_and_port_default (void)
 

Variables

snat_main_t snat_main
 
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_fast_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node) More...
 
vlib_node_registration_t snat_out2in_fast_node
 (constructor) VLIB_REGISTER_NODE (snat_out2in_fast_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 snat_det_in2out_node
 (constructor) VLIB_REGISTER_NODE (snat_det_in2out_node) More...
 
vlib_node_registration_t snat_det_out2in_node
 (constructor) VLIB_REGISTER_NODE (snat_det_out2in_node) More...
 
vlib_node_registration_t snat_hairpin_dst_node
 (constructor) VLIB_REGISTER_NODE (snat_hairpin_dst_node) More...
 
vlib_node_registration_t snat_hairpin_src_node
 (constructor) VLIB_REGISTER_NODE (snat_hairpin_src_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...
 
vlib_node_registration_t nat44_ed_hairpin_dst_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node) More...
 
vlib_node_registration_t nat44_ed_hairpin_src_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node) More...
 
vlib_node_registration_t nat44_ed_in2out_worker_handoff_node
 
vlib_node_registration_t nat44_ed_in2out_output_worker_handoff_node
 
vlib_node_registration_t nat44_ed_out2in_worker_handoff_node
 
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_det_map_ses
 

Macro Definition Documentation

#define foreach_snat_protocol
Value:
_(UDP, 0, udp, "udp") \
_(TCP, 1, tcp, "tcp") \
_(ICMP, 2, icmp, "icmp")

Definition at line 102 of file nat.h.

#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 114 of file nat.h.

#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 520 of file nat.h.

#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 514 of file nat.h.

#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 508 of file nat.h.

#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 502 of file nat.h.

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

Definition at line 137 of file nat.h.

#define NAT44_SES_I2O_FIN   1

Definition at line 132 of file nat.h.

#define NAT44_SES_I2O_FIN_ACK   4

Definition at line 134 of file nat.h.

#define NAT44_SES_O2I_FIN   2

Definition at line 133 of file nat.h.

#define NAT44_SES_O2I_FIN_ACK   8

Definition at line 135 of file nat.h.

#define NAT_FQ_NELTS   64

Definition at line 41 of file nat.h.

#define NAT_INTERFACE_FLAG_IS_INSIDE   1

Definition at line 146 of file nat.h.

#define NAT_INTERFACE_FLAG_IS_OUTSIDE   2

Definition at line 147 of file nat.h.

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

Definition at line 522 of file nat.h.

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

Definition at line 523 of file nat.h.

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

Definition at line 533 of file nat.h.

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

Definition at line 525 of file nat.h.

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

Definition at line 531 of file nat.h.

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

Definition at line 529 of file nat.h.

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

Definition at line 527 of file nat.h.

#define SNAT_FLAG_HAIRPINNING   (1 << 0)

Definition at line 43 of file nat.h.

#define SNAT_ICMP_TIMEOUT   60

Definition at line 39 of file nat.h.

#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 490 of file nat.h.

#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 496 of file nat.h.

#define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT   16

Definition at line 143 of file nat.h.

#define SNAT_SESSION_FLAG_FWD_BYPASS   32

Definition at line 144 of file nat.h.

#define SNAT_SESSION_FLAG_LOAD_BALANCING   4

Definition at line 141 of file nat.h.

#define SNAT_SESSION_FLAG_STATIC_MAPPING   1

Definition at line 139 of file nat.h.

#define SNAT_SESSION_FLAG_TWICE_NAT   8

Definition at line 142 of file nat.h.

#define SNAT_SESSION_FLAG_UNKNOWN_PROTO   2

Definition at line 140 of file nat.h.

#define SNAT_TCP_ESTABLISHED_TIMEOUT   7440

Definition at line 37 of file nat.h.

#define SNAT_TCP_INCOMING_SYN   6

Definition at line 38 of file nat.h.

#define SNAT_TCP_TRANSITORY_TIMEOUT   240

Definition at line 36 of file nat.h.

#define SNAT_UDP_TIMEOUT   300

Definition at line 34 of file nat.h.

#define SNAT_UDP_TIMEOUT_MIN   120

Definition at line 35 of file nat.h.

Typedef Documentation

typedef int nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp, u16 port_per_thread, u32 snat_thread_index)

Definition at line 315 of file nat.h.

typedef u32( snat_get_worker_function_t) (ip4_header_t *ip, u32 rx_fib_index)

Definition at line 313 of file nat.h.

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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)

Definition at line 302 of file nat.h.

typedef struct snat_main_s snat_main_t

Enumeration Type Documentation

Enumerator
foreach_snat_protocol 

Definition at line 107 of file nat.h.

Enumerator
foreach_snat_session_state 

Definition at line 126 of file nat.h.

Enumerator
TWICE_NAT_DISABLED 
TWICE_NAT 
TWICE_NAT_SELF 

Definition at line 236 of file nat.h.

Function Documentation

typedef CLIB_PACKED ( struct{snat_session_key_t out2in;snat_session_key_t in2out;u32 flags;u32 per_user_index;u32 per_user_list_head_index;f64 last_heard;u64 total_bytes;u32 total_pkts;u32 outside_address_index;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;}  )
u8* format_snat_protocol ( u8 s,
va_list *  args 
)

Definition at line 2439 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 icmp_match_in2out_det ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

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
[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 4402 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

Definition at line 2644 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

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
[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 604 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

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
[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 500 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 icmp_match_out2in_det ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

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
[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 3331 of file out2in.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

Definition at line 1822 of file out2in.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

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
[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 404 of file out2in.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

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
[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 286 of file out2in.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void increment_v4_address ( ip4_address_t a)

Definition at line 730 of file nat.c.

+ Here is the caller graph for this function:

void nat44_add_del_address_dpo ( ip4_address_t  addr,
u8  is_add 
)

Definition at line 2402 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1221 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 3412 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3369 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 187 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 332 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void nat_set_alloc_addr_and_port_default ( void  )

Definition at line 3467 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3456 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 288 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 657 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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_indexInterface.
is_addIf 0 delete, otherwise add.

Definition at line 625 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3302 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
snat_protocol_t  proto,
int  is_add,
twice_nat_type_t  twice_nat,
u8  out2in_only,
u8 tag 
)

Add static mapping.

Create static mapping between local addr+port and external addr+port.

Parameters
l_addrLocal IPv4 address.
e_addrExternal IPv4 address.
l_portLocal port number.
e_portExternal port number.
vrf_idVRF ID.
addr_onlyIf 0 address port and pair mapping, otherwise address only.
sw_if_indexExternal port instead of specific IP address.
is_addIf 0 delete static mapping, otherwise add.
twice_natIf value is TWICE_NAT then translate external host address and port. If value is TWICE_NAT_SELF then translate external host address and port whenever external host address equals local address of internal host.
out2in_onlyIf 1 rule match only out2in direction
tag- opaque string tag
Returns

Definition at line 798 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int snat_alloc_outside_address_and_port ( snat_address_t addresses,
u32  fib_index,
u32  thread_index,
snat_session_key_t k,
u32 address_indexp,
u16  port_per_thread,
u32  snat_thread_index 
)

Definition at line 2241 of file nat.c.

+ Here is the caller graph for this function:

clib_error_t* snat_api_init ( vlib_main_t vm,
snat_main_t sm 
)

Definition at line 3145 of file nat_api.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1480 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void snat_free_outside_address_and_port ( snat_address_t addresses,
u32  thread_index,
snat_session_key_t k 
)

Definition at line 2086 of file nat.c.

+ Here is the caller graph for this function:

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

Definition at line 1583 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1820 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int snat_set_workers ( uword bitmap)

Definition at line 1936 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int snat_static_mapping_match ( snat_main_t sm,
snat_session_key_t  match,
snat_session_key_t mapping,
u8  by_external,
u8 is_addr_only,
twice_nat_type_t twice_nat,
u8 lb 
)

Match NAT44 static mapping.

Parameters
smNAT main.
matchAddress and port to match.
mappingExternal or local address and port of the matched mapping.
by_externalIf 0 match by local address otherwise match by external address.
is_addr_onlyIf matched mapping is address only
twice_natIf matched mapping is twice NAT.
lbIf matched mapping is load-balanced.
Returns
0 if match found otherwise 1.

Definition at line 2137 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_snat_protocol ( unformat_input_t input,
va_list *  args 
)

Definition at line 2425 of file nat.c.

+ Here is the caller graph for this function:

Variable Documentation

format_function_t format_det_map_ses

Definition at line 479 of file nat.h.

format_function_t format_snat_session

Definition at line 478 of file nat.h.

format_function_t format_snat_static_map_to_resolve

Definition at line 477 of file nat.h.

format_function_t format_snat_static_mapping

Definition at line 476 of file nat.h.

format_function_t format_snat_user

Definition at line 475 of file nat.h.

vlib_node_registration_t nat44_ed_hairpin_dst_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node)

Definition at line 123 of file in2out.c.

vlib_node_registration_t nat44_ed_hairpin_src_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node)

Definition at line 124 of file in2out.c.

vlib_node_registration_t nat44_ed_in2out_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)

Definition at line 119 of file in2out.c.

vlib_node_registration_t nat44_ed_in2out_output_node

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)

Definition at line 121 of file in2out.c.

vlib_node_registration_t nat44_ed_in2out_output_worker_handoff_node
vlib_node_registration_t nat44_ed_in2out_worker_handoff_node
vlib_node_registration_t nat44_ed_out2in_node
Initial value:
= {
.name = "nat44-ed-out2in",
.vector_size = sizeof (u32),
.error_strings = snat_out2in_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = NAT44_ED_OUT2IN_N_NEXT,
.next_nodes = {
[NAT44_ED_OUT2IN_NEXT_DROP] = "error-drop",
[NAT44_ED_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[NAT44_ED_OUT2IN_NEXT_SLOW_PATH] = "nat44-ed-out2in-slowpath",
[NAT44_ED_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[NAT44_ED_OUT2IN_NEXT_IN2OUT] = "nat44-ed-in2out",
},
}
static u8 * format_nat44_ed_out2in_trace(u8 *s, va_list *args)
Definition: out2in.c:1556
unsigned int u32
Definition: types.h:88
#define ARRAY_LEN(x)
Definition: clib.h:59
static char * snat_out2in_error_strings[]
Definition: out2in.c:129
static uword nat44_ed_out2in_fast_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: out2in.c:2761

(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)

Definition at line 2768 of file out2in.c.

vlib_node_registration_t nat44_ed_out2in_worker_handoff_node
vlib_node_registration_t snat_det_in2out_node

(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)

Definition at line 111 of file in2out.c.

vlib_node_registration_t snat_det_out2in_node
Initial value:
= {
.name = "nat44-det-out2in",
.vector_size = sizeof (u32),
.format_trace = format_snat_out2in_trace,
.error_strings = snat_out2in_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_OUT2IN_N_NEXT,
.next_nodes = {
[SNAT_OUT2IN_NEXT_DROP] = "error-drop",
[SNAT_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[SNAT_OUT2IN_NEXT_REASS] = "nat44-out2in-reass",
},
}
unsigned int u32
Definition: types.h:88
#define ARRAY_LEN(x)
Definition: clib.h:59
static uword snat_det_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: out2in.c:2833
static char * snat_out2in_error_strings[]
Definition: out2in.c:129
static u8 * format_snat_out2in_trace(u8 *s, va_list *args)
Definition: out2in.c:47

(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)

Definition at line 3293 of file out2in.c.

vlib_node_registration_t snat_hairpin_dst_node

(constructor) VLIB_REGISTER_NODE (snat_hairpin_dst_node)

Definition at line 115 of file in2out.c.

vlib_node_registration_t snat_hairpin_src_node

(constructor) VLIB_REGISTER_NODE (snat_hairpin_src_node)

Definition at line 116 of file in2out.c.

vlib_node_registration_t snat_in2out_fast_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)

Definition at line 109 of file in2out.c.

vlib_node_registration_t snat_in2out_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_node)

Definition at line 107 of file in2out.c.

vlib_node_registration_t snat_in2out_output_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)

Definition at line 112 of file in2out.c.

vlib_node_registration_t snat_in2out_output_worker_handoff_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)

Definition at line 114 of file in2out.c.

vlib_node_registration_t snat_in2out_worker_handoff_node

(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)

Definition at line 110 of file in2out.c.

snat_main_t snat_main

Definition at line 36 of file nat.c.

vlib_node_registration_t snat_out2in_fast_node
Initial value:
= {
.name = "nat44-out2in-fast",
.vector_size = sizeof (u32),
.error_strings = snat_out2in_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_OUT2IN_N_NEXT,
.next_nodes = {
[SNAT_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_OUT2IN_NEXT_DROP] = "error-drop",
[SNAT_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[SNAT_OUT2IN_NEXT_REASS] = "nat44-out2in-reass",
},
}
static u8 * format_snat_out2in_fast_trace(u8 *s, va_list *args)
Definition: out2in.c:58
unsigned int u32
Definition: types.h:88
#define ARRAY_LEN(x)
Definition: clib.h:59
static char * snat_out2in_error_strings[]
Definition: out2in.c:129
static uword snat_out2in_fast_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: out2in.c:3649

(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)

Definition at line 3815 of file out2in.c.

vlib_node_registration_t snat_out2in_node
Initial value:
= {
.function = snat_out2in_node_fn,
.name = "nat44-out2in",
.vector_size = sizeof (u32),
.format_trace = format_snat_out2in_trace,
.error_strings = snat_out2in_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_OUT2IN_N_NEXT,
.next_nodes = {
[SNAT_OUT2IN_NEXT_DROP] = "error-drop",
[SNAT_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[SNAT_OUT2IN_NEXT_REASS] = "nat44-out2in-reass",
},
}
unsigned int u32
Definition: types.h:88
#define ARRAY_LEN(x)
Definition: clib.h:59
static char * snat_out2in_error_strings[]
Definition: out2in.c:129
static u8 * format_snat_out2in_trace(u8 *s, va_list *args)
Definition: out2in.c:47
static uword snat_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: out2in.c:647

(constructor) VLIB_REGISTER_NODE (snat_out2in_node)

Definition at line 1225 of file out2in.c.

vlib_node_registration_t snat_out2in_worker_handoff_node
Initial value:
= {
.name = "nat44-out2in-worker-handoff",
.vector_size = sizeof (u32),
.error_strings = snat_out2in_error_strings,
.n_next_nodes = 1,
.next_nodes = {
[0] = "error-drop",
},
}
unsigned int u32
Definition: types.h:88
static uword snat_out2in_worker_handoff_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: out2in.c:3460
#define ARRAY_LEN(x)
Definition: clib.h:59
static char * snat_out2in_error_strings[]
Definition: out2in.c:129
static u8 * format_snat_out2in_worker_handoff_trace(u8 *s, va_list *args)
Definition: out2in.c:69

(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)

Definition at line 3629 of file out2in.c.