39 #define ED_PORT_ALLOC_ATTEMPTS (10) 42 #define _(sym,string) string, 65 "NAT44_IN2OUT_ED_FAST_PATH";
67 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
73 #ifndef CLIB_MARCH_VARIANT 80 u64 sess_timeout_time;
94 if (ctx->
now >= sess_timeout_time)
99 l_addr = &s->out2in.addr;
100 r_addr = &s->ext_host_addr;
101 fib_index = s->out2in.fib_index;
104 proto = s->in2out.port;
111 l_port = s->out2in.port;
112 r_port = s->ext_host_port;
114 init_ed_k (&ed_kv, *l_addr, l_port, *r_addr, r_port, fib_index, proto);
115 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &ed_kv, 0))
122 s->in2out.addr.as_u32,
123 s->out2in.addr.as_u32,
127 s->in2out.fib_index);
130 &s->in2out.addr, s->in2out.port,
131 &s->ext_host_nat_addr, s->ext_host_nat_port,
132 &s->out2in.addr, s->out2in.port,
133 &s->ext_host_addr, s->ext_host_port,
136 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
137 s->ext_host_port, s->nat_proto, s->out2in.fib_index,
147 if (a->
addr.
as_u32 == s->ext_host_nat_addr.as_u32)
151 &s->ext_host_nat_addr,
152 s->ext_host_nat_port,
163 &s->out2in.addr, s->out2in.port,
177 u32 sw_if_index0,
u32 rx_fib_index0,
179 u32 thread_index, snat_session_t ** p_s0)
183 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
184 next0, thread_index, p_s0, 0);
185 snat_session_t *s0 = *p_s0;
191 (vm, b0), thread_index);
200 u32 nat_proto,
u32 thread_index,
202 u16 port_per_thread,
u32 snat_thread_index,
212 const u16 port_thread_offset = (port_per_thread * snat_thread_index) + 1024;
219 #define _(N, j, n, unused) \ 220 case NAT_PROTOCOL_##N: \ 221 if (a->fib_index == rx_fib_index) \ 224 u16 port = clib_net_to_host_u16 (*outside_port); \ 225 u16 port_offset = port - port_thread_offset; \ 226 if (port <= port_thread_offset || \ 227 port > port_thread_offset + port_per_thread) \ 231 port_offset = snat_random_port (0, port_per_thread - 1); \ 232 port = port_thread_offset + port_offset; \ 234 u16 attempts = ED_PORT_ALLOC_ATTEMPTS; \ 237 init_ed_kv (out2in_ed_kv, a->addr, clib_host_to_net_u16 (port), \ 238 r_addr, r_port, s->out2in.fib_index, proto, \ 239 thread_index, s - tsm->sessions); \ 240 int rv = clib_bihash_add_del_16_8 (&sm->out2in_ed, out2in_ed_kv, \ 244 ++a->busy_##n##_port_refcounts[port]; \ 245 a->busy_##n##_ports_per_thread[thread_index]++; \ 246 a->busy_##n##_ports++; \ 247 *outside_addr = a->addr; \ 248 *outside_port = clib_host_to_net_u16 (port); \ 251 port_offset = snat_random_port (0, port_per_thread - 1); \ 252 port = port_thread_offset + port_offset; \ 255 while (attempts > 0); \ 257 else if (a->fib_index == ~0) \ 299 .fp_addr = {.ip4.as_u32 = addr.
as_u32,}
328 snat_session_t ** sessionp,
339 snat_session_t *s = NULL;
348 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_NON_SYN];
358 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
371 (sm, l_addr, l_port, rx_fib_index, nat_proto, &sm_addr, &sm_port,
372 &sm_fib_index, 0, 0, 0, &lb, 0, &identity_nat, 0))
376 s->in2out.addr = l_addr;
377 s->in2out.port = l_port;
378 s->nat_proto = nat_proto;
379 s->in2out.fib_index = rx_fib_index;
396 outside_port = l_port;
398 thread_index, r_addr, r_port, proto,
402 &outside_port, &out2in_ed_kv))
405 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
409 s->out2in.addr = outside_addr;
410 s->out2in.port = outside_port;
421 s->out2in.addr = sm_addr;
422 s->out2in.port = sm_port;
423 s->in2out.addr = l_addr;
424 s->in2out.port = l_port;
425 s->nat_proto = nat_proto;
426 s->in2out.fib_index = rx_fib_index;
443 init_ed_kv (&out2in_ed_kv, sm_addr, sm_port, r_addr, r_port,
444 s->out2in.fib_index, proto, thread_index,
446 if (clib_bihash_add_or_overwrite_stale_16_8
455 s->ext_host_addr = r_addr;
456 s->ext_host_port = r_port;
459 init_ed_kv (&in2out_ed_kv, l_addr, l_port, r_addr, r_port, rx_fib_index,
460 proto, thread_index, s - tsm->
sessions);
463 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, &in2out_ed_kv,
472 s->in2out.addr.as_u32,
473 s->out2in.addr.as_u32,
476 s->out2in.port, s->in2out.fib_index);
479 &s->in2out.addr, s->in2out.port,
480 &s->ext_host_nat_addr, s->ext_host_nat_port,
481 &s->out2in.addr, s->out2in.port,
482 &s->ext_host_addr, s->ext_host_port, s->nat_proto,
485 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
486 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
487 &s->ext_host_nat_addr, s->ext_host_nat_port,
488 s->nat_proto, s->in2out.fib_index, s->flags, thread_index, 0);
498 u32 rx_fib_index,
u32 thread_index)
507 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
511 u16 placeholder_port;
512 u32 placeholder_fib_index;
515 &placeholder_addr, &placeholder_port, &placeholder_fib_index, 1, 0,
531 u32 thread_index,
f64 now,
535 snat_session_t *s = 0;
541 if (ip->
protocol == IP_PROTOCOL_ICMP)
546 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
558 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
566 if (ip->
protocol == IP_PROTOCOL_TCP)
588 u32 thread_index,
u32 rx_sw_if_index,
601 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
608 && (!s->tcp_closed_timestamp || now >= s->tcp_closed_timestamp))
619 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
642 #ifndef CLIB_MARCH_VARIANT 648 void *d,
void *e,
u8 * dont_translate)
655 snat_session_t *s = NULL;
656 u16 l_port = 0, r_port = 0;
675 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
681 (sm, ip, l_port, r_port, thread_index,
691 ip, NAT_PROTOCOL_ICMP,
702 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags)))
704 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
711 ip->
protocol, rx_fib_index, &s, node, next,
726 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
728 &&
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
731 reass.icmp_type_or_tcp_flags)))
733 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
746 *addr = s->out2in.addr;
747 *port = s->out2in.port;
748 *fib_index = s->out2in.fib_index;
752 *(snat_session_t **) d = s;
758 static snat_session_t *
770 u32 old_addr, new_addr = 0;
795 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &s_kv, &s_value))
807 (sm, rx_fib_index, thread_index)))
809 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
835 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
847 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
861 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
869 s->out2in.addr.as_u32 = new_addr;
870 s->out2in.fib_index = outside_fib_index;
871 s->in2out.addr.as_u32 = old_addr;
872 s->in2out.fib_index = rx_fib_index;
873 s->in2out.port = s->out2in.port = ip->
protocol;
880 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
884 outside_fib_index, ip->
protocol, thread_index,
886 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &s_kv, 1))
917 int is_output_feature)
919 u32 n_left_from, *from;
934 while (n_left_from > 0)
937 u32 sw_if_index0, rx_fib_index0, proto0, new_addr0, old_addr0,
939 u16 old_port0, new_port0;
943 snat_session_t *s0 = 0;
962 if (is_output_feature)
964 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
980 ICMP4_time_exceeded_ttl_exceeded_in_transit,
996 if (is_output_feature)
1000 (sm, ip0, thread_index, now, vm, b0)))
1016 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1036 if (s0->tcp_closed_timestamp)
1038 if (now >= s0->tcp_closed_timestamp)
1046 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_TCP_CLOSED];
1053 u64 sess_timeout_time;
1056 if (now >= sess_timeout_time)
1065 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1067 if (!is_output_feature)
1083 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1089 new_port0 = udp0->
src_port = s0->out2in.port;
1090 sum0 = tcp0->checksum;
1107 tcp0->dst_port = s0->ext_host_port;
1114 thread_index, sw_if_index0, 1);
1120 new_port0 = udp0->
src_port = s0->out2in.port;
1136 udp0->
dst_port = s0->ext_host_port;
1141 thread_index, sw_if_index0, 1);
1147 new_port0 = udp0->
src_port = s0->out2in.port;
1150 udp0->
dst_port = s0->ext_host_port;
1154 in2out_ed.udp, thread_index,
1169 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1186 in2out_ed.drops, thread_index,
1203 int is_output_feature)
1205 u32 n_left_from, *from;
1218 while (n_left_from > 0)
1221 u32 sw_if_index0, rx_fib_index0, proto0, new_addr0, old_addr0,
1223 u16 old_port0, new_port0;
1227 icmp46_header_t *icmp0;
1228 snat_session_t *s0 = 0;
1234 if (is_output_feature)
1235 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1250 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1258 icmp0 = (icmp46_header_t *) udp0;
1265 thread_index, now, vm, node);
1270 in2out_ed.other, thread_index,
1279 rx_fib_index0, node, next[0], now,
1282 in2out_ed.icmp, thread_index,
1291 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1298 if (s0->tcp_closed_timestamp && now >= s0->tcp_closed_timestamp)
1308 if (is_output_feature)
1323 (proto0 == NAT_PROTOCOL_UDP
1325 clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_server))
1333 (sm, node, sw_if_index0, ip0, proto0, rx_fib_index0,
1342 ip0->
protocol, rx_fib_index0, &s0, node, next[0],
1353 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1355 if (!is_output_feature)
1369 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1375 new_port0 = udp0->
src_port = s0->out2in.port;
1376 sum0 = tcp0->checksum;
1387 s0->ext_host_addr.as_u32,
1393 tcp0->dst_port = s0->ext_host_port;
1400 thread_index, sw_if_index0, 1);
1406 new_port0 = udp0->
src_port = s0->out2in.port;
1416 s0->ext_host_addr.as_u32,
1422 udp0->
dst_port = s0->ext_host_port;
1427 thread_index, sw_if_index0, 1);
1433 new_port0 = udp0->
src_port = s0->out2in.port;
1436 udp0->
dst_port = s0->ext_host_port;
1440 in2out_ed.udp, thread_index,
1448 (vm, b0), thread_index);
1454 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1471 in2out_ed.drops, thread_index,
1495 .name =
"nat44-ed-in2out",
1496 .vector_size =
sizeof (
u32),
1497 .sibling_of =
"nat-default",
1515 .name =
"nat44-ed-in2out-output",
1516 .vector_size =
sizeof (
u32),
1517 .sibling_of =
"nat-default",
1535 .name =
"nat44-ed-in2out-slowpath",
1536 .vector_size =
sizeof (
u32),
1537 .sibling_of =
"nat-default",
1556 .name =
"nat44-ed-in2out-output-slowpath",
1557 .vector_size =
sizeof (
u32),
1558 .sibling_of =
"nat-default",
1593 .name =
"nat-pre-in2out",
1594 .vector_size =
sizeof (
u32),
1595 .sibling_of =
"nat-default",
1602 .name =
"nat-pre-in2out-output",
1603 .vector_size =
sizeof (
u32),
1604 .sibling_of =
"nat-default",
ip4_address_t external_addr
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
fib_protocol_t fp_proto
protocol type
nat_outside_fib_t * outside_fibs
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
clib_bihash_16_8_t out2in_ed
#define nat_elog_info(nat_elog_str)
void nat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define nat_elog_notice(nat_elog_str)
vlib_node_registration_t nat_pre_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_output_node)
void nat_syslog_nat44_sadd(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *idaddr, u16 idport, ip4_address_t *xsaddr, u16 xsport, ip4_address_t *xdaddr, u16 xdport, nat_protocol_t proto, u8 is_twicenat)
vl_api_ip_port_and_mask_t dst_port
static f64 vlib_time_now(vlib_main_t *vm)
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
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)
static_always_inline void per_vrf_sessions_register_session(snat_session_t *s, u32 thread_index)
#define foreach_nat_in2out_ed_error
#define nat_elog_warn(nat_elog_str)
void nat_ha_sadd(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index, u8 is_resync)
Create session add HA event.
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
#define nat44_is_ses_closed(s)
Check if NAT44 endpoint-dependent TCP session is closed.
#define VLIB_NODE_FN(node)
static void nat_ed_session_delete(snat_main_t *sm, snat_session_t *ses, u32 thread_index, int lru_delete)
static void init_ed_kv(clib_bihash_kv_16_8_t *kv, ip4_address_t l_addr, u16 l_port, ip4_address_t r_addr, u16 r_port, u32 fib_index, u8 proto, u32 thread_index, u32 session_index)
static_always_inline int nat44_ed_not_translate(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index, ip4_header_t *ip, u32 proto, u32 rx_fib_index, u32 thread_index)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
struct _tcp_header tcp_header_t
#define snat_is_unk_proto_session(s)
Check if SNAT session for unknown protocol.
u32 max_translations_per_thread
static snat_session_t * nat44_ed_in2out_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index, f64 now, vlib_main_t *vm, vlib_node_runtime_t *node)
static uword nat44_ed_in2out_slow_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature)
static int snat_not_translate_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, ip4_header_t *ip0, u32 proto0, u32 rx_fib_index0)
Check if packet should be translated.
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define static_always_inline
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
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.
static void nat44_set_tcp_session_state_i2o(snat_main_t *sm, f64 now, snat_session_t *ses, vlib_buffer_t *b, u32 thread_index)
description fragment has unexpected format
static_always_inline u8 per_vrf_sessions_is_expired(snat_session_t *s, u32 thread_index)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Aggregate type for a prefix.
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
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)
#define is_fwd_bypass_session(s)
Check if NAT session is forwarding bypass.
static void * ip4_next_header(ip4_header_t *i)
static_always_inline int get_icmp_i2o_ed_key(vlib_buffer_t *b, ip4_header_t *ip0, u32 rx_fib_index, u32 thread_index, u32 session_index, nat_protocol_t *nat_proto, u16 *l_port, u16 *r_port, clib_bihash_kv_16_8_t *kv)
static_always_inline u32 nat_outside_fib_index_lookup(snat_main_t *sm, ip4_address_t addr)
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static u32 slow_path_ed(snat_main_t *sm, vlib_buffer_t *b, ip4_address_t l_addr, ip4_address_t r_addr, u16 l_port, u16 r_port, u8 proto, u32 rx_fib_index, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next, u32 thread_index, f64 now)
vlib_node_registration_t nat44_ed_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node)
static u32 ed_value_get_session_index(clib_bihash_kv_16_8_t *value)
snat_static_mapping_t * static_mappings
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
struct snat_main_s::@91 counters
static void mss_clamping(u16 mss_clamping, tcp_header_t *tcp, ip_csum_t *sum)
static int nat_ed_alloc_addr_and_port(snat_main_t *sm, u32 rx_fib_index, u32 nat_proto, u32 thread_index, ip4_address_t r_addr, u16 r_port, u8 proto, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port, clib_bihash_kv_16_8_t *out2in_ed_kv)
#define nat_interface_is_inside(i)
Check if NAT interface is inside.
vl_api_address_union_t src_address
struct snat_main_s::@91::@93 slowpath
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
static void init_nat_k(clib_bihash_kv_8_8_t *kv, ip4_address_t addr, u16 port, u32 fib_index, nat_protocol_t proto)
static_always_inline snat_session_t * nat_ed_session_alloc(snat_main_t *sm, u32 thread_index, f64 now, u8 proto)
static u8 * format_nat_pre_trace(u8 *s, va_list *args)
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
static u8 * format_nat_in2out_ed_trace(u8 *s, va_list *args)
snat_interface_t * output_feature_interfaces
vl_api_ip_port_and_mask_t src_port
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
vlib_node_registration_t nat44_ed_in2out_output_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
sll srl srl sll sra u16x4 i
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes, u32 thread_index)
void nat_ipfix_logging_nat44_ses_create(u32 thread_index, u32 src_ip, u32 nat_src_ip, nat_protocol_t nat_proto, u16 src_port, u16 nat_src_port, u32 fib_index)
Generate NAT44 session create event.
u32 fib_node_index_t
A typedef of a node index.
8 octet key, 8 octet key value pair
static_always_inline int nat_not_translate_output_feature_fwd(snat_main_t *sm, ip4_header_t *ip, u32 thread_index, f64 now, vlib_main_t *vm, vlib_buffer_t *b)
static uword nat_pre_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 def_next)
vlib_main_t vlib_node_runtime_t * node
void nat_syslog_nat44_sdel(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *idaddr, u16 idport, ip4_address_t *xsaddr, u16 xsport, ip4_address_t *xdaddr, u16 xdport, nat_protocol_t proto, u8 is_twicenat)
vl_api_interface_index_t tx_sw_if_index
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
#define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT
static u32 icmp_in2out_ed_slow_path(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, f64 now, u32 thread_index, snat_session_t **p_s0)
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
snat_address_t * twice_nat_addresses
static_always_inline u8 nat44_ed_maximum_sessions_exceeded(snat_main_t *sm, u32 fib_index, u32 thread_index)
static vlib_main_t * vlib_get_main(void)
void nat_ha_sdel(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 thread_index)
Create session delete HA event.
void nat_ipfix_logging_max_sessions(u32 thread_index, u32 limit)
Generate maximum session entries exceeded event.
struct snat_main_s::@91::@92 fastpath
#define FIB_NODE_INDEX_INVALID
int nat44_i2o_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static_always_inline u8 nat_proto_to_ip_proto(nat_protocol_t nat_proto)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
VLIB buffer representation.
snat_main_per_thread_data_t * per_thread_data
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
snat_address_t * addresses
static void init_ed_k(clib_bihash_kv_16_8_t *kv, ip4_address_t l_addr, u16 l_port, ip4_address_t r_addr, u16 r_port, u32 fib_index, u8 proto)
#define SNAT_SESSION_FLAG_STATIC_MAPPING
void nat44_ed_hairpinning_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
#define vec_foreach(var, vec)
Vector iterator.
u16 flags
Copy of main node flags.
#define is_twice_nat_session(s)
Check if NAT session is twice NAT.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
clib_bihash_16_8_t in2out_ed
static_always_inline int nat_lru_free_one(snat_main_t *sm, int thread_index, f64 now)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
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.
static_always_inline int nat44_ed_not_translate_output_feature(snat_main_t *sm, ip4_header_t *ip, u16 src_port, u16 dst_port, u32 thread_index, u32 rx_sw_if_index, u32 tx_sw_if_index, f64 now)
u32 icmp_match_in2out_ed(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b, ip4_header_t *ip, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
snat_session_t * sessions
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static char * nat_in2out_ed_error_strings[]
#define SNAT_SESSION_FLAG_LOAD_BALANCING
clib_bihash_8_8_t static_mapping_by_local
static u32 ed_value_get_thread_index(clib_bihash_kv_16_8_t *value)
static u16 ip_csum_fold(ip_csum_t c)
static uword nat44_ed_in2out_fast_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature)
vl_api_interface_index_t sw_if_index
void nat_ipfix_logging_nat44_ses_delete(u32 thread_index, u32 src_ip, u32 nat_src_ip, nat_protocol_t nat_proto, u16 src_port, u16 nat_src_port, u32 fib_index)
Generate NAT44 session delete event.
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)