51 s =
format (s,
"NAT44_OUT2IN: sw_if_index %d, next index %d, session index %d",
62 s =
format (s,
"NAT44_OUT2IN_FAST: sw_if_index %d, next index %d",
75 m = t->
do_handoff ?
"next worker" :
"same worker";
86 #define foreach_snat_out2in_error \ 87 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 88 _(OUT2IN_PACKETS, "Good out2in packets processed") \ 89 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 90 _(NO_TRANSLATION, "No translation") \ 91 _(MAX_SESSIONS_EXCEEDED, "Maximum sessions exceeded") 94 #define _(sym,str) SNAT_OUT2IN_ERROR_##sym, 101 #define _(sym,string) string, 127 static inline snat_session_t *
145 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_MAX_SESSIONS_EXCEEDED];
161 memset (u, 0,
sizeof (*u));
166 per_user_list_head_elt);
187 memset (s, 0,
sizeof (*s));
189 s->outside_address_index = ~0;
196 per_user_translation_list_elt);
198 per_user_translation_list_elt -
201 per_user_translation_list_elt->
value =
208 s->per_user_list_head_index,
209 per_user_translation_list_elt -
217 kv0.
key = s->in2out.as_u64;
223 kv0.
key = s->out2in.as_u64;
232 s->out2in.addr.as_u32,
236 s->in2out.fib_index);
244 icmp46_header_t *icmp0;
249 icmp46_header_t *inner_icmp0;
268 case SNAT_PROTOCOL_ICMP:
269 inner_icmp0 = (icmp46_header_t*)l4_header;
273 case SNAT_PROTOCOL_UDP:
274 case SNAT_PROTOCOL_TCP:
278 return SNAT_OUT2IN_ERROR_UNSUPPORTED_PROTOCOL;
303 u8 *p_dont_translate,
void *d,
void *e)
305 icmp46_header_t *icmp0;
310 snat_session_t *s0 = 0;
311 u8 dont_translate = 0;
326 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_UNSUPPORTED_PROTOCOL];
348 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
354 (icmp0->type != ICMP4_echo_request || !is_addr_only)))
356 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_BAD_ICMP_TYPE];
374 icmp0->type != ICMP4_echo_request &&
377 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_BAD_ICMP_TYPE];
389 *p_value = s0->in2out;
390 *p_dont_translate = dont_translate;
392 *(snat_session_t**)d = s0;
413 u8 *p_dont_translate,
void *d,
void *e)
415 icmp46_header_t *icmp0;
420 u8 dont_translate = 0;
446 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
452 (icmp0->type != ICMP4_echo_request || !is_addr_only) &&
455 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_BAD_ICMP_TYPE];
464 *p_dont_translate = dont_translate;
471 icmp46_header_t * icmp0,
485 icmp46_header_t *inner_icmp0;
487 u32 new_addr0, old_addr0;
488 u16 old_id0, new_id0;
496 &protocol, &sm0, &dont_translate, d, e);
505 if (checksum0 != 0 && checksum0 != 0xffff)
529 sum0 = icmp0->checksum;
550 sum0 = icmp0->checksum;
557 case SNAT_PROTOCOL_ICMP:
558 inner_icmp0 = (icmp46_header_t*)l4_header;
565 sum0 = icmp0->checksum;
570 case SNAT_PROTOCOL_UDP:
571 case SNAT_PROTOCOL_TCP:
576 sum0 = icmp0->checksum;
594 icmp46_header_t * icmp0,
600 snat_session_t ** p_s0)
602 next0 =
icmp_out2in(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
603 next0, thread_index, p_s0, 0);
604 snat_session_t * s0 = *p_s0;
608 s0->last_heard = now;
617 s0->per_user_list_head_index,
624 static snat_session_t *
638 u32 old_addr, new_addr;
658 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
667 b->
error = node->
errors[SNAT_OUT2IN_ERROR_MAX_SESSIONS_EXCEEDED];
678 b->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
691 if (clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
695 memset (u, 0,
sizeof (*u));
708 clib_bihash_add_del_8_8 (&tsm->
user_hash, &kv, 1);
717 memset (s, 0,
sizeof (*s));
722 s->outside_address_index = ~0;
723 s->out2in.addr.as_u32 = old_addr;
724 s->out2in.fib_index = rx_fib_index;
725 s->in2out.addr.as_u32 = new_addr;
727 s->in2out.port = s->out2in.port = ip->
protocol;
734 s->per_user_index = elt - tsm->
list_pool;
741 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &s_kv, 1))
748 if (clib_bihash_add_del_16_8 (&sm->
in2out_ed, &s_kv, 1))
771 static snat_session_t *
785 snat_session_t *s = 0;
789 u32 old_addr, new_addr;
791 u16 new_port, old_port;
808 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
816 b->
error = node->
errors[SNAT_OUT2IN_ERROR_MAX_SESSIONS_EXCEEDED];
832 if (clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
836 memset (u, 0,
sizeof (*u));
849 if (clib_bihash_add_del_8_8 (&tsm->
user_hash, &kv, 1))
859 memset (s, 0,
sizeof (*s));
864 s->outside_address_index = ~0;
873 s->per_user_index = elt - tsm->
list_pool;
880 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &s_kv, 1))
888 if (clib_bihash_add_del_16_8 (&sm->
in2out_ed, &s_kv, 1))
901 old_port = tcp->dst_port;
902 tcp->dst_port = s->in2out.port;
903 new_port = tcp->dst_port;
930 u32 n_left_from, * from, * to_next;
932 u32 pkts_processed = 0;
941 while (n_left_from > 0)
946 to_next, n_left_to_next);
948 while (n_left_from >= 4 && n_left_to_next >= 2)
954 u32 sw_if_index0, sw_if_index1;
957 u32 new_addr0, old_addr0;
958 u16 new_port0, old_port0;
959 u32 new_addr1, old_addr1;
960 u16 new_port1, old_port1;
963 icmp46_header_t * icmp0, * icmp1;
965 u32 rx_fib_index0, rx_fib_index1;
967 snat_session_t * s0 = 0, * s1 = 0;
985 to_next[0] = bi0 = from[0];
986 to_next[1] = bi1 = from[1];
1001 icmp0 = (icmp46_header_t *) udp0;
1011 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1022 thread_index, now, vm, node);
1031 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1032 next0, now, thread_index, &s0);
1050 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1055 if (proto0 != SNAT_PROTOCOL_UDP
1057 != clib_host_to_net_u16(UDP_DST_PORT_dhcp_to_client)))
1102 old_port0 = tcp0->dst_port;
1103 tcp0->dst_port = s0->in2out.port;
1104 new_port0 = tcp0->dst_port;
1106 sum0 = tcp0->checksum;
1124 s0->last_heard = now;
1131 s0->per_user_index);
1133 s0->per_user_list_head_index,
1134 s0->per_user_index);
1156 icmp1 = (icmp46_header_t *) udp1;
1166 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1177 thread_index, now, vm, node);
1186 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
1187 next1, now, thread_index, &s1);
1205 b1->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1210 if (proto1 != SNAT_PROTOCOL_UDP
1212 != clib_host_to_net_u16(UDP_DST_PORT_dhcp_to_client)))
1257 old_port1 = tcp1->dst_port;
1258 tcp1->dst_port = s1->in2out.port;
1259 new_port1 = tcp1->dst_port;
1261 sum1 = tcp1->checksum;
1279 s1->last_heard = now;
1286 s1->per_user_index);
1288 s1->per_user_list_head_index,
1289 s1->per_user_index);
1309 to_next, n_left_to_next,
1310 bi0, bi1, next0, next1);
1313 while (n_left_from > 0 && n_left_to_next > 0)
1321 u32 new_addr0, old_addr0;
1322 u16 new_port0, old_port0;
1325 icmp46_header_t * icmp0;
1329 snat_session_t * s0 = 0;
1338 n_left_to_next -= 1;
1347 icmp0 = (icmp46_header_t *) udp0;
1358 thread_index, now, vm, node);
1368 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1377 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1378 next0, now, thread_index, &s0);
1396 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1401 if (proto0 != SNAT_PROTOCOL_UDP
1403 != clib_host_to_net_u16(UDP_DST_PORT_dhcp_to_client)))
1449 old_port0 = tcp0->dst_port;
1450 tcp0->dst_port = s0->in2out.port;
1451 new_port0 = tcp0->dst_port;
1453 sum0 = tcp0->checksum;
1471 s0->last_heard = now;
1478 s0->per_user_index);
1480 s0->per_user_list_head_index,
1481 s0->per_user_index);
1501 to_next, n_left_to_next,
1509 SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
1516 .name =
"nat44-out2in",
1517 .vector_size =
sizeof (
u32),
1545 u32 n_left_from, * from, * to_next;
1547 u32 pkts_processed = 0;
1555 while (n_left_from > 0)
1560 to_next, n_left_to_next);
1562 while (n_left_from >= 4 && n_left_to_next >= 2)
1568 u32 sw_if_index0, sw_if_index1;
1572 u16 new_port0, old_port0, old_port1, new_port1;
1579 u32 rx_fib_index0, rx_fib_index1;
1580 icmp46_header_t * icmp0, * icmp1;
1597 to_next[0] = bi0 = from[0];
1598 to_next[1] = bi1 = from[1];
1602 n_left_to_next -= 2;
1617 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1628 icmp0 = (icmp46_header_t *) udp0;
1630 next0 =
icmp_out2in(sm, b0, ip0, icmp0, sw_if_index0,
1631 rx_fib_index0, node, next0, thread_index,
1646 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1651 clib_net_to_host_u16(tcp0->dst), &new_addr0);
1656 clib_warning(
"no match src %U:%d dst %U:%d for user %U",
1658 clib_net_to_host_u16 (tcp0->src),
1660 clib_net_to_host_u16 (tcp0->dst),
1663 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1681 ses0->
state = SNAT_SESSION_TCP_CLOSE_WAIT;
1682 else if (tcp0->flags &
TCP_FLAG_ACK && ses0->
state == SNAT_SESSION_TCP_LAST_ACK)
1685 old_port0 = tcp0->dst;
1686 tcp0->dst = new_port0;
1688 sum0 = tcp0->checksum;
1733 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1744 icmp1 = (icmp46_header_t *) udp1;
1746 next1 =
icmp_out2in(sm, b1, ip1, icmp1, sw_if_index1,
1747 rx_fib_index1, node, next1, thread_index,
1762 b1->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1767 clib_net_to_host_u16(tcp1->dst), &new_addr1);
1772 clib_warning(
"no match src %U:%d dst %U:%d for user %U",
1774 clib_net_to_host_u16 (tcp1->src),
1776 clib_net_to_host_u16 (tcp1->dst),
1779 b1->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1782 new_port1 = ses1->in_port;
1796 if (tcp1->flags &
TCP_FLAG_FIN && ses1->state == SNAT_SESSION_TCP_ESTABLISHED)
1797 ses1->state = SNAT_SESSION_TCP_CLOSE_WAIT;
1798 else if (tcp1->flags &
TCP_FLAG_ACK && ses1->state == SNAT_SESSION_TCP_LAST_ACK)
1801 old_port1 = tcp1->dst;
1802 tcp1->dst = new_port1;
1804 sum1 = tcp1->checksum;
1839 to_next, n_left_to_next,
1840 bi0, bi1, next0, next1);
1843 while (n_left_from > 0 && n_left_to_next > 0)
1852 u16 new_port0, old_port0;
1860 icmp46_header_t * icmp0;
1868 n_left_to_next -= 1;
1882 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1893 icmp0 = (icmp46_header_t *) udp0;
1895 next0 =
icmp_out2in(sm, b0, ip0, icmp0, sw_if_index0,
1896 rx_fib_index0, node, next0, thread_index,
1911 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1916 clib_net_to_host_u16(tcp0->dst), &new_addr0);
1921 clib_warning(
"no match src %U:%d dst %U:%d for user %U",
1923 clib_net_to_host_u16 (tcp0->src),
1925 clib_net_to_host_u16 (tcp0->dst),
1928 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
1946 ses0->
state = SNAT_SESSION_TCP_CLOSE_WAIT;
1947 else if (tcp0->flags &
TCP_FLAG_ACK && ses0->
state == SNAT_SESSION_TCP_LAST_ACK)
1950 old_port0 = tcp0->dst;
1951 tcp0->dst = new_port0;
1953 sum0 = tcp0->checksum;
1988 to_next, n_left_to_next,
1996 SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
2003 .name =
"nat44-det-out2in",
2004 .vector_size =
sizeof (
u32),
2042 u8 *p_dont_translate,
void *d,
void *e)
2044 icmp46_header_t *icmp0;
2048 u8 dont_translate = 0;
2052 void *l4_header = 0;
2053 icmp46_header_t *inner_icmp0;
2065 protocol = SNAT_PROTOCOL_ICMP;
2080 case SNAT_PROTOCOL_ICMP:
2081 inner_icmp0 = (icmp46_header_t*)l4_header;
2086 case SNAT_PROTOCOL_UDP:
2087 case SNAT_PROTOCOL_TCP:
2092 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_UNSUPPORTED_PROTOCOL];
2114 clib_net_to_host_u16(key0.
out_port), &new_addr0);
2126 clib_warning(
"no match src %U:%d dst %U:%d for user %U",
2130 clib_net_to_host_u16 (key0.
out_port),
2132 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
2140 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_BAD_ICMP_TYPE];
2148 *p_proto = protocol;
2151 p_value->
addr = new_addr0;
2155 *p_dont_translate = dont_translate;
2173 u32 n_left_from, *from, *to_next = 0;
2180 u32 n_left_to_next_worker = 0, *to_next_worker = 0;
2181 u32 next_worker_index = 0;
2182 u32 current_worker_index = ~0;
2199 while (n_left_from > 0)
2225 if (next_worker_index != current_worker_index)
2232 handoff_queue_elt_by_worker_index);
2236 current_worker_index = next_worker_index;
2240 to_next_worker[0] = bi0;
2242 n_left_to_next_worker--;
2244 if (n_left_to_next_worker == 0)
2248 current_worker_index = ~0;
2249 handoff_queue_elt_by_worker_index[next_worker_index] = 0;
2285 for (i = 0; i <
vec_len (handoff_queue_elt_by_worker_index); i++)
2287 if (handoff_queue_elt_by_worker_index[i])
2289 hf = handoff_queue_elt_by_worker_index[
i];
2297 handoff_queue_elt_by_worker_index[
i] = 0;
2302 congested_handoff_queue_by_worker_index[
i] =
2306 current_worker_index = ~0;
2312 .name =
"nat44-out2in-worker-handoff",
2313 .vector_size =
sizeof (
u32),
2331 u32 n_left_from, * from, * to_next;
2333 u32 pkts_processed = 0;
2340 while (n_left_from > 0)
2345 to_next, n_left_to_next);
2347 while (n_left_from > 0 && n_left_to_next > 0)
2355 u32 new_addr0, old_addr0;
2356 u16 new_port0, old_port0;
2359 icmp46_header_t * icmp0;
2370 n_left_to_next -= 1;
2377 icmp0 = (icmp46_header_t *) udp0;
2388 ICMP4_time_exceeded_ttl_exceeded_in_transit,
2401 next0 =
icmp_out2in(sm, b0, ip0, icmp0, sw_if_index0,
2402 rx_fib_index0, node, next0, ~0, 0, 0);
2412 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
2417 new_port0 = sm0.
port;
2432 old_port0 = tcp0->dst_port;
2433 tcp0->dst_port = new_port0;
2435 sum0 = tcp0->checksum;
2456 sum0 = tcp0->checksum;
2480 to_next, n_left_to_next,
2488 SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
2495 .name =
"nat44-out2in-fast",
2496 .vector_size =
sizeof (
u32),
vlib_node_registration_t snat_out2in_fast_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
VLIB_NODE_FUNCTION_MULTIARCH(snat_out2in_node, snat_out2in_node_fn)
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
u32 sessions_per_user_list_head_index
clib_bihash_16_8_t out2in_ed
sll srl srl sll sra u16x4 i
u32 icmp_match_out2in_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...
static void clib_dlist_init(dlist_elt_t *pool, u32 index)
static u8 * format_snat_out2in_fast_trace(u8 *s, va_list *args)
static u32 icmp_out2in_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)
static int ip4_header_bytes(ip4_header_t *i)
static f64 vlib_time_now(vlib_main_t *vm)
static void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
struct _vlib_node_registration vlib_node_registration_t
u32 icmp_match_out2in_det(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...
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
static snat_session_t * snat_out2in_lb(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)
clib_bihash_16_8_t in2out_ed
u32 buffer_index[VLIB_FRAME_SIZE]
vlib_error_t * errors
Vector of errors for this node.
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)
Match NAT44 static mapping.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
struct _tcp_header tcp_header_t
static void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
static snat_session_t * snat_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)
clib_bihash_8_8_t user_hash
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)
vlib_node_registration_t snat_det_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
ip4_address_t ext_host_addr
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static void * ip4_next_header(ip4_header_t *i)
#define foreach_snat_out2in_error
static uword snat_out2in_worker_handoff_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
snat_det_session_t * sessions
static snat_det_map_t * snat_det_map_by_out(snat_main_t *sm, ip4_address_t *out_addr)
static void clib_dlist_addtail(dlist_elt_t *pool, u32 head_index, u32 new_index)
snat_static_mapping_t * static_mappings
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
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 vlib_frame_queue_elt_t * vlib_get_worker_handoff_queue_elt(u32 frame_queue_index, u32 vlib_worker_index, vlib_frame_queue_elt_t **handoff_queue_elt_by_worker_index)
clib_bihash_8_8_t static_mapping_by_external
#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.
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
static_always_inline void vnet_feature_next(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
#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).
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)
static 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)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
static snat_session_t * create_session_for_static_mapping(snat_main_t *sm, vlib_buffer_t *b0, snat_session_key_t in2out, snat_session_key_t out2in, vlib_node_runtime_t *node, u32 thread_index)
Create session for static mapping.
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
deterministic NAT definitions
#define clib_warning(format, args...)
#define VLIB_BUFFER_IS_TRACED
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.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
snat_get_worker_function_t * worker_out2in_cb
static u32 ip_proto_to_snat_proto(u8 ip_proto)
snat_icmp_match_function_t * icmp_match_out2in_cb
static uword snat_det_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_NODE_FLAG_TRACE
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
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.
vlib_node_registration_t snat_out2in_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static char * snat_out2in_error_strings[]
static_always_inline u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
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_always_inline snat_out2in_error_t icmp_get_key(ip4_header_t *ip0, snat_session_key_t *p_key0)
static u8 * format_snat_out2in_trace(u8 *s, va_list *args)
static void vlib_put_frame_queue_elt(vlib_frame_queue_elt_t *hf)
static uword snat_out2in_fast_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static snat_det_session_t * snat_det_get_ses_by_out(snat_det_map_t *dm, ip4_address_t *in_addr, u64 out_key)
#define SNAT_SESSION_FLAG_STATIC_MAPPING
#define VLIB_REGISTER_NODE(x,...)
static vlib_thread_main_t * vlib_get_thread_main()
static uword snat_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u16 flags
Copy of main node flags.
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#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 u8 maximum_sessions_exceeded(snat_main_t *sm, u32 thread_index)
snat_session_t * sessions
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define SNAT_SESSION_FLAG_LOAD_BALANCING
static u16 ip_csum_fold(ip_csum_t c)
u32 icmp_match_out2in_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 u8 * format_snat_out2in_worker_handoff_trace(u8 *s, va_list *args)
static_always_inline u8 icmp_is_error_message(icmp46_header_t *icmp)