38 #define ED_PORT_ALLOC_ATTEMPTS (10) 41 #define _(sym,string) string, 70 "NAT44_IN2OUT_ED_FAST_PATH";
76 s =
format (s,
", session %d, translation result '%U' via %s",
87 s =
format (s,
"\n lookup skipped - cached session index used");
139 if (sw_if_index == ~0)
147 if (sw_if_index != ~0)
152 if (sw_if_index == ~0)
171 u16 port_per_thread,
u32 snat_thread_index, snat_session_t *s,
174 const u16 port_thread_offset = (port_per_thread * snat_thread_index) + 1024;
176 s->o2i.match.daddr = a->
addr;
178 u16 port = clib_net_to_host_u16 (*outside_port);
179 u16 port_offset = port - port_thread_offset;
180 if (port <= port_thread_offset ||
181 port > port_thread_offset + port_per_thread)
186 port = port_thread_offset + port_offset;
191 if (NAT_PROTOCOL_ICMP == nat_proto)
193 s->o2i.match.sport = clib_host_to_net_u16 (port);
195 s->o2i.match.dport = clib_host_to_net_u16 (port);
198 #define _(N, i, n, s) \ 199 case NAT_PROTOCOL_##N: \ 200 ++a->busy_##n##_port_refcounts[port]; \ 201 a->busy_##n##_ports_per_thread[thread_index]++; \ 202 a->busy_##n##_ports++; \ 212 *outside_addr = a->
addr;
213 *outside_port = clib_host_to_net_u16 (port);
217 port = port_thread_offset + port_offset;
220 while (attempts > 0);
227 u16 port_per_thread,
u32 snat_thread_index,
244 sm, nat_proto, thread_index, a, port_per_thread,
245 snat_thread_index, s, outside_addr, outside_port);
253 for (i = 0; i < s_addr_offset; ++
i)
259 sm, nat_proto, thread_index, a, port_per_thread,
260 snat_thread_index, s, outside_addr, outside_port);
271 sm, nat_proto, thread_index, a, port_per_thread, snat_thread_index,
272 s, outside_addr, outside_port);
288 .fp_addr = {.ip4.as_u32 = addr.
as_u32,}
313 init_nat_k (&kv, match_addr, match_port, match_fib_index, match_protocol);
344 u32 outside_fib_index;
348 snat_session_t *s = NULL;
359 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_NON_SYN];
369 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
398 nat_proto, &sm_addr, &sm_port, &sm_fib_index,
399 0, 0, 0, &lb, 0, &is_identity_nat, 0))
419 s->in2out.addr = l_addr;
420 s->in2out.port = l_port;
421 s->nat_proto = nat_proto;
422 s->in2out.fib_index = rx_fib_index;
423 s->out2in.fib_index = outside_fib_index;
426 outside_port = l_port;
430 sm, r_addr, r_port, nat_proto, outside_fib_index, &daddr, &dport);
436 s->out2in.fib_index, proto);
438 if (NAT_PROTOCOL_ICMP == nat_proto)
449 sm, rx_fib_index, nat_proto, thread_index, l_addr,
454 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
458 s->out2in.addr = outside_addr;
459 s->out2in.port = outside_port;
464 s->out2in.addr = outside_addr = sm_addr;
465 s->out2in.port = outside_port = sm_port;
466 s->in2out.addr = l_addr;
467 s->in2out.port = l_port;
468 s->nat_proto = nat_proto;
469 s->in2out.fib_index = rx_fib_index;
470 s->out2in.fib_index = outside_fib_index;
475 sm, r_addr, r_port, nat_proto, outside_fib_index, &daddr, &dport);
478 if (NAT_PROTOCOL_ICMP == nat_proto)
481 sm_port, s->out2in.fib_index, proto);
487 sm_port, s->out2in.fib_index, proto);
502 s->ext_host_addr = r_addr;
503 s->ext_host_port = r_port;
506 rx_fib_index, proto);
510 if (NAT_PROTOCOL_ICMP == nat_proto)
529 s->in2out.addr.as_u32,
530 s->out2in.addr.as_u32,
533 s->out2in.port, s->in2out.fib_index);
536 s->in2out.port, &s->ext_host_nat_addr,
537 s->ext_host_nat_port, &s->out2in.addr, s->out2in.port,
538 &s->ext_host_addr, s->ext_host_port, s->nat_proto, 0);
550 &outside_addr, outside_port,
555 *sessionp = s = NULL;
572 if (clib_bihash_search_16_8 (&sm->
flow_hash, &kv, &value))
576 u16 placeholder_port;
577 u32 placeholder_fib_index;
581 &placeholder_fib_index, 1, 0, 0, 0, 0, 0, 0))
600 snat_session_t *s = 0;
606 if (ip->
protocol == IP_PROTOCOL_ICMP)
609 u16 lookup_sport, lookup_dport;
612 &lookup_sport, &lookup_daddr,
613 &lookup_dport, &lookup_protocol))
615 init_ed_k (&kv, lookup_saddr, lookup_sport, lookup_daddr, lookup_dport,
618 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
630 if (!clib_bihash_search_16_8 (&sm->
flow_hash, &kv, &value))
639 if (ip->
protocol == IP_PROTOCOL_TCP)
663 f64 now,
int is_multi_worker)
675 if (!clib_bihash_search_16_8 (&sm->
flow_hash, &kv, &value))
682 && (!s->tcp_closed_timestamp || now >= s->tcp_closed_timestamp))
691 if (is_multi_worker &&
706 goto skip_dst_nat_lookup;
713 if (!clib_bihash_search_16_8 (&sm->
flow_hash, &kv, &value))
747 snat_session_t *s = NULL;
749 u16 lookup_sport, lookup_dport;
753 &lookup_sport, &lookup_daddr,
754 &lookup_dport, &lookup_protocol);
764 sm, b, ip, lookup_sport, lookup_dport, thread_index, sw_if_index,
773 ip, NAT_PROTOCOL_ICMP,
774 rx_fib_index, thread_index)))
781 vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags)))
783 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
788 lookup_sport, lookup_dport, ip->
protocol, rx_fib_index,
820 static snat_session_t *
831 snat_session_t *s = NULL;
840 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
876 if (clib_bihash_search_16_8 (&sm->
flow_hash, &s_kv, &s_value))
878 new_src_addr = s->out2in.addr;
890 if (clib_bihash_search_16_8 (&sm->
flow_hash, &s_kv, &s_value))
907 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
920 outside_fib_index, &new_dst_addr, NULL);
935 s->out2in.addr.as_u32 = new_src_addr.
as_u32;
936 s->out2in.fib_index = outside_fib_index;
938 s->in2out.fib_index = rx_fib_index;
939 s->in2out.port = s->out2in.port = ip->
protocol;
972 int is_output_feature,
990 while (n_left_from > 0)
993 u32 sw_if_index0, rx_fib_index0, iph_offset0 = 0;
996 snat_session_t *s0 = 0;
1001 int lookup_skipped = 0;
1018 if (is_output_feature)
1020 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1037 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1045 if (is_output_feature)
1049 (sm, ip0, thread_index, now, vm, b0)))
1056 ICMP4_echo_request &&
1062 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
1087 if (is_multi_worker &&
1111 if (clib_bihash_search_16_8 (&sm->
flow_hash, &kv0, &value0))
1125 ASSERT (thread_index == s0->thread_index);
1136 if (s0->tcp_closed_timestamp)
1138 if (now >= s0->tcp_closed_timestamp)
1146 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_TCP_CLOSED];
1153 u64 sess_timeout_time;
1156 if (now >= sess_timeout_time)
1165 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1187 sm, b0, ip0, f, proto0, is_output_feature)))
1197 case NAT_PROTOCOL_TCP:
1199 thread_index, sw_if_index0, 1);
1202 case NAT_PROTOCOL_UDP:
1204 thread_index, sw_if_index0, 1);
1206 case NAT_PROTOCOL_ICMP:
1208 thread_index, sw_if_index0, 1);
1210 case NAT_PROTOCOL_OTHER:
1212 thread_index, sw_if_index0, 1);
1226 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1253 thread_index, sw_if_index0, 1);
1269 int is_output_feature,
1270 int is_multi_worker)
1285 while (n_left_from > 0)
1288 u32 sw_if_index0, rx_fib_index0, iph_offset0 = 0;
1292 icmp46_header_t *icmp0;
1293 snat_session_t *s0 = 0;
1299 if (is_output_feature)
1300 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1315 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1322 icmp0 = (icmp46_header_t *) udp0;
1328 sm, b0, ip0, rx_fib_index0, thread_index, now, vm, node);
1334 sm, b0, ip0, &s0->i2o, proto0, is_output_feature)))
1340 thread_index, sw_if_index0, 1);
1347 sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, next[0],
1348 now, thread_index, proto0, &s0, is_multi_worker);
1352 sm, b0, ip0, &s0->i2o, proto0, is_output_feature)))
1358 thread_index, sw_if_index0, 1);
1366 if (!clib_bihash_search_16_8 (&sm->
flow_hash, &kv0, &value0))
1373 if (s0->tcp_closed_timestamp && now >= s0->tcp_closed_timestamp)
1383 if (is_output_feature)
1397 (proto0 == NAT_PROTOCOL_UDP
1399 clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_server))
1406 vm, sm, node, sw_if_index0, b0, ip0, proto0, rx_fib_index0,
1415 rx_fib_index0, &s0, node, next[0], thread_index, now);
1425 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1429 sm, b0, ip0, &s0->i2o, proto0, is_output_feature)))
1440 thread_index, sw_if_index0, 1);
1446 thread_index, sw_if_index0, 1);
1452 (vm, b0), thread_index);
1458 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1485 thread_index, sw_if_index0, 1);
1514 .name =
"nat44-ed-in2out",
1515 .vector_size =
sizeof (
u32),
1516 .sibling_of =
"nat-default",
1539 .name =
"nat44-ed-in2out-output",
1540 .vector_size =
sizeof (
u32),
1541 .sibling_of =
"nat-default",
1564 .name =
"nat44-ed-in2out-slowpath",
1565 .vector_size =
sizeof (
u32),
1566 .sibling_of =
"nat-default",
1590 .name =
"nat44-ed-in2out-output-slowpath",
1591 .vector_size =
sizeof (
u32),
1592 .sibling_of =
"nat-default",
1625 .name =
"nat-pre-in2out",
1626 .vector_size =
sizeof (
u32),
1627 .sibling_of =
"nat-default",
1634 .name =
"nat-pre-in2out-output",
1635 .vector_size =
sizeof (
u32),
1636 .sibling_of =
"nat-default",
ip4_address_t external_addr
vlib_main_t vlib_node_runtime_t * node
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
#define SNAT_SESSION_FLAG_STATIC_MAPPING
static ip_csum_t ip_incremental_checksum_buffer(vlib_main_t *vm, vlib_buffer_t *first_buffer, u32 first_buffer_offset, u32 n_bytes_to_checksum, ip_csum_t sum)
nat_outside_fib_t * outside_fibs
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, int is_multi_worker)
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.
static_always_inline void nat_6t_o2i_flow_init(snat_main_t *sm, u32 thread_idx, snat_session_t *s, ip4_address_t saddr, u16 sport, ip4_address_t daddr, u16 dport, u32 fib_index, u8 proto)
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 s_addr, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
static u8 * format_nat_pre_trace(u8 *s, va_list *args)
static_always_inline u16 snat_random_port(u16 min, u16 max)
static int nat_ed_alloc_addr_and_port_with_snat_address(snat_main_t *sm, u32 nat_proto, u32 thread_index, snat_address_t *a, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port)
#define nat_elog_info(_pm, nat_elog_str)
nat_translation_error_e translation_error
static_always_inline int nat_6t_t_eq(nat_6t_t *t1, nat_6t_t *t2)
void nat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
#define pool_foreach(VAR, POOL)
Iterate through pool.
static_always_inline void nat_6t_i2o_flow_init(snat_main_t *sm, u32 thread_idx, snat_session_t *s, ip4_address_t saddr, u16 sport, ip4_address_t daddr, u16 dport, u32 fib_index, u8 proto)
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
u16 nexts[VLIB_FRAME_SIZE]
static f64 vlib_time_now(vlib_main_t *vm)
#define foreach_nat_in2out_ed_error
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.
static u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
static snat_session_t * nat44_ed_in2out_slowpath_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_always_inline int nat_lru_free_one(snat_main_t *sm, int thread_index, f64 now)
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
#define VLIB_NODE_FN(node)
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes, u32 thread_index)
static void nat_6t_flow_saddr_rewrite_set(nat_6t_flow_t *f, u32 saddr)
static u32 icmp_in2out_ed_slow_path(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, icmp46_header_t *icmp, u32 sw_if_index, u32 rx_fib_index, vlib_node_runtime_t *node, u32 next, f64 now, u32 thread_index, nat_protocol_t nat_proto, snat_session_t **s_p, int is_multi_worker)
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)
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.
u32 max_translations_per_thread
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
static int ip4_is_fragment(const ip4_header_t *i)
#define clib_memcpy(d, s, n)
static void nat_6t_flow_daddr_rewrite_set(nat_6t_flow_t *f, u32 daddr)
static_always_inline void per_vrf_sessions_register_session(snat_session_t *s, u32 thread_index)
static_always_inline int nat44_ed_not_translate(vlib_main_t *vm, snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index, vlib_buffer_t *b, ip4_header_t *ip, u32 proto, u32 rx_fib_index, u32 thread_index)
#define static_always_inline
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 nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
vlib_get_buffers(vm, from, b, n_left_from)
static u8 * format_nat_in2out_ed_trace(u8 *s, va_list *args)
description fragment has unexpected format
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
static_always_inline int nat44_ed_external_sm_lookup(snat_main_t *sm, ip4_address_t match_addr, u16 match_port, nat_protocol_t match_protocol, u32 match_fib_index, ip4_address_t *daddr, u16 *dport)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Aggregate type for a prefix.
#define nat_elog_warn(_pm, nat_elog_str)
#define is_addr_only_static_mapping(sm)
Check if NAT static mapping is address only (1:1NAT).
static void * ip4_next_header(ip4_header_t *i)
static void nat_6t_flow_icmp_id_rewrite_set(nat_6t_flow_t *f, u16 id)
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
clib_bihash_kv_16_8_t search_key
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.
struct snat_main_s::@736::@737 fastpath
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.
vl_api_interface_index_t sw_if_index
static char * nat_in2out_ed_error_strings[]
#define ED_PORT_ALLOC_ATTEMPTS
static_always_inline u32 nat_outside_fib_index_lookup(snat_main_t *sm, ip4_address_t addr)
snat_static_mapping_t * static_mappings
format_function_t format_nat_ed_translation_error
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
format_function_t format_ed_session_kvp
static void nat_6t_flow_sport_rewrite_set(nat_6t_flow_t *f, u32 sport)
#define is_fwd_bypass_session(s)
Check if NAT session is forwarding bypass.
clib_bihash_8_8_t static_mapping_by_external
vlib_node_registration_t nat44_ed_in2out_output_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node)
static_always_inline int nat_get_icmp_session_lookup_values(vlib_buffer_t *b, ip4_header_t *ip0, ip4_address_t *lookup_saddr, u16 *lookup_sport, ip4_address_t *lookup_daddr, u16 *lookup_dport, u8 *lookup_protocol)
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
snat_interface_t * output_feature_interfaces
vl_api_ip_port_and_mask_t src_port
vlib_node_registration_t nat44_ed_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node)
static hash_pair_t * lookup(void *v, uword key, enum lookup_opcode op, void *new_value, void *old_value)
#define VLIB_REGISTER_NODE(x,...)
format_function_t format_nat_6t_flow
#define CLIB_PREFETCH(addr, size, type)
sll srl srl sll sra u16x4 i
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)
vlib_node_registration_t nat_pre_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_output_node)
struct snat_main_s::@736 counters
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.
static u32 slow_path_ed(vlib_main_t *vm, 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)
u32 fib_node_index_t
A typedef of a node index.
#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
#define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
static void nat_6t_flow_txfib_rewrite_set(nat_6t_flow_t *f, u32 tx_fib_index)
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)
#define nat_interface_is_outside(i)
Check if NAT interface is outside.
static_always_inline snat_session_t * nat_ed_session_alloc(snat_main_t *sm, u32 thread_index, f64 now, u8 proto)
vl_api_interface_index_t tx_sw_if_index
struct snat_main_s::@736::@738 slowpath
#define SNAT_SESSION_FLAG_HAIRPINNING
nat_translation_error_e nat_6t_flow_buf_translate(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, nat_6t_flow_t *f, nat_protocol_t proto, int is_output_feature)
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, int is_multi_worker)
static vlib_main_t * vlib_get_main(void)
void nat_ipfix_logging_max_sessions(u32 thread_index, u32 limit)
Generate maximum session entries exceeded event.
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 u32 ed_value_get_session_index(clib_bihash_kv_16_8_t *value)
static u32 ed_value_get_thread_index(clib_bihash_kv_16_8_t *value)
static_always_inline u8 per_vrf_sessions_is_expired(snat_session_t *s, u32 thread_index)
static_always_inline int nat_ed_ses_o2i_flow_hash_add_del(snat_main_t *sm, u32 thread_idx, snat_session_t *s, int is_add)
static void nat_ed_session_delete(snat_main_t *sm, snat_session_t *ses, u32 thread_index, int lru_delete)
#define nat_interface_is_inside(i)
Check if NAT interface is inside.
#define FIB_NODE_INDEX_INVALID
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
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 SNAT_SESSION_FLAG_LOAD_BALANCING
snat_address_t * addresses
static void nat_6t_flow_dport_rewrite_set(nat_6t_flow_t *f, u32 dport)
int snat_static_mapping_match(vlib_main_t *vm, 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 nat44_ed_maximum_sessions_exceeded(snat_main_t *sm, u32 fib_index, u32 thread_index)
#define vec_foreach(var, vec)
Vector iterator.
#define nat_elog_notice(_pm, nat_elog_str)
u16 flags
Copy of main node flags.
static_always_inline int nat_ed_ses_i2o_flow_hash_add_del(snat_main_t *sm, u32 thread_idx, snat_session_t *s, int is_add)
clib_bihash_16_8_t flow_hash
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
static int ip4_header_bytes(const ip4_header_t *i)
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
static_always_inline int nat44_ed_not_translate_output_feature(snat_main_t *sm, vlib_buffer_t *b, 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, int is_multi_worker)
static uword nat_pre_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 def_next)
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
snat_session_t * sessions
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)
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 void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
clib_bihash_8_8_t static_mapping_by_local
static u16 ip_csum_fold(ip_csum_t c)
snat_interface_t * interfaces
#define nat44_is_ses_closed(s)
Check if NAT44 endpoint-dependent TCP session is closed.