FD.io VPP
v18.07-rc0-415-g6c78436
Vector Packet Processing
|
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 | 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 |
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 u32( | snat_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, u32 address_index) |
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_t * | snat_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) |
u8 * | format_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_t * | nat_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) |
#define foreach_snat_protocol |
#define foreach_snat_session_state |
#define is_ed_session | ( | s | ) | (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT) |
#define is_fwd_bypass_session | ( | s | ) | (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS) |
#define is_lb_session | ( | s | ) | (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING) |
#define is_twice_nat_session | ( | s | ) | (s->flags & SNAT_SESSION_FLAG_TWICE_NAT) |
#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_debug | ( | ... | ) | vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__) |
#define nat_log_err | ( | ... | ) | vlib_log(VLIB_LOG_LEVEL_ERR, 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_notice | ( | ... | ) | vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__) |
#define nat_log_warn | ( | ... | ) | vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__) |
#define snat_is_session_static | ( | s | ) | (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING) |
#define snat_is_unk_proto_session | ( | s | ) | (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO) |
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 u32( snat_get_worker_function_t) (ip4_header_t *ip, u32 rx_fib_index) |
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 struct snat_main_s snat_main_t |
enum snat_protocol_t |
enum snat_session_state_t |
enum twice_nat_type_t |
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;} | ) |
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.
[in,out] | sm | NAT main |
[in,out] | node | NAT node runtime |
[in] | thread_index | thread index |
[in,out] | b0 | buffer containing packet to be translated |
[out] | p_proto | protocol used for matching |
[out] | p_value | address and port after NAT translation |
[out] | p_dont_translate | if packet should not be translated |
d | optional parameter | |
e | optional parameter |
Definition at line 4293 of file in2out.c.
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_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.
[in] | sm | NAT main |
[in,out] | node | NAT node runtime |
[in] | thread_index | thread index |
[in,out] | b0 | buffer containing packet to be translated |
[out] | p_proto | protocol used for matching |
[out] | p_value | address and port after NAT translation |
[out] | p_dont_translate | if packet should not be translated |
d | optional parameter | |
e | optional parameter |
Definition at line 572 of file in2out.c.
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.
[in,out] | sm | NAT main |
[in,out] | node | NAT node runtime |
[in] | thread_index | thread index |
[in,out] | b0 | buffer containing packet to be translated |
[out] | p_proto | protocol used for matching |
[out] | p_value | address and port after NAT translation |
[out] | p_dont_translate | if packet should not be translated |
d | optional parameter | |
e | optional parameter |
Definition at line 468 of file in2out.c.
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.
[in,out] | sm | NAT main |
[in,out] | node | NAT node runtime |
[in] | thread_index | thread index |
[in,out] | b0 | buffer containing packet to be translated |
[out] | p_proto | protocol used for matching |
[out] | p_value | address and port after NAT translation |
[out] | p_dont_translate | if packet should not be translated |
d | optional parameter | |
e | optional parameter |
Definition at line 3330 of file out2in.c.
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 | ||
) |
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.
[in] | sm | NAT main |
[in,out] | node | NAT node runtime |
[in] | thread_index | thread index |
[in,out] | b0 | buffer containing packet to be translated |
[out] | p_proto | protocol used for matching |
[out] | p_value | address and port after NAT translation |
[out] | p_dont_translate | if packet should not be translated |
d | optional parameter | |
e | optional parameter |
Definition at line 404 of file out2in.c.
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.
[in,out] | sm | NAT main |
[in,out] | node | NAT node runtime |
[in] | thread_index | thread index |
[in,out] | b0 | buffer containing packet to be translated |
[out] | p_proto | protocol used for matching |
[out] | p_value | address and port after NAT translation |
[out] | p_dont_translate | if packet should not be translated |
d | optional parameter | |
e | optional parameter |
Definition at line 286 of file out2in.c.
void increment_v4_address | ( | ip4_address_t * | a | ) |
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, | ||
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_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 | ||
) |
int nat44_del_session | ( | snat_main_t * | sm, |
ip4_address_t * | addr, | ||
u16 | port, | ||
snat_protocol_t | proto, | ||
u32 | vrf_id, | ||
int | is_in | ||
) |
void nat_free_session_data | ( | snat_main_t * | sm, |
snat_session_t * | s, | ||
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_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 | ||
) |
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 | Interface. |
is_add | If 0 delete, otherwise add. |
Definition at line 634 of file nat.c.
int snat_add_interface_address | ( | snat_main_t * | sm, |
u32 | sw_if_index, | ||
int | is_del, | ||
u8 | twice_nat | ||
) |
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.
l_addr | Local IPv4 address. |
e_addr | External IPv4 address. |
l_port | Local port number. |
e_port | External port number. |
vrf_id | VRF ID. |
addr_only | If 0 address port and pair mapping, otherwise address only. |
sw_if_index | External port instead of specific IP address. |
is_add | If 0 delete static mapping, otherwise add. |
twice_nat | If 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_only | If 1 rule match only out2in direction |
tag | - opaque string tag |
Definition at line 796 of file nat.c.
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 | ||
) |
clib_error_t* snat_api_init | ( | vlib_main_t * | vm, |
snat_main_t * | sm | ||
) |
int snat_del_address | ( | snat_main_t * | sm, |
ip4_address_t | addr, | ||
u8 | delete_sm, | ||
u8 | twice_nat | ||
) |
void snat_free_outside_address_and_port | ( | snat_address_t * | addresses, |
u32 | thread_index, | ||
snat_session_key_t * | k, | ||
u32 | address_index | ||
) |
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, | ||
u8 * | lb | ||
) |
Match NAT44 static mapping.
sm | NAT main. |
match | Address and port to match. |
mapping | External or local address and port of the matched mapping. |
by_external | If 0 match by local address otherwise match by external address. |
is_addr_only | If matched mapping is address only |
twice_nat | If matched mapping is twice NAT. |
lb | If matched mapping is load-balanced. |
Definition at line 2101 of file nat.c.
uword unformat_snat_protocol | ( | unformat_input_t * | input, |
va_list * | args | ||
) |
format_function_t format_det_map_ses |
format_function_t format_snat_session |
format_function_t format_snat_static_map_to_resolve |
format_function_t format_snat_static_mapping |
format_function_t format_snat_user |
vlib_node_registration_t nat44_ed_hairpin_dst_node |
vlib_node_registration_t nat44_ed_hairpin_src_node |
vlib_node_registration_t nat44_ed_in2out_node |
vlib_node_registration_t nat44_ed_in2out_output_node |
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 |
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
vlib_node_registration_t nat44_ed_out2in_worker_handoff_node |
vlib_node_registration_t snat_det_in2out_node |
vlib_node_registration_t snat_det_out2in_node |
(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)
vlib_node_registration_t snat_hairpin_dst_node |
vlib_node_registration_t snat_hairpin_src_node |
vlib_node_registration_t snat_in2out_fast_node |
vlib_node_registration_t snat_in2out_node |
vlib_node_registration_t snat_in2out_output_node |
vlib_node_registration_t snat_in2out_output_worker_handoff_node |
vlib_node_registration_t snat_in2out_worker_handoff_node |
snat_main_t snat_main |
vlib_node_registration_t snat_out2in_fast_node |
(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)
vlib_node_registration_t snat_out2in_node |
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
vlib_node_registration_t snat_out2in_worker_handoff_node |
(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)