36 #define _(sym,string) string, 64 "NAT44_OUT2IN_ED_FAST_PATH";
66 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
75 u32 sw_if_index0,
u32 rx_fib_index0,
77 u32 thread_index, snat_session_t ** p_s0)
81 next0 =
icmp_out2in (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
82 next0, thread_index, p_s0, 0);
83 snat_session_t *s0 = *p_s0;
89 (vm, b0), thread_index);
96 #ifndef CLIB_MARCH_VARIANT 103 u64 sess_timeout_time;
116 if (ctx->
now >= sess_timeout_time)
118 l_addr = &s->in2out.addr;
119 r_addr = &s->ext_host_addr;
120 fib_index = s->in2out.fib_index;
123 proto = s->in2out.port;
130 l_port = s->in2out.port;
131 r_port = s->ext_host_port;
135 r_addr = &s->ext_host_nat_addr;
136 r_port = s->ext_host_nat_port;
138 init_ed_k (&ed_kv, *l_addr, l_port, *r_addr, r_port, fib_index, proto);
139 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &ed_kv, 0))
146 s->in2out.addr.as_u32,
147 s->out2in.addr.as_u32,
151 s->in2out.fib_index);
154 &s->in2out.addr, s->in2out.port,
155 &s->ext_host_nat_addr, s->ext_host_nat_port,
156 &s->out2in.addr, s->out2in.port,
157 &s->ext_host_addr, s->ext_host_port,
160 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
161 s->ext_host_port, s->nat_proto, s->out2in.fib_index,
186 &s->out2in.addr, s->out2in.port,
204 u16 port_per_thread,
u32 snat_thread_index)
210 #define _(N, j, n, s) \ 211 case NAT_PROTOCOL_##N: \ 212 if (a->busy_##n##_ports_per_thread[thread_index] < port_per_thread) \ 216 portnum = (port_per_thread * \ 217 snat_thread_index) + \ 218 snat_random_port(0, port_per_thread - 1) + 1024; \ 219 if (a->busy_##n##_port_refcounts[portnum]) \ 221 --a->busy_##n##_port_refcounts[portnum]; \ 222 a->busy_##n##_ports_per_thread[thread_index]++; \ 223 a->busy_##n##_ports++; \ 225 *port = clib_host_to_net_u16(portnum); \ 243 static snat_session_t *
270 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
278 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_USER_SESS_EXCEEDED];
287 s->ext_host_port = nat_proto == NAT_PROTOCOL_ICMP ? 0 : udp->
src_port;
294 s->out2in.addr = o2i_addr;
295 s->out2in.port = o2i_port;
296 s->out2in.fib_index = o2i_fib_index;
297 s->in2out.addr = i2o_addr;
298 s->in2out.port = i2o_port;
299 s->in2out.fib_index = i2o_fib_index;
300 s->nat_proto = nat_proto;
303 init_ed_kv (&kv, o2i_addr, o2i_port, s->ext_host_addr, s->ext_host_port,
307 if (clib_bihash_add_or_overwrite_stale_16_8 (&sm->
out2in_ed, &kv,
337 &s->ext_host_nat_addr,
338 &s->ext_host_nat_port,
347 thread_index, nat_proto,
348 &s->ext_host_nat_addr,
349 &s->ext_host_nat_port,
356 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_OUT_OF_PORTS];
358 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &kv, 0))
364 init_ed_kv (&kv, i2o_addr, i2o_port, s->ext_host_nat_addr,
365 s->ext_host_nat_port, i2o_fib_index, ip->
protocol,
370 init_ed_kv (&kv, i2o_addr, i2o_port, s->ext_host_addr,
371 s->ext_host_port, i2o_fib_index, ip->
protocol,
374 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, &kv,
380 s->in2out.addr.as_u32,
381 s->out2in.addr.as_u32,
384 s->out2in.port, s->in2out.fib_index);
387 &s->in2out.addr, s->in2out.port,
388 &s->ext_host_nat_addr, s->ext_host_nat_port,
389 &s->out2in.addr, s->out2in.port,
390 &s->ext_host_addr, s->ext_host_port,
393 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
394 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
395 &s->ext_host_nat_addr, s->ext_host_nat_port,
396 s->nat_proto, s->in2out.fib_index, s->flags, thread_index, 0);
412 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
420 u32 rx_fib_index,
u32 thread_index)
424 snat_session_t *s = 0;
430 if (ip->
protocol == IP_PROTOCOL_ICMP)
433 (b, ip, rx_fib_index, ~0, ~0, 0, &l_port, &r_port, &kv))
453 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
460 else if (ip->
protocol == IP_PROTOCOL_ICMP &&
462 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags))
472 (sm, rx_fib_index, thread_index)))
485 s->ext_host_port = r_port;
488 s->out2in.port = l_port;
489 s->nat_proto =
proto;
490 if (proto == NAT_PROTOCOL_OTHER)
495 s->out2in.fib_index = rx_fib_index;
496 s->in2out.addr = s->out2in.addr;
497 s->in2out.port = s->out2in.port;
498 s->in2out.fib_index = s->out2in.fib_index;
501 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &kv, 1))
507 if (ip->
protocol == IP_PROTOCOL_TCP)
511 tcp->ack_number, tcp->seq_number,
524 u32 rx_fib_index,
u32 thread_index)
531 if (index != thread_index)
541 #ifndef CLIB_MARCH_VARIANT 547 void *d,
void *e,
u8 * dont_translate)
552 snat_session_t *s = 0;
553 u8 is_addr_only, identity_nat;
566 (b, ip, rx_fib_index, ~0, ~0, proto, &l_port, &r_port, &kv))
568 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_UNSUPPORTED_PROTOCOL];
573 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &kv, &value))
578 &sm_fib_index, 1, &is_addr_only, 0, 0, 0, &identity_nat, &m))
591 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
599 thread_index, rx_fib_index))
625 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
627 && (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
628 ICMP4_echo_request || !is_addr_only)))
630 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_BAD_ICMP_TYPE];
645 l_port, rx_fib_index, *proto,
655 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
657 &&
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
660 reass.icmp_type_or_tcp_flags)))
662 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_BAD_ICMP_TYPE];
675 *addr = s->in2out.addr;
676 *port = s->in2out.port;
677 *fib_index = s->in2out.fib_index;
680 *(snat_session_t **) d = s;
685 static snat_session_t *
697 u32 old_addr, new_addr;
707 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
719 (sm, rx_fib_index, thread_index)))
721 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
727 if (clib_bihash_search_8_8
730 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
742 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_USER_SESS_EXCEEDED];
751 s->out2in.addr.as_u32 = old_addr;
752 s->out2in.fib_index = rx_fib_index;
753 s->in2out.addr.as_u32 = new_addr;
755 s->in2out.port = s->out2in.port = ip->
protocol;
759 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &s_kv, 1))
764 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
792 u32 n_left_from, *from;
805 while (n_left_from > 0)
808 u32 sw_if_index0, rx_fib_index0, proto0, old_addr0, new_addr0;
809 u16 old_port0, new_port0;
813 snat_session_t *s0 = 0;
845 ICMP4_time_exceeded_ttl_exceeded_in_transit,
882 nat.ed_out2in_nat_session_index);
887 && s0->out2in.fib_index == rx_fib_index0
889 && s0->ext_host_port ==
898 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &kv0, &value0))
920 if (s0->tcp_closed_timestamp)
922 if (now >= s0->tcp_closed_timestamp)
930 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_TCP_CLOSED];
937 u64 sess_timeout_time;
940 if (now >= sess_timeout_time)
962 old_port0 =
vnet_buffer (b0)->ip.reass.l4_dst_port;
968 new_port0 = udp0->
dst_port = s0->in2out.port;
969 sum0 = tcp0->checksum;
979 s0->ext_host_nat_addr.as_u32,
986 tcp0->src_port = s0->ext_host_nat_port;
992 thread_index, sw_if_index0, 1);
995 reass.icmp_type_or_tcp_flags,
997 reass.tcp_ack_number,
999 reass.tcp_seq_number,
1005 new_port0 = udp0->
dst_port = s0->in2out.port;
1021 udp0->
src_port = s0->ext_host_nat_port;
1026 thread_index, sw_if_index0, 1);
1032 new_port0 = udp0->
dst_port = s0->in2out.port;
1035 udp0->
src_port = s0->ext_host_nat_port;
1040 thread_index, sw_if_index0, 1);
1052 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1069 out2in_ed.drops, thread_index,
1087 u32 n_left_from, *from;
1101 while (n_left_from > 0)
1104 u32 sw_if_index0, rx_fib_index0, proto0, old_addr0, new_addr0;
1105 u16 old_port0, new_port0;
1109 icmp46_header_t *icmp0;
1110 snat_session_t *s0 = 0;
1134 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1142 icmp0 = (icmp46_header_t *) udp0;
1149 thread_index, now, vm, node);
1156 out2in_ed.other, thread_index,
1164 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1165 next[0], now, thread_index, &s0);
1167 out2in_ed.icmp, thread_index,
1178 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &kv0, &value0))
1185 if (s0->tcp_closed_timestamp && now >= s0->tcp_closed_timestamp)
1201 proto0, &sm_addr, &sm_port, &sm_fib_index, 1, 0,
1202 &twice_nat0, &lb_nat0, &ip0->
src_address, &identity_nat0, &m))
1210 clib_host_to_net_u16
1211 (UDP_DST_PORT_dhcp_to_client))))
1219 node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1227 thread_index, rx_fib_index0))
1253 if ((proto0 == NAT_PROTOCOL_TCP)
1255 reass.icmp_type_or_tcp_flags))
1257 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NON_SYN];
1268 ip.reass.l4_dst_port,
1269 rx_fib_index0, proto0,
1270 node, rx_fib_index0,
1271 thread_index, twice_nat0,
1293 old_port0 =
vnet_buffer (b0)->ip.reass.l4_dst_port;
1299 new_port0 = udp0->
dst_port = s0->in2out.port;
1300 sum0 = tcp0->checksum;
1310 s0->ext_host_nat_addr.as_u32,
1317 tcp0->src_port = s0->ext_host_nat_port;
1323 thread_index, sw_if_index0, 1);
1326 reass.icmp_type_or_tcp_flags,
1328 reass.tcp_ack_number,
1330 reass.tcp_seq_number,
1336 new_port0 = udp0->
dst_port = s0->in2out.port;
1345 s0->ext_host_nat_addr.as_u32,
1351 udp0->
src_port = s0->ext_host_nat_port;
1356 thread_index, sw_if_index0, 1);
1362 new_port0 = udp0->
dst_port = s0->in2out.port;
1365 udp0->
src_port = s0->ext_host_nat_port;
1370 thread_index, sw_if_index0, 1);
1382 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1399 out2in_ed.drops, thread_index,
1419 u32 n_enq, n_left_from, *from;
1429 while (n_left_from >= 4)
1453 while (n_left_from > 0)
1466 ti = thread_indices;
1470 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
1486 if (n_enq < frame->n_vectors)
1489 NAT44_HANDOFF_ERROR_CONGESTION_DROP,
1512 .name =
"nat44-ed-out2in",
1513 .vector_size =
sizeof (
u32),
1514 .sibling_of =
"nat-default",
1532 .name =
"nat44-ed-out2in-slowpath",
1533 .vector_size =
sizeof (
u32),
1534 .sibling_of =
"nat-default",
1563 .name =
"nat44-ed-out2in-handoff",
1564 .vector_size =
sizeof (
u32),
1565 .sibling_of =
"nat-default",
1592 .name =
"nat-pre-out2in",
1593 .vector_size =
sizeof (
u32),
1594 .sibling_of =
"nat-default",
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
clib_bihash_16_8_t out2in_ed
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)
vl_api_wireguard_peer_flags_t flags
#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 nat_elog_notice(nat_elog_str)
static u8 * format_nat44_ed_out2in_handoff_trace(u8 *s, va_list *args)
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_always_inline int get_icmp_o2i_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 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 int nat_alloc_addr_and_port_exact(snat_address_t *a, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
static_always_inline void per_vrf_sessions_register_session(snat_session_t *s, u32 thread_index)
#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 nat44_set_tcp_session_state_o2i(snat_main_t *sm, f64 now, snat_session_t *ses, u8 tcp_flags, u32 tcp_ack_number, u32 tcp_seq_number, u32 thread_index)
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
#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)
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.
#define is_exact_address(s)
Check if exact pool address should be used.
static uword nat44_ed_out2in_fast_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_multi_worker)
static u32 icmp_out2in_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)
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define static_always_inline
static char * nat_out2in_ed_error_strings[]
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.
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.
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
static void * ip4_next_header(ip4_header_t *i)
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define foreach_nat_out2in_ed_error
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
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
clib_bihash_8_8_t static_mapping_by_external
u32 icmp_match_out2in_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)
vl_api_address_union_t src_address
struct snat_main_s::@91::@93 slowpath
u32 node_index
Node index.
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
#define SNAT_SESSION_FLAG_EXACT_ADDRESS
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 void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
vl_api_ip_port_and_mask_t src_port
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
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)
static u8 * format_nat44_ed_out2in_trace(u8 *s, va_list *args)
static u8 * format_nat_pre_trace(u8 *s, va_list *args)
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.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
8 octet key, 8 octet key value pair
static_always_inline int create_bypass_for_fwd_worker(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index)
vlib_node_registration_t nat44_ed_out2in_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node)
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
static snat_session_t * nat44_ed_out2in_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)
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)
vlib_node_registration_t nat44_ed_out2in_handoff_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_handoff_node)
#define SNAT_SESSION_FLAG_TWICE_NAT
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
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 SNAT_SESSION_FLAG_FWD_BYPASS
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)
#define SNAT_SESSION_FLAG_AFFINITY
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)
static u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
static void create_bypass_for_fwd(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index)
snat_address_t * addresses
static_always_inline u32 vlib_buffer_enqueue_to_thread(vlib_main_t *vm, u32 frame_queue_index, u32 *buffer_indices, u16 *thread_indices, u32 n_packets, int drop_on_congestion)
static uword nat_handoff_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 fq_index)
static snat_session_t * create_session_for_static_mapping_ed(snat_main_t *sm, vlib_buffer_t *b, ip4_address_t i2o_addr, u16 i2o_port, u32 i2o_fib_index, ip4_address_t o2i_addr, u16 o2i_port, u32 o2i_fib_index, nat_protocol_t nat_proto, vlib_node_runtime_t *node, u32 rx_fib_index, u32 thread_index, twice_nat_type_t twice_nat, lb_nat_type_t lb_nat, f64 now, snat_static_mapping_t *mapping)
snat_get_worker_in2out_function_t * worker_in2out_cb
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
#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 uword nat44_ed_out2in_slow_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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
static int next_src_nat(snat_main_t *sm, ip4_header_t *ip, u16 src_port, u16 dst_port, u32 thread_index, u32 rx_fib_index)
#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.
snat_session_t * sessions
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
#define SNAT_SESSION_FLAG_LOAD_BALANCING
static u32 ed_value_get_thread_index(clib_bihash_kv_16_8_t *value)
static u16 ip_csum_fold(ip_csum_t c)
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)