19 #ifndef __included_nat_h__ 20 #define __included_nat_h__ 40 #define SNAT_UDP_TIMEOUT 300 41 #define SNAT_TCP_TRANSITORY_TIMEOUT 240 42 #define SNAT_TCP_ESTABLISHED_TIMEOUT 7440 43 #define SNAT_ICMP_TIMEOUT 60 46 #define NAT_FQ_NELTS 64 49 #define SNAT_FLAG_HAIRPINNING (1 << 0) 87 #define foreach_nat_config_flag \ 88 _(0x01, IS_TWICE_NAT) \ 89 _(0x02, IS_SELF_TWICE_NAT) \ 90 _(0x04, IS_OUT2IN_ONLY) \ 91 _(0x08, IS_ADDR_ONLY) \ 95 _(0x80, IS_EXT_HOST_VALID) \ 99 #define _(n,f) NAT_API_##f = n, 105 #define foreach_nat_addr_and_port_alloc_alg \ 106 _(0, DEFAULT, "default") \ 107 _(1, MAPE, "map-e") \ 108 _(2, RANGE, "port-range") 112 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v, 118 #define foreach_snat_session_state \ 119 _(0, UNKNOWN, "unknown") \ 120 _(1, UDP_ACTIVE, "udp-active") \ 121 _(2, TCP_SYN_SENT, "tcp-syn-sent") \ 122 _(3, TCP_ESTABLISHED, "tcp-established") \ 123 _(4, TCP_FIN_WAIT, "tcp-fin-wait") \ 124 _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \ 125 _(6, TCP_CLOSING, "tcp-closing") \ 126 _(7, TCP_LAST_ACK, "tcp-last-ack") \ 127 _(8, TCP_CLOSED, "tcp-closed") \ 128 _(9, ICMP_ACTIVE, "icmp-active") 132 #define _(v, N, s) SNAT_SESSION_##N = v, 137 #define foreach_nat_in2out_ed_error \ 138 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 139 _(OUT_OF_PORTS, "out of ports") \ 140 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 141 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 142 _(NON_SYN, "non-SYN packet try to create session") \ 143 _(TCP_CLOSED, "drops due to TCP in transitory timeout") 147 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym, 153 #define foreach_nat_out2in_ed_error \ 154 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 155 _(OUT_OF_PORTS, "out of ports") \ 156 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 157 _(NO_TRANSLATION, "no translation") \ 158 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 159 _(MAX_USER_SESS_EXCEEDED, "max user sessions exceeded") \ 160 _(CANNOT_CREATE_USER, "cannot create NAT user") \ 161 _(NON_SYN, "non-SYN packet try to create session") \ 162 _(TCP_CLOSED, "drops due to TCP in transitory timeout") 166 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym, 174 #define NAT44_SES_I2O_FIN 1 175 #define NAT44_SES_O2I_FIN 2 176 #define NAT44_SES_I2O_FIN_ACK 4 177 #define NAT44_SES_O2I_FIN_ACK 8 178 #define NAT44_SES_I2O_SYN 16 179 #define NAT44_SES_O2I_SYN 32 180 #define NAT44_SES_RST 64 183 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1 184 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2 185 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4 186 #define SNAT_SESSION_FLAG_TWICE_NAT 8 187 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT 16 188 #define SNAT_SESSION_FLAG_FWD_BYPASS 32 189 #define SNAT_SESSION_FLAG_AFFINITY 64 190 #define SNAT_SESSION_FLAG_OUTPUT_FEATURE 128 191 #define SNAT_SESSION_FLAG_EXACT_ADDRESS 256 194 #define NAT_INTERFACE_FLAG_IS_INSIDE 1 195 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2 198 #define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY 1 199 #define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY 2 200 #define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT 4 201 #define NAT_STATIC_MAPPING_FLAG_LB 8 202 #define NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS 16 215 }) per_vrf_sessions_t;
244 u32 per_user_list_head_index;
256 f64 ha_last_refreshed;
268 u16 ext_host_nat_port;
274 u64 tcp_closed_timestamp;
280 u32 per_vrf_sessions_index;
299 #define _(N, i, n, s) \ 300 u16 busy_##n##_ports; \ 301 u16 * busy_##n##_ports_per_thread; \ 302 u32 busy_##n##_port_refcounts[65535]; 464 u8 * dont_translate);
485 u32 snat_thread_index);
487 #define foreach_nat_counter _ (tcp) _ (udp) _ (icmp) _ (other) _ (drops) 632 #define _(x) vlib_simple_counter_main_t x; 748 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING) 754 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO) 760 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT) 766 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING) 772 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS) 778 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT) 784 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY) 790 #define is_exact_address_session(s) (s->flags & SNAT_SESSION_FLAG_EXACT_ADDRESS) 796 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE 802 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE 808 #define nat44_is_ses_closed(s) s->state == 0xf 814 #define is_addr_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY) 820 #define is_out2in_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY) 826 #define is_identity_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT) 832 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB) 838 #define is_exact_address(s) (s->flags & NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS) 851 #define nat_log_err(...) \ 852 vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__) 853 #define nat_log_warn(...) \ 854 vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__) 855 #define nat_log_notice(...) \ 856 vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__) 857 #define nat_log_info(...) \ 858 vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__) 859 #define nat_log_debug(...)\ 860 vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__) 863 #define foreach_nat_log_level \ 866 _(0x02, LOG_WARNING) \ 867 _(0x03, LOG_NOTICE) \ 873 #define _(n,f) SNAT_##f = n, 878 #define nat_elog(_level, _str) \ 881 snat_main_t *sm = &snat_main; \ 882 if (PREDICT_FALSE (sm->log_level >= _level)) \ 884 ELOG_TYPE_DECLARE (e) = \ 886 .format = "nat-msg " _str, \ 889 ELOG_DATA (&vlib_global_main.elog_main, e); \ 893 #define nat_elog_addr(_level, _str, _addr) \ 896 if (PREDICT_FALSE (sm->log_level >= _level)) \ 898 ELOG_TYPE_DECLARE (e) = \ 900 .format = "nat-msg " _str " %d.%d.%d.%d", \ 901 .format_args = "i1i1i1i1", \ 910 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 911 ed->oct4 = _addr >> 24; \ 912 ed->oct3 = _addr >> 16; \ 913 ed->oct2 = _addr >> 8; \ 918 #define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst) \ 921 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 923 ELOG_TYPE_DECLARE (e) = \ 925 .format = "nat-msg " _str " ip src: %d.%d.%d.%d dst: %d.%d.%d.%d" \ 926 " tid from: %d to: %d fib: %d", \ 927 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 943 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 944 ed->src_oct1 = _src >> 24; \ 945 ed->src_oct2 = _src >> 16; \ 946 ed->src_oct3 = _src >> 8; \ 947 ed->src_oct4 = _src; \ 948 ed->dst_oct1 = _dst >> 24; \ 949 ed->dst_oct2 = _dst >> 16; \ 950 ed->dst_oct3 = _dst >> 8; \ 951 ed->dst_oct4 = _dst; \ 952 ed->ftid = vlib_get_thread_index (); \ 958 #define nat_elog_debug_handoff_v2(_str, _prt, _fib, _src, _dst) \ 961 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 963 ELOG_TYPE_DECLARE (e) = \ 965 .format = "nat-msg " _str " ip_src:%d.%d.%d.%d ip_dst:%d.%d.%d.%d" \ 966 " tid:%d prt:%d fib:%d", \ 967 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 983 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 984 ed->src_oct1 = _src >> 24; \ 985 ed->src_oct2 = _src >> 16; \ 986 ed->src_oct3 = _src >> 8; \ 987 ed->src_oct4 = _src; \ 988 ed->dst_oct1 = _dst >> 24; \ 989 ed->dst_oct2 = _dst >> 16; \ 990 ed->dst_oct3 = _dst >> 8; \ 991 ed->dst_oct4 = _dst; \ 992 ed->tid = vlib_get_thread_index (); \ 998 #define nat_elog_X1(_level, _fmt, _arg, _val1) \ 1001 snat_main_t *sm = &snat_main; \ 1002 if (PREDICT_FALSE (sm->log_level >= _level)) \ 1004 ELOG_TYPE_DECLARE (e) = \ 1006 .format = "nat-msg " _fmt, \ 1007 .format_args = _arg, \ 1009 CLIB_PACKED(struct \ 1011 typeof (_val1) val1; \ 1013 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 1018 #define nat_elog_notice(nat_elog_str) \ 1019 nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str) 1020 #define nat_elog_warn(nat_elog_str) \ 1021 nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str) 1022 #define nat_elog_err(nat_elog_str) \ 1023 nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str) 1024 #define nat_elog_debug(nat_elog_str) \ 1025 nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str) 1026 #define nat_elog_info(nat_elog_str) \ 1027 nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str) 1029 #define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1030 nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1031 #define nat_elog_warn_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1032 nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1033 #define nat_elog_err_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1034 nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1035 #define nat_elog_debug_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1036 nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1037 #define nat_elog_info_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1038 nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1044 u16 * port,
u32 * fib_index,
1046 u8 * dont_translate);
1050 u16 * port,
u32 * fib_index,
1052 u8 * dont_translate);
1056 u16 * port,
u32 * fib_index,
1058 u8 * dont_translate);
1062 u16 * port,
u32 * fib_index,
1064 u8 * dont_translate);
1071 void *d,
void *e,
u8 * dont_translate);
1076 void *d,
void *e,
u8 * dont_translate);
1079 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1084 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1169 twice_nat_type_t twice_nat,
u8 out2in_only,
1170 u8 * tag,
u8 identity_nat,
1191 twice_nat_type_t twice_nat,
1192 u8 out2in_only,
u8 * tag,
u32 affinity);
1284 u32 thread_index,
u8 is_ha);
1312 u32 thread_index,
u8 is_ha);
1356 u32 thread_index,
f64 now);
1411 u16 port_per_thread,
1412 u32 snat_thread_index);
1437 u32 match_fib_index,
1441 u32 * mapping_fib_index,
1444 twice_nat_type_t * twice_nat,
1447 u8 * is_identity_nat,
ip4_address_t external_addr
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Delete external address from NAT44 pool.
clib_error_t * snat_api_init(vlib_main_t *vm, snat_main_t *sm)
int snat_static_mapping_match(snat_main_t *sm, ip4_address_t match_addr, u16 match_port, u32 match_fib_index, nat_protocol_t match_protocol, ip4_address_t *mapping_addr, u16 *mapping_port, u32 *mapping_fib_index, u8 by_external, u8 *is_addr_only, twice_nat_type_t *twice_nat, lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_nat, snat_static_mapping_t **out)
Match NAT44 static mapping.
#define foreach_nat_addr_and_port_alloc_alg
nat_outside_fib_t * outside_fibs
vlib_node_registration_t nat_default_node
(constructor) VLIB_REGISTER_NODE (nat_default_node)
enum fib_source_t_ fib_source_t
The different sources that can create a route.
uword translation_memory_size
u32 * max_translations_per_fib
nat_addr_and_port_alloc_alg_t
u32 sessions_per_user_list_head_index
clib_bihash_16_8_t out2in_ed
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 feature on the interface.
u32 icmp_out2in(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
u32 hairpin_dst_node_index
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, ip4_address_t *addr, u16 port, nat_protocol_t protocol)
Free outside address and port pair.
u32 ed_hairpinning_node_index
u32 icmp_match_out2in_ed(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
vl_api_wireguard_peer_flags_t flags
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u32 affinity)
Add/delete static mapping with load-balancing (multiple backends)
u32 fq_in2out_output_index
int() nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
snat_session_t * nat_session_alloc_or_recycle(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate new NAT session or recycle last used.
#define foreach_snat_session_state
vl_api_ip_port_and_mask_t dst_port
int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
Add/delete NAT44 pool address from specific interface.
enum nat_log_level_t_ nat_log_level_t
per_vrf_sessions_t * per_vrf_sessions_vec
format_function_t format_nat_protocol
u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation.
u32 ed_out2in_slowpath_node_index
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
#define foreach_nat_in2out_ed_error
u32() snat_icmp_match_function_t(struct snat_main_s *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
int nat44_i2o_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
format_function_t format_snat_static_mapping
format_function_t format_snat_key
nat_alloc_out_addr_and_port_function_t * alloc_addr_and_port
NAT port/address allocation lib.
struct _tcp_header tcp_header_t
int snat_hairpinning(vlib_main_t *vm, vlib_node_runtime_t *node, snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0, int is_ed, int do_trace)
u32 max_translations_per_thread
vlib_simple_counter_main_t hairpinning
struct snat_main_s::@91::@92::@95 out2in
nat44_lb_addr_port_t * locals
int snat_set_workers(uword *bitmap)
Set NAT plugin workers.
clib_bihash_8_8_t user_hash
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.
u32 max_translations_per_user
vl_api_ip_proto_t protocol
u32 in2out_output_node_index
snat_get_worker_out2in_function_t * worker_out2in_cb
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
int nat44_set_session_limit(u32 session_limit, u32 vrf_id)
Set NAT44 session limit (session limit, vrf id)
u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
fib_source_t nat_fib_src_hi
void nat44_db_free(snat_main_per_thread_data_t *tsm)
Free NAT44 data.
struct snat_main_s::@91::@92::@94 in2out
int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
void nat44_sessions_clear()
A collection of simple counters.
vlib_node_registration_t snat_in2out_output_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)
vlib_node_registration_t snat_in2out_output_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)
fib_source_t nat_fib_src_low
u32() snat_get_worker_out2in_function_t(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
twice_nat_type_t twice_nat
u32 * auto_add_sw_if_indices_twice_nat
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
u32 handoff_in2out_output_index
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
#define foreach_nat_out2in_ed_error
u32 pre_in2out_node_index
snat_static_mapping_t * static_mappings
struct snat_main_s::@91 counters
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.
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index, u8 is_ha)
Free NAT44 session data (lookup keys, external address port)
void nat_set_alloc_addr_and_port_default(void)
Set address and port assignment algorithm to default/standard.
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.
u32 hairpin_src_node_index
clib_bihash_8_8_t static_mapping_by_external
u32 in2out_slowpath_output_node_index
struct snat_main_s snat_main_t
struct snat_main_s::@91::@93 slowpath
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
u8 translation_memory_size_set
API main structure, used by both vpp and binary API clients.
int nat44_o2i_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
snat_interface_t * output_feature_interfaces
u32 pre_out2in_node_index
u32 ed_hairpin_src_node_index
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
vl_api_ip_port_and_mask_t src_port
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
u8 static_mapping_connection_tracking
format_function_t format_snat_static_map_to_resolve
u32 ed_in2out_slowpath_node_index
int nat44_lb_static_mapping_add_del_local(ip4_address_t e_addr, u16 e_port, ip4_address_t l_addr, u16 l_port, nat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add)
format_function_t format_nat_addr_and_port_alloc_alg
void nat44_db_init(snat_main_per_thread_data_t *tsm)
Initialize NAT44 data.
8 octet key, 8 octet key value pair
u32 ed_hairpin_dst_node_index
#define foreach_nat_config_flag
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.
u32() snat_get_worker_in2out_function_t(ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
u32 tcp_transitory_timeout
typedef CLIB_PACKED(struct { u32 ses_count;u32 rx_fib_index;u32 tx_fib_index;u8 expired;}) per_vrf_sessions_t
vlib_main_t vlib_node_runtime_t * node
u32 * auto_add_sw_if_indices
u32 in2out_fast_node_index
void nat44_add_del_address_dpo(ip4_address_t addr, u8 is_add)
Add/delete external address to FIB DPO (out2in DPO mode)
unformat_function_t unformat_nat_protocol
u32 in2out_slowpath_node_index
snat_icmp_match_function_t * icmp_match_out2in_cb
vlib_log_class_t log_class
vlib_node_registration_t snat_out2in_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)
u32 icmp_match_in2out_ed(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, u32 sw_if_index, nat_protocol_t proto, int is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat, ip4_address_t pool_addr, int exact)
Add/delete NAT44 static mapping.
snat_address_t * twice_nat_addresses
format_function_t format_snat_session
struct _vlib_node_registration vlib_node_registration_t
u32 unk_proto_lru_head_index
vlib_simple_counter_main_t total_users
int nat44_del_session(snat_main_t *sm, ip4_address_t *addr, u16 port, nat_protocol_t proto, u32 vrf_id, int is_in)
Delete NAT44 session.
struct snat_main_s::@91::@92 fastpath
void nat_hairpinning_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
format_function_t format_static_mapping_key
u32 hairpinning_node_index
u32 tcp_trans_lru_head_index
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
VLIB buffer representation.
u32 tcp_estab_lru_head_index
snat_main_per_thread_data_t * per_thread_data
void expire_per_vrf_sessions(u32 fib_index)
int nat44_update_session_limit(u32 session_limit, u32 vrf_id)
Update NAT44 session limit flushing all data (session limit, vrf id)
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
u32 affinity_per_service_list_head_index
snat_address_t * addresses
u32 out2in_fast_node_index
u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
void nat_set_alloc_addr_and_port_range(u16 start_port, u16 end_port)
Set address and port assignment algorithm for port range.
format_function_t format_snat_user
snat_get_worker_in2out_function_t * worker_in2out_cb
snat_static_map_resolve_t * to_resolve
u8 * format_user_kvp(u8 *s, va_list *args)
void nat44_ed_hairpinning_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
vl_api_dhcp_client_state_t state
vlib_node_registration_t snat_in2out_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)
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)
u32 icmp_in2out(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
enum nat_config_flags_t_ nat_config_flags_t
clib_bihash_16_8_t in2out_ed
struct snat_main_s::@91::@92::@96 in2out_ed
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation.
vlib_simple_counter_main_t total_sessions
ip_lookup_main_t * ip4_lookup_main
void nat44_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index, u8 is_ha)
Free NAT44 ED session data (lookup keys, external address port)
snat_session_t * sessions
snat_icmp_match_function_t * icmp_match_in2out_cb
#define foreach_nat_log_level
clib_bihash_8_8_t static_mapping_by_local
vl_api_interface_index_t sw_if_index
snat_interface_t * interfaces
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
u32 tcp_established_timeout
vlib_simple_counter_main_t user_limit_reached
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)