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) 116 #define foreach_nat_config_flag \ 117 _(0x01, IS_TWICE_NAT) \ 118 _(0x02, IS_SELF_TWICE_NAT) \ 119 _(0x04, IS_OUT2IN_ONLY) \ 120 _(0x08, IS_ADDR_ONLY) \ 121 _(0x10, IS_OUTSIDE) \ 124 _(0x80, IS_EXT_HOST_VALID) \ 128 #define _(n,f) NAT_API_##f = n, 134 #define foreach_nat_addr_and_port_alloc_alg \ 135 _(0, DEFAULT, "default") \ 136 _(1, MAPE, "map-e") \ 137 _(2, RANGE, "port-range") 141 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v, 147 #define foreach_snat_session_state \ 148 _(0, UNKNOWN, "unknown") \ 149 _(1, UDP_ACTIVE, "udp-active") \ 150 _(2, TCP_SYN_SENT, "tcp-syn-sent") \ 151 _(3, TCP_ESTABLISHED, "tcp-established") \ 152 _(4, TCP_FIN_WAIT, "tcp-fin-wait") \ 153 _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \ 154 _(6, TCP_CLOSING, "tcp-closing") \ 155 _(7, TCP_LAST_ACK, "tcp-last-ack") \ 156 _(8, TCP_CLOSED, "tcp-closed") \ 157 _(9, ICMP_ACTIVE, "icmp-active") 161 #define _(v, N, s) SNAT_SESSION_##N = v, 166 #define foreach_nat_in2out_ed_error \ 167 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 168 _(IN2OUT_PACKETS, "good in2out packets processed") \ 169 _(OUT_OF_PORTS, "out of ports") \ 170 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 171 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 172 _(MAX_USER_SESS_EXCEEDED, "max user sessions exceeded") \ 173 _(DROP_FRAGMENT, "drop fragment") \ 174 _(CANNOT_CREATE_USER, "cannot create NAT user") \ 175 _(NON_SYN, "non-SYN packet try to create session") \ 176 _(TCP_PACKETS, "TCP packets") \ 177 _(TCP_CLOSED, "drops due to TCP in transitory timeout") \ 178 _(UDP_PACKETS, "UDP packets") \ 179 _(ICMP_PACKETS, "ICMP packets") \ 180 _(OTHER_PACKETS, "other protocol packets") \ 181 _(FRAGMENTS, "fragments") \ 182 _(CACHED_FRAGMENTS, "cached fragments") \ 183 _(PROCESSED_FRAGMENTS, "processed fragments") 187 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym, 193 #define foreach_nat_out2in_ed_error \ 194 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 195 _(OUT2IN_PACKETS, "good out2in packets processed") \ 196 _(OUT_OF_PORTS, "out of ports") \ 197 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 198 _(NO_TRANSLATION, "no translation") \ 199 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 200 _(MAX_USER_SESS_EXCEEDED, "max user sessions exceeded") \ 201 _(DROP_FRAGMENT, "drop fragment") \ 202 _(CANNOT_CREATE_USER, "cannot create NAT user") \ 203 _(NON_SYN, "non-SYN packet try to create session") \ 204 _(TCP_PACKETS, "TCP packets") \ 205 _(TCP_CLOSED, "drops due to TCP in transitory timeout") \ 206 _(UDP_PACKETS, "UDP packets") \ 207 _(ICMP_PACKETS, "ICMP packets") \ 208 _(OTHER_PACKETS, "other protocol packets") \ 209 _(FRAGMENTS, "fragments") \ 210 _(CACHED_FRAGMENTS, "cached fragments") \ 211 _(PROCESSED_FRAGMENTS, "processed fragments") 215 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym, 223 #define NAT44_SES_I2O_FIN 1 224 #define NAT44_SES_O2I_FIN 2 225 #define NAT44_SES_I2O_FIN_ACK 4 226 #define NAT44_SES_O2I_FIN_ACK 8 227 #define NAT44_SES_I2O_SYN 16 228 #define NAT44_SES_O2I_SYN 32 229 #define NAT44_SES_RST 64 232 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1 233 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2 234 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4 235 #define SNAT_SESSION_FLAG_TWICE_NAT 8 236 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT 16 237 #define SNAT_SESSION_FLAG_FWD_BYPASS 32 238 #define SNAT_SESSION_FLAG_AFFINITY 64 239 #define SNAT_SESSION_FLAG_OUTPUT_FEATURE 128 242 #define NAT_INTERFACE_FLAG_IS_INSIDE 1 243 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2 246 #define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY 1 247 #define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY 2 248 #define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT 4 249 #define NAT_STATIC_MAPPING_FLAG_LB 8 265 u32 per_user_list_head_index;
277 f64 ha_last_refreshed;
289 u16 ext_host_nat_port;
295 u64 tcp_closed_timestamp;
317 #define _(N, i, n, s) \ 318 u16 busy_##n##_ports; \ 319 u16 * busy_##n##_ports_per_thread; \ 320 u32 busy_##n##_port_refcounts[65535]; 497 u8 * p_dont_translate,
void *d,
517 u32 snat_thread_index);
728 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING) 734 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO) 740 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT) 746 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING) 752 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS) 758 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT) 764 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY) 770 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE 776 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE 782 #define nat44_is_ses_closed(s) s->state == 0xf 788 #define is_addr_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY) 794 #define is_out2in_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY) 800 #define is_identity_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT) 806 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB) 819 #define nat_log_err(...) \ 820 vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__) 821 #define nat_log_warn(...) \ 822 vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__) 823 #define nat_log_notice(...) \ 824 vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__) 825 #define nat_log_info(...) \ 826 vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__) 827 #define nat_log_debug(...)\ 828 vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__) 831 #define foreach_nat_log_level \ 834 _(0x02, LOG_WARNING) \ 835 _(0x03, LOG_NOTICE) \ 841 #define _(n,f) SNAT_##f = n, 846 #define nat_elog(_level, _str) \ 849 snat_main_t *sm = &snat_main; \ 850 if (PREDICT_FALSE (sm->log_level >= _level)) \ 852 ELOG_TYPE_DECLARE (e) = \ 854 .format = "nat-msg " _str, \ 857 ELOG_DATA (&vlib_global_main.elog_main, e); \ 861 #define nat_elog_addr(_level, _str, _addr) \ 864 if (PREDICT_FALSE (sm->log_level >= _level)) \ 866 ELOG_TYPE_DECLARE (e) = \ 868 .format = "nat-msg " _str " %d.%d.%d.%d", \ 869 .format_args = "i1i1i1i1", \ 878 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 879 ed->oct4 = _addr >> 24; \ 880 ed->oct3 = _addr >> 16; \ 881 ed->oct2 = _addr >> 8; \ 886 #define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst) \ 889 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 891 ELOG_TYPE_DECLARE (e) = \ 893 .format = "nat-msg " _str " ip src: %d.%d.%d.%d dst: %d.%d.%d.%d" \ 894 " tid from: %d to: %d fib: %d", \ 895 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 911 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 912 ed->src_oct1 = _src >> 24; \ 913 ed->src_oct2 = _src >> 16; \ 914 ed->src_oct3 = _src >> 8; \ 915 ed->src_oct4 = _src; \ 916 ed->dst_oct1 = _dst >> 24; \ 917 ed->dst_oct2 = _dst >> 16; \ 918 ed->dst_oct3 = _dst >> 8; \ 919 ed->dst_oct4 = _dst; \ 920 ed->ftid = vlib_get_thread_index (); \ 926 #define nat_elog_debug_handoff_v2(_str, _prt, _fib, _src, _dst) \ 929 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 931 ELOG_TYPE_DECLARE (e) = \ 933 .format = "nat-msg " _str " ip_src:%d.%d.%d.%d ip_dst:%d.%d.%d.%d" \ 934 " tid:%d prt:%d fib:%d", \ 935 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 951 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 952 ed->src_oct1 = _src >> 24; \ 953 ed->src_oct2 = _src >> 16; \ 954 ed->src_oct3 = _src >> 8; \ 955 ed->src_oct4 = _src; \ 956 ed->dst_oct1 = _dst >> 24; \ 957 ed->dst_oct2 = _dst >> 16; \ 958 ed->dst_oct3 = _dst >> 8; \ 959 ed->dst_oct4 = _dst; \ 960 ed->tid = vlib_get_thread_index (); \ 966 #define nat_elog_X1(_level, _fmt, _arg, _val1) \ 969 snat_main_t *sm = &snat_main; \ 970 if (PREDICT_FALSE (sm->log_level >= _level)) \ 972 ELOG_TYPE_DECLARE (e) = \ 974 .format = "nat-msg " _fmt, \ 975 .format_args = _arg, \ 979 typeof (_val1) val1; \ 981 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 986 #define nat_elog_notice(nat_elog_str) \ 987 nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str) 988 #define nat_elog_warn(nat_elog_str) \ 989 nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str) 990 #define nat_elog_err(nat_elog_str) \ 991 nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str) 992 #define nat_elog_debug(nat_elog_str) \ 993 nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str) 994 #define nat_elog_info(nat_elog_str) \ 995 nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str) 997 #define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 998 nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 999 #define nat_elog_warn_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1000 nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1001 #define nat_elog_err_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1002 nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1003 #define nat_elog_debug_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1004 nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1005 #define nat_elog_info_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1006 nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1013 u8 * p_dont_translate,
void *d,
void *e);
1018 u8 * p_dont_translate,
void *d,
void *e);
1023 u8 * p_dont_translate,
void *d,
void *e);
1028 u8 * p_dont_translate,
void *d,
void *e);
1035 u8 * p_dont_translate,
void *d,
void *e);
1040 u8 * p_dont_translate,
void *d,
void *e);
1047 u8 * p_dont_translate,
void *d,
void *e);
1052 u8 * p_dont_translate,
void *d,
void *e);
1055 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1060 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1141 twice_nat_type_t twice_nat,
u8 out2in_only,
1142 u8 * tag,
u8 identity_nat);
1162 twice_nat_type_t twice_nat,
1163 u8 out2in_only,
u8 * tag,
u32 affinity);
1255 u32 thread_index,
u8 is_ha);
1275 u32 thread_index,
u8 is_ha);
1317 u32 thread_index,
f64 now);
1369 u16 port_per_thread,
1370 u32 snat_thread_index);
1391 twice_nat_type_t * twice_nat,
1394 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)
#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
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
u32 ed_hairpinning_node_index
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
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...
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
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
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)
Add/delete NAT44 static mapping.
format_function_t format_nat_protocol
u32 ed_out2in_slowpath_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, 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...
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
format_function_t format_det_map_ses
#define foreach_nat_in2out_ed_error
vlib_node_registration_t snat_det_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)
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
snat_det_map_t * det_maps
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(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)
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)
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
u32 in2out_output_node_index
snat_get_worker_out2in_function_t * worker_out2in_cb
vl_api_interface_index_t sw_if_index
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
ip4_address_t ext_host_addr
u32 det_in2out_node_index
int nat44_set_session_limit(u32 session_limit, u32 vrf_id)
Set NAT44 session limit (session limit, vrf id)
fib_source_t nat_fib_src_hi
void nat44_db_free(snat_main_per_thread_data_t *tsm)
Free NAT44 data.
int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
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 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...
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
clib_bihash_16_8_t out2in_ed
snat_det_session_t * sessions
u32 pre_in2out_node_index
snat_static_mapping_t * static_mappings
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
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
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...
vlib_node_registration_t snat_det_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)
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.
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.
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)
vlib_main_t vlib_node_runtime_t * node
u32 tcp_transitory_timeout
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)
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...
unformat_function_t unformat_nat_protocol
u32 det_out2in_node_index
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.
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)
snat_address_t * twice_nat_addresses
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.
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.
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)
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;u32 lru_head_index;u32 lru_index;f64 last_lru_update;f64 last_heard;f64 ha_last_refreshed;u64 total_bytes;u32 total_pkts;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;u64 tcp_closed_timestamp;u32 user_index;}) snat_session_t
VLIB buffer representation.
u32 tcp_estab_lru_head_index
snat_main_per_thread_data_t * per_thread_data
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
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 affinity_per_service_list_head_index
snat_address_t * addresses
u32 out2in_fast_node_index
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
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_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.
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
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)
vlib_simple_counter_main_t total_sessions
ip_lookup_main_t * ip4_lookup_main
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.
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
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)
clib_bihash_8_8_t static_mapping_by_local
snat_interface_t * interfaces
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
u32 tcp_established_timeout
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)
int() nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)