X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fmap%2Fmap.h;h=b9b3353dd2e2318601b33056c6c01c13c96a156f;hb=71612d61930e57e7c8ebf9e5647b15a4b23720b2;hp=f446b739a931b040770b89afe6739b27e30c3e74;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vnet/map/map.h b/src/vnet/map/map.h index f446b739a93..b9b3353dd2e 100644 --- a/src/vnet/map/map.h +++ b/src/vnet/map/map.h @@ -25,12 +25,6 @@ #define MAP_SKIP_IP6_LOOKUP 1 -typedef enum -{ - MAP_SENDER, - MAP_RECEIVER -} map_dir_e; - 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, @@ -40,9 +34,6 @@ int map_delete_domain (u32 map_domain_index); int map_add_del_psid (u32 map_domain_index, u16 psid, ip6_address_t * tep, u8 is_add); u8 *format_map_trace (u8 * s, va_list * args); -i32 ip4_get_port (ip4_header_t * ip, map_dir_e dir, u16 buffer_len); -i32 ip6_get_port (ip6_header_t * ip6, map_dir_e dir, u16 buffer_len); -u16 ip4_map_get_port (ip4_header_t * ip, map_dir_e dir); typedef enum __attribute__ ((__packed__)) { @@ -198,6 +189,40 @@ typedef struct { map_ip6_fragment_t fragments[MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY]; } map_ip6_reass_t; +#ifdef MAP_SKIP_IP6_LOOKUP +/** + * A pre-resolved next-hop + */ +typedef struct map_main_pre_resolved_t_ +{ + /** + * Linkage into the FIB graph + */ + fib_node_t node; + + /** + * The FIB entry index of the next-hop + */ + fib_node_index_t fei; + + /** + * This object sibling index on the FIB entry's child dependency list + */ + u32 sibling; + + /** + * The Load-balance object index to use to forward + */ + dpo_id_t dpo; +} map_main_pre_resolved_t; + +/** + * Pre-resolved next hops for v4 and v6. Why these are global and not + * per-domain is beyond me. + */ +extern map_main_pre_resolved_t pre_resolved[FIB_PROTOCOL_MAX]; +#endif + typedef struct { /* pool of MAP domains */ map_domain_t *domains; @@ -207,13 +232,6 @@ typedef struct { vlib_combined_counter_main_t *domain_counters; volatile u32 *counter_lock; -#ifdef MAP_SKIP_IP6_LOOKUP - /* pre-presolve */ - u32 adj6_index, adj4_index; - ip4_address_t preresolve_ip4; - ip6_address_t preresolve_ip6; -#endif - /* Traffic class: zero, copy (~0) or fixed value */ u8 tc; bool tc_copy; @@ -311,7 +329,7 @@ typedef struct { u16 port; } map_trace_t; -map_main_t map_main; +extern map_main_t map_main; extern vlib_node_registration_t ip4_map_node; extern vlib_node_registration_t ip6_map_node; @@ -389,17 +407,11 @@ map_get_ip4 (ip6_address_t *addr) * Get the MAP domain from an IPv4 lookup adjacency. */ static_always_inline map_domain_t * -ip4_map_get_domain (u32 mdi, - u32 *map_domain_index) +ip4_map_get_domain (u32 mdi) { map_main_t *mm = &map_main; - map_dpo_t *md; - - md = map_dpo_get(mdi); - ASSERT(md); - *map_domain_index = md->md_domain; - return pool_elt_at_index(mm->domains, *map_domain_index); + return pool_elt_at_index(mm->domains, mdi); } /* @@ -408,23 +420,21 @@ ip4_map_get_domain (u32 mdi, * The IPv4 address is used otherwise. */ static_always_inline map_domain_t * -ip6_map_get_domain (u32 mdi, ip4_address_t *addr, - u32 *map_domain_index, u8 *error) +ip6_map_get_domain (u32 mdi, + ip4_address_t *addr, + u32 *map_domain_index, + u8 *error) { map_main_t *mm = &map_main; - map_dpo_t *md; /* * Disable direct MAP domain lookup on decap, until the security check is updated to verify IPv4 SA. * (That's done implicitly when MAP domain is looked up in the IPv4 FIB) */ #ifdef MAP_NONSHARED_DOMAIN_ENABLED - md = map_dpo_get(mdi); - - ASSERT(md); - *map_domain_index = md->md_domain; - if (*map_domain_index != ~0) - return pool_elt_at_index(mm->domains, *map_domain_index); +#error "How can you be sure this domain is not shared?" + *map_domain_index = mdi; + return pool_elt_at_index(mm->domains, mdi); #endif u32 lbi = ip4_fib_forwarding_lookup(0, addr); @@ -432,8 +442,7 @@ ip6_map_get_domain (u32 mdi, ip4_address_t *addr, if (PREDICT_TRUE(dpo->dpoi_type == map_dpo_type || dpo->dpoi_type == map_t_dpo_type)) { - md = map_dpo_get(dpo->dpoi_index); - *map_domain_index = md->md_domain; + *map_domain_index = dpo->dpoi_index; return pool_elt_at_index(mm->domains, *map_domain_index); } *error = MAP_ERROR_NO_DOMAIN; @@ -500,30 +509,10 @@ int map_ip6_reass_conf_lifetime(u16 lifetime_ms); int map_ip6_reass_conf_buffers(u32 buffers); #define MAP_IP6_REASS_CONF_BUFFERS_MAX (0xffffffff) -static_always_inline -int ip6_parse(const ip6_header_t *ip6, u32 buff_len, - u8 *l4_protocol, u16 *l4_offset, u16 *frag_hdr_offset) -{ - if (ip6->protocol == IP_PROTOCOL_IPV6_FRAGMENTATION) { - *l4_protocol = ((ip6_frag_hdr_t *)(ip6 + 1))->next_hdr; - *frag_hdr_offset = sizeof(*ip6); - *l4_offset = sizeof(*ip6) + sizeof(ip6_frag_hdr_t); - } else { - *l4_protocol = ip6->protocol; - *frag_hdr_offset = 0; - *l4_offset = sizeof(*ip6); - } - - return (buff_len < (*l4_offset + 4)) || - (clib_net_to_host_u16(ip6->payload_length) < (*l4_offset + 4 - sizeof(*ip6))); -} - #define u8_ptr_add(ptr, index) (((u8 *)ptr) + index) #define u16_net_add(u, val) clib_host_to_net_u16(clib_net_to_host_u16(u) + (val)) -#define frag_id_6to4(id) ((id) ^ ((id) >> 16)) - static_always_inline void ip4_map_t_embedded_address (map_domain_t *d, ip6_address_t *ip6, const ip4_address_t *ip4)