aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/map/map_api.c
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 /src/plugins/map/map_api.c
parentceebc1e71598349ee37b25cd82fe7533760d670a (diff)
MAP: Prevent duplicate MAP-E/T graph nodes.
Change-Id: I6031f3f9cfa048a901a8424d33d47679115c2eb3 Signed-off-by: Jon Loeliger <jdl@netgate.com>
Diffstat (limited to 'src/plugins/map/map_api.c')
-rw-r--r--src/plugins/map/map_api.c28
1 files changed, 28 insertions, 0 deletions
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;
}