62 s =
format (s,
" is-static-mapping");
95 #ifndef CLIB_MARCH_VARIANT 100 int is_ed,
int do_trace)
102 snat_session_t *s0 = NULL;
105 u32 new_dst_addr0 = 0, old_dst_addr0, ti = 0,
si = ~0;
106 u16 new_dst_port0 = ~0, old_dst_port0;
115 &sm0_addr, &sm0_port, &sm0_fib_index, 1, 0, 0, 0, 0, 0, 0))
117 new_dst_addr0 = sm0_addr.
as_u32;
118 new_dst_port0 = sm0_port;
126 (clib_net_to_host_u16 (udp0->
dst_port) -
137 rv = clib_bihash_search_16_8 (&sm->
out2in_ed, &ed_kv, &ed_value);
158 new_dst_addr0 = s0->in2out.addr.as_u32;
159 new_dst_port0 = s0->in2out.port;
168 old_dst_port0 = tcp0->dst;
169 if (new_dst_addr0 == old_dst_addr0
170 && new_dst_port0 == old_dst_port0
184 old_dst_port0 = tcp0->dst;
189 tcp0->dst = new_dst_port0;
190 sum0 = tcp0->checksum;
207 sum0 = tcp0->checksum;
219 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
223 t->
port = new_dst_port0;
238 #ifndef CLIB_MARCH_VARIANT 245 u32 old_dst_addr0, new_dst_addr0;
246 u32 old_addr0, new_addr0;
247 u16 old_port0, new_port0;
248 u16 old_checksum0, new_checksum0;
264 if (protocol != NAT_PROTOCOL_TCP && protocol != NAT_PROTOCOL_UDP)
273 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &ed_kv, &ed_value))
282 if (clib_bihash_search_8_8
288 new_dst_addr0 = s0->in2out.addr.as_u32;
295 sum0 = icmp0->checksum;
301 old_checksum0 = inner_ip0->
checksum;
306 new_checksum0 = inner_ip0->
checksum;
307 sum0 = icmp0->checksum;
314 l4_header->
src_port = s0->in2out.port;
316 sum0 = icmp0->checksum;
324 if (clib_bihash_search_8_8
335 (clib_net_to_host_u16 (icmp_id0) -
347 new_dst_addr0 = s0->in2out.addr.as_u32;
349 s0->in2out.fib_index;
351 sum0 = icmp0->checksum;
383 #ifndef CLIB_MARCH_VARIANT 390 u32 old_addr, new_addr;
410 #ifndef CLIB_MARCH_VARIANT 415 u32 old_addr, new_addr = 0, ti = 0;
430 if (clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
433 if (clib_bihash_search_8_8
463 u32 n_left_from, *from, *to_next;
474 while (n_left_from > 0)
480 while (n_left_from > 0 && n_left_to_next > 0)
511 (vm, node, sm, b0, ip0, udp0, tcp0, proto0, is_ed,
524 to_next, n_left_to_next,
543 .name =
"nat44-hairpinning",
544 .vector_size =
sizeof (
u32),
564 .name =
"nat44-ed-hairpinning",
565 .vector_size =
sizeof (
u32),
581 u32 n_left_from, *from, *to_next;
589 while (n_left_from > 0)
595 while (n_left_from > 0 && n_left_to_next > 0)
622 if (proto0 == NAT_PROTOCOL_TCP || proto0 == NAT_PROTOCOL_UDP)
630 else if (proto0 == NAT_PROTOCOL_ICMP)
657 to_next, n_left_to_next,
676 .name =
"nat44-hairpin-dst",
677 .vector_size =
sizeof (
u32),
697 .name =
"nat44-ed-hairpin-dst",
698 .vector_size =
sizeof (
u32),
714 u32 n_left_from, *from, *to_next;
722 while (n_left_from > 0)
728 while (n_left_from > 0 && n_left_to_next > 0)
776 to_next, n_left_to_next,
795 .name =
"nat44-hairpin-src",
796 .vector_size =
sizeof (
u32),
817 .name =
"nat44-ed-hairpin-src",
818 .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 vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
clib_bihash_16_8_t out2in_ed
vlib_node_registration_t snat_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_src_node)
vlib_node_registration_t nat44_ed_hairpinning_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpinning_node)
#define pool_foreach(VAR, POOL)
Iterate through pool.
vlib_node_registration_t nat44_ed_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node)
vl_api_ip_proto_t protocol
vlib_node_registration_t nat44_ed_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node)
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)
static u8 * format_nat_hairpin_trace(u8 *s, va_list *args)
struct _tcp_header tcp_header_t
vlib_simple_counter_main_t hairpinning
snat_get_worker_out2in_function_t * worker_out2in_cb
#define static_always_inline
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
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.
description fragment has unexpected format
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
static void * ip4_next_header(ip4_header_t *i)
void nat_hairpinning_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
vl_api_fib_path_type_t type
static uword snat_hairpin_dst_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ed)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static u32 ed_value_get_session_index(clib_bihash_kv_16_8_t *value)
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 * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
clib_bihash_8_8_t static_mapping_by_external
#define nat_interface_is_inside(i)
Check if NAT interface is inside.
vl_api_address_union_t src_address
#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)
snat_interface_t * output_feature_interfaces
vl_api_ip_port_and_mask_t src_port
vl_api_mac_address_t dst_addr
#define VLIB_REGISTER_NODE(x,...)
vlib_node_registration_t snat_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_dst_node)
sll srl srl sll sra u16x4 i
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
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 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
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
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
VLIB buffer representation.
snat_main_per_thread_data_t * per_thread_data
#define SNAT_FLAG_HAIRPINNING
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 uword nat44_hairpinning_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ed)
snat_address_t * addresses
struct _vnet_feature_arc_registration vnet_feature_arc_registration_t
feature registration object
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)
static uword snat_hairpin_src_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ed)
#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)
vlib_node_registration_t nat44_hairpinning_node
(constructor) VLIB_REGISTER_NODE (nat44_hairpinning_node)
#define VLIB_NODE_FLAG_TRACE
vnet_feature_config_main_t * feature_config_mains
feature config main objects
vnet_feature_main_t feature_main
vnet_feature_arc_registration_t vnet_feat_arc_ip4_local
snat_session_t * sessions
static_always_inline int is_hairpinning(snat_main_t *sm, ip4_address_t *dst_addr)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u32 ed_value_get_thread_index(clib_bihash_kv_16_8_t *value)
static u16 ip_csum_fold(ip_csum_t c)
vl_api_interface_index_t sw_if_index
void nat44_ed_hairpinning_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)