18 #ifndef __included_nat_h__ 19 #define __included_nat_h__ 36 #define SNAT_UDP_TIMEOUT 300 37 #define SNAT_TCP_TRANSITORY_TIMEOUT 240 38 #define SNAT_TCP_ESTABLISHED_TIMEOUT 7440 39 #define SNAT_ICMP_TIMEOUT 60 42 #define NAT_FQ_NELTS 64 45 #define SNAT_FLAG_HAIRPINNING (1 << 0) 71 #define nat_buffer_opaque(b) \ 72 ((nat_buffer_opaque_t *)((vnet_buffer_opaque2_t *)b->opaque2)->__unused2) 152 #define foreach_nat_config_flag \ 153 _(0x01, IS_TWICE_NAT) \ 154 _(0x02, IS_SELF_TWICE_NAT) \ 155 _(0x04, IS_OUT2IN_ONLY) \ 156 _(0x08, IS_ADDR_ONLY) \ 157 _(0x10, IS_OUTSIDE) \ 160 _(0x80, IS_EXT_HOST_VALID) \ 164 #define _(n,f) NAT_API_##f = n, 170 #define foreach_nat_addr_and_port_alloc_alg \ 171 _(0, DEFAULT, "default") \ 172 _(1, MAPE, "map-e") \ 173 _(2, RANGE, "port-range") 177 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v, 184 #define foreach_snat_protocol \ 185 _(UDP, 0, udp, "udp") \ 186 _(TCP, 1, tcp, "tcp") \ 187 _(ICMP, 2, icmp, "icmp") 191 #define _(N, i, n, s) SNAT_PROTOCOL_##N = i, 198 #define foreach_snat_session_state \ 199 _(0, UNKNOWN, "unknown") \ 200 _(1, UDP_ACTIVE, "udp-active") \ 201 _(2, TCP_SYN_SENT, "tcp-syn-sent") \ 202 _(3, TCP_ESTABLISHED, "tcp-established") \ 203 _(4, TCP_FIN_WAIT, "tcp-fin-wait") \ 204 _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \ 205 _(6, TCP_CLOSING, "tcp-closing") \ 206 _(7, TCP_LAST_ACK, "tcp-last-ack") \ 207 _(8, TCP_CLOSED, "tcp-closed") \ 208 _(9, ICMP_ACTIVE, "icmp-active") 212 #define _(v, N, s) SNAT_SESSION_##N = v, 217 #define foreach_nat_in2out_ed_error \ 218 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 219 _(IN2OUT_PACKETS, "good in2out packets processed") \ 220 _(OUT_OF_PORTS, "out of ports") \ 221 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 222 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 223 _(DROP_FRAGMENT, "drop fragment") \ 224 _(MAX_REASS, "maximum reassemblies exceeded") \ 225 _(MAX_FRAG, "maximum fragments per reassembly exceeded")\ 226 _(NON_SYN, "non-SYN packet try to create session") \ 227 _(TCP_PACKETS, "TCP packets") \ 228 _(UDP_PACKETS, "UDP packets") \ 229 _(ICMP_PACKETS, "ICMP packets") \ 230 _(OTHER_PACKETS, "other protocol packets") \ 231 _(FRAGMENTS, "fragments") \ 232 _(CACHED_FRAGMENTS, "cached fragments") \ 233 _(PROCESSED_FRAGMENTS, "processed fragments") 237 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym, 243 #define foreach_nat_out2in_ed_error \ 244 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 245 _(OUT2IN_PACKETS, "good out2in packets processed") \ 246 _(OUT_OF_PORTS, "out of ports") \ 247 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 248 _(NO_TRANSLATION, "no translation") \ 249 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 250 _(DROP_FRAGMENT, "drop fragment") \ 251 _(MAX_REASS, "maximum reassemblies exceeded") \ 252 _(MAX_FRAG, "maximum fragments per reassembly exceeded")\ 253 _(NON_SYN, "non-SYN packet try to create session") \ 254 _(TCP_PACKETS, "TCP packets") \ 255 _(UDP_PACKETS, "UDP packets") \ 256 _(ICMP_PACKETS, "ICMP packets") \ 257 _(OTHER_PACKETS, "other protocol packets") \ 258 _(FRAGMENTS, "fragments") \ 259 _(CACHED_FRAGMENTS, "cached fragments") \ 260 _(PROCESSED_FRAGMENTS, "processed fragments") 264 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym, 272 #define NAT44_SES_I2O_FIN 1 273 #define NAT44_SES_O2I_FIN 2 274 #define NAT44_SES_I2O_FIN_ACK 4 275 #define NAT44_SES_O2I_FIN_ACK 8 276 #define NAT44_SES_I2O_SYN 16 277 #define NAT44_SES_O2I_SYN 32 278 #define NAT44_SES_RST 64 281 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1 282 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2 283 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4 284 #define SNAT_SESSION_FLAG_TWICE_NAT 8 285 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT 16 286 #define SNAT_SESSION_FLAG_FWD_BYPASS 32 287 #define SNAT_SESSION_FLAG_AFFINITY 64 288 #define SNAT_SESSION_FLAG_OUTPUT_FEATURE 128 291 #define NAT_INTERFACE_FLAG_IS_INSIDE 1 292 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2 295 #define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY 1 296 #define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY 2 297 #define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT 4 298 #define NAT_STATIC_MAPPING_FLAG_LB 8 314 u32 per_user_list_head_index;
320 f64 ha_last_refreshed;
332 u16 ext_host_nat_port;
359 #define _(N, i, n, s) \ 360 u16 busy_##n##_ports; \ 361 u16 * busy_##n##_ports_per_thread; \ 362 uword * busy_##n##_port_bitmap; 530 u8 * p_dont_translate,
void *d,
550 u32 snat_thread_index);
765 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING) 771 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO) 777 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT) 783 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING) 789 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS) 795 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT) 801 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY) 807 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE 813 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE 819 #define nat44_is_ses_closed(s) s->state == 0xf 825 #define is_addr_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY) 831 #define is_out2in_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY) 837 #define is_identity_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT) 843 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB) 856 #define nat_log_err(...) \ 857 vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__) 858 #define nat_log_warn(...) \ 859 vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__) 860 #define nat_log_notice(...) \ 861 vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__) 862 #define nat_log_info(...) \ 863 vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__) 864 #define nat_log_debug(...)\ 865 vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__) 868 #define foreach_nat_log_level \ 871 _(0x02, LOG_WARNING) \ 872 _(0x03, LOG_NOTICE) \ 878 #define _(n,f) SNAT_##f = n, 883 #define nat_elog(_level, _str) \ 886 snat_main_t *sm = &snat_main; \ 887 if (PREDICT_FALSE (sm->log_level >= _level)) \ 889 ELOG_TYPE_DECLARE (e) = \ 891 .format = "nat-msg " _str, \ 894 ELOG_DATA (&sm->vlib_main->elog_main, e); \ 898 #define nat_elog_addr(_level, _str, _addr) \ 901 if (PREDICT_FALSE (sm->log_level >= _level)) \ 903 ELOG_TYPE_DECLARE (e) = \ 905 .format = "nat-msg " _str " %d.%d.%d.%d", \ 906 .format_args = "i1i1i1i1", \ 915 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 916 ed->oct4 = _addr >> 24; \ 917 ed->oct3 = _addr >> 16; \ 918 ed->oct2 = _addr >> 8; \ 923 #define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst) \ 926 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 928 ELOG_TYPE_DECLARE (e) = \ 930 .format = "nat-msg " _str " ip src: %d.%d.%d.%d dst: %d.%d.%d.%d" \ 931 " tid from: %d to: %d fib: %d", \ 932 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 948 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 949 ed->src_oct1 = _src >> 24; \ 950 ed->src_oct2 = _src >> 16; \ 951 ed->src_oct3 = _src >> 8; \ 952 ed->src_oct4 = _src; \ 953 ed->dst_oct1 = _dst >> 24; \ 954 ed->dst_oct2 = _dst >> 16; \ 955 ed->dst_oct3 = _dst >> 8; \ 956 ed->dst_oct4 = _dst; \ 957 ed->ftid = vlib_get_thread_index (); \ 963 #define nat_elog_debug_handoff_v2(_str, _prt, _fib, _src, _dst) \ 966 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 968 ELOG_TYPE_DECLARE (e) = \ 970 .format = "nat-msg " _str " ip_src:%d.%d.%d.%d ip_dst:%d.%d.%d.%d" \ 971 " tid:%d prt:%d fib:%d", \ 972 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 988 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 989 ed->src_oct1 = _src >> 24; \ 990 ed->src_oct2 = _src >> 16; \ 991 ed->src_oct3 = _src >> 8; \ 992 ed->src_oct4 = _src; \ 993 ed->dst_oct1 = _dst >> 24; \ 994 ed->dst_oct2 = _dst >> 16; \ 995 ed->dst_oct3 = _dst >> 8; \ 996 ed->dst_oct4 = _dst; \ 997 ed->tid = vlib_get_thread_index (); \ 1003 #define nat_elog_X1(_level, _fmt, _arg, _val1) \ 1006 snat_main_t *sm = &snat_main; \ 1007 if (PREDICT_FALSE (sm->log_level >= _level)) \ 1009 ELOG_TYPE_DECLARE (e) = \ 1011 .format = "nat-msg " _fmt, \ 1012 .format_args = _arg, \ 1014 CLIB_PACKED(struct \ 1016 typeof (_val1) val1; \ 1018 ed = ELOG_DATA (&sm->vlib_main->elog_main, e); \ 1023 #define nat_elog_notice(nat_elog_str) \ 1024 nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str) 1025 #define nat_elog_warn(nat_elog_str) \ 1026 nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str) 1027 #define nat_elog_err(nat_elog_str) \ 1028 nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str) 1029 #define nat_elog_debug(nat_elog_str) \ 1030 nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str) 1031 #define nat_elog_info(nat_elog_str) \ 1032 nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str) 1034 #define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1035 nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1036 #define nat_elog_warn_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1037 nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1038 #define nat_elog_err_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1039 nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1040 #define nat_elog_debug_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1041 nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1042 #define nat_elog_info_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1043 nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1050 u8 * p_dont_translate,
void *d,
void *e);
1055 u8 * p_dont_translate,
void *d,
void *e);
1060 u8 * p_dont_translate,
void *d,
void *e);
1065 u8 * p_dont_translate,
void *d,
void *e);
1072 u8 * p_dont_translate,
void *d,
void *e);
1077 u8 * p_dont_translate,
void *d,
void *e);
1084 u8 * p_dont_translate,
void *d,
void *e);
1089 u8 * p_dont_translate,
void *d,
void *e);
1092 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1097 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1114 u32 proto0,
int is_ed);
1183 snat_protocol_t
proto,
int is_add,
1184 twice_nat_type_t twice_nat,
u8 out2in_only,
1185 u8 * tag,
u8 identity_nat);
1203 snat_protocol_t
proto,
1205 twice_nat_type_t twice_nat,
1206 u8 out2in_only,
u8 * tag,
u32 affinity);
1296 u32 thread_index,
u8 is_ha);
1308 u32 fib_index,
u32 thread_index);
1320 u32 thread_index,
f64 now);
1331 u32 thread_index,
f64 now);
1383 u16 port_per_thread,
1384 u32 snat_thread_index);
1405 twice_nat_type_t * twice_nat,
1408 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)
vlib_node_registration_t snat_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_src_node)
enum fib_source_t_ fib_source_t
The different sources that can create a route.
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
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 interfce.
enum nat_log_level_t_ nat_log_level_t
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)
vlib_node_registration_t nat44_ed_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node)
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
#define foreach_snat_protocol
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
fib_source_t nat_fib_src_hi
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)
vlib_node_registration_t snat_out2in_fast_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)
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)
vlib_node_registration_t snat_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_dst_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.
vlib_node_registration_t nat44_ed_out2in_worker_handoff_node
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 addrres port)
void nat_set_alloc_addr_and_port_default(void)
Set address and port assignment algorithm to default/standard.
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)
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
vlib_node_registration_t nat44_ed_in2out_worker_handoff_node
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
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.
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
format_function_t format_nat_addr_and_port_alloc_alg
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)
void increment_v4_address(ip4_address_t *a)
Increment IPv4 address.
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_snat_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)
format_function_t format_snat_protocol
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
vlib_node_registration_t nat44_ed_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node)
vlib_simple_counter_main_t total_users
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
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
VLIB buffer representation.
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
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;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;u32 user_index;}) snat_session_t
void nat44_ed_hairpinning_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
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)
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)
vlib_node_registration_t snat_in2out_fast_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)
u32 translation_memory_size
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
vlib_node_registration_t nat44_ed_in2out_output_worker_handoff_node
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.
snat_session_t * sessions
snat_icmp_match_function_t * icmp_match_in2out_cb
#define foreach_nat_log_level
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.
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
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.
void nat44_reass_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, u16 sport, u16 dport, u32 proto0, int is_ed)
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)