40 #define ED_PORT_ALLOC_ATTEMPTS (10) 43 #define _(sym,string) string, 66 "NAT44_IN2OUT_ED_FAST_PATH";
68 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
74 #ifndef CLIB_MARCH_VARIANT 81 u64 sess_timeout_time;
95 if (ctx->
now >= sess_timeout_time)
100 l_addr = &s->out2in.addr;
101 r_addr = &s->ext_host_addr;
102 fib_index = s->out2in.fib_index;
105 proto = s->in2out.port;
112 l_port = s->out2in.port;
113 r_port = s->ext_host_port;
115 init_ed_k (&ed_kv, *l_addr, l_port, *r_addr, r_port, fib_index, proto);
116 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &ed_kv, 0))
123 s->in2out.addr.as_u32,
124 s->out2in.addr.as_u32,
128 s->in2out.fib_index);
131 &s->in2out.addr, s->in2out.port,
132 &s->ext_host_nat_addr, s->ext_host_nat_port,
133 &s->out2in.addr, s->out2in.port,
134 &s->ext_host_addr, s->ext_host_port,
137 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
138 s->ext_host_port, s->nat_proto, s->out2in.fib_index,
148 if (a->
addr.
as_u32 == s->ext_host_nat_addr.as_u32)
152 &s->ext_host_nat_addr,
153 s->ext_host_nat_port,
164 &s->out2in.addr, s->out2in.port,
178 u32 sw_if_index0,
u32 rx_fib_index0,
180 u32 thread_index, snat_session_t ** p_s0)
184 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
185 next0, thread_index, p_s0, 0);
186 snat_session_t *s0 = *p_s0;
192 (vm, b0), thread_index);
201 u32 nat_proto,
u32 thread_index,
203 u16 port_per_thread,
u32 snat_thread_index,
213 const u16 port_thread_offset = (port_per_thread * snat_thread_index) + 1024;
220 #define _(N, j, n, unused) \ 221 case NAT_PROTOCOL_##N: \ 222 if (a->fib_index == rx_fib_index) \ 225 u16 port = clib_net_to_host_u16 (*outside_port); \ 226 u16 port_offset = port - port_thread_offset; \ 227 if (port <= port_thread_offset || \ 228 port > port_thread_offset + port_per_thread) \ 232 port_offset = snat_random_port (0, port_per_thread - 1); \ 233 port = port_thread_offset + port_offset; \ 235 u16 attempts = ED_PORT_ALLOC_ATTEMPTS; \ 238 init_ed_kv (out2in_ed_kv, a->addr, clib_host_to_net_u16 (port), \ 239 r_addr, r_port, s->out2in.fib_index, proto, \ 240 thread_index, s - tsm->sessions); \ 241 int rv = clib_bihash_add_del_16_8 (&sm->out2in_ed, out2in_ed_kv, \ 245 ++a->busy_##n##_port_refcounts[port]; \ 246 a->busy_##n##_ports_per_thread[thread_index]++; \ 247 a->busy_##n##_ports++; \ 248 *outside_addr = a->addr; \ 249 *outside_port = clib_host_to_net_u16 (port); \ 252 port_offset = snat_random_port (0, port_per_thread - 1); \ 253 port = port_thread_offset + port_offset; \ 256 while (attempts > 0); \ 258 else if (a->fib_index == ~0) \ 300 .fp_addr = {.ip4.as_u32 = addr.
as_u32,}
329 snat_session_t ** sessionp,
340 snat_session_t *s = NULL;
349 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_NON_SYN];
359 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
372 (sm, l_addr, l_port, rx_fib_index, nat_proto, &sm_addr, &sm_port,
373 &sm_fib_index, 0, 0, 0, &lb, 0, &identity_nat, 0))
377 s->in2out.addr = l_addr;
378 s->in2out.port = l_port;
379 s->nat_proto = nat_proto;
380 s->in2out.fib_index = rx_fib_index;
397 outside_port = l_port;
399 thread_index, r_addr, r_port, proto,
403 &outside_port, &out2in_ed_kv))
406 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
410 s->out2in.addr = outside_addr;
411 s->out2in.port = outside_port;
422 s->out2in.addr = sm_addr;
423 s->out2in.port = sm_port;
424 s->in2out.addr = l_addr;
425 s->in2out.port = l_port;
426 s->nat_proto = nat_proto;
427 s->in2out.fib_index = rx_fib_index;
444 init_ed_kv (&out2in_ed_kv, sm_addr, sm_port, r_addr, r_port,
445 s->out2in.fib_index, proto, thread_index,
447 if (clib_bihash_add_or_overwrite_stale_16_8
456 s->ext_host_addr = r_addr;
457 s->ext_host_port = r_port;
460 init_ed_kv (&in2out_ed_kv, l_addr, l_port, r_addr, r_port, rx_fib_index,
461 proto, thread_index, s - tsm->
sessions);
464 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, &in2out_ed_kv,
473 s->in2out.addr.as_u32,
474 s->out2in.addr.as_u32,
477 s->out2in.port, s->in2out.fib_index);
480 &s->in2out.addr, s->in2out.port,
481 &s->ext_host_nat_addr, s->ext_host_nat_port,
482 &s->out2in.addr, s->out2in.port,
483 &s->ext_host_addr, s->ext_host_port, s->nat_proto,
486 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
487 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
488 &s->ext_host_nat_addr, s->ext_host_nat_port,
489 s->nat_proto, s->in2out.fib_index, s->flags, thread_index, 0);
499 u32 rx_fib_index,
u32 thread_index)
508 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
512 u16 placeholder_port;
513 u32 placeholder_fib_index;
516 &placeholder_addr, &placeholder_port, &placeholder_fib_index, 1, 0,
532 u32 thread_index,
f64 now,
536 snat_session_t *s = 0;
542 if (ip->
protocol == IP_PROTOCOL_ICMP)
547 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
559 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
567 if (ip->
protocol == IP_PROTOCOL_TCP)
570 (sm, now, s, b, thread_index))
591 u32 thread_index,
u32 rx_sw_if_index,
604 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
623 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
636 if ((nat_interface_is_inside (i)) && (rx_sw_if_index == i->sw_if_index))
646 #ifndef CLIB_MARCH_VARIANT 652 void *d,
void *e,
u8 * dont_translate)
659 snat_session_t *s = NULL;
660 u16 l_port = 0, r_port = 0;
678 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
684 (sm, ip, l_port, r_port, thread_index,
694 ip, NAT_PROTOCOL_ICMP,
705 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags)))
707 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
714 ip->
protocol, rx_fib_index, &s, node, next,
729 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
731 &&
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
734 reass.icmp_type_or_tcp_flags)))
736 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
749 *addr = s->out2in.addr;
750 *port = s->out2in.port;
751 *fib_index = s->out2in.fib_index;
755 *(snat_session_t **) d = s;
761 static snat_session_t *
773 u32 old_addr, new_addr = 0;
798 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &s_kv, &s_value))
810 (sm, rx_fib_index, thread_index)))
812 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
833 if (s->ext_host_addr.as_u32 == ip->dst_address.as_u32)
835 new_addr = ip->src_address.as_u32 = s->out2in.addr.as_u32;
837 init_ed_k(&s_kv, s->out2in.addr, 0, ip->dst_address, 0, outside_fib_index, ip->protocol);
838 if (clib_bihash_search_16_8 (&sm->out2in_ed, &s_kv, &s_value))
850 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
864 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
872 s->out2in.addr.as_u32 = new_addr;
873 s->out2in.fib_index = outside_fib_index;
874 s->in2out.addr.as_u32 = old_addr;
875 s->in2out.fib_index = rx_fib_index;
876 s->in2out.port = s->out2in.port = ip->
protocol;
883 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
887 outside_fib_index, ip->
protocol, thread_index,
889 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &s_kv, 1))
920 int is_output_feature)
922 u32 n_left_from, *from;
937 while (n_left_from > 0)
940 u32 sw_if_index0, rx_fib_index0, proto0, new_addr0, old_addr0,
942 u16 old_port0, new_port0;
946 snat_session_t *s0 = 0;
965 if (is_output_feature)
967 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
983 ICMP4_time_exceeded_ttl_exceeded_in_transit,
999 if (is_output_feature)
1003 (sm, ip0, thread_index, now, vm, b0)))
1019 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1039 if (s0->tcp_closed_timestamp)
1041 if (now >= s0->tcp_closed_timestamp)
1049 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_TCP_CLOSED];
1056 u64 sess_timeout_time;
1059 if (now >= sess_timeout_time)
1068 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1070 if (!is_output_feature)
1086 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1092 new_port0 = udp0->
src_port = s0->out2in.port;
1093 sum0 = tcp0->checksum;
1110 tcp0->dst_port = s0->ext_host_port;
1117 thread_index, sw_if_index0, 1);
1124 new_port0 = udp0->
src_port = s0->out2in.port;
1140 udp0->
dst_port = s0->ext_host_port;
1145 thread_index, sw_if_index0, 1);
1151 new_port0 = udp0->
src_port = s0->out2in.port;
1154 udp0->
dst_port = s0->ext_host_port;
1158 in2out_ed.udp, thread_index,
1173 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1190 in2out_ed.drops, thread_index,
1207 int is_output_feature)
1209 u32 n_left_from, *from;
1222 while (n_left_from > 0)
1225 u32 sw_if_index0, rx_fib_index0, proto0, new_addr0, old_addr0,
1227 u16 old_port0, new_port0;
1231 icmp46_header_t *icmp0;
1232 snat_session_t *s0 = 0;
1238 if (is_output_feature)
1239 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1254 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1262 icmp0 = (icmp46_header_t *) udp0;
1269 thread_index, now, vm, node);
1274 in2out_ed.other, thread_index,
1283 rx_fib_index0, node, next[0], now,
1286 in2out_ed.icmp, thread_index,
1295 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1302 if (s0->tcp_closed_timestamp && now >= s0->tcp_closed_timestamp)
1312 if (is_output_feature)
1326 (proto0 == NAT_PROTOCOL_UDP
1328 clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_server))
1336 (sm, node, sw_if_index0, ip0, proto0, rx_fib_index0,
1345 ip0->
protocol, rx_fib_index0, &s0, node, next[0],
1356 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1358 if (!is_output_feature)
1372 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1378 new_port0 = udp0->
src_port = s0->out2in.port;
1379 sum0 = tcp0->checksum;
1390 s0->ext_host_addr.as_u32,
1396 tcp0->dst_port = s0->ext_host_port;
1403 thread_index, sw_if_index0, 1);
1410 new_port0 = udp0->
src_port = s0->out2in.port;
1420 s0->ext_host_addr.as_u32,
1426 udp0->
dst_port = s0->ext_host_port;
1431 thread_index, sw_if_index0, 1);
1437 new_port0 = udp0->
src_port = s0->out2in.port;
1440 udp0->
dst_port = s0->ext_host_port;
1444 in2out_ed.udp, thread_index,
1452 (vm, b0), thread_index);
1458 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1475 in2out_ed.drops, thread_index,
1499 .name =
"nat44-ed-in2out",
1500 .vector_size =
sizeof (
u32),
1501 .sibling_of =
"nat-default",
1519 .name =
"nat44-ed-in2out-output",
1520 .vector_size =
sizeof (
u32),
1521 .sibling_of =
"nat-default",
1539 .name =
"nat44-ed-in2out-slowpath",
1540 .vector_size =
sizeof (
u32),
1541 .sibling_of =
"nat-default",
1560 .name =
"nat44-ed-in2out-output-slowpath",
1561 .vector_size =
sizeof (
u32),
1562 .sibling_of =
"nat-default",
1597 .name =
"nat-pre-in2out",
1598 .vector_size =
sizeof (
u32),
1599 .sibling_of =
"nat-default",
1606 .name =
"nat-pre-in2out-output",
1607 .vector_size =
sizeof (
u32),
1608 .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)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
#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.
void snat_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 vrf_id)
Generate NAT44 session create event.
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
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
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_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 SNAT_SESSION_FLAG_OUTPUT_FEATURE
#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)
void snat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
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)
void nat_ipfix_logging_max_sessions(u32 thread_index, u32 limit)
Generate maximum session entries exceeded event.
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)
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)
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 int nat44_set_tcp_session_state_i2o(snat_main_t *sm, f64 now, snat_session_t *ses, vlib_buffer_t *b, u32 thread_index)
Set TCP session state.
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)
void snat_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 vrf_id)
Generate NAT44 session delete event.
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.
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)
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)
#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.
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
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)