26 #define NAT44_EI_FLAG_HAIRPINNING (1 << 0) 64 s =
format (s,
" is-static-mapping");
95 #ifndef CLIB_MARCH_VARIANT 102 u32 old_addr, new_addr;
122 #ifndef CLIB_MARCH_VARIANT 128 u32 *required_thread_index)
130 nat44_ei_session_t *s0 = NULL;
133 u32 new_dst_addr0 = 0, old_dst_addr0,
si = ~0;
134 u16 new_dst_port0 = ~0, old_dst_port0;
144 &sm0_addr, &sm0_port, &sm0_fib_index, 1 , 0, 0))
146 new_dst_addr0 = sm0_addr.
as_u32;
147 new_dst_port0 = sm0_port;
155 rv = clib_bihash_search_8_8 (&nm->
out2in, &kv0, &value0);
170 new_dst_addr0 = s0->in2out.addr.as_u32;
171 new_dst_port0 = s0->in2out.port;
180 old_dst_port0 = tcp0->dst;
181 if (new_dst_addr0 == old_dst_addr0 && new_dst_port0 == old_dst_port0 &&
195 old_dst_port0 = tcp0->dst;
200 tcp0->dst = new_dst_port0;
201 sum0 = tcp0->checksum;
218 sum0 = tcp0->checksum;
230 (b0->
flags & VLIB_BUFFER_IS_TRACED)))
234 t->
port = new_dst_port0;
249 #ifndef CLIB_MARCH_VARIANT 253 icmp46_header_t *icmp0,
u32 *required_thread_index)
256 u32 old_dst_addr0, new_dst_addr0;
257 u32 old_addr0, new_addr0;
258 u16 old_port0, new_port0;
259 u16 old_checksum0, new_checksum0;
262 nat44_ei_session_t *s0;
266 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags))
275 if (protocol != NAT_PROTOCOL_TCP && protocol != NAT_PROTOCOL_UDP)
280 if (clib_bihash_search_8_8 (&nm->
out2in, &kv0, &value0))
283 if (ti != thread_index)
285 *required_thread_index =
ti;
290 new_dst_addr0 = s0->in2out.addr.as_u32;
297 sum0 = icmp0->checksum;
303 old_checksum0 = inner_ip0->
checksum;
308 new_checksum0 = inner_ip0->
checksum;
309 sum0 = icmp0->checksum;
316 l4_header->
src_port = s0->in2out.port;
318 sum0 = icmp0->checksum;
333 int rv = clib_bihash_search_8_8 (&nm->
out2in, &kv0, &value0);
337 if (ti != thread_index)
339 *required_thread_index =
ti;
344 new_dst_addr0 = s0->in2out.addr.as_u32;
347 sum0 = icmp0->checksum;
381 #ifndef CLIB_MARCH_VARIANT 388 u32 old_addr, new_addr;
417 next_index = node->cached_next_index;
419 while (n_left_from > 0)
425 while (n_left_from > 0 && n_left_to_next > 0)
456 goto skip_feature_next;
461 goto skip_feature_next;
479 n_left_to_next, bi0, next0);
497 n_left_from =
frame->n_vectors;
498 next_index = node->cached_next_index;
500 while (n_left_from > 0)
506 while (n_left_from > 0 && n_left_to_next > 0)
534 if (proto0 == NAT_PROTOCOL_TCP || proto0 == NAT_PROTOCOL_UDP)
540 udp0, tcp0, proto0, 1 ,
541 &required_thread_index);
543 else if (proto0 == NAT_PROTOCOL_ICMP)
548 &required_thread_index);
558 if (thread_index != required_thread_index)
561 required_thread_index;
573 n_left_to_next, bi0, next0);
579 return frame->n_vectors;
594 n_left_from =
frame->n_vectors;
595 next_index = node->cached_next_index;
597 while (n_left_from > 0)
603 while (n_left_from > 0 && n_left_to_next > 0)
630 int next0_resolved = 0;
634 &required_thread_index))
640 if (thread_index != required_thread_index)
643 required_thread_index;
660 n_left_to_next, bi0, next0);
666 return frame->n_vectors;
684 .name =
"nat44-ei-hairpin-dst-handoff",
685 .vector_size =
sizeof (
u32),
698 .name =
"nat44-ei-hairpinning-handoff",
699 .vector_size =
sizeof (
u32),
712 .name =
"nat44-ei-hairpin-src",
713 .vector_size =
sizeof (
u32),
725 .name =
"nat44-ei-hairpin-dst",
726 .vector_size =
sizeof (
u32),
738 .name =
"nat44-ei-hairpinning",
739 .vector_size =
sizeof (
u32),
vnet_config_main_t config_main
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 * format_nat44_ei_hairpin_trace(u8 *s, va_list *args)
static_always_inline int nat44_ei_is_hairpinning(nat44_ei_main_t *nm, ip4_address_t *dst_addr)
int nat44_ei_hairpinning(vlib_main_t *vm, vlib_node_runtime_t *node, nat44_ei_main_t *nm, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0, int do_trace, u32 *required_thread_index)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
vlib_node_registration_t nat44_ei_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (nat44_ei_hairpin_src_node)
#define pool_foreach(VAR, POOL)
Iterate through pool.
vl_api_ip_proto_t protocol
static uword nat44_ei_hairpinning_handoff_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 fq_index)
void nat44_ei_hairpinning_unknown_proto(nat44_ei_main_t *nm, vlib_buffer_t *b, ip4_header_t *ip)
NAT44 endpoint independent plugin declarations.
nat44_ei_session_t * sessions
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
static u32 nat_value_get_thread_index(clib_bihash_kv_8_8_t *value)
#define VLIB_NODE_FN(node)
vlib_node_registration_t nat44_ei_hairpinning_node
(constructor) VLIB_REGISTER_NODE (nat44_ei_hairpinning_node)
struct _tcp_header tcp_header_t
clib_bihash_8_8_t static_mapping_by_external
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
nat44_ei_static_mapping_t * static_mappings
#define static_always_inline
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
nat44_ei_address_t * addresses
description fragment has unexpected format
vlib_node_registration_t nat44_ei_hairpinning_dst_handoff_node
(constructor) VLIB_REGISTER_NODE (nat44_ei_hairpinning_dst_handoff_node)
vlib_simple_counter_main_t hairpinning
static u32 nat_value_get_session_index(clib_bihash_kv_8_8_t *value)
static void * ip4_next_header(ip4_header_t *i)
struct nat44_ei_main_s::@81 counters
vl_api_fib_path_type_t type
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vl_api_interface_index_t sw_if_index
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
nat44_ei_interface_t * output_feature_interfaces
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
vl_api_address_union_t src_address
void nat44_ei_hairpinning_sm_unknown_proto(nat44_ei_main_t *nm, vlib_buffer_t *b, ip4_header_t *ip)
#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.
vlib_main_t vlib_node_runtime_t * node
#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 u8 * format_nat44_ei_hairpinning_handoff_trace(u8 *s, va_list *args)
static char * nat44_ei_hairpinning_handoff_error_strings[]
vlib_node_registration_t nat44_ei_hairpinning_handoff_node
(constructor) VLIB_REGISTER_NODE (nat44_ei_hairpinning_handoff_node)
vl_api_ip_port_and_mask_t src_port
vl_api_mac_address_t dst_addr
#define VLIB_REGISTER_NODE(x,...)
nat44_ei_main_per_thread_data_t * per_thread_data
sll srl srl sll sra u16x4 i
vnet_feature_arc_registration_t vnet_feat_arc_ip4_local
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
u32 nat44_ei_icmp_hairpinning(nat44_ei_main_t *nm, vlib_buffer_t *b0, u32 thread_index, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 *required_thread_index)
vnet_feature_main_t feature_main
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
8 octet key, 8 octet key value pair
vlib_node_registration_t nat44_ei_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (nat44_ei_hairpin_dst_node)
vlib_put_next_frame(vm, node, next_index, 0)
nat44_ei_hairpin_src_next_t next_index
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
nat44_ei_hairpin_src_next_t
nat44_ei_main_t nat44_ei_main
#define ip_csum_update(sum, old, new, type, field)
struct _vnet_feature_arc_registration vnet_feature_arc_registration_t
feature registration object
#define vec_foreach(var, vec)
Vector iterator.
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)
#define VLIB_NODE_FLAG_TRACE
vnet_feature_config_main_t * feature_config_mains
feature config main objects
int nat44_ei_static_mapping_match(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, u8 *is_identity_nat)
Match NAT44-EI static mapping.
#define nat44_ei_interface_is_inside(ip)
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 vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define NAT44_EI_FLAG_HAIRPINNING
static u16 ip_csum_fold(ip_csum_t c)