32 #define foreach_nat_in2out_ed_error \ 33 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 34 _(IN2OUT_PACKETS, "Good in2out packets processed") \ 35 _(OUT_OF_PORTS, "Out of ports") \ 36 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 37 _(MAX_SESSIONS_EXCEEDED, "Maximum sessions exceeded") \ 38 _(DROP_FRAGMENT, "Drop fragment") \ 39 _(MAX_REASS, "Maximum reassemblies exceeded") \ 40 _(MAX_FRAG, "Maximum fragments per reassembly exceeded")\ 41 _(NON_SYN, "non-SYN packet try to create session") 45 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym, 52 #define _(sym,string) string, 91 "NAT44_IN2OUT_ED_FAST_PATH";
93 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
102 icmp46_header_t *icmp0;
107 icmp46_header_t *inner_icmp0;
114 key0.
proto = IP_PROTOCOL_ICMP;
129 case SNAT_PROTOCOL_ICMP:
130 inner_icmp0 = (icmp46_header_t *) l4_header;
135 case SNAT_PROTOCOL_UDP:
136 case SNAT_PROTOCOL_TCP:
141 return NAT_IN2OUT_ED_ERROR_UNSUPPORTED_PROTOCOL;
154 u64 sess_timeout_time;
165 if (ctx->
now >= sess_timeout_time)
170 ed_key.
l_addr = s->out2in.addr;
171 ed_key.
r_addr = s->ext_host_addr;
175 ed_key.
proto = s->in2out.port;
182 ed_key.
l_port = s->out2in.port;
183 ed_key.
r_port = s->ext_host_port;
187 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &ed_kv, 0))
194 s->out2in.addr.as_u32,
198 s->in2out.fib_index);
205 key.
port = s->ext_host_nat_port;
207 if (a->
addr.
as_u32 == s->ext_host_nat_addr.as_u32)
233 u32 sw_if_index0,
u32 rx_fib_index0,
235 u32 thread_index, snat_session_t ** p_s0)
237 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
238 next0, thread_index, p_s0, 0);
239 snat_session_t *s0 = *p_s0;
257 snat_session_t ** sessionp,
261 snat_session_t *s = 0;
282 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
295 (sm, key0, &key1, 0, 0, 0, &lb, 0, &identity_nat))
304 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
319 if (proto == SNAT_PROTOCOL_TCP)
323 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_NON_SYN];
334 thread_index, &key1);
345 thread_index, &key1);
355 s->ext_host_addr = key->
r_addr;
356 s->ext_host_port = key->
r_port;
378 s->out2in.fib_index = outside_fib->
fib_index;
391 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, kv,
399 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
out2in_ed, kv,
408 s->out2in.addr.as_u32,
411 s->out2in.port, s->in2out.fib_index);
418 u32 rx_fib_index,
u32 thread_index)
430 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
452 u32 thread_index,
f64 now,
458 snat_session_t *s = 0;
464 if (ip->
protocol == IP_PROTOCOL_ICMP)
473 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
485 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
490 if (ip->
protocol == IP_PROTOCOL_TCP)
513 u32 thread_index,
u32 rx_sw_if_index,
526 if (!clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
544 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
554 if ((nat_interface_is_inside (i)) && (rx_sw_if_index == i->sw_if_index))
568 u8 * p_dont_translate,
void *d,
void *e)
570 icmp46_header_t *icmp;
574 snat_session_t *s = 0;
575 u8 dont_translate = 0;
598 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
622 ip, SNAT_PROTOCOL_ICMP,
633 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
638 next =
slow_path_ed (sm, b, rx_fib_index, &kv, &s, node, next,
653 icmp->type != ICMP4_echo_reply &&
656 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
667 *p_value = s->out2in;
668 *p_dont_translate = dont_translate;
670 *(snat_session_t **) d = s;
674 static snat_session_t *
686 u32 old_addr, new_addr = 0;
691 u32 elt_index, head_index, ses_index;
723 outside_fib_index = outside_fib->
fib_index;
736 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &s_kv, &s_value))
745 b->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
775 elt_index = head->
next;
781 ses_index = elt->
value;
784 while (ses_index != ~0)
787 elt_index = elt->
next;
789 ses_index = elt->
value;
796 ip->
protocol, outside_fib_index, 0, 0);
797 if (clib_bihash_search_16_8
808 ip->
protocol, outside_fib_index, 0, 0);
809 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &s_kv, &s_value))
831 s->out2in.addr.as_u32 = new_addr;
832 s->out2in.fib_index = outside_fib_index;
833 s->in2out.addr.as_u32 = old_addr;
834 s->in2out.fib_index = rx_fib_index;
835 s->in2out.port = s->out2in.port = ip->
protocol;
844 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
848 outside_fib_index, 0, 0);
850 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &s_kv, 1))
878 int is_output_feature)
880 u32 n_left_from, *from, *to_next, pkts_processed = 0, stats_node_index;
894 while (n_left_from > 0)
900 while (n_left_from >= 4 && n_left_to_next >= 2)
904 u32 next0, sw_if_index0, rx_fib_index0, iph_offset0 = 0, proto0,
905 new_addr0, old_addr0;
906 u32 next1, sw_if_index1, rx_fib_index1, iph_offset1 = 0, proto1,
907 new_addr1, old_addr1;
908 u16 old_port0, new_port0, old_port1, new_port1;
912 icmp46_header_t *icmp0, *icmp1;
913 snat_session_t *s0 = 0, *s1 = 0;
932 to_next[0] = bi0 = from[0];
933 to_next[1] = bi1 = from[1];
944 if (is_output_feature)
945 iph_offset0 =
vnet_buffer (b0)->ip.save_rewrite_length;
959 ICMP4_time_exceeded_ttl_exceeded_in_transit,
967 icmp0 = (icmp46_header_t *) udp0;
976 thread_index, now, vm,
986 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
987 next0, now, thread_index, &s0);
1005 if (is_output_feature)
1009 (sm, ip0, thread_index, now, vm, b0)))
1024 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1028 if (is_output_feature)
1033 udp0->
dst_port, thread_index, sw_if_index0,
1049 next0, thread_index, now, tcp0);
1068 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1070 if (!is_output_feature)
1086 old_port0 = tcp0->src_port;
1087 new_port0 = tcp0->src_port = s0->out2in.port;
1089 sum0 = tcp0->checksum;
1097 s0->ext_host_addr.as_u32,
1102 tcp0->dst_port = s0->ext_host_port;
1108 (sm, s0, tcp0, thread_index))
1117 udp0->
dst_port = s0->ext_host_port;
1131 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1148 if (is_output_feature)
1149 iph_offset1 =
vnet_buffer (b1)->ip.save_rewrite_length;
1163 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1171 icmp1 = (icmp46_header_t *) udp1;
1180 thread_index, now, vm,
1190 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
1191 next1, now, thread_index, &s1);
1209 if (is_output_feature)
1213 (sm, ip1, thread_index, now, vm, b1)))
1228 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv1, &value1))
1232 if (is_output_feature)
1237 udp1->
dst_port, thread_index, sw_if_index1,
1253 next1, thread_index, now, tcp1);
1272 b1->
flags |= VNET_BUFFER_F_IS_NATED;
1274 if (!is_output_feature)
1290 old_port1 = tcp1->src_port;
1291 new_port1 = tcp1->src_port = s1->out2in.port;
1293 sum1 = tcp1->checksum;
1301 s1->ext_host_addr.as_u32,
1306 tcp1->dst_port = s1->ext_host_port;
1312 (sm, s1, tcp1, thread_index))
1321 udp1->
dst_port = s1->ext_host_port;
1335 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
1351 to_next, n_left_to_next,
1352 bi0, bi1, next0, next1);
1355 while (n_left_from > 0 && n_left_to_next > 0)
1359 u32 next0, sw_if_index0, rx_fib_index0, iph_offset0 = 0, proto0,
1360 new_addr0, old_addr0;
1361 u16 old_port0, new_port0;
1365 icmp46_header_t *icmp0;
1366 snat_session_t *s0 = 0;
1376 n_left_to_next -= 1;
1381 if (is_output_feature)
1382 iph_offset0 =
vnet_buffer (b0)->ip.save_rewrite_length;
1396 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1404 icmp0 = (icmp46_header_t *) udp0;
1413 thread_index, now, vm,
1423 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1424 next0, now, thread_index, &s0);
1442 if (is_output_feature)
1446 (sm, ip0, thread_index, now, vm, b0)))
1461 if (clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv0, &value0))
1465 if (is_output_feature)
1470 udp0->
dst_port, thread_index, sw_if_index0,
1486 next0, thread_index, now, tcp0);
1505 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1507 if (!is_output_feature)
1523 old_port0 = tcp0->src_port;
1524 new_port0 = tcp0->src_port = s0->out2in.port;
1526 sum0 = tcp0->checksum;
1534 s0->ext_host_addr.as_u32,
1539 tcp0->dst_port = s0->ext_host_port;
1545 (sm, s0, tcp0, thread_index))
1554 udp0->
dst_port = s0->ext_host_port;
1568 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1584 to_next, n_left_to_next,
1592 NAT_IN2OUT_ED_ERROR_IN2OUT_PACKETS,
1608 .name =
"nat44-ed-in2out",
1609 .vector_size =
sizeof (
u32),
1640 .name =
"nat44-ed-in2out-output",
1641 .vector_size =
sizeof (
u32),
1672 .name =
"nat44-ed-in2out-slowpath",
1673 .vector_size =
sizeof (
u32),
1704 .name =
"nat44-ed-in2out-output-slowpath",
1705 .vector_size =
sizeof (
u32),
1729 int is_output_feature)
1731 u32 n_left_from, *from, *to_next;
1733 u32 pkts_processed = 0;
1739 u32 *fragments_to_drop = 0;
1740 u32 *fragments_to_loopback = 0;
1746 while (n_left_from > 0)
1752 while (n_left_from > 0 && n_left_to_next > 0)
1754 u32 bi0, sw_if_index0, proto0, rx_fib_index0, new_addr0, old_addr0;
1755 u32 iph_offset0 = 0;
1760 nat_reass_ip4_t *reass0;
1763 icmp46_header_t *icmp0;
1765 snat_session_t *s0 = 0;
1766 u16 old_port0, new_port0;
1775 n_left_to_next -= 1;
1789 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_DROP_FRAGMENT];
1793 if (is_output_feature)
1794 iph_offset0 =
vnet_buffer (b0)->ip.save_rewrite_length;
1801 icmp0 = (icmp46_header_t *) udp0;
1808 1, &fragments_to_drop);
1813 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_REASS];
1822 if (is_output_feature)
1826 (sm, ip0, thread_index, now, vm, b0)))
1832 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1833 next0, now, thread_index, &s0);
1838 reass0->sess_index = s0 - per_thread_data->
sessions;
1842 &fragments_to_loopback);
1852 if (clib_bihash_search_16_8
1853 (&per_thread_data->
in2out_ed, &kv0, &value0))
1855 if (is_output_feature)
1860 udp0->
dst_port, thread_index, sw_if_index0,
1865 &fragments_to_loopback);
1879 &fragments_to_loopback);
1885 &s0, node, next0, thread_index, now,
1897 reass0->sess_index = s0 - per_thread_data->
sessions;
1903 reass0->sess_index = value0.
value;
1914 (reass0, bi0, &fragments_to_drop))
1916 b0->
error = node->
errors[NAT_IN2OUT_ED_ERROR_MAX_FRAG];
1918 (
"maximum fragments per reassembly exceeded");
1926 reass0->sess_index);
1932 if (!is_output_feature)
1949 old_port0 = tcp0->src_port;
1950 tcp0->src_port = s0->out2in.port;
1951 new_port0 = tcp0->src_port;
1953 sum0 = tcp0->checksum;
1963 s0->ext_host_addr.as_u32,
1968 tcp0->dst_port = s0->ext_host_port;
1980 udp0->
dst_port = s0->ext_host_port;
1988 s0->ext_host_port, proto0, 1);
1999 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
2019 to_next, n_left_to_next,
2023 if (n_left_from == 0 &&
vec_len (fragments_to_loopback))
2030 sizeof (
u32) * len);
2037 fragments_to_loopback + (len -
2050 NAT_IN2OUT_ED_ERROR_IN2OUT_PACKETS,
2054 &node->
errors[NAT_IN2OUT_ED_ERROR_DROP_FRAGMENT],
2073 .name =
"nat44-ed-in2out-reass",
2074 .vector_size =
sizeof (
u32),
2104 .name =
"nat44-ed-in2out-reass-output",
2105 .vector_size =
sizeof (
u32),
ip4_address_t external_addr
void nat_ipfix_logging_max_sessions(u32 limit)
Generate maximum session entries exceeded event.
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.
u32 sessions_per_user_list_head_index
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)
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
static uword nat44_ed_in2out_output_fast_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline u8 icmp_is_error_message(icmp46_header_t *icmp)
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)
VLIB_NODE_FUNCTION_MULTIARCH(nat44_ed_in2out_node, nat44_ed_in2out_fast_path_fn)
#define nat_log_warn(...)
#define nat44_is_ses_closed(s)
Check if NAT44 endpoint-dependent TCP session is closed.
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)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int ip4_is_fragment(const ip4_header_t *i)
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 tcp_is_init(t)
Check if client initiating TCP connection (received SYN from client)
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#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.
Aggregrate 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.
#define NAT_REASS_FLAG_ED_DONT_TRANSLATE
static void * ip4_next_header(ip4_header_t *i)
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.
static uword nat44_ed_in2out_fast_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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)
static void mss_clamping(snat_main_t *sm, tcp_header_t *tcp, ip_csum_t *sum)
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.
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Free NAT44 session data (lookup keys, external addrres port)
clib_bihash_16_8_t out2in_ed
static uword nat44_ed_in2out_output_slow_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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 snat_ipfix_logging_nat44_ses_delete(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.
void snat_ipfix_logging_nat44_ses_create(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_always_inline int icmp_get_ed_key(ip4_header_t *ip0, nat_ed_ses_key_t *p_key0)
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).
#define nat_log_notice(...)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
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
static void nat44_delete_user_with_no_session(snat_main_t *sm, snat_user_t *u, u32 thread_index)
#define VLIB_REGISTER_NODE(x,...)
#define nat_log_debug(...)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
u8 nat_reass_is_drop_frag(u8 is_ip6)
Get status of virtual fragmentation reassembly.
#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)
#define vec_free(V)
Free vector's memory (no header).
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
#define clib_memcpy(a, b, c)
vlib_node_registration_t nat44_ed_in2out_reass_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_reass_node)
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes)
u32 fib_node_index_t
A typedef of a node index.
static uword nat44_ed_in2out_reass_output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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 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)
static int nat44_set_tcp_session_state_i2o(snat_main_t *sm, snat_session_t *ses, tcp_header_t *tcp, u32 thread_index)
Set TCP session state.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static uword nat44_ed_in2out_reass_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature)
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
static uword nat44_ed_in2out_reass_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#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 void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
format_function_t format_snat_session
struct _vlib_node_registration vlib_node_registration_t
format_function_t format_nat44_reass_trace
static int ip4_is_first_fragment(const ip4_header_t *i)
static u32 ip_proto_to_snat_proto(u8 ip_proto)
The NAT inline functions.
#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)
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)
nat_reass_ip4_t * nat_ip4_reass_find_or_create(ip4_address_t src, ip4_address_t dst, u16 frag_id, u8 proto, u8 reset_timeout, u32 **bi_to_drop)
Find or create reassembly.
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)
int nat_ip4_reass_add_fragment(nat_reass_ip4_t *reass, u32 bi, u32 **bi_to_drop)
Cache fragment.
#define foreach_nat_in2out_ed_error
#define vec_foreach(var, vec)
Vector iterator.
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.
static void nat_send_all_to_node(vlib_main_t *vm, u32 *bi_vector, vlib_node_runtime_t *node, vlib_error_t *error, u32 next)
#define is_twice_nat_session(s)
Check if NAT session is twice NAT.
clib_bihash_16_8_t in2out_ed
void nat_ip4_reass_get_frags(nat_reass_ip4_t *reass, u32 **bi)
Get cached fragments.
NAT plugin virtual fragmentation reassembly.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static uword nat44_ed_in2out_slow_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
snat_session_t * sessions
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
vlib_node_registration_t nat44_ed_in2out_reass_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_reass_output_node)
static u16 ip_csum_fold(ip_csum_t c)
void nat44_reass_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, u16 sport, u16 dport, u32 proto0, int is_ed)
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, tcp_header_t *tcp)
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)