FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
nat.c File Reference
+ Include dependency graph for nat.c:

Go to the source code of this file.

Enumerations

enum  nat44_classify_next_t { NAT44_CLASSIFY_NEXT_IN2OUT, NAT44_CLASSIFY_NEXT_OUT2IN, NAT44_CLASSIFY_N_NEXT }
 

Functions

 VNET_FEATURE_INIT (ip4_snat_in2out, static)
 
 VNET_FEATURE_INIT (ip4_snat_out2in, static)
 
 VNET_FEATURE_INIT (ip4_nat_classify, static)
 
 VNET_FEATURE_INIT (ip4_snat_det_in2out, static)
 
 VNET_FEATURE_INIT (ip4_snat_det_out2in, static)
 
 VNET_FEATURE_INIT (ip4_nat_det_classify, static)
 
 VNET_FEATURE_INIT (ip4_snat_in2out_worker_handoff, static)
 
 VNET_FEATURE_INIT (ip4_snat_out2in_worker_handoff, static)
 
 VNET_FEATURE_INIT (ip4_nat_handoff_classify, static)
 
 VNET_FEATURE_INIT (ip4_snat_in2out_fast, static)
 
 VNET_FEATURE_INIT (ip4_snat_out2in_fast, static)
 
 VNET_FEATURE_INIT (ip4_snat_hairpin_dst, static)
 
 VNET_FEATURE_INIT (ip4_snat_in2out_output, static)
 
 VNET_FEATURE_INIT (ip4_snat_in2out_output_worker_handoff, static)
 
 VNET_FEATURE_INIT (ip4_snat_hairpin_src, static)
 
 VNET_FEATURE_INIT (ip4_nat_hairpinning, static)
 
 VLIB_PLUGIN_REGISTER ()
 
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)
 
static uword nat44_classify_node_fn_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static uword nat44_classify_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (nat44_classify_node, nat44_classify_node_fn)
 
static uword nat44_det_classify_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (nat44_det_classify_node, nat44_det_classify_node_fn)
 
static uword nat44_handoff_classify_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (nat44_handoff_classify_node, nat44_handoff_classify_node_fn)
 
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 snat_add_address (snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
 
static int is_snat_address_used_in_static_mapping (snat_main_t *sm, ip4_address_t addr)
 
void increment_v4_address (ip4_address_t *a)
 
static void snat_add_static_mapping_when_resolved (snat_main_t *sm, ip4_address_t l_addr, u16 l_port, u32 sw_if_index, u16 e_port, u32 vrf_id, snat_protocol_t proto, int addr_only, int 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, u8 twice_nat)
 Add static mapping. More...
 
static int lb_local_exists (nat44_lb_addr_port_t *local, ip4_address_t *e_addr, u16 e_port)
 
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, u8 twice_nat)
 
int snat_del_address (snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
 
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_set_workers (uword *bitmap)
 
static void snat_ip4_add_del_interface_address_cb (ip4_main_t *im, uword opaque, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 if_address_index, u32 is_delete)
 
static int nat_alloc_addr_and_port_default (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)
 
static clib_error_tsnat_init (vlib_main_t *vm)
 
void snat_free_outside_address_and_port (snat_address_t *addresses, u32 thread_index, snat_session_key_t *k, u32 address_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, u8 *twice_nat)
 Match NAT44 static mapping. More...
 
static_always_inline u16 snat_random_port (u16 min, u16 max)
 
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)
 
static int nat_alloc_addr_and_port_mape (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)
 
static clib_error_tadd_address_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_feature_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
uword unformat_snat_protocol (unformat_input_t *input, va_list *args)
 
u8format_snat_protocol (u8 *s, va_list *args)
 
static clib_error_tadd_static_mapping_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tadd_identity_mapping_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tadd_lb_static_mapping_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tset_workers_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_ipfix_logging_enable_disable_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static u32 snat_get_worker_in2out_cb (ip4_header_t *ip0, u32 rx_fib_index0)
 
static u32 snat_get_worker_out2in_cb (ip4_header_t *ip0, u32 rx_fib_index0)
 
static clib_error_tsnat_config (vlib_main_t *vm, unformat_input_t *input)
 
u8format_snat_session_state (u8 *s, va_list *args)
 
u8format_snat_key (u8 *s, va_list *args)
 
u8format_snat_session (u8 *s, va_list *args)
 
u8format_snat_user (u8 *s, va_list *args)
 
u8format_snat_static_mapping (u8 *s, va_list *args)
 
u8format_snat_static_map_to_resolve (u8 *s, va_list *args)
 
u8format_det_map_ses (u8 *s, va_list *args)
 
static clib_error_tshow_snat_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
int snat_add_interface_address (snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
 
static clib_error_tsnat_add_interface_address_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
int nat44_del_session (snat_main_t *sm, ip4_address_t *addr, u16 port, snat_protocol_t proto, u32 vrf_id, int is_in)
 
static clib_error_tnat44_del_session_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tnat44_set_alloc_addr_and_port_alg_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_det_map_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_det_forward_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_det_reverse_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tset_timeout_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_det_close_session_out_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_det_close_session_in_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_forwarding_set_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 

Variables

snat_main_t snat_main
 
vlib_node_registration_t nat44_classify_node
 (constructor) VLIB_REGISTER_NODE (nat44_classify_node) More...
 
vlib_node_registration_t nat44_det_classify_node
 (constructor) VLIB_REGISTER_NODE (nat44_det_classify_node) More...
 
vlib_node_registration_t nat44_handoff_classify_node
 (constructor) VLIB_REGISTER_NODE (nat44_handoff_classify_node) More...
 
static vlib_cli_command_t add_address_command
 (constructor) VLIB_CLI_COMMAND (add_address_command) More...
 
static vlib_cli_command_t set_interface_snat_command
 (constructor) VLIB_CLI_COMMAND (set_interface_snat_command) More...
 
static vlib_cli_command_t add_static_mapping_command
 (constructor) VLIB_CLI_COMMAND (add_static_mapping_command) More...
 
static vlib_cli_command_t add_identity_mapping_command
 (constructor) VLIB_CLI_COMMAND (add_identity_mapping_command) More...
 
static vlib_cli_command_t add_lb_static_mapping_command
 (constructor) VLIB_CLI_COMMAND (add_lb_static_mapping_command) More...
 
static vlib_cli_command_t set_workers_command
 (constructor) VLIB_CLI_COMMAND (set_workers_command) More...
 
static vlib_cli_command_t snat_ipfix_logging_enable_disable_command
 (constructor) VLIB_CLI_COMMAND (snat_ipfix_logging_enable_disable_command) More...
 
static vlib_cli_command_t show_snat_command
 (constructor) VLIB_CLI_COMMAND (show_snat_command) More...
 
static vlib_cli_command_t snat_add_interface_address_command
 (constructor) VLIB_CLI_COMMAND (snat_add_interface_address_command) More...
 
static vlib_cli_command_t nat44_del_session_command
 (constructor) VLIB_CLI_COMMAND (nat44_del_session_command) More...
 
static vlib_cli_command_t nat44_set_alloc_addr_and_port_alg_command
 (constructor) VLIB_CLI_COMMAND (nat44_set_alloc_addr_and_port_alg_command) More...
 
static vlib_cli_command_t snat_det_map_command
 (constructor) VLIB_CLI_COMMAND (snat_det_map_command) More...
 
static vlib_cli_command_t snat_det_forward_command
 (constructor) VLIB_CLI_COMMAND (snat_det_forward_command) More...
 
static vlib_cli_command_t snat_det_reverse_command
 (constructor) VLIB_CLI_COMMAND (snat_det_reverse_command) More...
 
static vlib_cli_command_t set_timeout_command
 (constructor) VLIB_CLI_COMMAND (set_timeout_command) More...
 
static vlib_cli_command_t snat_det_close_sesion_out_command
 (constructor) VLIB_CLI_COMMAND (snat_det_close_sesion_out_command) More...
 
static vlib_cli_command_t snat_det_close_session_in_command
 (constructor) VLIB_CLI_COMMAND (snat_det_close_session_in_command) More...
 
static vlib_cli_command_t snat_forwarding_set_command
 (constructor) VLIB_CLI_COMMAND (snat_forwarding_set_command) More...
 

Enumeration Type Documentation

Enumerator
NAT44_CLASSIFY_NEXT_IN2OUT 
NAT44_CLASSIFY_NEXT_OUT2IN 
NAT44_CLASSIFY_N_NEXT 

Definition at line 135 of file nat.c.

Function Documentation

static clib_error_t* add_address_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2034 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* add_identity_mapping_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2409 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* add_lb_static_mapping_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2504 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* add_static_mapping_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2285 of file nat.c.

+ Here is the call graph for this function:

u8* format_det_map_ses ( u8 s,
va_list *  args 
)

Definition at line 3208 of file nat.c.

+ Here is the call graph for this function:

u8* format_snat_key ( u8 s,
va_list *  args 
)

Definition at line 3053 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_protocol ( u8 s,
va_list *  args 
)

Definition at line 2266 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_session ( u8 s,
va_list *  args 
)

Definition at line 3064 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_session_state ( u8 s,
va_list *  args 
)

Definition at line 3036 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_static_map_to_resolve ( u8 s,
va_list *  args 
)

Definition at line 3188 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_static_mapping ( u8 s,
va_list *  args 
)

Definition at line 3154 of file nat.c.

+ Here is the call graph for this function:

u8* format_snat_user ( u8 s,
va_list *  args 
)

Definition at line 3114 of file nat.c.

+ Here is the call graph for this function:

void increment_v4_address ( ip4_address_t a)

Definition at line 599 of file nat.c.

+ Here is the caller graph for this function:

static int is_snat_address_used_in_static_mapping ( snat_main_t sm,
ip4_address_t  addr 
)
static

Definition at line 586 of file nat.c.

+ Here is the caller graph for this function:

static int lb_local_exists ( nat44_lb_addr_port_t local,
ip4_address_t e_addr,
u16  e_port 
)
static

Definition at line 972 of file nat.c.

+ 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,
u8  twice_nat 
)

Definition at line 999 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uword nat44_classify_node_fn ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 418 of file nat.c.

+ Here is the call graph for this function:

static uword nat44_classify_node_fn_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
inlinestatic

Definition at line 344 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 3703 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* nat44_del_session_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3754 of file nat.c.

+ Here is the call graph for this function:

static uword nat44_det_classify_node_fn ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 441 of file nat.c.

+ Here is the call graph for this function:

static uword nat44_handoff_classify_node_fn ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 464 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* nat44_set_alloc_addr_and_port_alg_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3816 of file nat.c.

+ Here is the call graph for this function:

static int nat_alloc_addr_and_port_default ( 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 
)
static

Definition at line 1889 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int nat_alloc_addr_and_port_mape ( 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 
)
static

Definition at line 1981 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 142 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 283 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 239 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* set_timeout_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 4050 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* set_workers_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2604 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* show_snat_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3238 of file nat.c.

+ Here is the call graph for this function:

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

Definition at line 531 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 499 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 3577 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* snat_add_interface_address_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3644 of file nat.c.

+ Here is the call 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,
u8  twice_nat 
)

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 1 translate external host address and port.
Returns

Definition at line 648 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void snat_add_static_mapping_when_resolved ( snat_main_t sm,
ip4_address_t  l_addr,
u16  l_port,
u32  sw_if_index,
u16  e_port,
u32  vrf_id,
snat_protocol_t  proto,
int  addr_only,
int  is_add 
)
static

Definition at line 608 of file nat.c.

+ 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 1873 of file nat.c.

+ Here is the caller graph for this function:

static clib_error_t* snat_config ( vlib_main_t vm,
unformat_input_t input 
)
static

Definition at line 2890 of file nat.c.

+ Here is the call 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 1263 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* snat_det_close_session_in_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 4185 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_det_close_session_out_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 4114 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_det_forward_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3926 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_det_map_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3862 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_det_reverse_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 3986 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_feature_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2136 of file nat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_forwarding_set_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 4254 of file nat.c.

+ Here is the call graph for this function:

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

Definition at line 1741 of file nat.c.

+ Here is the caller graph for this function:

static u32 snat_get_worker_in2out_cb ( ip4_header_t ip0,
u32  rx_fib_index0 
)
static

Definition at line 2734 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 snat_get_worker_out2in_cb ( ip4_header_t ip0,
u32  rx_fib_index0 
)
static

Definition at line 2753 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* snat_init ( vlib_main_t vm)
static

Definition at line 1656 of file nat.c.

+ Here is the call graph for this function:

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

Definition at line 1375 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 1517 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void snat_ip4_add_del_interface_address_cb ( ip4_main_t im,
uword  opaque,
u32  sw_if_index,
ip4_address_t address,
u32  address_length,
u32  if_address_index,
u32  is_delete 
)
static

Definition at line 3488 of file nat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* snat_ipfix_logging_enable_disable_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2673 of file nat.c.

+ Here is the call graph for this function:

static_always_inline u16 snat_random_port ( u16  min,
u16  max 
)

Definition at line 1865 of file nat.c.

+ Here is the call graph for this function:

int snat_set_workers ( uword bitmap)

Definition at line 1612 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,
u8 twice_nat 
)

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.
Returns
0 if match found otherwise 1.

Definition at line 1785 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 2252 of file nat.c.

+ Here is the caller graph for this function:

VLIB_NODE_FUNCTION_MULTIARCH ( nat44_classify_node  ,
nat44_classify_node_fn   
)

+ Here is the caller graph for this function:

VLIB_NODE_FUNCTION_MULTIARCH ( nat44_det_classify_node  ,
nat44_det_classify_node_fn   
)
VLIB_NODE_FUNCTION_MULTIARCH ( nat44_handoff_classify_node  ,
nat44_handoff_classify_node_fn   
)
VLIB_PLUGIN_REGISTER ( )
VNET_FEATURE_INIT ( ip4_snat_in2out  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_out2in  ,
static   
)
VNET_FEATURE_INIT ( ip4_nat_classify  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_det_in2out  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_det_out2in  ,
static   
)
VNET_FEATURE_INIT ( ip4_nat_det_classify  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_in2out_worker_handoff  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_out2in_worker_handoff  ,
static   
)
VNET_FEATURE_INIT ( ip4_nat_handoff_classify  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_in2out_fast  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_out2in_fast  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_hairpin_dst  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_in2out_output  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_in2out_output_worker_handoff  ,
static   
)
VNET_FEATURE_INIT ( ip4_snat_hairpin_src  ,
static   
)
VNET_FEATURE_INIT ( ip4_nat_hairpinning  ,
static   
)

Variable Documentation

vlib_cli_command_t add_address_command
static
Initial value:
= {
.path = "nat44 add address",
.short_help = "nat44 add address <ip4-range-start> [- <ip4-range-end>] "
"[tenant-vrf <vrf-id>] [twice-nat] [del]",
}
static clib_error_t * add_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2034

(constructor) VLIB_CLI_COMMAND (add_address_command)

Definition at line 2128 of file nat.c.

vlib_cli_command_t add_identity_mapping_command
static
Initial value:
= {
.path = "nat44 add identity mapping",
.short_help = "nat44 add identity mapping <interface>|<ip4-addr> "
"[<protocol> <port>] [vrf <table-id>] [del]",
}
static clib_error_t * add_identity_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2409

(constructor) VLIB_CLI_COMMAND (add_identity_mapping_command)

Definition at line 2496 of file nat.c.

vlib_cli_command_t add_lb_static_mapping_command
static
Initial value:
= {
.path = "nat44 add load-balancing static mapping",
.short_help =
"nat44 add load-balancing static mapping protocol tcp|udp "
"external <addr>:<port> local <addr>:<port> probability <n> [twice-nat] "
"[vrf <table-id>] [del]",
}
static clib_error_t * add_lb_static_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2504

(constructor) VLIB_CLI_COMMAND (add_lb_static_mapping_command)

Definition at line 2594 of file nat.c.

vlib_cli_command_t add_static_mapping_command
static
Initial value:
= {
.path = "nat44 add static mapping",
.short_help =
"nat44 add static mapping tcp|udp|icmp local <addr> [<port>] "
"external <addr> [<port>] [vrf <table-id>] [twice-nat] [del]",
}
static clib_error_t * add_static_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2285

(constructor) VLIB_CLI_COMMAND (add_static_mapping_command)

Definition at line 2400 of file nat.c.

vlib_node_registration_t nat44_classify_node
Initial value:
= {
.name = "nat44-classify",
.vector_size = sizeof (u32),
.n_next_nodes = NAT44_CLASSIFY_N_NEXT,
.next_nodes = {
[NAT44_CLASSIFY_NEXT_IN2OUT] = "nat44-in2out",
[NAT44_CLASSIFY_NEXT_OUT2IN] = "nat44-out2in",
},
}
static uword nat44_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat.c:418
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (nat44_classify_node)

Definition at line 131 of file nat.c.

vlib_cli_command_t nat44_del_session_command
static
Initial value:
= {
.path = "nat44 del session",
.short_help = "nat44 del session in|out <addr>:<port> tcp|udp|icmp [vrf <id>]",
}
static clib_error_t * nat44_del_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3754

(constructor) VLIB_CLI_COMMAND (nat44_del_session_command)

Definition at line 3809 of file nat.c.

vlib_node_registration_t nat44_det_classify_node
Initial value:
= {
.name = "nat44-det-classify",
.vector_size = sizeof (u32),
.n_next_nodes = NAT44_CLASSIFY_N_NEXT,
.next_nodes = {
[NAT44_CLASSIFY_NEXT_IN2OUT] = "nat44-det-in2out",
[NAT44_CLASSIFY_NEXT_OUT2IN] = "nat44-det-out2in",
},
}
static uword nat44_det_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat.c:441
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (nat44_det_classify_node)

Definition at line 132 of file nat.c.

vlib_node_registration_t nat44_handoff_classify_node
Initial value:
= {
.name = "nat44-handoff-classify",
.vector_size = sizeof (u32),
.n_next_nodes = NAT44_CLASSIFY_N_NEXT,
.next_nodes = {
[NAT44_CLASSIFY_NEXT_IN2OUT] = "nat44-in2out-worker-handoff",
[NAT44_CLASSIFY_NEXT_OUT2IN] = "nat44-out2in-worker-handoff",
},
}
static uword nat44_handoff_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat.c:464
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (nat44_handoff_classify_node)

Definition at line 133 of file nat.c.

vlib_cli_command_t nat44_set_alloc_addr_and_port_alg_command
static
Initial value:
= {
.path = "nat addr-port-assignment-alg",
.short_help = "nat addr-port-assignment-alg <alg-name> [<alg-params>]",
}
static clib_error_t * nat44_set_alloc_addr_and_port_alg_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3816

(constructor) VLIB_CLI_COMMAND (nat44_set_alloc_addr_and_port_alg_command)

Definition at line 3855 of file nat.c.

vlib_cli_command_t set_interface_snat_command
static
Initial value:
= {
.path = "set interface nat44",
.short_help = "set interface nat44 in <intfc> out <intfc> [output-feature] "
"[del]",
}
static clib_error_t * snat_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2136

(constructor) VLIB_CLI_COMMAND (set_interface_snat_command)

Definition at line 2244 of file nat.c.

vlib_cli_command_t set_timeout_command
static
Initial value:
= {
.path = "set nat44 deterministic timeout",
.short_help =
"set nat44 deterministic timeout [udp <sec> | tcp-established <sec> "
"tcp-transitory <sec> | icmp <sec> | reset]",
}
static clib_error_t * set_timeout_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:4050

(constructor) VLIB_CLI_COMMAND (set_timeout_command)

Definition at line 4105 of file nat.c.

vlib_cli_command_t set_workers_command
static
Initial value:
= {
.path = "set nat workers",
.short_help =
"set nat workers <workers-list>",
}
static clib_error_t * set_workers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2604

(constructor) VLIB_CLI_COMMAND (set_workers_command)

Definition at line 2665 of file nat.c.

vlib_cli_command_t show_snat_command
static
Initial value:
= {
.path = "show nat44",
.short_help = "show nat44",
.function = show_snat_command_fn,
}
static clib_error_t * show_snat_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3238

(constructor) VLIB_CLI_COMMAND (show_snat_command)

Definition at line 3480 of file nat.c.

vlib_cli_command_t snat_add_interface_address_command
static
Initial value:
= {
.path = "nat44 add interface address",
.short_help = "nat44 add interface address <interface> [twice-nat] [del]",
}
static clib_error_t * snat_add_interface_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3644

(constructor) VLIB_CLI_COMMAND (snat_add_interface_address_command)

Definition at line 3696 of file nat.c.

vlib_cli_command_t snat_det_close_sesion_out_command
static
Initial value:
= {
.path = "nat44 deterministic close session out",
.short_help = "nat44 deterministic close session out "
"<out_addr>:<out_port> <ext_addr>:<ext_port>",
}
static clib_error_t * snat_det_close_session_out_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:4114

(constructor) VLIB_CLI_COMMAND (snat_det_close_sesion_out_command)

Definition at line 4177 of file nat.c.

vlib_cli_command_t snat_det_close_session_in_command
static
Initial value:
= {
.path = "nat44 deterministic close session in",
.short_help = "nat44 deterministic close session in "
"<in_addr>:<in_port> <ext_addr>:<ext_port>",
}
static clib_error_t * snat_det_close_session_in_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:4185

(constructor) VLIB_CLI_COMMAND (snat_det_close_session_in_command)

Definition at line 4246 of file nat.c.

vlib_cli_command_t snat_det_forward_command
static
Initial value:
= {
.path = "nat44 deterministic forward",
.short_help = "nat44 deterministic forward <addr>",
}
static clib_error_t * snat_det_forward_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3926

(constructor) VLIB_CLI_COMMAND (snat_det_forward_command)

Definition at line 3979 of file nat.c.

vlib_cli_command_t snat_det_map_command
static
Initial value:
= {
.path = "nat44 deterministic add",
.short_help = "nat44 deterministic add in <addr>/<plen> out <addr>/<plen> [del]",
}
static clib_error_t * snat_det_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3862

(constructor) VLIB_CLI_COMMAND (snat_det_map_command)

Definition at line 3919 of file nat.c.

vlib_cli_command_t snat_det_reverse_command
static
Initial value:
= {
.path = "nat44 deterministic reverse",
.short_help = "nat44 deterministic reverse <addr>:<port>",
}
static clib_error_t * snat_det_reverse_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:3986

(constructor) VLIB_CLI_COMMAND (snat_det_reverse_command)

Definition at line 4043 of file nat.c.

vlib_cli_command_t snat_forwarding_set_command
static
Initial value:
= {
.path = "nat44 forwarding",
.short_help = "nat44 forwarding enable|disable",
}
static clib_error_t * snat_forwarding_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:4254

(constructor) VLIB_CLI_COMMAND (snat_forwarding_set_command)

Definition at line 4314 of file nat.c.

vlib_cli_command_t snat_ipfix_logging_enable_disable_command
static
Initial value:
= {
.path = "nat ipfix logging",
.short_help = "nat ipfix logging [domain <domain-id>] [src-port <port>] [disable]",
}
static clib_error_t * snat_ipfix_logging_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nat.c:2673

(constructor) VLIB_CLI_COMMAND (snat_ipfix_logging_enable_disable_command)

Definition at line 2727 of file nat.c.

snat_main_t snat_main

Definition at line 33 of file nat.c.