26 #define MAP_SKIP_IP6_LOOKUP 1 37 u8 ea_bits_len,
u8 psid_offset,
u8 psid_length,
47 typedef enum __attribute__ ((__packed__))
65 #define MAP_IP4_REASS_LIFETIME_DEFAULT (100) 66 #define MAP_IP4_REASS_HT_RATIO_DEFAULT (1.0) 67 #define MAP_IP4_REASS_POOL_SIZE_DEFAULT 1024 // Number of reassembly structures 68 #define MAP_IP4_REASS_BUFFERS_DEFAULT 2048 70 #define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY 5 // Number of fragment per reassembly 72 #define MAP_IP6_REASS_LIFETIME_DEFAULT (100) 73 #define MAP_IP6_REASS_HT_RATIO_DEFAULT (1.0) 74 #define MAP_IP6_REASS_POOL_SIZE_DEFAULT 1024 // Number of reassembly structures 75 #define MAP_IP6_REASS_BUFFERS_DEFAULT 2048 77 #define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY 5 79 #define MAP_IP6_REASS_COUNT_BYTES 80 #define MAP_IP4_REASS_COUNT_BYTES 114 "MAP domain fits in one cacheline");
116 #define MAP_REASS_INDEX_NONE ((u16)0xffff) 138 #ifdef MAP_IP4_REASS_COUNT_BYTES 189 #ifdef MAP_IP6_REASS_COUNT_BYTES 210 #ifdef MAP_SKIP_IP6_LOOKUP 281 #define foreach_map_error \ 283 _(NONE, "valid MAP packets") \ 284 _(BAD_PROTOCOL, "bad protocol") \ 285 _(SEC_CHECK, "security check failed") \ 286 _(ENCAP_SEC_CHECK, "encap security check failed") \ 287 _(DECAP_SEC_CHECK, "decap security check failed") \ 288 _(ICMP, "unable to translate ICMP") \ 289 _(ICMP_RELAY, "unable to relay ICMP") \ 290 _(UNKNOWN, "unknown") \ 291 _(NO_BINDING, "no binding") \ 292 _(NO_DOMAIN, "no domain") \ 293 _(FRAGMENTED, "packet is a fragment") \ 294 _(FRAGMENT_MEMORY, "could not cache fragment") \ 295 _(FRAGMENT_MALFORMED, "fragment has unexpected format")\ 296 _(FRAGMENT_DROPPED, "dropped cached fragment") \ 297 _(MALFORMED, "malformed packet") \ 298 _(DF_SET, "can't fragment, DF set") 301 #define _(sym,str) MAP_ERROR_##sym, 338 return clib_net_to_host_u64(d->
rules[psid].
as_u64[0]);
349 return clib_host_to_net_u64(
map_get_pfx(d, clib_net_to_host_u32(addr),
350 clib_net_to_host_u16(port)));
363 return clib_net_to_host_u64(d->
rules[psid].
as_u64[1]);
372 return ((
u64) addr << 16) | psid;
378 return clib_host_to_net_u64(
map_get_sfx(d, clib_net_to_host_u32(addr),
379 clib_net_to_host_u16(port)));
385 return clib_host_to_net_u32(clib_net_to_host_u64(addr->
as_u64[1]) >> 16);
393 u32 *map_domain_index)
412 u32 *map_domain_index,
u8 *error)
421 #ifdef MAP_NONSHARED_DOMAIN_ENABLED 426 if (*map_domain_index != ~0)
439 *error = MAP_ERROR_NO_DOMAIN;
445 u8 protocol,
u32 **pi_to_drop);
449 #define map_ip4_reass_lock() while (__sync_lock_test_and_set(map_main.ip4_reass_lock, 1)) {} 450 #define map_ip4_reass_unlock() do {CLIB_MEMORY_BARRIER(); *map_main.ip4_reass_lock = 0;} while(0) 468 u8 protocol,
u32 **pi_to_drop);
472 #define map_ip6_reass_lock() while (__sync_lock_test_and_set(map_main.ip6_reass_lock, 1)) {} 473 #define map_ip6_reass_unlock() do {CLIB_MEMORY_BARRIER(); *map_main.ip6_reass_lock = 0;} while(0) 477 u16 data_offset,
u16 next_data_offset,
478 u8 *data_start,
u16 data_len);
483 #define MAP_IP4_REASS_CONF_HT_RATIO_MAX 100 485 #define MAP_IP4_REASS_CONF_POOL_SIZE_MAX (0xfeff) 487 #define MAP_IP4_REASS_CONF_LIFETIME_MAX 0xffff 489 #define MAP_IP4_REASS_CONF_BUFFERS_MAX (0xffffffff) 495 #define MAP_IP6_REASS_CONF_HT_RATIO_MAX 100 497 #define MAP_IP6_REASS_CONF_POOL_SIZE_MAX (0xfeff) 499 #define MAP_IP6_REASS_CONF_LIFETIME_MAX 0xffff 501 #define MAP_IP6_REASS_CONF_BUFFERS_MAX (0xffffffff) 505 u8 *l4_protocol,
u16 *l4_offset,
u16 *frag_hdr_offset)
507 if (ip6->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION) {
508 *l4_protocol = ((ip6_frag_hdr_t *)(ip6 + 1))->next_hdr;
509 *frag_hdr_offset =
sizeof(*ip6);
510 *l4_offset =
sizeof(*ip6) +
sizeof(ip6_frag_hdr_t);
513 *frag_hdr_offset = 0;
514 *l4_offset =
sizeof(*ip6);
517 return (buff_len < (*l4_offset + 4)) ||
518 (clib_net_to_host_u16(ip6->
payload_length) < (*l4_offset + 4 -
sizeof(*ip6)));
522 #define u8_ptr_add(ptr, index) (((u8 *)ptr) + index) 523 #define u16_net_add(u, val) clib_host_to_net_u16(clib_net_to_host_u16(u) + (val)) 525 #define frag_id_6to4(id) ((id) ^ ((id) >> 16)) 564 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
567 n_left_from =
vec_len(pi_vector);
569 while (n_left_from > 0) {
571 while (n_left_from > 0 && n_left_to_next > 0) {
572 u32 pi0 = to_next[0] = from[0];
static map_dpo_t * map_dpo_get(index_t index)
map_ip6_reass_t * map_ip6_reass_get(ip6_address_t *src, ip6_address_t *dst, u32 fragment_id, u8 protocol, u32 **pi_to_drop)
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.
i32 ip4_get_port(ip4_header_t *ip, map_dir_e dir, u16 buffer_len)
map_ip4_reass_t * ip4_reass_pool
int map_ip4_reass_add_fragment(map_ip4_reass_t *r, u32 pi)
u32 ip4_reass_conf_buffers
sll srl srl sll sra u16x4 i
vlib_node_registration_t ip4_map_t_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_node)
static_always_inline u64 map_get_pfx(map_domain_t *d, u32 addr, u16 port)
volatile u32 * ip6_reass_lock
volatile u32 * counter_lock
u32 fragments[MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY]
vlib_node_registration_t ip4_map_t_icmp_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_icmp_node)
int map_ip4_reass_conf_buffers(u32 buffers)
static_always_inline int ip6_parse(const ip6_header_t *ip6, u32 buff_len, u8 *l4_protocol, u16 *l4_offset, u16 *frag_hdr_offset)
int map_ip6_reass_conf_lifetime(u16 lifetime_ms)
int map_ip4_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void map_domain_counter_unlock(map_main_t *mm)
struct _vlib_node_registration vlib_node_registration_t
u32 ip4_reass_buffered_counter
ip6_address_t preresolve_ip6
map_ip6_reass_t * ip6_reass_pool
ip4_address_t preresolve_ip4
vlib_node_registration_t ip6_map_t_tcp_udp_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_tcp_udp_node)
static_always_inline void ip4_map_t_embedded_address(map_domain_t *d, ip6_address_t *ip6, const ip4_address_t *ip4)
#define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
static_always_inline u32 ip6_map_t_embedded_address(map_domain_t *d, ip6_address_t *addr)
#define static_always_inline
vlib_combined_counter_main_t * domain_counters
ip4_address_t icmp4_src_address
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)
vlib_simple_counter_main_t icmp_relayed
int map_ip4_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
int map_ip6_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
A collection of simple counters.
int map_ip6_reass_conf_buffers(u32 buffers)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
map_ip4_reass_t * map_ip4_reass_get(u32 src, u32 dst, u16 fragment_id, u8 protocol, u32 **pi_to_drop)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
int map_create_domain(ip4_address_t *ip4_prefix, u8 ip4_prefix_len, ip6_address_t *ip6_prefix, u8 ip6_prefix_len, ip6_address_t *ip6_src, u8 ip6_src_len, u8 ea_bits_len, u8 psid_offset, u8 psid_length, u32 *map_domain_index, u16 mtu, u8 flags)
dpo_type_t dpoi_type
the type
volatile u32 * ip4_reass_lock
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
static_always_inline map_domain_t * ip6_map_get_domain(u32 mdi, ip4_address_t *addr, u32 *map_domain_index, u8 *error)
u16 ip4_reass_conf_pool_size
int map_ip6_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
static_always_inline u64 map_get_sfx_net(map_domain_t *d, u32 addr, u16 port)
u16 * ip6_reass_hash_table
u16 * ip4_reass_hash_table
#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).
dpo_type_t map_dpo_type
The register MAP DPO type.
const dpo_id_t * load_balance_get_bucket(index_t lbi, u32 bucket)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
vlib_node_registration_t ip4_map_t_tcp_udp_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_tcp_udp_node)
vlib_node_registration_t ip4_map_t_fragmented_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_fragmented_node)
u16 ip6_reass_conf_pool_size
void map_ip4_drop_pi(u32 pi)
static_always_inline void map_ip4_reass_get_fragments(map_ip4_reass_t *r, u32 **pi)
vlib_node_registration_t ip6_map_t_icmp_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_icmp_node)
void map_ip6_reass_free(map_ip6_reass_t *r, u32 **pi_to_drop)
#define foreach_map_error
static void map_domain_counter_lock(map_main_t *mm)
f32 ip4_reass_conf_ht_ratio
A representation of a MAP DPO.
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
vlib_node_registration_t ip6_map_node
(constructor) VLIB_REGISTER_NODE (ip6_map_node)
STATIC_ASSERT((sizeof(map_domain_t)<=CLIB_CACHE_LINE_BYTES),"MAP domain fits in one cacheline")
static index_t ip4_fib_forwarding_lookup(u32 fib_index, const ip4_address_t *addr)
u16 ip4_map_get_port(ip4_header_t *ip, map_dir_e dir)
void map_ip6_drop_pi(u32 pi)
f32 ip6_reass_conf_ht_ratio
u8 * format_map_trace(u8 *s, va_list *args)
i32 ip6_get_port(ip6_header_t *ip6, map_dir_e dir, u16 buffer_len)
index_t dpoi_index
the index of objects of that type
static_always_inline u32 map_get_ip4(ip6_address_t *addr)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u16 ip6_reass_conf_lifetime_ms
dpo_type_t map_t_dpo_type
A collection of combined counters.
static_always_inline map_domain_t * ip4_map_get_domain(u32 mdi, u32 *map_domain_index)
vlib_simple_counter_main_t * simple_domain_counters
u64 map_error_counter_get(u32 node_index, map_error_t map_error)
#define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
void map_ip4_reass_free(map_ip4_reass_t *r, u32 **pi_to_drop)
u16 ip4_reass_conf_lifetime_ms
int map_delete_domain(u32 map_domain_index)
static_always_inline u64 map_get_sfx(map_domain_t *d, u32 addr, u16 port)
int map_add_del_psid(u32 map_domain_index, u16 psid, ip6_address_t *tep, u8 is_add)
int map_ip4_reass_conf_lifetime(u16 lifetime_ms)
vlib_node_registration_t ip6_map_t_fragmented_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_fragmented_node)
vlib_node_registration_t ip6_map_t_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_node)
u32 ip6_reass_buffered_counter
#define CLIB_CACHE_LINE_BYTES
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
int map_ip6_reass_add_fragment(map_ip6_reass_t *r, u32 pi, u16 data_offset, u16 next_data_offset, u8 *data_start, u16 data_len)
u32 ip6_reass_conf_buffers
u32 md_domain
the MAP domain index