36 #define _(sym,string) string, 59 "NAT44_IN2OUT_ED_FAST_PATH";
61 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
67 #ifndef CLIB_MARCH_VARIANT 74 u64 sess_timeout_time;
85 if (ctx->
now >= sess_timeout_time)
90 ed_key.
l_addr = s->out2in.addr;
91 ed_key.
r_addr = s->ext_host_addr;
95 ed_key.
proto = s->in2out.port;
102 ed_key.
l_port = s->out2in.port;
103 ed_key.
r_port = s->ext_host_port;
107 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &ed_kv, 0))
114 s->in2out.addr.as_u32,
115 s->out2in.addr.as_u32,
119 s->in2out.fib_index);
122 &s->in2out.addr, s->in2out.port,
123 &s->ext_host_nat_addr, s->ext_host_nat_port,
124 &s->out2in.addr, s->out2in.port,
125 &s->ext_host_addr, s->ext_host_port,
128 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
129 s->ext_host_port, s->out2in.protocol, s->out2in.fib_index,
137 key.
port = s->ext_host_nat_port;
139 if (a->
addr.
as_u32 == s->ext_host_nat_addr.as_u32)
166 u32 sw_if_index0,
u32 rx_fib_index0,
168 u32 thread_index, snat_session_t ** p_s0)
170 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
171 next0, thread_index, p_s0, 0);
172 snat_session_t *s0 = *p_s0;
190 snat_session_t ** sessionp,
193 snat_session_t *s = 0;
216 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
229 (sm, key0, &key1, 0, 0, 0, &lb, 0, &identity_nat))
238 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
253 if (
proto == SNAT_PROTOCOL_TCP)
258 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_NON_SYN];
269 thread_index, &key1);
280 thread_index, &key1);
290 s->ext_host_addr = key->
r_addr;
291 s->ext_host_port = key->
r_port;
313 s->out2in.fib_index = outside_fib->
fib_index;
326 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, kv,
334 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
out2in_ed, kv,
343 s->in2out.addr.as_u32,
344 s->out2in.addr.as_u32,
347 s->out2in.port, s->in2out.fib_index);
350 &s->in2out.addr, s->in2out.port,
351 &s->ext_host_nat_addr, s->ext_host_nat_port,
352 &s->out2in.addr, s->out2in.port,
353 &s->ext_host_addr, s->ext_host_port,
354 s->in2out.protocol, 0);
356 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
357 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
358 &s->ext_host_nat_addr, s->ext_host_nat_port,
359 s->in2out.protocol, s->in2out.fib_index, s->flags,
368 u32 rx_fib_index,
u32 thread_index)
380 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
402 u32 thread_index,
f64 now,
407 snat_session_t *s = 0;
413 if (ip->
protocol == IP_PROTOCOL_ICMP)
422 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
434 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
439 if (ip->
protocol == IP_PROTOCOL_TCP)
462 u32 thread_index,
u32 rx_sw_if_index,
475 if (!clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
491 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
501 if ((nat_interface_is_inside (i)) && (rx_sw_if_index == i->sw_if_index))
511 #ifndef CLIB_MARCH_VARIANT 516 u8 * p_dont_translate,
void *d,
void *e)
521 snat_session_t *s = 0;
522 u8 dont_translate = 0;
544 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
560 ip, SNAT_PROTOCOL_ICMP,
571 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags)))
573 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
578 next =
slow_path_ed (sm, b, rx_fib_index, &kv, &s, node, next,
593 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
595 &&
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
598 reass.icmp_type_or_tcp_flags)))
600 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
611 *p_value = s->out2in;
612 *p_dont_translate = dont_translate;
614 *(snat_session_t **) d = s;
619 static snat_session_t *
631 u32 old_addr, new_addr = 0;
636 u32 elt_index, head_index, ses_index;
668 outside_fib_index = outside_fib->
fib_index;
681 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &s_kv, &s_value))
690 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
720 elt_index = head->
next;
726 ses_index = elt->
value;
729 while (ses_index != ~0)
732 elt_index = elt->
next;
734 ses_index = elt->
value;
741 ip->
protocol, outside_fib_index, 0, 0);
742 if (clib_bihash_search_16_8
753 ip->
protocol, outside_fib_index, 0, 0);
754 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &s_kv, &s_value))
776 s->out2in.addr.as_u32 = new_addr;
777 s->out2in.fib_index = outside_fib_index;
778 s->in2out.addr.as_u32 = old_addr;
779 s->in2out.fib_index = rx_fib_index;
780 s->in2out.port = s->out2in.port = ip->
protocol;
789 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
793 outside_fib_index, 0, 0);
795 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &s_kv, 1))
824 int is_output_feature)
826 u32 n_left_from, *from, *to_next, pkts_processed = 0, stats_node_index;
832 u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
845 while (n_left_from > 0)
851 while (n_left_from >= 4 && n_left_to_next >= 2)
855 u32 next0, sw_if_index0, rx_fib_index0, iph_offset0 = 0, proto0,
856 new_addr0, old_addr0;
857 u32 next1, sw_if_index1, rx_fib_index1, iph_offset1 = 0, proto1,
858 new_addr1, old_addr1;
859 u16 old_port0, new_port0, old_port1, new_port1;
863 icmp46_header_t *icmp0, *icmp1;
864 snat_session_t *s0 = 0, *s1 = 0;
883 to_next[0] = bi0 = from[0];
884 to_next[1] = bi1 = from[1];
893 if (is_output_feature)
903 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
904 iph_offset1 =
vnet_buffer (b1)->ip.reass.save_rewrite_length;
922 ICMP4_time_exceeded_ttl_exceeded_in_transit,
930 icmp0 = (icmp46_header_t *) udp0;
939 thread_index, now, vm,
950 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
951 next0, now, thread_index, &s0);
964 if (is_output_feature)
968 (sm, ip0, thread_index, now, vm, b0)))
984 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
988 if (is_output_feature)
995 thread_index, sw_if_index0,
1004 ((b0->
flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
1005 && proto0 == SNAT_PROTOCOL_UDP
1007 clib_host_to_net_u16
1008 (UDP_DST_PORT_dhcp_to_server))))
1023 next0, thread_index, now);
1042 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1044 if (!is_output_feature)
1058 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1064 new_port0 = udp0->
src_port = s0->out2in.port;
1065 sum0 = tcp0->checksum;
1075 s0->ext_host_addr.as_u32,
1080 reass.l4_dst_port, s0->ext_host_port,
1082 tcp0->dst_port = s0->ext_host_port;
1095 new_port0 = udp0->
src_port = s0->out2in.port;
1104 s0->ext_host_addr.as_u32,
1110 udp0->
dst_port = s0->ext_host_port;
1120 new_port0 = udp0->
src_port = s0->out2in.port;
1123 udp0->
dst_port = s0->ext_host_port;
1140 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1166 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1174 icmp1 = (icmp46_header_t *) udp1;
1194 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1,
1195 node, next1, now, thread_index, &s1);
1208 if (is_output_feature)
1212 (sm, ip1, thread_index, now, vm, b1)))
1228 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv1, &value1))
1232 if (is_output_feature)
1239 thread_index, sw_if_index1,
1248 ((b1->
flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
1249 && proto1 == SNAT_PROTOCOL_UDP
1251 clib_host_to_net_u16
1252 (UDP_DST_PORT_dhcp_to_server))))
1268 next1, thread_index, now);
1287 b1->
flags |= VNET_BUFFER_F_IS_NATED;
1289 if (!is_output_feature)
1303 old_port1 =
vnet_buffer (b1)->ip.reass.l4_src_port;
1309 new_port1 = udp1->
src_port = s1->out2in.port;
1310 sum1 = tcp1->checksum;
1321 s1->ext_host_addr.as_u32,
1326 reass.l4_dst_port, s1->ext_host_port,
1328 tcp1->dst_port = s1->ext_host_port;
1341 new_port1 = udp1->
src_port = s1->out2in.port;
1353 s1->ext_host_addr.as_u32,
1359 udp1->
dst_port = s1->ext_host_port;
1369 new_port1 = udp1->
src_port = s1->out2in.port;
1372 udp1->
dst_port = s1->ext_host_port;
1389 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
1406 to_next, n_left_to_next,
1407 bi0, bi1, next0, next1);
1410 while (n_left_from > 0 && n_left_to_next > 0)
1414 u32 next0, sw_if_index0, rx_fib_index0, iph_offset0 = 0, proto0,
1415 new_addr0, old_addr0;
1416 u16 old_port0, new_port0;
1420 icmp46_header_t *icmp0;
1421 snat_session_t *s0 = 0;
1431 n_left_to_next -= 1;
1435 if (is_output_feature)
1442 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1459 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1467 icmp0 = (icmp46_header_t *) udp0;
1487 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0,
1488 node, next0, now, thread_index, &s0);
1501 if (is_output_feature)
1505 (sm, ip0, thread_index, now, vm, b0)))
1521 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1525 if (is_output_feature)
1532 thread_index, sw_if_index0,
1541 ((b0->
flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
1542 && proto0 == SNAT_PROTOCOL_UDP
1544 clib_host_to_net_u16
1545 (UDP_DST_PORT_dhcp_to_server))))
1561 next0, thread_index, now);
1580 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1582 if (!is_output_feature)
1596 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1602 new_port0 = udp0->
src_port = s0->out2in.port;
1603 sum0 = tcp0->checksum;
1614 s0->ext_host_addr.as_u32,
1619 reass.l4_dst_port, s0->ext_host_port,
1621 tcp0->dst_port = s0->ext_host_port;
1634 new_port0 = udp0->
src_port = s0->out2in.port;
1645 s0->ext_host_addr.as_u32,
1651 udp0->
dst_port = s0->ext_host_port;
1661 new_port0 = udp0->
src_port = s0->out2in.port;
1664 udp0->
dst_port = s0->ext_host_port;
1674 (vm, b0), thread_index);
1680 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1696 to_next, n_left_to_next,
1704 NAT_IN2OUT_ED_ERROR_IN2OUT_PACKETS,
1707 NAT_IN2OUT_ED_ERROR_TCP_PACKETS, tcp_packets);
1709 NAT_IN2OUT_ED_ERROR_UDP_PACKETS, udp_packets);
1711 NAT_IN2OUT_ED_ERROR_ICMP_PACKETS,
1714 NAT_IN2OUT_ED_ERROR_OTHER_PACKETS,
1728 .name =
"nat44-ed-in2out",
1729 .vector_size =
sizeof (
u32),
1730 .sibling_of =
"nat-default",
1748 .name =
"nat44-ed-in2out-output",
1749 .vector_size =
sizeof (
u32),
1750 .sibling_of =
"nat-default",
1768 .name =
"nat44-ed-in2out-slowpath",
1769 .vector_size =
sizeof (
u32),
1770 .sibling_of =
"nat-default",
1789 .name =
"nat44-ed-in2out-output-slowpath",
1790 .vector_size =
sizeof (
u32),
1791 .sibling_of =
"nat-default",
1818 .name =
"nat-pre-in2out",
1819 .vector_size =
sizeof (
u32),
1820 .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 nat_buffer_opaque(b)
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
u32 sessions_per_user_list_head_index
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
static uword nat44_ed_in2out_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_slow_path, int is_output_feature)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
#define nat_elog_notice(nat_elog_str)
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.
static void make_sm_kv(clib_bihash_kv_8_8_t *kv, ip4_address_t *addr, u8 proto, u32 fib_index, u16 port)
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 addrres port)
#define foreach_nat_in2out_ed_error
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, snat_protocol_t proto, u8 is_twicenat)
#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.
#define nat44_is_ses_closed(s)
Check if NAT44 endpoint-dependent TCP session is closed.
#define VLIB_NODE_FN(node)
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.
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 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.
vl_api_interface_index_t sw_if_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.
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 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.
static u8 maximum_sessions_exceeded(snat_main_t *sm, u32 thread_index)
int snat_static_mapping_match(snat_main_t *sm, snat_session_key_t match, snat_session_key_t *mapping, 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)
Match NAT44 static mapping.
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, snat_session_key_t *k)
Free outside address and port pair.
static void nat44_delete_session(snat_main_t *sm, snat_session_t *ses, u32 thread_index)
vl_api_fib_path_type_t type
static_always_inline int get_icmp_i2o_ed_key(vlib_buffer_t *b, ip4_header_t *ip0, nat_ed_ses_key_t *p_key0)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void mss_clamping(snat_main_t *sm, tcp_header_t *tcp, ip_csum_t *sum)
static int nat44_set_tcp_session_state_i2o(snat_main_t *sm, snat_session_t *ses, vlib_buffer_t *b, u32 thread_index)
Set TCP session state.
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
snat_user_t * nat_user_get_or_create(snat_main_t *sm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
Find or create NAT user.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
clib_bihash_16_8_t out2in_ed
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
vlib_node_registration_t nat44_ed_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node)
snat_session_t * nat_ed_session_alloc(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate NAT endpoint-dependent session.
snat_static_mapping_t * static_mappings
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
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, snat_protocol_t proto, u8 is_twicenat)
vl_api_address_union_t src_address
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static u8 * format_nat_pre_trace(u8 *s, va_list *args)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static u32 slow_path_ed(snat_main_t *sm, vlib_buffer_t *b, u32 rx_fib_index, clib_bihash_kv_16_8_t *kv, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next, u32 thread_index, f64 now)
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
void snat_ipfix_logging_nat44_ses_delete(u32 thread_index, u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session delete event.
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
static void nat44_delete_user_with_no_session(snat_main_t *sm, snat_user_t *u, u32 thread_index)
#define VLIB_REGISTER_NODE(x,...)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
#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 vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes, u32 thread_index)
u32 ed_in2out_slowpath_node_index
u32 fib_node_index_t
A typedef of a node index.
8 octet key, 8 octet key value pair
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
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)
The NAT inline functions.
static void make_ed_kv(clib_bihash_kv_16_8_t *kv, ip4_address_t *l_addr, ip4_address_t *r_addr, u8 proto, u32 fib_index, u16 l_port, u16 r_port)
vlib_main_t vlib_node_runtime_t * node
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
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
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.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static u32 ip_proto_to_snat_proto(u8 ip_proto)
#define FIB_NODE_INDEX_INVALID
int nat44_i2o_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
static void user_session_increment(snat_main_t *sm, snat_user_t *u, u8 is_static)
#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_always_inline void nat44_session_try_cleanup(ip4_address_t *addr, u32 fib_index, u32 thread_index, f64 now)
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
#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.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
u16 flags
Copy of main node flags.
#define is_twice_nat_session(s)
Check if NAT session is twice NAT.
clib_bihash_16_8_t in2out_ed
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
snat_session_t * sessions
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static char * nat_in2out_ed_error_strings[]
#define SNAT_SESSION_FLAG_LOAD_BALANCING
clib_bihash_8_8_t static_mapping_by_local
static u16 ip_csum_fold(ip_csum_t c)
void snat_ipfix_logging_nat44_ses_create(u32 thread_index, u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session create event.
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)
static_always_inline int nat44_ed_not_translate_output_feature(snat_main_t *sm, ip4_header_t *ip, u8 proto, u16 src_port, u16 dst_port, u32 thread_index, u32 rx_sw_if_index, u32 tx_sw_if_index)