summaryrefslogtreecommitdiffstats
path: root/src/vnet/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/map')
-rw-r--r--src/vnet/map/ip4_map.c20
-rw-r--r--src/vnet/map/ip4_map_t.c15
-rw-r--r--src/vnet/map/map.c52
-rw-r--r--src/vnet/map/map.h29
-rw-r--r--src/vnet/map/map_dpo.c69
-rw-r--r--src/vnet/map/map_dpo.h24
6 files changed, 42 insertions, 167 deletions
diff --git a/src/vnet/map/ip4_map.c b/src/vnet/map/ip4_map.c
index 2be9ad37e72..1a20d704732 100644
--- a/src/vnet/map/ip4_map.c
+++ b/src/vnet/map/ip4_map.c
@@ -293,12 +293,10 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
p1 = vlib_get_buffer (vm, pi1);
ip40 = vlib_buffer_get_current (p0);
ip41 = vlib_buffer_get_current (p1);
- d0 =
- ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
- &map_domain_index0);
- d1 =
- ip4_map_get_domain (vnet_buffer (p1)->ip.adj_index[VLIB_TX],
- &map_domain_index1);
+ map_domain_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
+ d0 = ip4_map_get_domain (map_domain_index0);
+ map_domain_index1 = vnet_buffer (p1)->ip.adj_index[VLIB_TX];
+ d1 = ip4_map_get_domain (map_domain_index1);
ASSERT (d0);
ASSERT (d1);
@@ -464,9 +462,8 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
p0 = vlib_get_buffer (vm, pi0);
ip40 = vlib_buffer_get_current (p0);
- d0 =
- ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
- &map_domain_index0);
+ map_domain_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
+ d0 = ip4_map_get_domain (map_domain_index0);
ASSERT (d0);
/*
@@ -597,9 +594,8 @@ ip4_map_reass (vlib_main_t * vm,
p0 = vlib_get_buffer (vm, pi0);
ip60 = vlib_buffer_get_current (p0);
ip40 = (ip4_header_t *) (ip60 + 1);
- d0 =
- ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
- &map_domain_index0);
+ map_domain_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
+ d0 = ip4_map_get_domain (map_domain_index0);
map_ip4_reass_lock ();
map_ip4_reass_t *r = map_ip4_reass_get (ip40->src_address.as_u32,
diff --git a/src/vnet/map/ip4_map_t.c b/src/vnet/map/ip4_map_t.c
index 15974d8a46e..b63d76bf4f4 100644
--- a/src/vnet/map/ip4_map_t.c
+++ b/src/vnet/map/ip4_map_t.c
@@ -1100,10 +1100,12 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
next1 = IP4_MAPT_NEXT_DROP;
}
- d0 = ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
- &vnet_buffer (p0)->map_t.map_domain_index);
- d1 = ip4_map_get_domain (vnet_buffer (p1)->ip.adj_index[VLIB_TX],
- &vnet_buffer (p1)->map_t.map_domain_index);
+ vnet_buffer (p0)->map_t.map_domain_index =
+ vnet_buffer (p0)->ip.adj_index[VLIB_TX];
+ d0 = ip4_map_get_domain (vnet_buffer (p0)->map_t.map_domain_index);
+ vnet_buffer (p1)->map_t.map_domain_index =
+ vnet_buffer (p1)->ip.adj_index[VLIB_TX];
+ d1 = ip4_map_get_domain (vnet_buffer (p1)->map_t.map_domain_index);
vnet_buffer (p0)->map_t.mtu = d0->mtu ? d0->mtu : ~0;
vnet_buffer (p1)->map_t.mtu = d1->mtu ? d1->mtu : ~0;
@@ -1213,8 +1215,9 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
next0 = IP4_MAPT_NEXT_DROP;
}
- d0 = ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
- &vnet_buffer (p0)->map_t.map_domain_index);
+ vnet_buffer (p0)->map_t.map_domain_index =
+ vnet_buffer (p0)->ip.adj_index[VLIB_TX];
+ d0 = ip4_map_get_domain (vnet_buffer (p0)->map_t.map_domain_index);
vnet_buffer (p0)->map_t.mtu = d0->mtu ? d0->mtu : ~0;
diff --git a/src/vnet/map/map.c b/src/vnet/map/map.c
index 99305afaf41..811a0abc040 100644
--- a/src/vnet/map/map.c
+++ b/src/vnet/map/map.c
@@ -177,7 +177,6 @@ map_create_domain (ip4_address_t * ip4_prefix,
map_main_t *mm = &map_main;
dpo_id_t dpo_v4 = DPO_INVALID;
dpo_id_t dpo_v6 = DPO_INVALID;
- fib_node_index_t fei;
map_domain_t *d;
/* Sanity check on the src prefix length */
@@ -268,57 +267,28 @@ map_create_domain (ip4_address_t * ip4_prefix,
dpo_reset (&dpo_v4);
/*
- * Multiple MAP domains may share same source IPv6 TEP.
- * In this case the route will exist and be MAP sourced.
- * Find the adj (if any) already contributed and modify it
+ * construct a DPO to use the v6 domain
*/
- fib_prefix_t pfx6 = {
- .fp_proto = FIB_PROTOCOL_IP6,
- .fp_len = d->ip6_src_len,
- .fp_addr = {
- .ip6 = d->ip6_src,
- }
- ,
- };
- fei = fib_table_lookup_exact_match (0, &pfx6);
-
- if (FIB_NODE_INDEX_INVALID != fei)
- {
- dpo_id_t dpo = DPO_INVALID;
-
- if (fib_entry_get_dpo_for_source (fei, FIB_SOURCE_MAP, &dpo))
- {
- /*
- * modify the existing MAP to indicate it's shared
- * skip to route add.
- */
- const dpo_id_t *md_dpo;
- map_dpo_t *md;
-
- ASSERT (DPO_LOAD_BALANCE == dpo.dpoi_type);
-
- md_dpo = load_balance_get_bucket (dpo.dpoi_index, 0);
- md = map_dpo_get (md_dpo->dpoi_index);
-
- md->md_domain = ~0;
- dpo_copy (&dpo_v6, md_dpo);
- dpo_reset (&dpo);
-
- goto route_add;
- }
- }
-
if (d->flags & MAP_DOMAIN_TRANSLATION)
map_t_dpo_create (DPO_PROTO_IP6, *map_domain_index, &dpo_v6);
else
map_dpo_create (DPO_PROTO_IP6, *map_domain_index, &dpo_v6);
-route_add:
/*
+ * Multiple MAP domains may share same source IPv6 TEP. Which is just dandy.
+ * We are not tracking the sharing. So a v4 lookup to find the correct
+ * domain post decap/trnaslate is always done
+ *
* Create ip6 route. This is a reference counted add. If the prefix
* already exists and is MAP sourced, it is now MAP source n+1 times
* and will need to be removed n+1 times.
*/
+ fib_prefix_t pfx6 = {
+ .fp_proto = FIB_PROTOCOL_IP6,
+ .fp_len = d->ip6_src_len,
+ .fp_addr.ip6 = d->ip6_src,
+ };
+
fib_table_entry_special_dpo_add (0, &pfx6,
FIB_SOURCE_MAP,
FIB_ENTRY_FLAG_EXCLUSIVE, &dpo_v6);
diff --git a/src/vnet/map/map.h b/src/vnet/map/map.h
index 616d42c027a..644e80f56cf 100644
--- a/src/vnet/map/map.h
+++ b/src/vnet/map/map.h
@@ -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;
diff --git a/src/vnet/map/map_dpo.c b/src/vnet/map/map_dpo.c
index df2b5fa4197..430c1fbf266 100644
--- a/src/vnet/map/map_dpo.c
+++ b/src/vnet/map/map_dpo.c
@@ -17,48 +17,20 @@
#include <vnet/map/map_dpo.h>
/**
- * pool of all MPLS Label DPOs
- */
-map_dpo_t *map_dpo_pool;
-
-/**
* The register MAP DPO type
*/
dpo_type_t map_dpo_type;
dpo_type_t map_t_dpo_type;
-static map_dpo_t *
-map_dpo_alloc (void)
-{
- map_dpo_t *md;
-
- pool_get_aligned(map_dpo_pool, md, CLIB_CACHE_LINE_BYTES);
- memset(md, 0, sizeof(*md));
-
- return (md);
-}
-
-static index_t
-map_dpo_get_index (map_dpo_t *md)
-{
- return (md - map_dpo_pool);
-}
-
void
map_dpo_create (dpo_proto_t dproto,
u32 domain_index,
dpo_id_t *dpo)
{
- map_dpo_t *md;
-
- md = map_dpo_alloc();
- md->md_domain = domain_index;
- md->md_proto = dproto;
-
dpo_set(dpo,
map_dpo_type,
dproto,
- map_dpo_get_index(md));
+ domain_index);
}
void
@@ -66,16 +38,10 @@ map_t_dpo_create (dpo_proto_t dproto,
u32 domain_index,
dpo_id_t *dpo)
{
- map_dpo_t *md;
-
- md = map_dpo_alloc();
- md->md_domain = domain_index;
- md->md_proto = dproto;
-
dpo_set(dpo,
map_t_dpo_type,
dproto,
- map_dpo_get_index(md));
+ domain_index);
}
@@ -84,14 +50,8 @@ format_map_dpo (u8 *s, va_list *args)
{
index_t index = va_arg (*args, index_t);
CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
- map_dpo_t *md;
-
- md = map_dpo_get(index);
- return (format(s, "map:[%d]:%U domain:%d",
- index,
- format_dpo_proto, md->md_proto,
- md->md_domain));
+ return (format(s, "map: domain:%d", index));
}
u8*
@@ -99,40 +59,19 @@ format_map_t_dpo (u8 *s, va_list *args)
{
index_t index = va_arg (*args, index_t);
CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
- map_dpo_t *md;
-
- md = map_dpo_get(index);
- return (format(s, "map-t:[%d]:%U domain:%d",
- index,
- format_dpo_proto, md->md_proto,
- md->md_domain));
+ return (format(s, "map-t: domain:%d", index));
}
static void
map_dpo_lock (dpo_id_t *dpo)
{
- map_dpo_t *md;
-
- md = map_dpo_get(dpo->dpoi_index);
-
- md->md_locks++;
}
static void
map_dpo_unlock (dpo_id_t *dpo)
{
- map_dpo_t *md;
-
- md = map_dpo_get(dpo->dpoi_index);
-
- md->md_locks--;
-
- if (0 == md->md_locks)
- {
- pool_put(map_dpo_pool, md);
- }
}
const static dpo_vft_t md_vft = {
diff --git a/src/vnet/map/map_dpo.h b/src/vnet/map/map_dpo.h
index be510dbaea6..63bf4787383 100644
--- a/src/vnet/map/map_dpo.h
+++ b/src/vnet/map/map_dpo.h
@@ -22,23 +22,6 @@
/**
* A representation of a MAP DPO
*/
-typedef struct map_dpo_t
-{
- /**
- * The dat-plane protocol
- */
- dpo_proto_t md_proto;
-
- /**
- * the MAP domain index
- */
- u32 md_domain;
-
- /**
- * Number of locks/users of the label
- */
- u16 md_locks;
-} map_dpo_t;
extern void map_dpo_create (dpo_proto_t dproto,
u32 domain_index,
@@ -52,16 +35,9 @@ extern u8* format_map_dpo(u8 *s, va_list *args);
/*
* Encapsulation violation for fast data-path access
*/
-extern map_dpo_t *map_dpo_pool;
extern dpo_type_t map_dpo_type;
extern dpo_type_t map_t_dpo_type;
-static inline map_dpo_t *
-map_dpo_get (index_t index)
-{
- return (pool_elt_at_index(map_dpo_pool, index));
-}
-
extern void map_dpo_module_init(void);
#endif