18 #ifndef __included_nat_h__ 19 #define __included_nat_h__ 35 #define SNAT_UDP_TIMEOUT 300 36 #define SNAT_TCP_TRANSITORY_TIMEOUT 240 37 #define SNAT_TCP_ESTABLISHED_TIMEOUT 7440 38 #define SNAT_ICMP_TIMEOUT 60 41 #define NAT_FQ_NELTS 64 44 #define SNAT_FLAG_HAIRPINNING (1 << 0) 73 #define nat_buffer_opaque(b) \ 74 ((nat_buffer_opaque_t *)((vnet_buffer_opaque2_t *)b->opaque2)->__unused2) 154 #define foreach_nat_config_flag \ 155 _(0x01, IS_TWICE_NAT) \ 156 _(0x02, IS_SELF_TWICE_NAT) \ 157 _(0x04, IS_OUT2IN_ONLY) \ 158 _(0x08, IS_ADDR_ONLY) \ 159 _(0x10, IS_OUTSIDE) \ 162 _(0x80, IS_EXT_HOST_VALID) \ 166 #define _(n,f) NAT_API_##f = n, 172 #define foreach_nat_addr_and_port_alloc_alg \ 173 _(0, DEFAULT, "default") \ 174 _(1, MAPE, "map-e") \ 175 _(2, RANGE, "port-range") 179 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v, 186 #define foreach_snat_protocol \ 187 _(UDP, 0, udp, "udp") \ 188 _(TCP, 1, tcp, "tcp") \ 189 _(ICMP, 2, icmp, "icmp") 193 #define _(N, i, n, s) SNAT_PROTOCOL_##N = i, 200 #define foreach_snat_session_state \ 201 _(0, UNKNOWN, "unknown") \ 202 _(1, UDP_ACTIVE, "udp-active") \ 203 _(2, TCP_SYN_SENT, "tcp-syn-sent") \ 204 _(3, TCP_ESTABLISHED, "tcp-established") \ 205 _(4, TCP_FIN_WAIT, "tcp-fin-wait") \ 206 _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \ 207 _(6, TCP_CLOSING, "tcp-closing") \ 208 _(7, TCP_LAST_ACK, "tcp-last-ack") \ 209 _(8, TCP_CLOSED, "tcp-closed") \ 210 _(9, ICMP_ACTIVE, "icmp-active") 214 #define _(v, N, s) SNAT_SESSION_##N = v, 219 #define foreach_nat_in2out_ed_error \ 220 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 221 _(IN2OUT_PACKETS, "good in2out packets processed") \ 222 _(OUT_OF_PORTS, "out of ports") \ 223 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 224 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 225 _(DROP_FRAGMENT, "drop fragment") \ 226 _(MAX_REASS, "maximum reassemblies exceeded") \ 227 _(MAX_FRAG, "maximum fragments per reassembly exceeded")\ 228 _(NON_SYN, "non-SYN packet try to create session") \ 229 _(TCP_PACKETS, "TCP packets") \ 230 _(UDP_PACKETS, "UDP packets") \ 231 _(ICMP_PACKETS, "ICMP packets") \ 232 _(OTHER_PACKETS, "other protocol packets") \ 233 _(FRAGMENTS, "fragments") \ 234 _(CACHED_FRAGMENTS, "cached fragments") \ 235 _(PROCESSED_FRAGMENTS, "processed fragments") 239 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym, 245 #define foreach_nat_out2in_ed_error \ 246 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 247 _(OUT2IN_PACKETS, "good out2in packets processed") \ 248 _(OUT_OF_PORTS, "out of ports") \ 249 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 250 _(NO_TRANSLATION, "no translation") \ 251 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 252 _(DROP_FRAGMENT, "drop fragment") \ 253 _(MAX_REASS, "maximum reassemblies exceeded") \ 254 _(MAX_FRAG, "maximum fragments per reassembly exceeded")\ 255 _(NON_SYN, "non-SYN packet try to create session") \ 256 _(TCP_PACKETS, "TCP packets") \ 257 _(UDP_PACKETS, "UDP packets") \ 258 _(ICMP_PACKETS, "ICMP packets") \ 259 _(OTHER_PACKETS, "other protocol packets") \ 260 _(FRAGMENTS, "fragments") \ 261 _(CACHED_FRAGMENTS, "cached fragments") \ 262 _(PROCESSED_FRAGMENTS, "processed fragments") 266 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym, 274 #define NAT44_SES_I2O_FIN 1 275 #define NAT44_SES_O2I_FIN 2 276 #define NAT44_SES_I2O_FIN_ACK 4 277 #define NAT44_SES_O2I_FIN_ACK 8 278 #define NAT44_SES_I2O_SYN 16 279 #define NAT44_SES_O2I_SYN 32 280 #define NAT44_SES_RST 64 283 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1 284 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2 285 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4 286 #define SNAT_SESSION_FLAG_TWICE_NAT 8 287 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT 16 288 #define SNAT_SESSION_FLAG_FWD_BYPASS 32 289 #define SNAT_SESSION_FLAG_AFFINITY 64 290 #define SNAT_SESSION_FLAG_OUTPUT_FEATURE 128 293 #define NAT_INTERFACE_FLAG_IS_INSIDE 1 294 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2 297 #define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY 1 298 #define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY 2 299 #define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT 4 300 #define NAT_STATIC_MAPPING_FLAG_LB 8 316 u32 per_user_list_head_index;
322 f64 ha_last_refreshed;
334 u16 ext_host_nat_port;
361 #define _(N, i, n, s) \ 362 u16 busy_##n##_ports; \ 363 u16 * busy_##n##_ports_per_thread; \ 364 uword * busy_##n##_port_bitmap; 532 u8 * p_dont_translate,
void *d,
537 u32 rx_fib_index,
u8 is_output);
546 u32 snat_thread_index);
763 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING) 769 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO) 775 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT) 781 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING) 787 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS) 793 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT) 799 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY) 805 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE 811 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE 817 #define nat44_is_ses_closed(s) s->state == 0xf 823 #define is_addr_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY) 829 #define is_out2in_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY) 835 #define is_identity_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT) 841 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB) 847 #define tcp_is_init(t) ((t->flags & TCP_FLAG_SYN) && !(t->flags & TCP_FLAG_ACK)) 850 #define nat_log_err(...) \ 851 vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__) 852 #define nat_log_warn(...) \ 853 vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__) 854 #define nat_log_notice(...) \ 855 vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__) 856 #define nat_log_info(...) \ 857 vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__) 858 #define nat_log_debug(...)\ 859 vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__) 862 #define foreach_nat_log_level \ 865 _(0x02, LOG_WARNING) \ 866 _(0x03, LOG_NOTICE) \ 872 #define _(n,f) SNAT_##f = n, 877 #define nat_elog(_level, _str) \ 880 snat_main_t *sm = &snat_main; \ 881 if (PREDICT_FALSE (sm->log_level >= _level)) \ 883 ELOG_TYPE_DECLARE (e) = \ 885 .format = "nat-msg " _str, \ 888 ELOG_DATA (&sm->vlib_main->elog_main, e); \ 892 #define nat_elog_addr(_level, _str, _addr) \ 895 if (PREDICT_FALSE (sm->log_level >= _level)) \ 897 ELOG_TYPE_DECLARE (e) = \ 899 .format = "nat-msg " _str " %d.%d.%d.%d", \ 900 .format_args = "i1i1i1i1", \ 909 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 910 ed->oct4 = _addr >> 24; \ 911 ed->oct3 = _addr >> 16; \ 912 ed->oct2 = _addr >> 8; \ 917 #define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst) \ 920 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 922 ELOG_TYPE_DECLARE (e) = \ 924 .format = "nat-msg " _str " ip src: %d.%d.%d.%d dst: %d.%d.%d.%d" \ 925 " tid from: %d to: %d fib: %d", \ 926 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 942 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 943 ed->src_oct1 = _src >> 24; \ 944 ed->src_oct2 = _src >> 16; \ 945 ed->src_oct3 = _src >> 8; \ 946 ed->src_oct4 = _src; \ 947 ed->dst_oct1 = _dst >> 24; \ 948 ed->dst_oct2 = _dst >> 16; \ 949 ed->dst_oct3 = _dst >> 8; \ 950 ed->dst_oct4 = _dst; \ 951 ed->ftid = vlib_get_thread_index (); \ 957 #define nat_elog_debug_handoff_v2(_str, _prt, _fib, _src, _dst) \ 960 if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \ 962 ELOG_TYPE_DECLARE (e) = \ 964 .format = "nat-msg " _str " ip_src:%d.%d.%d.%d ip_dst:%d.%d.%d.%d" \ 965 " tid:%d prt:%d fib:%d", \ 966 .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \ 982 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 983 ed->src_oct1 = _src >> 24; \ 984 ed->src_oct2 = _src >> 16; \ 985 ed->src_oct3 = _src >> 8; \ 986 ed->src_oct4 = _src; \ 987 ed->dst_oct1 = _dst >> 24; \ 988 ed->dst_oct2 = _dst >> 16; \ 989 ed->dst_oct3 = _dst >> 8; \ 990 ed->dst_oct4 = _dst; \ 991 ed->tid = vlib_get_thread_index (); \ 997 #define nat_elog_X1(_level, _fmt, _arg, _val1) \ 1000 snat_main_t *sm = &snat_main; \ 1001 if (PREDICT_FALSE (sm->log_level >= _level)) \ 1003 ELOG_TYPE_DECLARE (e) = \ 1005 .format = "nat-msg " _fmt, \ 1006 .format_args = _arg, \ 1008 CLIB_PACKED(struct \ 1010 typeof (_val1) val1; \ 1012 ed = ELOG_DATA (&sm->vlib_main->elog_main, e); \ 1017 #define nat_elog_notice(nat_elog_str) \ 1018 nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str) 1019 #define nat_elog_warn(nat_elog_str) \ 1020 nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str) 1021 #define nat_elog_err(nat_elog_str) \ 1022 nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str) 1023 #define nat_elog_debug(nat_elog_str) \ 1024 nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str) 1025 #define nat_elog_info(nat_elog_str) \ 1026 nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str) 1028 #define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1029 nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1030 #define nat_elog_warn_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1031 nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1032 #define nat_elog_err_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1033 nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1034 #define nat_elog_debug_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1035 nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1036 #define nat_elog_info_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \ 1037 nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) 1044 u8 * p_dont_translate,
void *d,
void *e);
1049 u8 * p_dont_translate,
void *d,
void *e);
1054 u8 * p_dont_translate,
void *d,
void *e);
1059 u8 * p_dont_translate,
void *d,
void *e);
1066 u8 * p_dont_translate,
void *d,
void *e);
1071 u8 * p_dont_translate,
void *d,
void *e);
1078 u8 * p_dont_translate,
void *d,
void *e);
1083 u8 * p_dont_translate,
void *d,
void *e);
1086 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1091 icmp46_header_t * icmp0,
u32 sw_if_index0,
u32 rx_fib_index0,
1108 u32 proto0,
int is_ed);
1177 snat_protocol_t
proto,
int is_add,
1178 twice_nat_type_t twice_nat,
u8 out2in_only,
1179 u8 * tag,
u8 identity_nat);
1197 snat_protocol_t
proto,
1199 twice_nat_type_t twice_nat,
1200 u8 out2in_only,
u8 * tag,
u32 affinity);
1205 u8 probability,
u8 is_add);
1265 snat_protocol_t
proto,
u32 vrf_id,
int is_in);
1280 u32 vrf_id,
int is_in);
1290 u32 thread_index,
u8 is_ha);
1302 u32 fib_index,
u32 thread_index);
1314 u32 thread_index,
f64 now);
1325 u32 thread_index,
f64 now);
1377 u16 port_per_thread,
1378 u32 snat_thread_index);
1399 twice_nat_type_t * twice_nat,
1402 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)
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_in2out_reass_node_index
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_reass_node_index
u32 in2out_output_node_index
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 snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
vhost_vring_state_t state
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)
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...
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)
u32 ed_out2in_reass_node_index
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
u8 static_mapping_connection_tracking
snat_get_worker_function_t * worker_in2out_cb
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.
void increment_v4_address(ip4_address_t *a)
Increment IPv4 address.
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.
snat_get_worker_function_t * worker_out2in_cb
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
u32() snat_get_worker_function_t(ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
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
u32 out2in_reass_node_index
struct _vlib_node_registration vlib_node_registration_t
format_function_t format_nat44_reass_trace
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_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)
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
vl_api_fib_path_nh_proto_t proto
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
u32 tcp_established_timeout
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)