|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
41 #define foreach_nat64_out2in_error \
42 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
43 _(NO_TRANSLATION, "no translation") \
48 #define _(sym,str) NAT64_OUT2IN_ERROR_##sym,
55 #define _(sym,string) string,
88 nat64_db_bib_entry_t *bibe;
89 nat64_db_st_entry_t *ste;
92 ip6_address_t ip6_saddr;
105 if (
ip4->protocol == IP_PROTOCOL_UDP)
113 clib_host_to_net_u16 (
ip4->length) -
sizeof (*ip4);
119 clib_host_to_net_u16 (IP_PROTOCOL_UDP));
127 checksum = &tcp->checksum;
131 old_src.
as_u32 =
ip4->src_address.as_u32;
132 old_dst.
as_u32 =
ip4->dst_address.as_u32;
140 sizeof (*
ip4) -
sizeof (*ip6) -
154 ip6->ip_version_traffic_class_and_flow_label =
155 clib_host_to_net_u32 ((6 << 28) + (
ip4->tos << 20));
157 ip6->hop_limit =
ip4->ttl;
158 ip6->protocol =
ip4->protocol;
164 saddr.ip4.as_u32 =
ip4->src_address.as_u32;
166 daddr.ip4.as_u32 =
ip4->dst_address.as_u32;
196 ip6->src_address.as_u64[0] = ste->in_r_addr.as_u64[0];
197 ip6->src_address.as_u64[1] = ste->in_r_addr.as_u64[1];
199 ip6->dst_address.as_u64[0] = bibe->in_addr.as_u64[0];
200 ip6->dst_address.as_u64[1] = bibe->in_addr.as_u64[1];
208 frag->next_hdr =
ip6->protocol;
209 frag->identification = frag_id;
211 frag->fragment_offset_and_more =
213 ip6->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
221 if (
proto == IP_PROTOCOL_TCP)
246 nat64_db_bib_entry_t *bibe;
247 nat64_db_st_entry_t *ste;
248 ip46_address_t saddr, daddr;
249 ip6_address_t ip6_saddr;
258 saddr.ip4.as_u32 =
ip4->src_address.as_u32;
260 daddr.ip4.as_u32 =
ip4->dst_address.as_u32;
262 if (
icmp->type == ICMP6_echo_request ||
icmp->type == ICMP6_echo_reply)
267 IP_PROTOCOL_ICMP, fib_index, 0);
281 IP_PROTOCOL_ICMP, fib_index, 0);
288 bibe, &ip6_saddr, &saddr.ip4, 0);
299 ip6->src_address.as_u64[0] = ste->in_r_addr.as_u64[0];
300 ip6->src_address.as_u64[1] = ste->in_r_addr.as_u64[1];
302 ip6->dst_address.as_u64[0] = bibe->in_addr.as_u64[0];
303 ip6->dst_address.as_u64[1] = bibe->in_addr.as_u64[1];
304 ((
u16 *) (
icmp))[2] = bibe->in_port;
327 nat64_db_bib_entry_t *bibe;
328 nat64_db_st_entry_t *ste;
329 ip46_address_t saddr, daddr;
339 saddr.ip4.as_u32 =
ip4->src_address.as_u32;
341 daddr.ip4.as_u32 =
ip4->dst_address.as_u32;
343 if (
proto == IP_PROTOCOL_ICMP6)
347 proto = IP_PROTOCOL_ICMP;
350 (
icmp->type == ICMP6_echo_request
351 ||
icmp->type == ICMP6_echo_reply))
364 ip6->dst_address.as_u64[0] = ste->in_r_addr.as_u64[0];
365 ip6->dst_address.as_u64[1] = ste->in_r_addr.as_u64[1];
366 ip6->src_address.as_u64[0] = bibe->in_addr.as_u64[0];
367 ip6->src_address.as_u64[1] = bibe->in_addr.as_u64[1];
368 ((
u16 *) (
icmp))[2] = bibe->in_port;
392 ip6->src_address.as_u64[0] = bibe->in_addr.as_u64[0];
393 ip6->src_address.as_u64[1] = bibe->in_addr.as_u64[1];
396 if (
proto == IP_PROTOCOL_UDP)
399 checksum = &tcp->checksum;
419 ip6_frag_hdr_t *frag;
423 nat64_db_bib_entry_t *bibe;
424 nat64_db_st_entry_t *ste;
425 ip46_address_t saddr, daddr;
426 ip6_address_t ip6_saddr;
437 sizeof (*
ip4) -
sizeof (*ip6) -
451 ip6->ip_version_traffic_class_and_flow_label =
452 clib_host_to_net_u32 ((6 << 28) + (
ip4->tos << 20));
454 ip6->hop_limit =
ip4->ttl;
455 ip6->protocol =
ip4->protocol;
459 frag->next_hdr =
ip6->protocol;
460 frag->identification = frag_id;
462 frag->fragment_offset_and_more =
464 ip6->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
472 saddr.ip4.as_u32 =
ip4->src_address.as_u32;
474 daddr.ip4.as_u32 =
ip4->dst_address.as_u32;
493 bibe, &ip6_saddr, &saddr.ip4, 0);
504 ip6->src_address.as_u64[0] = ste->in_r_addr.as_u64[0];
505 ip6->src_address.as_u64[1] = ste->in_r_addr.as_u64[1];
507 ip6->dst_address.as_u64[0] = bibe->in_addr.as_u64[0];
508 ip6->dst_address.as_u64[1] = bibe->in_addr.as_u64[1];
568 b0->
error =
node->errors[NAT64_OUT2IN_ERROR_NO_TRANSLATION];
575 if (proto0 == NAT_PROTOCOL_ICMP)
584 b0->
error =
node->errors[NAT64_OUT2IN_ERROR_NO_TRANSLATION];
590 if (proto0 == NAT_PROTOCOL_TCP)
604 if ((proto0 == NAT_PROTOCOL_UDP)
606 clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_client)))
612 b0->
error =
node->errors[NAT64_OUT2IN_ERROR_NO_TRANSLATION];
619 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
635 n_left_to_next, bi0, next0);
639 return frame->n_vectors;
644 .name =
"nat64-out2in",
645 .vector_size =
sizeof (
u32),
670 #define foreach_nat64_out2in_handoff_error \
671 _(CONGESTION_DROP, "congestion drop") \
672 _(SAME_WORKER, "same worker") \
673 _(DO_HANDOFF, "do handoff")
677 #define _(sym,str) NAT64_OUT2IN_HANDOFF_ERROR_##sym,
684 #define _(sym,string) string,
718 u32 do_handoff = 0, same_worker = 0;
743 && (
b[0]->
flags & VLIB_BUFFER_IS_TRACED)))
756 thread_indices,
frame->n_vectors, 1);
760 NAT64_OUT2IN_HANDOFF_ERROR_CONGESTION_DROP,
761 frame->n_vectors - n_enq);
763 NAT64_OUT2IN_HANDOFF_ERROR_SAME_WORKER,
766 NAT64_OUT2IN_HANDOFF_ERROR_DO_HANDOFF,
769 return frame->n_vectors;
774 .name =
"nat64-out2in-handoff",
775 .vector_size =
sizeof (
u32),
static char * nat64_out2in_handoff_error_strings[]
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
#define u8_ptr_add(ptr, index)
static_always_inline u32 vlib_buffer_enqueue_to_thread(vlib_main_t *vm, vlib_node_runtime_t *node, u32 frame_queue_index, u32 *buffer_indices, u16 *thread_indices, u32 n_packets, int drop_on_congestion)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
nat44_ei_hairpin_src_next_t next_index
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
struct _tcp_header tcp_header_t
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
vlib_main_t vlib_node_runtime_t * node
struct nat64_out2in_set_ctx_t_ nat64_out2in_set_ctx_t
#define ip6_frag_hdr_offset_and_more(offset, more)
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define foreach_nat64_out2in_error
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
struct nat44_ei_main_s::@81 counters
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_NODE_FN(node)
static char * nat64_out2in_error_strings[]
#define VLIB_NODE_FLAG_TRACE
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
nat64_out2in_handoff_error_t
vlib_node_registration_t nat64_out2in_node
(constructor) VLIB_REGISTER_NODE (nat64_out2in_node)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static int icmp_to_icmp6(vlib_buffer_t *p, ip4_to_ip6_set_fn_t fn, void *ctx, ip4_to_ip6_set_fn_t inner_fn, void *inner_ctx)
Translate ICMP4 packet to ICMP6.
struct _vlib_node_registration vlib_node_registration_t
static u16 ip4_get_fragment_more(const ip4_header_t *i)
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
@ NAT64_OUT2IN_NEXT_IP6_LOOKUP
#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.
static void vlib_set_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 value)
Set a simple counter.
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
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.
struct nat64_out2in_frag_set_ctx_t_ nat64_out2in_frag_set_ctx_t
@ NAT64_OUT2IN_HANDOFF_N_ERROR
nat64_db_st_entry_t * nat64_db_st_entry_find(nat64_db_t *db, ip46_address_t *l_addr, ip46_address_t *r_addr, u16 l_port, u16 r_port, u8 proto, u32 fib_index, u8 is_ip6)
Find NAT64 session table entry.
static u8 * format_nat64_out2in_trace(u8 *s, va_list *args)
nat64_db_st_entry_t * nat64_db_st_entry_create(u32 thread_index, nat64_db_t *db, nat64_db_bib_entry_t *bibe, ip6_address_t *in_r_addr, ip4_address_t *out_r_addr, u16 r_port)
Create new NAT64 session table entry.
static int nat64_out2in_tcp_udp(vlib_main_t *vm, vlib_buffer_t *b, nat64_out2in_set_ctx_t *ctx)
u32 nat64_get_worker_out2in(vlib_buffer_t *b, ip4_header_t *ip)
Get worker thread index for NAT64 out2in.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
nat64_db_bib_entry_t * nat64_db_bib_entry_find(nat64_db_t *db, ip46_address_t *addr, u16 port, u8 proto, u32 fib_index, u8 is_ip6)
Find NAT64 BIB entry.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
void nat64_tcp_session_set_state(nat64_db_st_entry_t *ste, tcp_header_t *tcp, u8 is_ip6)
Set NAT64 TCP session state.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static int nat64_out2in_inner_icmp_set_cb(vlib_buffer_t *b, ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
IPv4 to IPv6 translation.
static u8 * format_nat64_out2in_handoff_trace(u8 *s, va_list *args)
#define u16_net_add(u, val)
void nat64_compose_ip6(ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
Compose IPv4-embedded IPv6 addresses.
void nat64_session_reset_timeout(nat64_db_st_entry_t *ste, vlib_main_t *vm)
Reset NAT64 session timeout.
nat64_db_bib_entry_t * nat64_db_bib_entry_by_index(nat64_db_t *db, u8 proto, u32 bibe_index)
Get BIB entry by index and protocol.
vlib_simple_counter_main_t total_sessions
#define foreach_nat64_out2in_handoff_error
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)
vl_api_interface_index_t sw_if_index
#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 u16 ip_csum_fold(ip_csum_t c)
vlib_node_registration_t nat64_out2in_handoff_node
(constructor) VLIB_REGISTER_NODE (nat64_out2in_handoff_node)
vl_api_fib_path_type_t type
static void * ip4_next_header(ip4_header_t *i)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
static int nat64_out2in_unk_proto(vlib_main_t *vm, vlib_buffer_t *p, nat64_out2in_set_ctx_t *ctx)
static int nat64_out2in_icmp_set_cb(vlib_buffer_t *b, ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
@ NAT64_OUT2IN_NEXT_IP4_LOOKUP