summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2019-01-03 17:12:59 -0600
committerOle Trøan <otroan@employees.org>2019-01-07 21:30:11 +0000
commit2500c79423c7d8d35b4e7b8f50060c09f2f857be (patch)
treeec443acb90a8b5d0a738e84ec2aee393b31513dd
parentceebc1e71598349ee37b25cd82fe7533760d670a (diff)
MAP: Prevent duplicate MAP-E/T graph nodes.
Change-Id: I6031f3f9cfa048a901a8424d33d47679115c2eb3 Signed-off-by: Jon Loeliger <jdl@netgate.com>
-rw-r--r--src/plugins/map/map.c3
-rw-r--r--src/plugins/map/map.h4
-rw-r--r--src/plugins/map/map_api.c28
3 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/map/map.c b/src/plugins/map/map.c
index 1ce3b6faeec..6b15ee1919e 100644
--- a/src/plugins/map/map.c
+++ b/src/plugins/map/map.c
@@ -2256,6 +2256,9 @@ map_init (vlib_main_t * vm)
mm->ip6_prefix_tbl = lpm_table_init (LPM_TYPE_KEY128);
mm->ip6_src_prefix_tbl = lpm_table_init (LPM_TYPE_KEY128);
+ mm->bm_trans_enabled_by_sw_if = 0;
+ mm->bm_encap_enabled_by_sw_if = 0;
+
error = map_plugin_api_hookup (vm);
return error;
diff --git a/src/plugins/map/map.h b/src/plugins/map/map.h
index 2169435bc09..22ab7193ab4 100644
--- a/src/plugins/map/map.h
+++ b/src/plugins/map/map.h
@@ -321,6 +321,10 @@ typedef struct {
/* Counters */
u32 ip6_reass_buffered_counter;
+ /* Graph node state */
+ uword *bm_trans_enabled_by_sw_if;
+ uword *bm_encap_enabled_by_sw_if;
+
/* Lookup tables */
lpm_t *ip4_prefix_tbl;
lpm_t *ip6_prefix_tbl;
diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c
index 1b8ffc72a6a..b4f1467d1ac 100644
--- a/src/plugins/map/map_api.c
+++ b/src/plugins/map/map_api.c
@@ -600,12 +600,36 @@ vl_api_map_param_get_t_handler (vl_api_map_param_get_t * mp)
int
map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation)
{
+ map_main_t *mm = &map_main;
+
+ if (pool_is_free_index (mm->vnet_main->interface_main.sw_interfaces,
+ sw_if_index))
+ return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+
+ is_enable = ! !is_enable;
+
+ if (is_translation)
+ {
+ if (clib_bitmap_get (mm->bm_trans_enabled_by_sw_if, sw_if_index)
+ == is_enable)
+ return 0;
+ }
+ else
+ {
+ if (clib_bitmap_get (mm->bm_encap_enabled_by_sw_if, sw_if_index)
+ == is_enable)
+ return 0;
+ }
+
if (is_translation == false)
{
vnet_feature_enable_disable ("ip4-unicast", "ip4-map", sw_if_index,
is_enable ? 1 : 0, 0, 0);
vnet_feature_enable_disable ("ip6-unicast", "ip6-map", sw_if_index,
is_enable ? 1 : 0, 0, 0);
+ mm->bm_encap_enabled_by_sw_if =
+ clib_bitmap_set (mm->bm_encap_enabled_by_sw_if, sw_if_index,
+ is_enable);
}
else
{
@@ -613,7 +637,11 @@ map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation)
is_enable ? 1 : 0, 0, 0);
vnet_feature_enable_disable ("ip6-unicast", "ip6-map-t", sw_if_index,
is_enable ? 1 : 0, 0, 0);
+ mm->bm_trans_enabled_by_sw_if =
+ clib_bitmap_set (mm->bm_trans_enabled_by_sw_if, sw_if_index,
+ is_enable);
}
+
return 0;
}