18 #define MAP_ENCAP_DUAL 0 21 #include "../ip/ip_frag.h" 27 #ifdef MAP_SKIP_IP6_LOOKUP 69 (ip->
protocol == IP_PROTOCOL_UDP))) {
72 }
else if (ip->
protocol == IP_PROTOCOL_ICMP) {
78 icmp46_header_t *icmp = (
void *)(ip + 1);
79 if (icmp->type == ICMP4_echo_request || icmp->type == ICMP4_echo_reply) {
80 return *((
u16 *)(icmp + 1));
81 }
else if (clib_net_to_host_u16(ip->
length) >= 56) {
84 (icmp_ip->
protocol == IP_PROTOCOL_UDP))) {
87 }
else if (icmp_ip->
protocol == IP_PROTOCOL_ICMP) {
88 icmp46_header_t *inner_icmp = (
void *)(icmp_ip + 1);
89 if (inner_icmp->type == ICMP4_echo_request || inner_icmp->type == ICMP4_echo_reply)
90 return (*((
u16 *)(inner_icmp + 1)));
111 *error = MAP_ERROR_ENCAP_SEC_CHECK;
117 *error = MAP_ERROR_BAD_PROTOCOL;
134 u32 vtcfl = 0x6 << 28;
136 vtcfl |=
vnet_buffer(p)->ip.flow_hash & 0x000fffff;
138 return (clib_host_to_net_u32(vtcfl));
144 #ifdef MAP_SKIP_IP6_LOOKUP 147 if (adj_index0 > 0) {
150 if (adj->
n_adj > 1) {
152 adj_index0 += (hash_c0 & (adj->
n_adj - 1));
172 u32 checksum = ip->
checksum + clib_host_to_net_u16(0x0100);
173 checksum += checksum >= 0xffff;
177 *error = ttl <= 0 ? IP4_ERROR_TIME_EXPIRED : *error;
194 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set, mtu);
196 *error = MAP_ERROR_DF_SET;
212 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
221 while (n_left_from > 0) {
225 while (n_left_from >= 4 && n_left_to_next >= 2) {
229 u8 error0 = MAP_ERROR_NONE, error1 = MAP_ERROR_NONE;
231 u16 port0 = 0, port1 = 0;
233 u32 map_domain_index0 = ~0, map_domain_index1 = ~0;
250 pi0 = to_next[0] = from[0];
251 pi1 = to_next[1] = from[1];
281 u16 dp40 = clib_net_to_host_u16(port0);
282 u16 dp41 = clib_net_to_host_u16(port1);
287 if (dal60 == 0 && dar60 == 0 && error0 == MAP_ERROR_NONE && next0 !=
IP4_MAP_NEXT_REASS)
288 error0 = MAP_ERROR_NO_BINDING;
289 if (dal61 == 0 && dar61 == 0 && error1 == MAP_ERROR_NONE && next1 !=
IP4_MAP_NEXT_REASS)
290 error0 = MAP_ERROR_NO_BINDING;
304 ip6h0->
protocol = IP_PROTOCOL_IP_IN_IP;
305 ip6h1->
protocol = IP_PROTOCOL_IP_IN_IP;
364 while (n_left_from > 0 && n_left_to_next > 0) {
368 u8 error0 = MAP_ERROR_NONE;
373 u32 map_domain_index0 = ~0;
375 pi0 = to_next[0] = from[0];
397 u16 dp40 = clib_net_to_host_u16(port0);
400 if (dal60 == 0 && dar60 == 0 && error0 == MAP_ERROR_NONE && next0 !=
IP4_MAP_NEXT_REASS)
401 error0 = MAP_ERROR_NO_BINDING;
410 ip6h0->
protocol = IP_PROTOCOL_IP_IN_IP;
455 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
464 u32 *fragments_to_loopback =
NULL;
466 while (n_left_from > 0) {
469 while (n_left_from > 0 && n_left_to_next > 0) {
473 u8 error0 = MAP_ERROR_NONE;
478 u32 map_domain_index0;
481 pi0 = to_next[0] = from[0];
497 error0 = MAP_ERROR_FRAGMENT_MEMORY;
504 error0 = MAP_ERROR_FRAGMENT_MEMORY;
511 error0 = MAP_ERROR_BAD_PROTOCOL;
519 #ifdef MAP_IP4_REASS_COUNT_BYTES 537 vnet_buffer(p0)->ip_frag.header_offset =
sizeof(*ip60);
556 if (error0 == MAP_ERROR_NONE)
565 if(n_left_from == 0 &&
vec_len(fragments_to_loopback)) {
583 &error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED],
592 #define _(sym,string) string, 600 .vector_size =
sizeof(
u32),
610 #ifdef MAP_SKIP_IP6_LOOKUP 623 .name =
"ip4-map-reass",
624 .vector_size =
sizeof(
u32),
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
#define map_ip4_reass_lock()
u8 * format_ip4_map_reass_trace(u8 *s, va_list *args)
static_always_inline u64 map_get_pfx(map_domain_t *d, u32 addr, u16 port)
void ip_frag_set_vnet_buffer(vlib_buffer_t *b, u16 offset, u16 mtu, u8 next_index, u8 flags)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
always_inline int ip4_get_fragment_offset(ip4_header_t *i)
struct _vlib_node_registration vlib_node_registration_t
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
always_inline int ip4_get_fragment_more(ip4_header_t *i)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define static_always_inline
vlib_combined_counter_main_t * domain_counters
always_inline void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
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)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
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)
u16 current_length
Nbytes between current data and the end of this buffer.
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
uword os_get_cpu_number(void)
static_always_inline u64 map_get_sfx_net(map_domain_t *d, u32 addr, u16 port)
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)
i32 ip4_get_port(ip4_header_t *ip, map_dir_e dir, u16 buffer_len)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
always_inline u16 ip4_header_checksum(ip4_header_t *i)
vlib_node_registration_t ip4_map_reass_node
(constructor) VLIB_REGISTER_NODE (ip4_map_reass_node)
u16 ip4_map_get_port(ip4_header_t *ip, map_dir_e dir)
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)
static_always_inline bool ip4_map_ip6_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
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).
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
#define clib_memcpy(a, b, c)
static void ip4_map_decrement_ttl(ip4_header_t *ip, u8 *error)
#define foreach_map_error
static char * map_error_strings[]
#define IP_FRAG_FLAG_IP6_HEADER
ip_lookup_main_t lookup_main
#define map_ip4_reass_unlock()
u8 * format_map_trace(u8 *s, va_list *args)
#define IP_FLOW_HASH_DEFAULT
#define VLIB_BUFFER_IS_TRACED
always_inline ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
static_always_inline map_domain_t * ip4_map_get_domain(u32 adj_index, u32 *map_domain_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
always_inline u32 ip4_compute_flow_hash(ip4_header_t *ip, u32 flow_hash_config)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
always_inline vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static_always_inline u64 map_get_sfx(map_domain_t *d, u32 addr, u16 port)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static_always_inline u16 ip4_map_port_and_security_check(map_domain_t *d, ip4_header_t *ip, u32 *next, u8 *error)