33 #define foreach_nat_out2in_ed_error \ 34 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 35 _(OUT2IN_PACKETS, "Good out2in packets processed") \ 36 _(OUT_OF_PORTS, "Out of ports") \ 37 _(BAD_ICMP_TYPE, "unsupported ICMP type") \ 38 _(NO_TRANSLATION, "No translation") \ 39 _(MAX_SESSIONS_EXCEEDED, "Maximum sessions exceeded") \ 40 _(DROP_FRAGMENT, "Drop fragment") \ 41 _(MAX_REASS, "Maximum reassemblies exceeded") \ 42 _(MAX_FRAG, "Maximum fragments per reassembly exceeded")\ 43 _(NON_SYN, "non-SYN packet try to create session") 47 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym, 54 #define _(sym,string) string, 92 "NAT44_OUT2IN_ED_FAST_PATH";
94 s =
format (s,
"%s: sw_if_index %d, next index %d, session %d", tag,
103 u32 sw_if_index0,
u32 rx_fib_index0,
105 u32 thread_index, snat_session_t ** p_s0)
107 next0 =
icmp_out2in (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
108 next0, thread_index, p_s0, 0);
109 snat_session_t *s0 = *p_s0;
128 u64 sess_timeout_time;
139 if (ctx->
now >= sess_timeout_time)
141 ed_key.
l_addr = s->in2out.addr;
142 ed_key.
r_addr = s->ext_host_addr;
146 ed_key.
proto = s->in2out.port;
153 ed_key.
l_port = s->in2out.port;
154 ed_key.
r_port = s->ext_host_port;
158 ed_key.
r_addr = s->ext_host_nat_addr;
159 ed_key.
r_port = s->ext_host_nat_port;
163 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &ed_kv, 0))
170 s->out2in.addr.as_u32,
174 s->in2out.fib_index);
181 key.
port = s->ext_host_nat_port;
183 if (a->
addr.
as_u32 == s->ext_host_nat_addr.as_u32)
206 static snat_session_t *
227 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
251 s->ext_host_port = e_key.
protocol == SNAT_PROTOCOL_ICMP ? 0 : udp->
src_port;
260 s->in2out.
protocol = s->out2in.protocol;
269 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
out2in_ed, &kv,
279 thread_index, &eh_key,
283 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_OUT_OF_PORTS];
285 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &kv, 0))
289 s->ext_host_nat_addr.as_u32 = eh_key.
addr.
as_u32;
290 s->ext_host_nat_port = eh_key.
port;
301 if (clib_bihash_add_or_overwrite_stale_16_8 (&tsm->
in2out_ed, &kv,
312 icmp46_header_t *icmp0;
317 icmp46_header_t *inner_icmp0;
324 key0.
proto = IP_PROTOCOL_ICMP;
339 case SNAT_PROTOCOL_ICMP:
340 inner_icmp0 = (icmp46_header_t *) l4_header;
345 case SNAT_PROTOCOL_UDP:
346 case SNAT_PROTOCOL_TCP:
366 rx_fib_index, src_port, dst_port);
367 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
381 snat_session_t *s = 0;
385 if (ip->
protocol == IP_PROTOCOL_ICMP)
390 else if (ip->
protocol == IP_PROTOCOL_UDP || ip->
protocol == IP_PROTOCOL_TCP)
410 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &kv, &value))
435 s->ext_host_addr = key.
r_addr;
436 s->ext_host_port = key.
r_port;
438 s->out2in.addr = key.
l_addr;
439 s->out2in.port = key.
l_port;
441 s->out2in.fib_index = 0;
442 s->in2out = s->out2in;
446 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &kv, 1))
450 if (ip->
protocol == IP_PROTOCOL_TCP)
467 u8 * p_dont_translate,
void *d,
void *e)
470 icmp46_header_t *icmp;
474 snat_session_t *s = 0;
475 u8 dont_translate = 0, is_addr_only, identity_nat;
484 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_UNSUPPORTED_PROTOCOL];
492 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
500 (sm, e_key, &l_key, 1, &is_addr_only, 0, 0, 0, &identity_nat))
511 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
519 thread_index, rx_fib_index))
530 (icmp->type != ICMP4_echo_request || !is_addr_only)))
532 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_BAD_ICMP_TYPE];
558 icmp->type != ICMP4_echo_request &&
561 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_BAD_ICMP_TYPE];
572 *p_value = s->in2out;
573 *p_dont_translate = dont_translate;
575 *(snat_session_t **) d = s;
579 static snat_session_t *
591 u32 old_addr, new_addr;
602 if (!clib_bihash_search_16_8 (&tsm->
out2in_ed, &s_kv, &s_value))
611 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
617 if (clib_bihash_search_8_8
620 b->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
649 s->out2in.addr.as_u32 = old_addr;
650 s->out2in.fib_index = rx_fib_index;
651 s->in2out.addr.as_u32 = new_addr;
653 s->in2out.port = s->out2in.port = ip->
protocol;
658 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &s_kv, 1))
664 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &s_kv, 1))
688 u32 n_left_from, *from, *to_next, pkts_processed = 0, stats_node_index;
702 while (n_left_from > 0)
708 while (n_left_from >= 4 && n_left_to_next >= 2)
712 u32 next0, sw_if_index0, rx_fib_index0, proto0, old_addr0,
714 u32 next1, sw_if_index1, rx_fib_index1, proto1, old_addr1,
716 u16 old_port0, new_port0, old_port1, new_port1;
720 icmp46_header_t *icmp0, *icmp1;
721 snat_session_t *s0 = 0, *s1 = 0;
727 u8 identity_nat0, identity_nat1;
744 to_next[0] = bi0 = from[0];
745 to_next[1] = bi1 = from[1];
767 ICMP4_time_exceeded_ttl_exceeded_in_transit,
775 icmp0 = (icmp46_header_t *) udp0;
784 thread_index, now, vm,
797 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
798 next0, now, thread_index, &s0);
827 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv0, &value0))
838 &twice_nat0, &lb_nat0,
849 (UDP_DST_PORT_dhcp_to_client))))
858 node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
865 thread_index, rx_fib_index0))
879 if ((proto0 == SNAT_PROTOCOL_TCP) && !
tcp_is_init (tcp0))
881 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NON_SYN];
925 old_port0 = tcp0->dst_port;
926 new_port0 = tcp0->dst_port = s0->in2out.port;
928 sum0 = tcp0->checksum;
936 s0->ext_host_nat_addr.as_u32,
941 tcp0->src_port = s0->ext_host_nat_port;
946 (sm, s0, tcp0, thread_index))
954 udp0->
src_port = s0->ext_host_nat_port;
969 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
996 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1004 icmp1 = (icmp46_header_t *) udp1;
1013 thread_index, now, vm,
1026 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
1027 next1, now, thread_index, &s1);
1056 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv1, &value1))
1067 &twice_nat1, &lb_nat1,
1077 clib_host_to_net_u16
1078 (UDP_DST_PORT_dhcp_to_client))))
1087 node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1094 thread_index, rx_fib_index1))
1108 if ((proto1 == SNAT_PROTOCOL_TCP) && !
tcp_is_init (tcp1))
1110 b1->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NON_SYN];
1154 old_port1 = tcp1->dst_port;
1155 new_port1 = tcp1->dst_port = s1->in2out.port;
1157 sum1 = tcp1->checksum;
1165 s1->ext_host_nat_addr.as_u32,
1170 tcp1->src_port = s1->ext_host_nat_port;
1175 (sm, s1, tcp1, thread_index))
1183 udp1->
src_port = s1->ext_host_nat_port;
1198 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
1214 to_next, n_left_to_next,
1215 bi0, bi1, next0, next1);
1218 while (n_left_from > 0 && n_left_to_next > 0)
1222 u32 next0, sw_if_index0, rx_fib_index0, proto0, old_addr0,
1224 u16 old_port0, new_port0;
1228 icmp46_header_t *icmp0;
1229 snat_session_t *s0 = 0;
1243 n_left_to_next -= 1;
1259 ICMP4_time_exceeded_ttl_exceeded_in_transit,
1267 icmp0 = (icmp46_header_t *) udp0;
1276 thread_index, now, vm,
1289 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1290 next0, now, thread_index, &s0);
1319 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv0, &value0))
1330 &twice_nat0, &lb_nat0,
1340 clib_host_to_net_u16
1341 (UDP_DST_PORT_dhcp_to_client))))
1350 node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1357 thread_index, rx_fib_index0))
1371 if ((proto0 == SNAT_PROTOCOL_TCP) && !
tcp_is_init (tcp0))
1373 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NON_SYN];
1417 old_port0 = tcp0->dst_port;
1418 new_port0 = tcp0->dst_port = s0->in2out.port;
1420 sum0 = tcp0->checksum;
1428 s0->ext_host_nat_addr.as_u32,
1433 tcp0->src_port = s0->ext_host_nat_port;
1438 (sm, s0, tcp0, thread_index))
1446 udp0->
src_port = s0->ext_host_nat_port;
1461 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1476 to_next, n_left_to_next,
1484 NAT_OUT2IN_ED_ERROR_OUT2IN_PACKETS,
1500 .name =
"nat44-ed-out2in",
1501 .vector_size =
sizeof (
u32),
1533 .name =
"nat44-ed-out2in-slowpath",
1534 .vector_size =
sizeof (
u32),
1560 u32 n_left_from, *from, *to_next;
1562 u32 pkts_processed = 0;
1568 u32 *fragments_to_drop = 0;
1569 u32 *fragments_to_loopback = 0;
1575 while (n_left_from > 0)
1581 while (n_left_from > 0 && n_left_to_next > 0)
1583 u32 bi0, sw_if_index0, proto0, rx_fib_index0, new_addr0, old_addr0;
1588 nat_reass_ip4_t *reass0;
1591 icmp46_header_t *icmp0;
1593 snat_session_t *s0 = 0;
1594 u16 old_port0, new_port0;
1607 n_left_to_next -= 1;
1620 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_DROP_FRAGMENT];
1627 icmp0 = (icmp46_header_t *) udp0;
1634 1, &fragments_to_drop);
1639 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_REASS];
1649 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1650 next0, now, thread_index, &s0);
1655 reass0->sess_index = s0 - per_thread_data->
sessions;
1658 reass0->thread_index = thread_index;
1660 &fragments_to_loopback);
1670 if (clib_bihash_search_16_8
1671 (&per_thread_data->
out2in_ed, &kv0, &value0))
1680 &twice_nat0, &lb0, 0,
1690 clib_host_to_net_u16
1691 (UDP_DST_PORT_dhcp_to_client))))
1700 node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1707 thread_index, rx_fib_index0))
1716 &fragments_to_loopback);
1727 if ((proto0 == SNAT_PROTOCOL_TCP) && !
tcp_is_init (tcp0))
1729 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_NON_SYN];
1743 node->
errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1747 reass0->sess_index = s0 - per_thread_data->
sessions;
1748 reass0->thread_index = thread_index;
1754 reass0->sess_index = value0.
value;
1765 (reass0, bi0, &fragments_to_drop))
1767 b0->
error = node->
errors[NAT_OUT2IN_ED_ERROR_MAX_FRAG];
1769 (
"maximum fragments per reassembly exceeded");
1777 reass0->sess_index);
1799 old_port0 = tcp0->dst_port;
1800 tcp0->dst_port = s0->in2out.port;
1801 new_port0 = tcp0->dst_port;
1803 sum0 = tcp0->checksum;
1814 s0->ext_host_nat_addr.as_u32,
1817 s0->ext_host_nat_port,
1819 tcp0->src_port = s0->ext_host_nat_port;
1830 udp0->
src_port = s0->ext_host_nat_port;
1846 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1866 to_next, n_left_to_next,
1870 if (n_left_from == 0 &&
vec_len (fragments_to_loopback))
1877 sizeof (
u32) * len);
1884 fragments_to_loopback + (len -
1897 NAT_OUT2IN_ED_ERROR_OUT2IN_PACKETS,
1901 &node->
errors[NAT_OUT2IN_ED_ERROR_DROP_FRAGMENT],
1912 .name =
"nat44-ed-out2in-reass",
1913 .vector_size =
sizeof (
u32),
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
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)
static int next_src_nat(snat_main_t *sm, ip4_header_t *ip, u8 proto, u16 src_port, u16 dst_port, u32 thread_index, u32 rx_fib_index)
#define foreach_nat_out2in_ed_error
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
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)
#define nat_log_warn(...)
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_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
#define snat_is_unk_proto_session(s)
Check if SNAT session for unknown protocol.
static int nat44_set_tcp_session_state_o2i(snat_main_t *sm, snat_session_t *ses, tcp_header_t *tcp, u32 thread_index)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int ip4_is_fragment(const ip4_header_t *i)
static u32 icmp_out2in_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)
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
static char * nat_out2in_ed_error_strings[]
static uword nat44_ed_out2in_fast_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static_always_inline int icmp_get_ed_key(ip4_header_t *ip0, nat_ed_ses_key_t *p_key0)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define NAT_REASS_FLAG_ED_DONT_TRANSLATE
static void * ip4_next_header(ip4_header_t *i)
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)
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
VLIB_NODE_FUNCTION_MULTIARCH(nat44_ed_out2in_node, nat44_ed_out2in_fast_path_fn)
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.
clib_bihash_16_8_t out2in_ed
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.
clib_bihash_8_8_t static_mapping_by_external
vl_api_address_union_t src_address
static void create_bypass_for_fwd(snat_main_t *sm, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index)
#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_node_registration_t nat44_ed_out2in_reass_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_reass_node)
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 void nat44_delete_user_with_no_session(snat_main_t *sm, snat_user_t *u, u32 thread_index)
#define VLIB_REGISTER_NODE(x,...)
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)
#define vec_free(V)
Free vector's memory (no header).
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static u8 * format_nat44_ed_out2in_trace(u8 *s, va_list *args)
static uword nat44_ed_out2in_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_slow_path)
#define clib_memcpy(a, b, c)
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes)
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 uword nat44_ed_out2in_reass_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t nat44_ed_out2in_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node)
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 snat_session_t * nat44_ed_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)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define SNAT_SESSION_FLAG_TWICE_NAT
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
static snat_session_t * create_session_for_static_mapping_ed(snat_main_t *sm, vlib_buffer_t *b, snat_session_key_t l_key, snat_session_key_t e_key, vlib_node_runtime_t *node, u32 thread_index, twice_nat_type_t twice_nat, lb_nat_type_t lb_nat, f64 now)
#define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT
snat_address_t * twice_nat_addresses
static uword nat44_ed_out2in_slow_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
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)
#define SNAT_SESSION_FLAG_FWD_BYPASS
static u32 ip_proto_to_snat_proto(u8 ip_proto)
The NAT inline functions.
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)
u32 icmp_match_out2in_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)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define SNAT_SESSION_FLAG_AFFINITY
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 u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
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
int nat_ip4_reass_add_fragment(nat_reass_ip4_t *reass, u32 bi, u32 **bi_to_drop)
Cache fragment.
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.
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)