MAP - add the domain struct directly into the dat-path and avoid the indirectiob...
[vpp.git] / src / vnet / map / map.h
index 616d42c..644e80f 100644 (file)
@@ -416,17 +416,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);
 }
 
 /*
@@ -435,23 +429,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);
@@ -459,8 +451,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;