56 tag = t->
is_slow_path ?
"NAT44_IN2OUT_SLOW_PATH" :
"NAT44_IN2OUT_FAST_PATH";
58 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
71 s =
format (s,
"NAT44_IN2OUT_FAST: sw_if_index %d, next index %d",
77 #define foreach_snat_in2out_error \ 78 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 79 _(IN2OUT_PACKETS, "good in2out packets processed") \ 80 _(OUT_OF_PORTS, "out of ports") \ 81 _(BAD_OUTSIDE_FIB, "outside VRF ID not found") \ 82 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 83 _(NO_TRANSLATION, "no translation") \ 84 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 85 _(DROP_FRAGMENT, "drop fragment") \ 86 _(TCP_PACKETS, "TCP packets") \ 87 _(UDP_PACKETS, "UDP packets") \ 88 _(ICMP_PACKETS, "ICMP packets") \ 89 _(OTHER_PACKETS, "other protocol packets") \ 90 _(FRAGMENTS, "fragments") \ 91 _(CACHED_FRAGMENTS, "cached fragments") \ 92 _(PROCESSED_FRAGMENTS, "processed fragments") 96 #define _(sym,str) SNAT_IN2OUT_ERROR_##sym, 103 #define _(sym,string) string, 120 u32 rx_fib_index0,
u32 thread_index)
167 if (!clib_bihash_search_8_8
176 if (!clib_bihash_search_8_8
183 if ((nat_interface_is_inside(i)) && (sw_if_index == i->sw_if_index))
193 #ifndef CLIB_MARCH_VARIANT 200 u64 sess_timeout_time;
207 if (ctx->
now >= sess_timeout_time)
209 s_kv.
key = s->out2in.as_u64;
210 if (clib_bihash_add_del_8_8 (&tsm->
out2in, &s_kv, 0))
214 s->in2out.addr.as_u32,
215 s->out2in.addr.as_u32,
219 s->in2out.fib_index);
222 &s->in2out.addr, s->in2out.port,
223 &s->out2in.addr, s->out2in.port,
226 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
227 s->ext_host_port, s->out2in.protocol, s->out2in.fib_index,
247 snat_session_t ** sessionp,
251 snat_session_t *s = 0;
272 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_MAX_SESSIONS_EXCEEDED];
282 (sm, *key0, &key1, 0, 0, 0, 0, 0, &identity_nat))
291 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_OUT_OF_PORTS];
346 s->out2in.fib_index = outside_fib->
fib_index;
355 s->ext_host_port =
vnet_buffer (b0)->ip.reass.l4_dst_port;
361 kv0.
key = s->in2out.as_u64;
363 if (clib_bihash_add_or_overwrite_stale_8_8
368 kv0.
key = s->out2in.as_u64;
371 if (clib_bihash_add_or_overwrite_stale_8_8
378 s->in2out.addr.as_u32,
379 s->out2in.addr.as_u32,
382 s->out2in.port, s->in2out.fib_index);
385 &s->in2out.addr, s->in2out.port, &s->out2in.addr,
386 s->out2in.port, s->in2out.protocol);
388 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
389 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
390 &s->ext_host_nat_addr, s->ext_host_nat_port,
391 s->in2out.protocol, s->in2out.fib_index, s->flags,
397 #ifndef CLIB_MARCH_VARIANT 402 icmp46_header_t *icmp0;
407 icmp46_header_t *inner_icmp0;
413 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags))
427 case SNAT_PROTOCOL_ICMP:
428 inner_icmp0 = (icmp46_header_t *) l4_header;
432 case SNAT_PROTOCOL_UDP:
433 case SNAT_PROTOCOL_TCP:
437 return SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL;
463 u8 * p_dont_translate,
void *d,
void *e)
468 snat_session_t *s0 = 0;
469 u8 dont_translate = 0;
507 ip0, SNAT_PROTOCOL_ICMP,
520 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE];
525 next0 =
slow_path (sm, b0, ip0, rx_fib_index0, &key0, &s0, node, next0,
545 reass.icmp_type_or_tcp_flags)))
547 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE];
559 *p_value = s0->out2in;
560 *p_dont_translate = dont_translate;
562 *(snat_session_t **) d = s0;
567 #ifndef CLIB_MARCH_VARIANT 586 u8 * p_dont_translate,
void *d,
void *e)
592 u8 dont_translate = 0;
610 (sm, key0, &sm0, 0, &is_addr_only, 0, 0, 0, 0))
627 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_NO_TRANSLATION];
633 (
vnet_buffer (b0)->
ip.reass.icmp_type_or_tcp_flags != ICMP4_echo_request
635 ICMP4_echo_reply || !is_addr_only)
637 reass.icmp_type_or_tcp_flags)))
639 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE];
648 *p_dont_translate = dont_translate;
653 #ifndef CLIB_MARCH_VARIANT 658 icmp46_header_t * icmp0,
662 u32 next0,
u32 thread_index,
void *d,
void *e)
669 icmp46_header_t *inner_icmp0;
671 u32 new_addr0, old_addr0;
672 u16 old_id0, new_id0;
673 u16 old_checksum0, new_checksum0;
681 &protocol, &sm0, &dont_translate, d,
713 if (icmp0->checksum == 0)
714 icmp0->checksum = 0xffff;
725 sum0 = icmp0->checksum;
747 sum0 = icmp0->checksum;
753 old_checksum0 = inner_ip0->
checksum;
758 new_checksum0 = inner_ip0->
checksum;
759 sum0 = icmp0->checksum;
767 case SNAT_PROTOCOL_ICMP:
768 inner_icmp0 = (icmp46_header_t *) l4_header;
775 sum0 = icmp0->checksum;
781 case SNAT_PROTOCOL_UDP:
782 case SNAT_PROTOCOL_TCP:
787 sum0 = icmp0->checksum;
815 icmp46_header_t * icmp0,
820 f64 now,
u32 thread_index, snat_session_t ** p_s0)
822 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
823 next0, thread_index, p_s0, 0);
824 snat_session_t *s0 = *p_s0;
845 u32 old_addr, new_addr;
879 int is_output_feature)
881 u32 n_left_from, *from, *to_next;
883 u32 pkts_processed = 0;
886 u32 stats_node_index;
888 u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
898 while (n_left_from > 0)
904 while (n_left_from >= 4 && n_left_to_next >= 2)
909 u32 sw_if_index0, sw_if_index1;
912 u32 new_addr0, old_addr0, new_addr1, old_addr1;
913 u16 old_port0, new_port0, old_port1, new_port1;
916 icmp46_header_t *icmp0, *icmp1;
918 u32 rx_fib_index0, rx_fib_index1;
920 snat_session_t *s0 = 0, *s1 = 0;
922 u32 iph_offset0 = 0, iph_offset1 = 0;
939 to_next[0] = bi0 = from[0];
940 to_next[1] = bi1 = from[1];
949 if (is_output_feature)
950 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
957 icmp0 = (icmp46_header_t *) udp0;
969 ICMP4_time_exceeded_ttl_exceeded_in_transit,
983 (sm, b0, ip0, rx_fib_index0))
987 node->
errors[SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
996 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0,
997 node, next0, now, thread_index, &s0);
1025 (clib_bihash_search_8_8
1031 if (is_output_feature)
1038 thread_index, sw_if_index0)))
1046 ((b0->
flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
1047 && proto0 == SNAT_PROTOCOL_UDP
1049 clib_host_to_net_u16
1050 (UDP_DST_PORT_dhcp_to_server))))
1057 (sm, node, sw_if_index0, ip0, proto0,
1058 rx_fib_index0, thread_index)))
1062 next0 =
slow_path (sm, b0, ip0, rx_fib_index0, &key0,
1063 &s0, node, next0, thread_index, now);
1081 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1086 if (!is_output_feature)
1100 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1101 new_port0 = udp0->
src_port = s0->out2in.port;
1102 sum0 = tcp0->checksum;
1120 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1121 new_port0 = udp0->
src_port = s0->out2in.port;
1144 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1159 if (is_output_feature)
1160 iph_offset1 =
vnet_buffer (b1)->ip.reass.save_rewrite_length;
1167 icmp1 = (icmp46_header_t *) udp1;
1177 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1191 (sm, b1, ip1, rx_fib_index1))
1195 node->
errors[SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
1204 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
1205 next1, now, thread_index, &s1);
1233 (clib_bihash_search_8_8
1239 if (is_output_feature)
1246 thread_index, sw_if_index1)))
1254 ((b1->
flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
1255 && proto1 == SNAT_PROTOCOL_UDP
1257 clib_host_to_net_u16
1258 (UDP_DST_PORT_dhcp_to_server))))
1265 (sm, node, sw_if_index1, ip1, proto1,
1266 rx_fib_index1, thread_index)))
1270 next1 =
slow_path (sm, b1, ip1, rx_fib_index1, &key1,
1271 &s1, node, next1, thread_index, now);
1289 b1->
flags |= VNET_BUFFER_F_IS_NATED;
1294 if (!is_output_feature)
1307 old_port1 =
vnet_buffer (b1)->ip.reass.l4_src_port;
1308 new_port1 = udp1->
src_port = s1->out2in.port;
1309 sum1 = tcp1->checksum;
1327 old_port1 =
vnet_buffer (b1)->ip.reass.l4_src_port;
1328 new_port1 = udp1->
src_port = s1->out2in.port;
1351 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
1367 to_next, n_left_to_next,
1368 bi0, bi1, next0, next1);
1371 while (n_left_from > 0 && n_left_to_next > 0)
1379 u32 new_addr0, old_addr0;
1380 u16 old_port0, new_port0;
1383 icmp46_header_t *icmp0;
1387 snat_session_t *s0 = 0;
1389 u32 iph_offset0 = 0;
1397 n_left_to_next -= 1;
1402 if (is_output_feature)
1403 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1410 icmp0 = (icmp46_header_t *) udp0;
1420 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1434 (sm, b0, ip0, rx_fib_index0))
1438 node->
errors[SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
1447 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1448 next0, now, thread_index, &s0);
1475 if (clib_bihash_search_8_8
1480 if (is_output_feature)
1487 thread_index, sw_if_index0)))
1495 ((b0->
flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
1496 && proto0 == SNAT_PROTOCOL_UDP
1498 clib_host_to_net_u16
1499 (UDP_DST_PORT_dhcp_to_server))))
1506 (sm, node, sw_if_index0, ip0, proto0,
1507 rx_fib_index0, thread_index)))
1511 next0 =
slow_path (sm, b0, ip0, rx_fib_index0, &key0,
1512 &s0, node, next0, thread_index, now);
1531 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1536 if (!is_output_feature)
1549 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1550 new_port0 = udp0->
src_port = s0->out2in.port;
1551 sum0 = tcp0->checksum;
1569 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1570 new_port0 = udp0->
src_port = s0->out2in.port;
1593 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1610 to_next, n_left_to_next,
1618 SNAT_IN2OUT_ERROR_IN2OUT_PACKETS,
1621 SNAT_IN2OUT_ERROR_TCP_PACKETS, tcp_packets);
1623 SNAT_IN2OUT_ERROR_UDP_PACKETS, udp_packets);
1625 SNAT_IN2OUT_ERROR_ICMP_PACKETS, icmp_packets);
1627 SNAT_IN2OUT_ERROR_OTHER_PACKETS,
1630 SNAT_IN2OUT_ERROR_FRAGMENTS, fragments);
1645 .name =
"nat44-in2out",
1646 .vector_size =
sizeof (
u32),
1677 .name =
"nat44-in2out-output",
1678 .vector_size =
sizeof (
u32),
1709 .name =
"nat44-in2out-slowpath",
1710 .vector_size =
sizeof (
u32),
1741 .name =
"nat44-in2out-output-slowpath",
1742 .vector_size =
sizeof (
u32),
1767 u32 n_left_from, *from, *to_next;
1769 u32 pkts_processed = 0;
1771 u32 stats_node_index;
1776 n_left_from =
frame->n_vectors;
1777 next_index =
node->cached_next_index;
1779 while (n_left_from > 0)
1785 while (n_left_from > 0 && n_left_to_next > 0)
1793 u32 new_addr0, old_addr0;
1794 u16 old_port0, new_port0;
1797 icmp46_header_t *icmp0;
1808 n_left_to_next -= 1;
1816 icmp0 = (icmp46_header_t *) udp0;
1826 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1839 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0,
1840 rx_fib_index0,
node, next0, ~0, 0, 0);
1851 b0->
error =
node->errors[SNAT_IN2OUT_ERROR_NO_TRANSLATION];
1857 new_port0 = sm0.
port;
1875 sum0 = tcp0->checksum;
1901 sum0 = tcp0->checksum;
1923 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1935 to_next, n_left_to_next,
1943 SNAT_IN2OUT_ERROR_IN2OUT_PACKETS,
1945 return frame->n_vectors;
1951 .name =
"nat44-in2out-fast",
1952 .vector_size =
sizeof (
u32),
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
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 u32 slow_path(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, u32 rx_fib_index0, snat_session_key_t *key0, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next0, u32 thread_index, f64 now)
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
static int nat_not_translate_output_feature(snat_main_t *sm, ip4_header_t *ip0, u32 proto0, u16 src_port, u16 dst_port, u32 thread_index, u32 sw_if_index)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
static u8 * format_snat_in2out_fast_trace(u8 *s, va_list *args)
#define nat_elog_notice(nat_elog_str)
static uword snat_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 f64 vlib_time_now(vlib_main_t *vm)
static char * snat_in2out_error_strings[]
#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.
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
#define VLIB_NODE_FN(node)
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
int snat_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0, int is_ed)
u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation.
static_always_inline snat_in2out_error_t icmp_get_key(vlib_buffer_t *b, ip4_header_t *ip0, snat_session_key_t *p_key0)
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.
snat_session_t * nat_session_alloc_or_recycle(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate new NAT session or recycle last used.
vlib_node_registration_t snat_in2out_output_slowpath_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_slowpath_node)
vl_api_ip_proto_t protocol
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define static_always_inline
static uword ip4_header_checksum_is_valid(ip4_header_t *i)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
vlib_node_registration_t snat_in2out_fast_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)
static int snat_not_translate(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, ip4_header_t *ip0, u32 proto0, u32 rx_fib_index0, 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.
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)
static void * ip4_next_header(ip4_header_t *i)
vlib_node_registration_t snat_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_slowpath_node)
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)
#define foreach_snat_in2out_error
vl_api_fib_path_type_t type
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)
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.
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
static u32 icmp_in2out_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)
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_apmadd(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, snat_protocol_t proto)
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 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).
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
int nat44_o2i_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
snat_interface_t * output_feature_interfaces
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
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.
static int nat_in2out_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index)
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 CLIB_PREFETCH(addr, size, type)
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
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
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.
u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
vlib_main_t vlib_node_runtime_t * node
u32 in2out_fast_node_index
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u32 in2out_slowpath_node_index
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
void nat_syslog_nat44_apmdel(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, snat_protocol_t proto)
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)
#define vec_elt(v, i)
Get vector value at index i.
void nat_hairpinning_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
static u32 ip_proto_to_snat_proto(u8 ip_proto)
#define FIB_NODE_INDEX_INVALID
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
#define vec_foreach(var, vec)
Vector iterator.
vlib_node_registration_t snat_in2out_output_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u16 flags
Copy of main node flags.
static int ip4_header_bytes(const ip4_header_t *i)
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
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.
snat_icmp_match_function_t * icmp_match_in2out_cb
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.