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];
375 (sm, l_addr, l_port, rx_fib_index, nat_proto, &sm_addr, &sm_port,
376 &sm_fib_index, 0, 0, 0, &lb, 0, &identity_nat, 0))
380 s->in2out.addr = l_addr;
381 s->in2out.port = l_port;
382 s->nat_proto = nat_proto;
383 s->in2out.fib_index = rx_fib_index;
400 outside_port = l_port;
402 thread_index, r_addr, r_port, proto,
406 &outside_port, &out2in_ed_kv))
409 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
413 s->out2in.addr = outside_addr;
414 s->out2in.port = outside_port;
425 s->out2in.addr = sm_addr;
426 s->out2in.port = sm_port;
427 s->in2out.addr = l_addr;
428 s->in2out.port = l_port;
429 s->nat_proto = nat_proto;
430 s->in2out.fib_index = rx_fib_index;
447 init_ed_kv (&out2in_ed_kv, sm_addr, sm_port, r_addr, r_port,
448 s->out2in.fib_index, proto, thread_index,
450 if (clib_bihash_add_or_overwrite_stale_16_8
459 s->ext_host_addr = r_addr;
460 s->ext_host_port = r_port;
463 init_ed_kv (&in2out_ed_kv, l_addr, l_port, r_addr, r_port, rx_fib_index,
464 proto, thread_index, s - tsm->
sessions);
465 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, &in2out_ed_kv,
474 s->in2out.addr.as_u32,
475 s->out2in.addr.as_u32,
478 s->out2in.port, s->in2out.fib_index);
481 &s->in2out.addr, s->in2out.port,
482 &s->ext_host_nat_addr, s->ext_host_nat_port,
483 &s->out2in.addr, s->out2in.port,
484 &s->ext_host_addr, s->ext_host_port, s->nat_proto,
487 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
488 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
489 &s->ext_host_nat_addr, s->ext_host_nat_port,
490 s->nat_proto, s->in2out.fib_index, s->flags, thread_index, 0);
500 u32 rx_fib_index,
u32 thread_index)
509 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
513 u16 placeholder_port;
514 u32 placeholder_fib_index;
517 &placeholder_addr, &placeholder_port, &placeholder_fib_index, 1, 0,
533 u32 thread_index,
f64 now,
537 snat_session_t *s = 0;
543 if (ip->
protocol == IP_PROTOCOL_ICMP)
548 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
560 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
568 if (ip->
protocol == IP_PROTOCOL_TCP)
590 u32 thread_index,
u32 rx_sw_if_index,
603 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
610 && (!s->tcp_closed_timestamp || now >= s->tcp_closed_timestamp))
621 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
644 #ifndef CLIB_MARCH_VARIANT 650 void *d,
void *e,
u8 * dont_translate)
657 snat_session_t *s = NULL;
658 u16 l_port = 0, r_port = 0;
677 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
683 (sm, ip, l_port, r_port, thread_index,
693 ip, NAT_PROTOCOL_ICMP,
704 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags)))
706 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
713 ip->
protocol, rx_fib_index, &s, node, next,
728 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
730 &&
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
733 reass.icmp_type_or_tcp_flags)))
735 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
748 *addr = s->out2in.addr;
749 *port = s->out2in.port;
750 *fib_index = s->out2in.fib_index;
754 *(snat_session_t **) d = s;
760 static snat_session_t *
772 u32 old_addr, new_addr = 0;
797 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &s_kv, &s_value))
809 (sm, rx_fib_index, thread_index)))
811 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
837 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
849 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
863 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
871 s->out2in.addr.as_u32 = new_addr;
872 s->out2in.fib_index = outside_fib_index;
873 s->in2out.addr.as_u32 = old_addr;
874 s->in2out.fib_index = rx_fib_index;
875 s->in2out.port = s->out2in.port = ip->
protocol;
882 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
886 outside_fib_index, ip->
protocol, thread_index,
888 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &s_kv, 1))
919 int is_output_feature)
921 u32 n_left_from, *from;
936 while (n_left_from > 0)
939 u32 sw_if_index0, rx_fib_index0, proto0, new_addr0, old_addr0,
941 u16 old_port0, new_port0;
945 snat_session_t *s0 = 0;
964 if (is_output_feature)
966 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
982 ICMP4_time_exceeded_ttl_exceeded_in_transit,
998 if (is_output_feature)
1002 (sm, ip0, thread_index, now, vm, b0)))
1018 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1038 if (s0->tcp_closed_timestamp)
1040 if (now >= s0->tcp_closed_timestamp)
1048 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_TCP_CLOSED];
1055 u64 sess_timeout_time;
1058 if (now >= sess_timeout_time)
1067 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1069 if (!is_output_feature)
1085 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1091 new_port0 = udp0->
src_port = s0->out2in.port;
1092 sum0 = tcp0->checksum;
1109 tcp0->dst_port = s0->ext_host_port;
1116 thread_index, sw_if_index0, 1);
1122 new_port0 = udp0->
src_port = s0->out2in.port;
1138 udp0->
dst_port = s0->ext_host_port;
1143 thread_index, sw_if_index0, 1);
1149 new_port0 = udp0->
src_port = s0->out2in.port;
1152 udp0->
dst_port = s0->ext_host_port;
1156 in2out_ed.udp, thread_index,
1171 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1188 in2out_ed.drops, thread_index,
1205 int is_output_feature)
1207 u32 n_left_from, *from;
1220 while (n_left_from > 0)
1223 u32 sw_if_index0, rx_fib_index0, proto0, new_addr0, old_addr0,
1225 u16 old_port0, new_port0;
1229 icmp46_header_t *icmp0;
1230 snat_session_t *s0 = 0;
1236 if (is_output_feature)
1237 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1252 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1260 icmp0 = (icmp46_header_t *) udp0;
1267 thread_index, now, vm, node);
1272 in2out_ed.other, thread_index,
1281 rx_fib_index0, node, next[0], now,
1284 in2out_ed.icmp, thread_index,
1293 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1300 if (s0->tcp_closed_timestamp && now >= s0->tcp_closed_timestamp)
1310 if (is_output_feature)
1325 (proto0 == NAT_PROTOCOL_UDP
1327 clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_server))
1335 (sm, node, sw_if_index0, ip0, proto0, rx_fib_index0,
1344 ip0->
protocol, rx_fib_index0, &s0, node, next[0],
1355 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1357 if (!is_output_feature)
1371 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1377 new_port0 = udp0->
src_port = s0->out2in.port;
1378 sum0 = tcp0->checksum;
1389 s0->ext_host_addr.as_u32,
1395 tcp0->dst_port = s0->ext_host_port;
1402 thread_index, sw_if_index0, 1);
1408 new_port0 = udp0->
src_port = s0->out2in.port;
1418 s0->ext_host_addr.as_u32,
1424 udp0->
dst_port = s0->ext_host_port;
1429 thread_index, sw_if_index0, 1);
1435 new_port0 = udp0->
src_port = s0->out2in.port;
1438 udp0->
dst_port = s0->ext_host_port;
1442 in2out_ed.udp, thread_index,
1450 (vm, b0), thread_index);
1456 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1473 in2out_ed.drops, thread_index,
1497 .name =
"nat44-ed-in2out",
1498 .vector_size =
sizeof (
u32),
1499 .sibling_of =
"nat-default",
1517 .name =
"nat44-ed-in2out-output",
1518 .vector_size =
sizeof (
u32),
1519 .sibling_of =
"nat-default",
1537 .name =
"nat44-ed-in2out-slowpath",
1538 .vector_size =
sizeof (
u32),
1539 .sibling_of =
"nat-default",
1558 .name =
"nat44-ed-in2out-output-slowpath",
1559 .vector_size =
sizeof (
u32),
1560 .sibling_of =
"nat-default",
1595 .name =
"nat-pre-in2out",
1596 .vector_size =
sizeof (
u32),
1597 .sibling_of =
"nat-default",
1604 .name =
"nat-pre-in2out-output",
1605 .vector_size =
sizeof (
u32),
1606 .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)