46 #define foreach_nat64_out2in_error \ 47 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 48 _(OUT2IN_PACKETS, "Good out2in packets processed") \ 49 _(NO_TRANSLATION, "No translation") \ 54 #define _(sym,str) NAT64_OUT2IN_ERROR_##sym, 61 #define _(sym,string) string, 85 nat64_db_bib_entry_t *bibe;
86 nat64_db_st_entry_t *ste;
87 ip46_address_t saddr, daddr;
94 u32 sw_if_index, fib_index;
101 memset (&saddr, 0,
sizeof (saddr));
103 memset (&daddr, 0,
sizeof (daddr));
138 if (proto == SNAT_PROTOCOL_UDP)
141 checksum = &tcp->checksum;
156 nat64_db_bib_entry_t *bibe;
157 nat64_db_st_entry_t *ste;
158 ip46_address_t saddr, daddr;
160 u32 sw_if_index, fib_index;
166 memset (&saddr, 0,
sizeof (saddr));
168 memset (&daddr, 0,
sizeof (daddr));
171 if (icmp->type == ICMP6_echo_request || icmp->type == ICMP6_echo_reply)
173 u16 out_id = ((
u16 *) (icmp))[2];
176 SNAT_PROTOCOL_ICMP, fib_index, 0);
190 SNAT_PROTOCOL_ICMP, fib_index, 0);
207 ((
u16 *) (icmp))[2] = bibe->in_port;
230 nat64_db_bib_entry_t *bibe;
231 nat64_db_st_entry_t *ste;
232 ip46_address_t saddr, daddr;
233 u32 sw_if_index, fib_index;
240 memset (&saddr, 0,
sizeof (saddr));
242 memset (&daddr, 0,
sizeof (daddr));
245 if (proto == SNAT_PROTOCOL_ICMP)
248 u16 out_id = ((
u16 *) (icmp))[2];
251 (icmp->type == ICMP6_echo_request
252 || icmp->type == ICMP6_echo_reply))
269 ((
u16 *) (icmp))[2] = bibe->in_port;
297 if (proto == SNAT_PROTOCOL_UDP)
300 checksum = &tcp->checksum;
318 u32 n_left_from, *from, *to_next;
320 u32 pkts_processed = 0;
325 while (n_left_from > 0)
331 while (n_left_from > 0 && n_left_to_next > 0)
361 node->
errors[NAT64_OUT2IN_ERROR_UNSUPPORTED_PROTOCOL];
365 if (proto0 == SNAT_PROTOCOL_ICMP)
372 b0->
error = node->
errors[NAT64_OUT2IN_ERROR_NO_TRANSLATION];
381 b0->
error = node->
errors[NAT64_OUT2IN_ERROR_NO_TRANSLATION];
400 n_left_to_next, bi0, next0);
405 NAT64_OUT2IN_ERROR_OUT2IN_PACKETS,
413 .name =
"nat64-out2in",
414 .vector_size =
sizeof (
u32),
static char * nat64_out2in_error_strings[]
nat64_db_st_entry_t * nat64_db_st_entry_create(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.
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.
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.
struct _vlib_node_registration vlib_node_registration_t
static int nat64_out2in_tcp_udp_set_cb(ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
vlib_error_t * errors
Vector of errors for this node.
struct _tcp_header tcp_header_t
struct nat64_out2in_set_ctx_t_ nat64_out2in_set_ctx_t
IPv4 to IPv6 translation.
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, snat_protocol_t proto, u32 fib_index, u8 is_ip6)
Find NAT64 session table entry.
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
nat64_db_bib_entry_t * nat64_db_bib_entry_find(nat64_db_t *db, ip46_address_t *addr, u16 port, snat_protocol_t proto, u32 fib_index, u8 is_ip6)
Find NAT64 BIB entry.
static void * ip4_next_header(ip4_header_t *i)
nat64_db_t db
BIB and session DB.
void nat64_session_reset_timeout(nat64_db_st_entry_t *ste, vlib_main_t *vm)
Reset NAT64 session timeout.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static int nat64_out2in_icmp_set_cb(ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
static u8 * format_nat64_out2in_trace(u8 *s, va_list *args)
#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).
void nat64_compose_ip6(ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
Compose IPv4-embedded IPv6 addresses.
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)
nat64_db_bib_entry_t * nat64_db_bib_entry_by_index(nat64_db_t *db, snat_protocol_t proto, u32 bibe_index)
Get BIB entry by index and protocol.
static int ip4_to_ip6_tcp_udp(vlib_buffer_t *p, ip4_to_ip6_set_fn_t fn, void *ctx)
Translate IPv4 UDP/TCP packet to IPv6.
#define VLIB_BUFFER_IS_TRACED
static int nat64_out2in_inner_icmp_set_cb(ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
static uword nat64_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define u8_ptr_add(ptr, index)
VLIB_NODE_FUNCTION_MULTIARCH(nat64_out2in_node, nat64_out2in_node_fn)
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
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.
vlib_node_registration_t nat64_out2in_node
(constructor) VLIB_REGISTER_NODE (nat64_out2in_node)
#define VLIB_NODE_FLAG_TRACE
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
NAT64 global declarations.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static u32 ip_proto_to_snat_proto(u8 ip_proto)
#define VLIB_REGISTER_NODE(x,...)
u16 flags
Copy of main node flags.
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip_csum_fold(ip_csum_t c)
#define foreach_nat64_out2in_error
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)