58 tag = t->
is_slow_path ?
"NAT44_IN2OUT_SLOW_PATH" :
"NAT44_IN2OUT_FAST_PATH";
60 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
64 s =
format (s,
", with-hairpinning");
77 s =
format (s,
"NAT44_IN2OUT_FAST: sw_if_index %d, next index %d",
83 #define foreach_snat_in2out_error \ 84 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \ 85 _(OUT_OF_PORTS, "out of ports") \ 86 _(BAD_OUTSIDE_FIB, "outside VRF ID not found") \ 87 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 88 _(NO_TRANSLATION, "no translation") \ 89 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \ 90 _(CANNOT_CREATE_USER, "cannot create NAT user") 94 #define _(sym,str) SNAT_IN2OUT_ERROR_##sym, 101 #define _(sym,string) string, 118 u32 rx_fib_index0,
u32 thread_index)
133 u16 placeholder_port;
134 u32 placeholder_fib_index;
137 proto0, &placeholder_addr, &placeholder_port,
138 &placeholder_fib_index, 1, 0, 0, 0, 0, 0, 0))
163 if (!clib_bihash_search_8_8
170 if (!clib_bihash_search_8_8
177 if ((nat_interface_is_inside(i)) && (sw_if_index == i->sw_if_index))
187 #ifndef CLIB_MARCH_VARIANT 194 u64 sess_timeout_time;
201 if (ctx->
now >= sess_timeout_time)
204 if (clib_bihash_add_del_8_8 (&tsm->
out2in, &s_kv, 0))
208 s->in2out.addr.as_u32,
209 s->out2in.addr.as_u32,
213 s->in2out.fib_index);
216 &s->in2out.addr, s->in2out.port,
217 &s->out2in.addr, s->out2in.port, s->nat_proto);
219 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
220 s->ext_host_port, s->nat_proto, s->out2in.fib_index,
226 s->out2in.port, s->nat_proto);
243 snat_session_t ** sessionp,
247 snat_session_t *s = 0;
267 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_MAX_SESSIONS_EXCEEDED];
276 (sm, i2o_addr, i2o_port, rx_fib_index0, nat_proto, &sm_addr,
277 &sm_port, &sm_fib_index, 0, 0, 0, 0, 0, &identity_nat, 0))
288 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_OUT_OF_PORTS];
307 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_CANNOT_CREATE_USER];
322 s->in2out.addr = i2o_addr;
323 s->in2out.port = i2o_port;
324 s->in2out.fib_index = rx_fib_index0;
325 s->nat_proto = nat_proto;
326 s->out2in.addr = sm_addr;
327 s->out2in.port = sm_port;
346 s->out2in.fib_index = outside_fib->
fib_index;
355 s->ext_host_port =
vnet_buffer (b0)->ip.reass.l4_dst_port;
362 if (clib_bihash_add_or_overwrite_stale_8_8
368 if (clib_bihash_add_or_overwrite_stale_8_8
375 s->in2out.addr.as_u32,
376 s->out2in.addr.as_u32,
379 s->out2in.port, s->in2out.fib_index);
382 &s->in2out.addr, s->in2out.port, &s->out2in.addr,
383 s->out2in.port, s->nat_proto);
385 nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
386 s->out2in.port, &s->ext_host_addr, s->ext_host_port,
387 &s->ext_host_nat_addr, s->ext_host_nat_port,
388 s->nat_proto, s->in2out.fib_index, s->flags, thread_index, 0);
393 #ifndef CLIB_MARCH_VARIANT 398 icmp46_header_t *icmp0;
402 icmp46_header_t *inner_icmp0;
408 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags))
410 *nat_proto = NAT_PROTOCOL_ICMP;
422 case NAT_PROTOCOL_ICMP:
423 inner_icmp0 = (icmp46_header_t *) l4_header;
427 case NAT_PROTOCOL_UDP:
428 case NAT_PROTOCOL_TCP:
432 return SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL;
458 void *e,
u8 * dont_translate)
462 snat_session_t *s0 = 0;
480 init_nat_k (&kv0, *addr, *port, *fib_index, *proto);
481 if (clib_bihash_search_8_8 (&tsm->
in2out, &kv0, &value0))
487 (sm, ip0, *proto, *port, *port, thread_index, sw_if_index0)))
496 ip0, NAT_PROTOCOL_ICMP,
497 *fib_index, thread_index)))
508 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE];
514 slow_path (sm, b0, ip0, *addr, *port, *fib_index, *proto, &s0, node,
534 reass.icmp_type_or_tcp_flags)))
536 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE];
547 *addr = s0->out2in.addr;
548 *port = s0->out2in.port;
549 *fib_index = s0->out2in.fib_index;
552 *(snat_session_t **) (d) = s0;
557 #ifndef CLIB_MARCH_VARIANT 577 void *e,
u8 * dont_translate)
601 (sm, *addr, *port, *fib_index, *proto, &sm_addr, &sm_port,
602 &sm_fib_index, 0, &is_addr_only, 0, 0, 0, 0, 0))
619 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_NO_TRANSLATION];
625 (
vnet_buffer (b0)->
ip.reass.icmp_type_or_tcp_flags != ICMP4_echo_request
627 ICMP4_echo_reply || !is_addr_only)
629 reass.icmp_type_or_tcp_flags)))
631 b0->
error = node->
errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE];
641 #ifndef CLIB_MARCH_VARIANT 646 icmp46_header_t * icmp0,
650 u32 next0,
u32 thread_index,
void *d,
void *e)
660 icmp46_header_t *inner_icmp0;
662 u32 new_addr0, old_addr0;
663 u16 old_id0, new_id0;
664 u16 old_checksum0, new_checksum0;
673 &fib_index, &protocol, d, e, &dont_translate);
705 if (icmp0->checksum == 0)
706 icmp0->checksum = 0xffff;
717 sum0 = icmp0->checksum;
739 sum0 = icmp0->checksum;
745 old_checksum0 = inner_ip0->
checksum;
750 new_checksum0 = inner_ip0->
checksum;
751 sum0 = icmp0->checksum;
759 case NAT_PROTOCOL_ICMP:
760 inner_icmp0 = (icmp46_header_t *) l4_header;
767 sum0 = icmp0->checksum;
773 case NAT_PROTOCOL_UDP:
774 case NAT_PROTOCOL_TCP:
779 sum0 = icmp0->checksum;
806 icmp46_header_t * icmp0,
811 f64 now,
u32 thread_index, snat_session_t ** p_s0)
815 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
816 next0, thread_index, p_s0, 0);
817 snat_session_t *s0 = *p_s0;
823 (vm, b0), thread_index);
837 u32 old_addr, new_addr;
867 int is_output_feature)
869 u32 n_left_from, *from;
881 while (n_left_from >= 2)
885 u32 sw_if_index0, sw_if_index1;
888 u32 new_addr0, old_addr0, new_addr1, old_addr1;
889 u16 old_port0, new_port0, old_port1, new_port1;
892 icmp46_header_t *icmp0, *icmp1;
893 u32 rx_fib_index0, rx_fib_index1;
895 snat_session_t *s0 = 0, *s1 = 0;
897 u32 iph_offset0 = 0, iph_offset1 = 0;
919 if (is_output_feature)
920 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
927 icmp0 = (icmp46_header_t *) udp0;
939 ICMP4_time_exceeded_ttl_exceeded_in_transit,
956 node->
errors[SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
961 in2out.other, thread_index,
969 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0,
970 node, next0, now, thread_index, &s0);
974 in2out.icmp, thread_index,
998 (clib_bihash_search_8_8
1003 if (is_output_feature)
1010 thread_index, sw_if_index0)))
1018 (proto0 == NAT_PROTOCOL_UDP
1020 clib_host_to_net_u16
1021 (UDP_DST_PORT_dhcp_to_server))
1029 (sm, node, sw_if_index0, ip0, proto0,
1030 rx_fib_index0, thread_index)))
1038 proto0, &s0, node, next0, thread_index, now);
1056 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1061 if (!is_output_feature)
1074 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1075 new_port0 = udp0->
src_port = s0->out2in.port;
1076 sum0 = tcp0->checksum;
1087 counters.
slowpath.in2out.tcp : &sm->
1089 thread_index, sw_if_index0, 1);
1098 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1111 counters.
slowpath.in2out.udp : &sm->
1113 thread_index, sw_if_index0, 1);
1125 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1142 in2out.drops, thread_index,
1146 if (is_output_feature)
1147 iph_offset1 =
vnet_buffer (b1)->ip.reass.save_rewrite_length;
1154 icmp1 = (icmp46_header_t *) udp1;
1164 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1181 node->
errors[SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
1186 in2out.other, thread_index,
1194 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
1195 next1, now, thread_index, &s1);
1199 in2out.icmp, thread_index,
1223 (clib_bihash_search_8_8
1228 if (is_output_feature)
1235 thread_index, sw_if_index1)))
1243 (proto1 == NAT_PROTOCOL_UDP
1245 clib_host_to_net_u16
1246 (UDP_DST_PORT_dhcp_to_server))
1254 (sm, node, sw_if_index1, ip1, proto1,
1255 rx_fib_index1, thread_index)))
1262 rx_fib_index1, proto1, &s1, node, next1,
1281 b1->
flags |= VNET_BUFFER_F_IS_NATED;
1286 if (!is_output_feature)
1298 old_port1 =
vnet_buffer (b1)->ip.reass.l4_src_port;
1299 new_port1 = udp1->
src_port = s1->out2in.port;
1300 sum1 = tcp1->checksum;
1311 counters.
slowpath.in2out.tcp : &sm->
1313 thread_index, sw_if_index1, 1);
1322 old_port1 =
vnet_buffer (b1)->ip.reass.l4_src_port;
1335 counters.
slowpath.in2out.udp : &sm->
1337 thread_index, sw_if_index1, 1);
1349 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
1365 in2out.drops, thread_index,
1375 while (n_left_from > 0)
1382 u32 new_addr0, old_addr0;
1383 u16 old_port0, new_port0;
1386 icmp46_header_t *icmp0;
1389 snat_session_t *s0 = 0;
1391 u32 iph_offset0 = 0;
1397 if (is_output_feature)
1398 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1405 icmp0 = (icmp46_header_t *) udp0;
1415 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1432 node->
errors[SNAT_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
1437 in2out.other, thread_index,
1445 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1446 next0, now, thread_index, &s0);
1450 in2out.icmp, thread_index,
1474 if (clib_bihash_search_8_8
1479 if (is_output_feature)
1486 thread_index, sw_if_index0)))
1494 (proto0 == NAT_PROTOCOL_UDP
1496 clib_host_to_net_u16
1497 (UDP_DST_PORT_dhcp_to_server))
1505 (sm, node, sw_if_index0, ip0, proto0, rx_fib_index0,
1513 rx_fib_index0, proto0, &s0, node, next0,
1533 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1538 if (!is_output_feature)
1550 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1551 new_port0 = udp0->
src_port = s0->out2in.port;
1552 sum0 = tcp0->checksum;
1564 counters.
slowpath.in2out.tcp : &sm->
1566 thread_index, sw_if_index0, 1);
1575 old_port0 =
vnet_buffer (b0)->ip.reass.l4_src_port;
1589 counters.
slowpath.in2out.udp : &sm->
1591 thread_index, sw_if_index0, 1);
1603 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1620 in2out.drops, thread_index,
1644 .name =
"nat44-in2out",
1645 .vector_size =
sizeof (
u32),
1676 .name =
"nat44-in2out-output",
1677 .vector_size =
sizeof (
u32),
1708 .name =
"nat44-in2out-slowpath",
1709 .vector_size =
sizeof (
u32),
1740 .name =
"nat44-in2out-output-slowpath",
1741 .vector_size =
sizeof (
u32),
1766 u32 n_left_from, *from, *to_next;
1772 n_left_from =
frame->n_vectors;
1773 next_index =
node->cached_next_index;
1775 while (n_left_from > 0)
1781 while (n_left_from > 0 && n_left_to_next > 0)
1789 u32 new_addr0, old_addr0;
1790 u16 old_port0, new_port0;
1793 icmp46_header_t *icmp0;
1807 n_left_to_next -= 1;
1815 icmp0 = (icmp46_header_t *) udp0;
1825 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1838 next0 =
icmp_in2out (sm, b0, ip0, icmp0, sw_if_index0,
1839 rx_fib_index0,
node, next0, ~0, 0, 0);
1845 &sm0_addr, &sm0_port, &sm0_fib_index, 0, 0, 0, 0, 0, 0, 0))
1847 b0->
error =
node->errors[SNAT_IN2OUT_ERROR_NO_TRANSLATION];
1852 new_addr0 = sm0_addr.
as_u32;
1853 new_port0 = sm0_port;
1871 sum0 = tcp0->checksum;
1897 sum0 = tcp0->checksum;
1921 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1934 in2out.other, sw_if_index0,
1940 to_next, n_left_to_next,
1947 return frame->n_vectors;
1953 .name =
"nat44-in2out-fast",
1954 .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
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
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 void init_nat_i2o_kv(clib_bihash_kv_8_8_t *kv, snat_session_t *s, u64 value)
vl_api_ip_port_and_mask_t dst_port
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.
static u32 slow_path(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t i2o_addr, u16 i2o_port, u32 rx_fib_index0, nat_protocol_t nat_proto, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next0, u32 thread_index, f64 now)
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)
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.
void snat_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 vrf_id)
Generate NAT44 session create event.
struct _tcp_header tcp_header_t
int snat_hairpinning(vlib_main_t *vm, vlib_node_runtime_t *node, 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, int do_trace)
u32 max_translations_per_thread
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.
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
vlib_node_registration_t snat_in2out_fast_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)
void nat_syslog_nat44_apmdel(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, nat_protocol_t proto)
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
static_always_inline snat_in2out_error_t icmp_get_key(vlib_buffer_t *b, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, nat_protocol_t *nat_proto)
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)
int snat_static_mapping_match(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 void init_nat_o2i_kv(clib_bihash_kv_8_8_t *kv, snat_session_t *s, u64 value)
#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.
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
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 init_nat_o2i_k(clib_bihash_kv_8_8_t *kv, snat_session_t *s)
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 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.
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.
void nat_syslog_nat44_apmadd(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, nat_protocol_t proto)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
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.
struct snat_main_s::@91 counters
static void mss_clamping(u16 mss_clamping, tcp_header_t *tcp, ip_csum_t *sum)
vl_api_address_union_t src_address
struct snat_main_s::@91::@93 slowpath
#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 void init_nat_k(clib_bihash_kv_8_8_t *kv, ip4_address_t addr, u16 port, u32 fib_index, nat_protocol_t proto)
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
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...
vl_api_ip_port_and_mask_t src_port
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,...)
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation.
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
sll srl srl sll sra u16x4 i
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.
vlib_main_t vlib_node_runtime_t * node
static_always_inline u8 nat44_maximum_sessions_exceeded(snat_main_t *sm, u32 thread_index)
The NAT44 inline functions.
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
void snat_ipfix_logging_nat44_ses_delete(u32 thread_index, u32 src_ip, u32 nat_src_ip, nat_protocol_t nat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session delete event.
static vlib_main_t * vlib_get_main(void)
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.
#define vec_elt(v, i)
Get vector value at index i.
struct snat_main_s::@91::@92 fastpath
void nat_hairpinning_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
#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_main_t vlib_node_runtime_t vlib_frame_t * frame
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 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)
u16 flags
Copy of main node flags.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static int ip4_header_bytes(const ip4_header_t *i)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
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.
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
snat_session_t * sessions
static_always_inline int is_hairpinning(snat_main_t *sm, ip4_address_t *dst_addr)
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)
vl_api_interface_index_t sw_if_index