|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
38 #define ED_PORT_ALLOC_ATTEMPTS (10)
41 #define _(sym,string) string,
70 "NAT44_IN2OUT_ED_FAST_PATH";
76 s =
format (s,
", session %d, translation result '%U' via %s",
87 s =
format (s,
"\n lookup skipped - cached session index used");
170 u16 port_per_thread,
u32 snat_thread_index, snat_session_t *s,
173 const u16 port_thread_offset = (port_per_thread * snat_thread_index) + 1024;
175 s->o2i.match.daddr =
a->addr;
177 u16 port = clib_net_to_host_u16 (*outside_port);
178 u16 port_offset =
port - port_thread_offset;
179 if (
port <= port_thread_offset ||
180 port > port_thread_offset + port_per_thread)
185 port = port_thread_offset + port_offset;
190 if (NAT_PROTOCOL_ICMP == nat_proto)
192 s->o2i.match.sport = clib_host_to_net_u16 (
port);
194 s->o2i.match.dport = clib_host_to_net_u16 (
port);
197 #define _(N, i, n, s) \
198 case NAT_PROTOCOL_##N: \
199 ++a->busy_##n##_port_refcounts[port]; \
200 a->busy_##n##_ports_per_thread[thread_index]++; \
201 a->busy_##n##_ports++; \
211 *outside_addr =
a->addr;
212 *outside_port = clib_host_to_net_u16 (
port);
216 port = port_thread_offset + port_offset;
219 while (attempts > 0);
226 u16 port_per_thread,
u32 snat_thread_index,
240 if (
a->fib_index == rx_fib_index)
244 snat_thread_index, s, outside_addr, outside_port);
246 else if (
a->fib_index == ~0)
252 for (
i = 0;
i < s_addr_offset; ++
i)
255 if (
a->fib_index == rx_fib_index)
259 snat_thread_index, s, outside_addr, outside_port);
261 else if (
a->fib_index == ~0)
270 sm, nat_proto,
thread_index,
a, port_per_thread, snat_thread_index,
271 s, outside_addr, outside_port);
287 .fp_addr = {.ip4.as_u32 =
addr.as_u32,}
312 init_nat_k (&kv, match_addr, match_port, match_fib_index, match_protocol);
343 u32 outside_fib_index;
344 u8 is_identity_nat = 0;
347 snat_session_t *s = NULL;
357 b->
error =
node->errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
386 nat_proto, &sm_addr, &sm_port, &sm_fib_index,
387 0, 0, 0, &lb, 0, &is_identity_nat, 0))
406 b->
error =
node->errors[NAT_IN2OUT_ED_ERROR_NON_SYN];
416 s->in2out.addr = l_addr;
417 s->in2out.port = l_port;
418 s->nat_proto = nat_proto;
419 s->in2out.fib_index = rx_fib_index;
420 s->out2in.fib_index = outside_fib_index;
423 outside_port = l_port;
427 sm, r_addr, r_port, nat_proto, outside_fib_index, &daddr, &
dport);
433 s->out2in.fib_index,
proto);
435 if (NAT_PROTOCOL_ICMP == nat_proto)
451 b->
error =
node->errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS];
455 s->out2in.addr = outside_addr;
456 s->out2in.port = outside_port;
461 s->out2in.addr = outside_addr = sm_addr;
462 s->out2in.port = outside_port = sm_port;
463 s->in2out.addr = l_addr;
464 s->in2out.port = l_port;
465 s->nat_proto = nat_proto;
466 s->in2out.fib_index = rx_fib_index;
467 s->out2in.fib_index = outside_fib_index;
472 sm, r_addr, r_port, nat_proto, outside_fib_index, &daddr, &
dport);
475 if (NAT_PROTOCOL_ICMP == nat_proto)
478 sm_port, s->out2in.fib_index,
proto);
484 sm_port, s->out2in.fib_index,
proto);
498 s->ext_host_addr = r_addr;
499 s->ext_host_port = r_port;
502 rx_fib_index,
proto);
506 if (NAT_PROTOCOL_ICMP == nat_proto)
525 s->in2out.addr.as_u32,
526 s->out2in.addr.as_u32,
529 s->out2in.port, s->in2out.fib_index);
532 s->in2out.port, &s->ext_host_nat_addr,
533 s->ext_host_nat_port, &s->out2in.addr, s->out2in.port,
534 &s->ext_host_addr, s->ext_host_port, s->nat_proto, 0);
546 &outside_addr, outside_port,
551 *sessionp = s = NULL;
572 u16 placeholder_port;
573 u32 placeholder_fib_index;
577 &placeholder_fib_index, 1, 0, 0, 0, 0, 0, 0))
595 snat_session_t *s = 0;
601 if (
ip->protocol == IP_PROTOCOL_ICMP)
604 u16 lookup_sport, lookup_dport;
607 &lookup_sport, &lookup_daddr,
608 &lookup_dport, &lookup_protocol))
610 init_ed_k (&kv, lookup_saddr, lookup_sport, lookup_daddr, lookup_dport,
613 else if (
ip->protocol == IP_PROTOCOL_UDP ||
ip->protocol == IP_PROTOCOL_TCP)
634 if (
ip->protocol == IP_PROTOCOL_TCP)
658 f64 now,
int is_multi_worker)
669 tx_fib_index,
ip->protocol);
677 && (!s->tcp_closed_timestamp ||
now >= s->tcp_closed_timestamp))
686 if (is_multi_worker &&
691 lookup.fib_index = rx_fib_index;
693 lookup.daddr.as_u32 =
ip->src_address.as_u32;
695 lookup.saddr.as_u32 =
ip->dst_address.as_u32;
701 goto skip_dst_nat_lookup;
707 rx_fib_index,
ip->protocol);
723 (rx_sw_if_index ==
i->sw_if_index))
737 snat_session_t **s_p,
int is_multi_worker)
742 snat_session_t *s = NULL;
743 u8 lookup_protocol =
ip->protocol;
744 u16 lookup_sport, lookup_dport;
748 &lookup_sport, &lookup_daddr,
749 &lookup_dport, &lookup_protocol);
768 ip, NAT_PROTOCOL_ICMP,
778 b->
error =
node->errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
783 lookup_sport, lookup_dport,
ip->protocol, rx_fib_index,
815 static snat_session_t *
826 snat_session_t *s = NULL;
835 b->
error =
node->errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
867 if (s->ext_host_addr.as_u32 ==
ip->dst_address.as_u32)
869 init_ed_k (&s_kv, s->out2in.addr, 0,
ip->dst_address, 0,
870 outside_fib_index,
ip->protocol);
871 if (clib_bihash_search_16_8 (&sm->
flow_hash, &s_kv, &s_value))
873 new_src_addr = s->out2in.addr;
884 outside_fib_index,
ip->protocol);
885 if (clib_bihash_search_16_8 (&sm->
flow_hash, &s_kv, &s_value))
902 b->
error =
node->errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
908 ip->dst_address, 0, rx_fib_index,
ip->protocol);
915 outside_fib_index, &new_dst_addr, NULL);
922 outside_fib_index,
ip->protocol);
927 s->ext_host_addr.as_u32 =
ip->dst_address.as_u32;
929 s->out2in.addr.as_u32 = new_src_addr.
as_u32;
930 s->out2in.fib_index = outside_fib_index;
931 s->in2out.addr.as_u32 =
ip->src_address.as_u32;
932 s->in2out.fib_index = rx_fib_index;
933 s->in2out.port = s->out2in.port =
ip->protocol;
966 int is_output_feature,
987 u32 rx_sw_if_index0, rx_fib_index0, iph_offset0 = 0;
989 u32 cntr_sw_if_index0;
992 snat_session_t *s0 = 0;
997 int lookup_skipped = 0;
1014 if (is_output_feature)
1016 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1027 is_output_feature ? tx_sw_if_index0 : rx_sw_if_index0;
1030 lookup.fib_index = rx_fib_index0;
1036 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1044 if (is_output_feature)
1055 ICMP4_echo_request &&
1061 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_BAD_ICMP_TYPE];
1086 if (is_multi_worker &&
1110 if (clib_bihash_search_16_8 (&sm->
flow_hash, &kv0, &value0))
1135 if (s0->tcp_closed_timestamp)
1137 if (
now >= s0->tcp_closed_timestamp)
1145 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_TCP_CLOSED];
1152 u64 sess_timeout_time;
1155 if (
now >= sess_timeout_time)
1164 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1181 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED];
1187 vm, sm, b0, ip0,
f, proto0, is_output_feature)))
1192 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED];
1198 case NAT_PROTOCOL_TCP:
1203 case NAT_PROTOCOL_UDP:
1207 case NAT_PROTOCOL_ICMP:
1211 case NAT_PROTOCOL_OTHER:
1227 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1263 return frame->n_vectors;
1270 int is_output_feature,
1271 int is_multi_worker)
1289 u32 rx_sw_if_index0, rx_fib_index0, iph_offset0 = 0;
1290 u32 tx_sw_if_index0;
1291 u32 cntr_sw_if_index0;
1295 icmp46_header_t *icmp0;
1296 snat_session_t *s0 = 0;
1302 if (is_output_feature)
1303 iph_offset0 =
vnet_buffer (b0)->ip.reass.save_rewrite_length;
1313 is_output_feature ? tx_sw_if_index0 : rx_sw_if_index0;
1321 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1328 icmp0 = (icmp46_header_t *) udp0;
1341 vm, sm, b0, ip0, &s0->i2o, proto0, is_output_feature)))
1346 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED];
1358 sm, b0, ip0, icmp0, rx_sw_if_index0, rx_fib_index0,
node,
next[0],
1363 vm, sm, b0, ip0, &s0->i2o, proto0, is_output_feature)))
1368 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED];
1381 if (!clib_bihash_search_16_8 (&sm->
flow_hash, &kv0, &value0))
1388 if (s0->tcp_closed_timestamp &&
now >= s0->tcp_closed_timestamp)
1398 if (is_output_feature)
1403 rx_sw_if_index0, tx_sw_if_index0,
now, is_multi_worker)))
1411 (proto0 == NAT_PROTOCOL_UDP
1413 clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_server))
1421 ip0, proto0, rx_fib_index0)))
1439 b0->
flags |= VNET_BUFFER_F_IS_NATED;
1443 vm, sm, b0, ip0, &s0->i2o, proto0, is_output_feature)))
1448 b0->
error =
node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED];
1473 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1511 return frame->n_vectors;
1529 .name =
"nat44-ed-in2out",
1530 .vector_size =
sizeof (
u32),
1531 .sibling_of =
"nat-default",
1554 .name =
"nat44-ed-in2out-output",
1555 .vector_size =
sizeof (
u32),
1556 .sibling_of =
"nat-default",
1579 .name =
"nat44-ed-in2out-slowpath",
1580 .vector_size =
sizeof (
u32),
1581 .sibling_of =
"nat-default",
1605 .name =
"nat44-ed-in2out-output-slowpath",
1606 .vector_size =
sizeof (
u32),
1607 .sibling_of =
"nat-default",
1640 .name =
"nat-pre-in2out",
1641 .vector_size =
sizeof (
u32),
1642 .sibling_of =
"nat-default",
1649 .name =
"nat-pre-in2out-output",
1650 .vector_size =
sizeof (
u32),
1651 .sibling_of =
"nat-default",
static bool nat44_ed_is_interface_outside(snat_interface_t *i)
Check if NAT interface is outside.
static u32 ed_value_get_thread_index(clib_bihash_kv_16_8_t *value)
static uword nat44_ed_in2out_fast_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature, int is_multi_worker)
struct snat_main_s::@746::@747 fastpath
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)
static void nat_6t_flow_saddr_rewrite_set(nat_6t_flow_t *f, u32 saddr)
static uword nat44_ed_in2out_slow_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature, int is_multi_worker)
static_always_inline int nat44_ed_external_sm_lookup(snat_main_t *sm, ip4_address_t match_addr, u16 match_port, nat_protocol_t match_protocol, u32 match_fib_index, ip4_address_t *daddr, u16 *dport)
#define nat_elog_notice(_pm, nat_elog_str)
static u32 ed_value_get_session_index(clib_bihash_kv_16_8_t *value)
snat_static_mapping_t * static_mappings
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
#define SNAT_SESSION_FLAG_HAIRPINNING
vl_api_ip_port_and_mask_t dst_port
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define nat_elog_warn(_pm, nat_elog_str)
static int nat_ed_alloc_addr_and_port_with_snat_address(snat_main_t *sm, u32 nat_proto, u32 thread_index, snat_address_t *a, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port)
#define clib_memcpy(d, s, n)
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
struct snat_main_s::@746 counters
#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, u8 is_ha)
Free NAT44 session data (lookup keys, external address port)
static_always_inline int nat_get_icmp_session_lookup_values(vlib_buffer_t *b, ip4_header_t *ip0, ip4_address_t *lookup_saddr, u16 *lookup_sport, ip4_address_t *lookup_daddr, u16 *lookup_dport, u8 *lookup_protocol)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
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.
static hash_pair_t * lookup(void *v, uword key, enum lookup_opcode op, void *new_value, void *old_value)
static_always_inline void nat_6t_o2i_flow_init(snat_main_t *sm, u32 thread_idx, snat_session_t *s, ip4_address_t saddr, u16 sport, ip4_address_t daddr, u16 dport, u32 fib_index, u8 proto)
struct snat_main_s::@746::@748 slowpath
vlib_get_buffers(vm, from, b, n_left_from)
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
@ VLIB_NODE_TYPE_INTERNAL
snat_interface_t * interfaces
vlib_node_registration_t nat44_ed_in2out_output_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node)
#define FIB_NODE_INDEX_INVALID
nat_translation_error_e translation_error
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define SNAT_SESSION_FLAG_STATIC_MAPPING
static_always_inline int nat44_ed_not_translate(vlib_main_t *vm, snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index, vlib_buffer_t *b, ip4_header_t *ip, u32 proto, u32 rx_fib_index)
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)
static void nat44_set_tcp_session_state_i2o(snat_main_t *sm, f64 now, snat_session_t *ses, vlib_buffer_t *b, u32 thread_index)
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.
@ NAT_NEXT_IN2OUT_ED_SLOW_PATH
static_always_inline u8 nat44_ed_maximum_sessions_exceeded(snat_main_t *sm, u32 fib_index, u32 thread_index)
static void nat_6t_flow_daddr_rewrite_set(nat_6t_flow_t *f, u32 daddr)
int snat_static_mapping_match(vlib_main_t *vm, 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.
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
snat_address_t * addresses
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
clib_bihash_8_8_t static_mapping_by_external
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
void nat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
static_always_inline void nat_6t_i2o_flow_init(snat_main_t *sm, u32 thread_idx, snat_session_t *s, ip4_address_t saddr, u16 sport, ip4_address_t daddr, u16 dport, u32 fib_index, u8 proto)
static_always_inline void per_vrf_sessions_register_session(snat_session_t *s, u32 thread_index)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
clib_bihash_kv_16_8_t search_key
static bool nat44_is_ses_closed(snat_session_t *s)
Check if NAT44 endpoint-dependent TCP session is closed.
#define pool_foreach(VAR, POOL)
Iterate through pool.
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
@ NAT_NEXT_IN2OUT_ED_OUTPUT_SLOW_PATH
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, nat_protocol_t proto, u8 is_twicenat)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
snat_main_per_thread_data_t * per_thread_data
vlib_node_registration_t nat_pre_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_output_node)
#define VLIB_NODE_FN(node)
static int nat_ed_alloc_addr_and_port(snat_main_t *sm, u32 rx_fib_index, u32 nat_proto, u32 thread_index, ip4_address_t s_addr, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port)
static u8 * format_nat_in2out_ed_trace(u8 *s, va_list *args)
clib_bihash_16_8_t flow_hash
void nat_ipfix_logging_max_sessions(u32 thread_index, u32 limit)
Generate maximum session entries exceeded event.
static int ip4_is_fragment(const ip4_header_t *i)
@ NAT_NEXT_IN2OUT_ED_FAST_PATH
#define VLIB_NODE_FLAG_TRACE
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
nat_outside_fib_t * outside_fibs
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static_always_inline u16 snat_random_port(u16 min, u16 max)
static bool is_sm_addr_only(u32 f)
static_always_inline int nat44_ed_not_translate_output_feature(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u16 src_port, u16 dst_port, u32 thread_index, u32 rx_sw_if_index, u32 tx_sw_if_index, f64 now, int is_multi_worker)
#define static_always_inline
u32 fib_node_index_t
A typedef of a node index.
vl_api_interface_index_t tx_sw_if_index
static void init_ed_k(clib_bihash_kv_16_8_t *kv, ip4_address_t l_addr, u16 l_port, ip4_address_t r_addr, u16 r_port, u32 fib_index, u8 proto)
vl_api_ip_port_and_mask_t src_port
static uword nat_pre_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 def_next)
static void nat_6t_flow_icmp_id_rewrite_set(nat_6t_flow_t *f, u16 id)
vlib_node_registration_t nat44_ed_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
snat_session_t * sessions
@ NAT_ED_TRNSL_ERR_FLOW_MISMATCH
struct _vlib_node_registration vlib_node_registration_t
static void nat_ed_session_delete(snat_main_t *sm, snat_session_t *ses, u32 thread_index, int lru_delete)
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 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)
#define foreach_nat_in2out_ed_error
static u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
format_function_t format_nat_ed_translation_error
static_always_inline int nat_6t_t_eq(nat_6t_t *t1, nat_6t_t *t2)
#define SNAT_SESSION_FLAG_LOAD_BALANCING
@ NAT_NEXT_IN2OUT_ED_OUTPUT_FAST_PATH
static_always_inline snat_session_t * nat_ed_session_alloc(snat_main_t *sm, u32 thread_index, f64 now, u8 proto)
void nat_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 fib_index)
Generate NAT44 session create event.
static_always_inline int nat_lru_free_one(snat_main_t *sm, int thread_index, f64 now)
#define nat_elog_info(_pm, nat_elog_str)
static void nat_6t_flow_sport_rewrite_set(nat_6t_flow_t *f, u32 sport)
description fragment has unexpected format
static bool nat44_ed_is_interface_inside(snat_interface_t *i)
Check if NAT interface is inside.
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 u8 * format_nat_pre_trace(u8 *s, va_list *args)
static_always_inline void clib_prefetch_load(void *p)
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes, u32 thread_index)
nat_translation_error_e nat_6t_flow_buf_translate_i2o(vlib_main_t *vm, snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, nat_6t_flow_t *f, nat_protocol_t proto, int is_output_feature)
#define vec_foreach(var, vec)
Vector iterator.
clib_bihash_8_8_t static_mapping_by_local
8 octet key, 8 octet key value pair
format_function_t format_ed_session_kvp
u32 max_translations_per_thread
fib_protocol_t fp_proto
protocol type
@ NAT_NEXT_OUT2IN_ED_SLOW_PATH
format_function_t format_nat_6t_flow
static_always_inline int nat_ed_ses_i2o_flow_hash_add_del(snat_main_t *sm, u32 thread_idx, snat_session_t *s, int is_add)
static_always_inline u8 per_vrf_sessions_is_expired(snat_session_t *s, u32 thread_index)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static char * nat_in2out_ed_error_strings[]
static vlib_main_t * vlib_get_main(void)
static u32 icmp_in2out_ed_slow_path(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, icmp46_header_t *icmp, u32 sw_if_index, u32 rx_fib_index, vlib_node_runtime_t *node, u32 next, f64 now, u32 thread_index, snat_session_t **s_p, int is_multi_worker)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vlib_main_t vlib_node_runtime_t * node
ip4_address_t external_addr
u16 nexts[VLIB_FRAME_SIZE]
static int ip4_header_bytes(const ip4_header_t *i)
static f64 vlib_time_now(vlib_main_t *vm)
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
vl_api_interface_index_t sw_if_index
static u16 ip_csum_fold(ip_csum_t c)
@ NAT_ED_TRNSL_ERR_SUCCESS
static void nat_6t_flow_dport_rewrite_set(nat_6t_flow_t *f, u32 dport)
static snat_session_t * nat44_ed_in2out_slowpath_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 void init_nat_k(clib_bihash_kv_8_8_t *kv, ip4_address_t addr, u16 port, u32 fib_index, nat_protocol_t proto)
static int snat_not_translate_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, ip4_header_t *ip0, u32 rx_fib_index0)
Check if packet should be translated.
static u32 slow_path_ed(vlib_main_t *vm, snat_main_t *sm, vlib_buffer_t *b, ip4_address_t l_addr, ip4_address_t r_addr, u16 l_port, u16 r_port, u8 proto, u32 rx_fib_index, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next, u32 thread_index, f64 now)
Aggregate type for a prefix.
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
vl_api_fib_path_type_t type
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
#define ED_PORT_ALLOC_ATTEMPTS
static_always_inline int nat_ed_ses_o2i_flow_hash_add_del(snat_main_t *sm, u32 thread_idx, snat_session_t *s, int is_add)
static void * ip4_next_header(ip4_header_t *i)
static bool na44_ed_is_fwd_bypass_session(snat_session_t *s)
Check if NAT session is forwarding bypass.
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
static void nat_6t_flow_txfib_rewrite_set(nat_6t_flow_t *f, u32 tx_fib_index)
VLIB buffer representation.
snat_interface_t * output_feature_interfaces
#define VLIB_REGISTER_NODE(x,...)
static_always_inline u32 nat_outside_fib_index_lookup(snat_main_t *sm, ip4_address_t addr)