summaryrefslogtreecommitdiffstats
path: root/src/vnet/map/map.c
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2017-12-19 20:57:48 +0100
committerOle Trøan <otroan@employees.org>2018-01-11 09:34:35 +0000
commit0ae15ed43aaa600a75ca4c154bc62478820c00b4 (patch)
tree572c7433f53622d2de6d7979cd6448e02fc1d9ae /src/vnet/map/map.c
parentc5c6a3342f3cbaaac647d52fd960b6f5b0fcd4e0 (diff)
Add support for MAP-T CE (VPP-1058)
Change-Id: Ib99058323c50f20fcdb44185aee027c5c6ef8c91 Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Diffstat (limited to 'src/vnet/map/map.c')
-rw-r--r--src/vnet/map/map.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/vnet/map/map.c b/src/vnet/map/map.c
index b2eefee9bb2..702b5f80e52 100644
--- a/src/vnet/map/map.c
+++ b/src/vnet/map/map.c
@@ -106,7 +106,8 @@ map_create_domain (ip4_address_t * ip4_prefix,
/* How many, and which bits to grab from the IPv4 DA */
if (ip4_prefix_len + ea_bits_len < 32)
{
- flags |= MAP_DOMAIN_PREFIX;
+ if (!(flags & MAP_DOMAIN_TRANSLATION))
+ flags |= MAP_DOMAIN_PREFIX;
suffix_shift = 32 - ip4_prefix_len - ea_bits_len;
suffix_len = ea_bits_len;
}
@@ -126,6 +127,12 @@ map_create_domain (ip4_address_t * ip4_prefix,
return -1;
}
+ if (mm->is_ce && !(flags & MAP_DOMAIN_TRANSLATION))
+ {
+ clib_warning ("MAP-E CE is not supported yet");
+ return -1;
+ }
+
/* Get domain index */
pool_get_aligned (mm->domains, d, CLIB_CACHE_LINE_BYTES);
memset (d, 0, sizeof (*d));
@@ -157,11 +164,23 @@ map_create_domain (ip4_address_t * ip4_prefix,
map_dpo_create (DPO_PROTO_IP4, *map_domain_index, &dpo_v4);
/* Create ip4 route */
+ u8 ip4_pfx_len;
+ ip4_address_t ip4_pfx;
+ if (mm->is_ce)
+ {
+ ip4_pfx_len = 0;
+ ip4_pfx.as_u32 = 0;
+ }
+ else
+ {
+ ip4_pfx_len = d->ip4_prefix_len;
+ ip4_pfx = d->ip4_prefix;
+ }
fib_prefix_t pfx = {
.fp_proto = FIB_PROTOCOL_IP4,
- .fp_len = d->ip4_prefix_len,
+ .fp_len = ip4_pfx_len,
.fp_addr = {
- .ip4 = d->ip4_prefix,
+ .ip4 = ip4_pfx,
}
,
};
@@ -187,10 +206,22 @@ map_create_domain (ip4_address_t * ip4_prefix,
* already exists and is MAP sourced, it is now MAP source n+1 times
* and will need to be removed n+1 times.
*/
+ u8 ip6_pfx_len;
+ ip6_address_t ip6_pfx;
+ if (mm->is_ce)
+ {
+ ip6_pfx_len = d->ip6_prefix_len;
+ ip6_pfx = d->ip6_prefix;
+ }
+ else
+ {
+ ip6_pfx_len = d->ip6_src_len;
+ ip6_pfx = d->ip6_src;
+ }
fib_prefix_t pfx6 = {
.fp_proto = FIB_PROTOCOL_IP6,
- .fp_len = d->ip6_src_len,
- .fp_addr.ip6 = d->ip6_src,
+ .fp_len = ip6_pfx_len,
+ .fp_addr.ip6 = ip6_pfx,
};
fib_table_entry_special_dpo_add (0, &pfx6,
@@ -2146,7 +2177,7 @@ VLIB_CLI_COMMAND(map_add_domain_command, static) = {
.path = "map add domain",
.short_help = "map add domain ip4-pfx <ip4-pfx> ip6-pfx <ip6-pfx> "
"ip6-src <ip6-pfx> ea-bits-len <n> psid-offset <n> psid-len <n> "
- "[map-t] [mtu <mtu>]",
+ "[map-t] [map-ce] [mtu <mtu>]",
.function = map_add_domain_command_fn,
};
@@ -2216,6 +2247,28 @@ VLIB_CLI_COMMAND(show_map_fragments_command, static) = {
};
/* *INDENT-ON* */
+static clib_error_t *
+map_config (vlib_main_t * vm, unformat_input_t * input)
+{
+ map_main_t *mm = &map_main;
+ u8 is_ce = false;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "customer edge"))
+ is_ce = true;
+ else
+ return clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, input);
+ }
+
+ mm->is_ce = is_ce;
+
+ return 0;
+}
+
+VLIB_CONFIG_FUNCTION (map_config, "map");
+
/*
* map_init
*/
@@ -2246,6 +2299,8 @@ map_init (vlib_main_t * vm)
/* ICMP6 Type 1, Code 5 for security check failure */
mm->icmp6_enabled = false;
+ mm->is_ce = false;
+
/* Inner or outer fragmentation */
mm->frag_inner = false;
mm->frag_ignore_df = false;