FD.io VPP
v19.01.2-3-gf61a1a8
Vector Packet Processing
|
Go to the source code of this file.
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_nat44_ed_in2out, static) | |
VNET_FEATURE_INIT (ip4_nat44_ed_out2in, static) | |
VNET_FEATURE_INIT (ip4_nat44_ed_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_nat44_ed_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_nat44_ed_in2out_output, static) | |
VNET_FEATURE_INIT (ip4_nat44_ed_hairpin_src, static) | |
VNET_FEATURE_INIT (ip4_nat_hairpinning, static) | |
VNET_FEATURE_INIT (ip4_nat44_ed_hairpinning, static) | |
VLIB_PLUGIN_REGISTER () | |
void | nat_free_session_data (snat_main_t *sm, snat_session_t *s, u32 thread_index) |
Free NAT44 session data (lookup keys, external addrres port) More... | |
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. More... | |
snat_session_t * | nat_session_alloc_or_recycle (snat_main_t *sm, snat_user_t *u, u32 thread_index) |
Allocate new NAT session or recycle last used. More... | |
snat_session_t * | nat_ed_session_alloc (snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now) |
Allocate NAT endpoint-dependent session. 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... | |
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... | |
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) |
Increment IPv4 address. More... | |
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, u8 *tag, int twice_nat, int out2in_only, int identity_nat) |
static u32 | get_thread_idx_by_port (u16 e_port) |
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, u8 identity_nat) |
Add/delete NAT44 static mapping. More... | |
int | nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port, snat_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, snat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add) |
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... | |
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_set_workers (uword *bitmap) |
Set NAT plugin workers. More... | |
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 void | nat_ip4_add_del_addr_only_sm_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, u16 port_per_thread, u32 snat_thread_index) |
static clib_error_t * | snat_init (vlib_main_t *vm) |
void | snat_free_outside_address_and_port (snat_address_t *addresses, u32 thread_index, snat_session_key_t *k) |
Free outside address and port pair. More... | |
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, lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_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, u16 port_per_thread, u32 snat_thread_index) |
Alloc outside address and port. More... | |
static int | nat_alloc_addr_and_port_mape (snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index) |
static int | nat_alloc_addr_and_port_range (snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index) |
void | nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add) |
Add/delete external address to FIB DPO (out2in DPO mode) More... | |
u8 * | format_session_kvp (u8 *s, va_list *args) |
u8 * | format_static_mapping_kvp (u8 *s, va_list *args) |
u8 * | format_user_kvp (u8 *s, va_list *args) |
u8 * | format_ed_session_kvp (u8 *s, va_list *args) |
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 u32 | nat44_ed_get_worker_out2in_cb (ip4_header_t *ip, u32 rx_fib_index) |
static clib_error_t * | snat_config (vlib_main_t *vm, unformat_input_t *input) |
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 interfce. More... | |
int | nat44_del_session (snat_main_t *sm, ip4_address_t *addr, u16 port, snat_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_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... | |
Variables | |
snat_main_t | snat_main |
void increment_v4_address | ( | ip4_address_t * | a | ) |
|
static |
void nat44_add_del_address_dpo | ( | ip4_address_t | addr, |
u8 | is_add | ||
) |
int nat44_add_del_lb_static_mapping | ( | ip4_address_t | e_addr, |
u16 | e_port, | ||
snat_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)
e_addr | external IPv4 address |
e_port | external port number |
proto | L4 protocol |
locals | list of local backends |
is_add | 1 = add, 0 = delete |
twice_nat | twice-nat mode |
out2in_only | if 1 rule match only out2in direction |
tag | opaque string tag |
affinity | 0 = disabled, otherwise client IP affinity sticky time |
Definition at line 1142 of file nat.c.
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.
addr | IPv4 address |
port | L4 port number |
proto | L4 protocol |
vrf_id | VRF ID |
is_in | 1 = inside network addres and por pair, 0 = outside |
Definition at line 3409 of file nat.c.
int nat44_del_session | ( | snat_main_t * | sm, |
ip4_address_t * | addr, | ||
u16 | port, | ||
snat_protocol_t | proto, | ||
u32 | vrf_id, | ||
int | is_in | ||
) |
Delete NAT44 session.
addr | IPv4 address |
port | L4 port number |
proto | L4 protocol |
vrf_id | VRF ID |
is_in | 1 = inside network addres and por pair, 0 = outside |
Definition at line 3366 of file nat.c.
|
static |
int nat44_lb_static_mapping_add_del_local | ( | ip4_address_t | e_addr, |
u16 | e_port, | ||
ip4_address_t | l_addr, | ||
u16 | l_port, | ||
snat_protocol_t | proto, | ||
u32 | vrf_id, | ||
u8 | probability, | ||
u8 | is_add | ||
) |
|
static |
|
static |
|
static |
snat_session_t* nat_ed_session_alloc | ( | snat_main_t * | sm, |
snat_user_t * | u, | ||
u32 | thread_index, | ||
f64 | now | ||
) |
void nat_free_session_data | ( | snat_main_t * | sm, |
snat_session_t * | s, | ||
u32 | thread_index | ||
) |
|
static |
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_default | ( | void | ) |
snat_user_t* nat_user_get_or_create | ( | snat_main_t * | sm, |
ip4_address_t * | addr, | ||
u32 | fib_index, | ||
u32 | thread_index | ||
) |
int snat_add_address | ( | snat_main_t * | sm, |
ip4_address_t * | addr, | ||
u32 | vrf_id, | ||
u8 | twice_nat | ||
) |
Add external address to NAT44 pool.
addr | IPv4 address |
vrf_id | VRF id of tenant, ~0 means independent of VRF |
twice_nat | 1 if twice NAT address |
Definition at line 516 of file nat.c.
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.
addr | IPv4 address |
plen | address prefix length |
sw_if_index | software index of the outside interface |
is_add | 0 = delete, 1 = add. |
Definition at line 488 of file nat.c.
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 interfce.
sw_if_index | software index of the interface |
is_del | 1 = delete, 0 = add |
twice_nat | 1 = twice NAT address for extenal hosts |
Definition at line 3298 of file nat.c.
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, | ||
u8 | identity_nat | ||
) |
Add/delete NAT44 static mapping.
l_addr | local IPv4 address |
e_addr | external IPv4 address |
l_port | local port number |
e_port | external port number |
vrf_id | local VRF ID |
addr_only | 1 = 1:1NAT, 0 = 1:1NAPT |
sw_if_index | use interface address as external IPv4 address |
proto | L4 protocol |
is_add | 1 = add, 0 = delete |
twice_nat | twice-nat mode |
out2in_only | if 1 rule match only out2in direction |
tag | opaque string tag |
identity_nat | identity NAT |
Definition at line 652 of file nat.c.
|
static |
int snat_alloc_outside_address_and_port | ( | snat_address_t * | addresses, |
u32 | fib_index, | ||
u32 | thread_index, | ||
snat_session_key_t * | k, | ||
u16 | port_per_thread, | ||
u32 | snat_thread_index | ||
) |
Alloc outside address and port.
addresses | vector of outside addresses |
fib_index | FIB table index |
thread_index | thread index |
k | allocated address and port pair |
port_per_thread | number of ports per threead |
snat_thread_index | NAT thread index |
Definition at line 2432 of file nat.c.
|
static |
int snat_del_address | ( | snat_main_t * | sm, |
ip4_address_t | addr, | ||
u8 | delete_sm, | ||
u8 | twice_nat | ||
) |
Delete external address from NAT44 pool.
addr | IPv4 address |
delete_sm | 1 if delete static mapping using address |
twice_nat | 1 if twice NAT address |
Definition at line 1601 of file nat.c.
void snat_free_outside_address_and_port | ( | snat_address_t * | addresses, |
u32 | thread_index, | ||
snat_session_key_t * | k | ||
) |
|
static |
|
static |
|
static |
Enable/disable NAT44 feature on the interface.
sw_if_index | software index of the interface |
is_inside | 1 = inside, 0 = outside |
is_del | 1 = delete, 0 = add |
Definition at line 1715 of file nat.c.
Enable/disable NAT44 output feature on the interface (postrouting NAT)
sw_if_index | software index of the interface |
is_inside | 1 = inside, 0 = outside |
is_del | 1 = delete, 0 = add |
Definition at line 1964 of file nat.c.
|
static |
static_always_inline u16 snat_random_port | ( | u16 | min, |
u16 | max | ||
) |
int snat_set_workers | ( | uword * | bitmap | ) |
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, | ||
lb_nat_type_t * | lb, | ||
ip4_address_t * | ext_host_addr, | ||
u8 * | is_identity_nat | ||
) |
Match NAT44 static mapping.
match | address and port to match |
mapping | external/local address and port of the matched mapping |
by_external | if 0 match by local address otherwise match by external address |
is_addr_only | 1 if matched mapping is address only |
twice_nat | matched mapping is twice NAT type |
lb | 1 if matched mapping is load-balanced |
ext_host_addr | external host address |
Definition at line 2287 of file nat.c.
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_nat44_ed_in2out | , |
static | |||
) |
VNET_FEATURE_INIT | ( | ip4_nat44_ed_out2in | , |
static | |||
) |
VNET_FEATURE_INIT | ( | ip4_nat44_ed_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_nat44_ed_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_nat44_ed_in2out_output | , |
static | |||
) |
VNET_FEATURE_INIT | ( | ip4_nat44_ed_hairpin_src | , |
static | |||
) |
VNET_FEATURE_INIT | ( | ip4_nat_hairpinning | , |
static | |||
) |
VNET_FEATURE_INIT | ( | ip4_nat44_ed_hairpinning | , |
static | |||
) |
snat_main_t snat_main |