28 #ifdef MAP_SKIP_IP6_LOOKUP 60 return format (s,
"MAP domain index: %d L4 port: %u Status: %s",
62 t->
cached ?
"cached" :
"forwarded");
67 u32 * next,
u8 * error)
77 || clib_host_to_net_u16 (ip->
length) < 28))
86 && (clib_net_to_host_u16 (port) <
89 *error = MAP_ERROR_ENCAP_SEC_CHECK;
100 *error = MAP_ERROR_BAD_PROTOCOL;
119 u32 vtcfl = 0x6 << 28;
121 vtcfl |=
vnet_buffer (p)->ip.flow_hash & 0x000fffff;
123 return (clib_host_to_net_u32 (vtcfl));
137 u32 checksum = ip->
checksum + clib_host_to_net_u16 (0x0100);
138 checksum += checksum >= 0xffff;
142 *error = ttl <= 0 ? IP4_ERROR_TIME_EXPIRED : *error;
166 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set,
169 *error = MAP_ERROR_DF_SET;
184 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
194 while (n_left_from > 0)
199 while (n_left_from >= 4 && n_left_to_next >= 2)
204 u8 error0 = MAP_ERROR_NONE, error1 = MAP_ERROR_NONE;
206 u16 port0 = 0, port1 = 0;
208 u32 map_domain_index0 = ~0, map_domain_index1 = ~0;
226 pi0 = to_next[0] = from[0];
227 pi1 = to_next[1] = from[1];
263 u16 dp40 = clib_net_to_host_u16 (port0);
264 u16 dp41 = clib_net_to_host_u16 (port1);
269 if (dal60 == 0 && dar60 == 0 && error0 == MAP_ERROR_NONE
271 error0 = MAP_ERROR_NO_BINDING;
272 if (dal61 == 0 && dar61 == 0 && error1 == MAP_ERROR_NONE
274 error1 = MAP_ERROR_NO_BINDING;
290 ip6h0->
protocol = IP_PROTOCOL_IP_IN_IP;
291 ip6h1->
protocol = IP_PROTOCOL_IP_IN_IP;
310 sizeof (*ip6h0) > d0->
mtu)))
322 map_domain_index0, 1,
342 sizeof (*ip6h1) > d1->
mtu)))
354 map_domain_index1, 1,
382 n_left_to_next, pi0, pi1, next0,
386 while (n_left_from > 0 && n_left_to_next > 0)
391 u8 error0 = MAP_ERROR_NONE;
396 u32 map_domain_index0 = ~0;
398 pi0 = to_next[0] = from[0];
429 u16 dp40 = clib_net_to_host_u16 (port0);
432 if (dal60 == 0 && dar60 == 0 && error0 == MAP_ERROR_NONE
434 error0 = MAP_ERROR_NO_BINDING;
444 ip6h0->
protocol = IP_PROTOCOL_IP_IN_IP;
459 sizeof (*ip6h0) > d0->
mtu)))
471 map_domain_index0, 1,
492 n_left_to_next, pi0, next0);
507 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
516 u32 *fragments_to_drop = NULL;
517 u32 *fragments_to_loopback = NULL;
519 while (n_left_from > 0)
523 while (n_left_from > 0 && n_left_to_next > 0)
528 u8 error0 = MAP_ERROR_NONE;
533 u32 map_domain_index0 = ~0;
536 pi0 = to_next[0] = from[0];
558 error0 = MAP_ERROR_FRAGMENT_MEMORY;
570 error0 = MAP_ERROR_FRAGMENT_MEMORY;
581 error0 = MAP_ERROR_BAD_PROTOCOL;
591 #ifdef MAP_IP4_REASS_COUNT_BYTES 598 clib_host_to_net_u16 (ip40->
length) - 20;
616 sizeof (*ip60) > d0->
mtu)))
642 if (error0 == MAP_ERROR_NONE)
645 map_domain_index0, 1,
652 n_left_to_next, pi0, next0);
656 if (n_left_from == 0 &&
vec_len (fragments_to_loopback))
681 &error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED],
690 #define _(sym,string) string, 699 .arc_name =
"ip4-unicast",
700 .node_name =
"ip4-map",
708 .vector_size =
sizeof(
u32),
718 #ifdef MAP_SKIP_IP6_LOOKUP 733 .name =
"ip4-map-reass",
734 .vector_size =
sizeof(
u32),
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
#define map_ip4_reass_lock()
u8 * format_ip4_map_reass_trace(u8 *s, va_list *args)
void ip_frag_set_vnet_buffer(vlib_buffer_t *b, u16 mtu, u8 next_index, u8 flags)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static_always_inline u64 map_get_pfx(map_domain_t *d, u32 addr, u16 port)
#define clib_memcpy_fast(a, b, c)
static_always_inline map_domain_t * ip4_map_get_domain(ip4_address_t *addr, u32 *map_domain_index, u8 *error)
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
vlib_error_t * errors
Vector of errors for this node.
IPv4 to IPv6 translation.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define static_always_inline
vlib_combined_counter_main_t * domain_counters
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static_always_inline void map_send_all_to_node(vlib_main_t *vm, u32 *pi_vector, vlib_node_runtime_t *node, vlib_error_t *error, u32 next)
int map_ip4_reass_add_fragment(map_ip4_reass_t *r, u32 pi)
static u16 ip4_get_port(ip4_header_t *ip, u8 sender)
Get TCP/UDP port number or ICMP id from IPv4 packet.
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static u32 ip4_map_fragment(vlib_buffer_t *b, u16 mtu, bool df, u8 *error)
static uword ip4_map_reass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
static int ip4_get_fragment_offset(const ip4_header_t *i)
static_always_inline u64 map_get_sfx_net(map_domain_t *d, u32 addr, u16 port)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
map_ip4_reass_t * map_ip4_reass_get(u32 src, u32 dst, u16 fragment_id, u8 protocol, u32 **pi_to_drop)
static_always_inline u32 ip4_map_vtcfl(ip4_header_t *ip4, vlib_buffer_t *p)
#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 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).
vlib_node_registration_t ip4_map_reass_node
(constructor) VLIB_REGISTER_NODE (ip4_map_reass_node)
void map_ip4_reass_free(map_ip4_reass_t *r, u32 **pi_to_drop)
static uword ip4_map(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline void map_ip4_reass_get_fragments(map_ip4_reass_t *r, u32 **pi)
#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)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
static void ip4_map_decrement_ttl(ip4_header_t *ip, u8 *error)
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.
#define foreach_map_error
static int ip4_get_fragment_more(const ip4_header_t *i)
static char * map_error_strings[]
#define IP_FRAG_FLAG_IP6_HEADER
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static_always_inline bool ip4_map_ip6_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define map_ip4_reass_unlock()
u8 * format_map_trace(u8 *s, va_list *args)
VNET_FEATURE_INIT(ip4_map_feature, static)
#define VNET_FEATURES(...)
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
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static_always_inline u64 map_get_sfx(map_domain_t *d, u32 addr, u16 port)
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static_always_inline u16 ip4_map_port_and_security_check(map_domain_t *d, ip4_header_t *ip, u32 *next, u8 *error)