aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-05-30 15:57:40 +0200
committerChris Luke <chris_luke@cable.comcast.com>2016-05-31 18:50:39 +0000
commit58f886ab9a2dd8d3f5bdcb34fd1c4fde212ede97 (patch)
tree4217d71c4ea9abde14ecb82db201cf56fd04edbe
parent6a2e4392e9206fe4398e1ccdd431446097fc5503 (diff)
Add CLI/API for clearing all remote mappings
Change-Id: I5aef12d3a9c8daefff52e5f958c504f5d2ff9fd0 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--vnet/vnet/lisp-cp/control.c100
-rw-r--r--vnet/vnet/lisp-cp/control.h5
-rw-r--r--vpp-api-test/vat/api_format.c7
-rw-r--r--vpp/api/api.c4
-rw-r--r--vpp/api/vpe.api2
5 files changed, 90 insertions, 28 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c
index 7d545c56976..30d2a1afd41 100644
--- a/vnet/vnet/lisp-cp/control.c
+++ b/vnet/vnet/lisp-cp/control.c
@@ -366,11 +366,13 @@ lisp_add_del_negative_static_mapping (gid_address_t * deid,
* @param rlocs vector of remote locators
* @param action action for negative map-reply
* @param is_add add mapping if non-zero, delete otherwise
+ * @param del_all if set, delete all remote mappings
* @return return code
*/
int
vnet_lisp_add_del_remote_mapping (gid_address_t * deid, gid_address_t * seid,
- ip_address_t * rlocs, u8 action, u8 is_add)
+ ip_address_t * rlocs, u8 action, u8 is_add,
+ u8 del_all)
{
vnet_lisp_add_del_mapping_args_t _dm_args, * dm_args = &_dm_args;
vnet_lisp_add_del_mapping_args_t _sm_args, * sm_args = &_sm_args;
@@ -381,6 +383,9 @@ vnet_lisp_add_del_remote_mapping (gid_address_t * deid, gid_address_t * seid,
ip_address_t * dl;
int rc = -1;
+ if (del_all)
+ return vnet_lisp_clear_all_remote_mappings ();
+
memset (sm_args, 0, sizeof (sm_args[0]));
memset (dm_args, 0, sizeof (dm_args[0]));
memset (ls, 0, sizeof (ls[0]));
@@ -487,6 +492,50 @@ done:
return rc;
}
+int
+vnet_lisp_clear_all_remote_mappings (void)
+{
+ int rv = 0;
+ u32 mi, * map_indices = 0, * map_indexp;
+ lisp_cp_main_t * lcm = vnet_lisp_cp_get_main ();
+ vnet_lisp_add_del_mapping_args_t _dm_args, * dm_args = &_dm_args;
+ vnet_lisp_add_del_locator_set_args_t _ls, * ls = &_ls;
+
+ pool_foreach_index (mi, lcm->mapping_pool,
+ ({
+ vec_add1 (map_indices, mi);
+ }));
+
+ vec_foreach (map_indexp, map_indices)
+ {
+ mapping_t * map = pool_elt_at_index (lcm->mapping_pool, map_indexp[0]);
+ if (!map->local)
+ {
+ del_fwd_entry (lcm, 0, map_indexp[0]);
+
+ dm_args->is_add = 0;
+ gid_address_copy (&dm_args->deid, &map->eid);
+ dm_args->locator_set_index = map->locator_set_index;
+
+ /* delete mapping associated to fwd entry */
+ vnet_lisp_add_del_mapping (dm_args, 0);
+
+ ls->is_add = 0;
+ ls->local = 0;
+ ls->index = map->locator_set_index;
+ /* delete locator set */
+ rv = vnet_lisp_add_del_locator_set (ls, 0);
+ if (rv != 0)
+ goto cleanup;
+ }
+ }
+
+cleanup:
+ if (map_indices)
+ vec_free (map_indices);
+ return rv;
+}
+
/**
* Handler for add/del remote mapping CLI.
*
@@ -502,7 +551,7 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
{
clib_error_t * error = 0;
unformat_input_t _line_input, * line_input = &_line_input;
- u8 is_add = 1;
+ u8 is_add = 1, del_all = 0;
ip_address_t rloc, * rlocs = 0;
ip_prefix_t * deid_ippref, * seid_ippref;
gid_address_t seid, deid;
@@ -525,9 +574,11 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "del"))
+ if (unformat (line_input, "del-all"))
+ del_all = 1;
+ else if (unformat (line_input, "del"))
is_add = 0;
- if (unformat (line_input, "add"))
+ else if (unformat (line_input, "add"))
;
else if (unformat (line_input, "deid %U",
unformat_ip_prefix, deid_ippref))
@@ -567,30 +618,33 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
}
}
- if (!deid_set)
+ if (!del_all)
{
- clib_warning ("missing deid!");
- goto done;
- }
+ if (!deid_set)
+ {
+ clib_warning ("missing deid!");
+ goto done;
+ }
- if (is_add
- && (ip_prefix_version (deid_ippref)
- != ip_prefix_version (seid_ippref)))
- {
- clib_warning ("source and destination EIDs are not"
- " in the same IP family!");
- goto done;
- }
+ if (is_add
+ && (ip_prefix_version (deid_ippref)
+ != ip_prefix_version (seid_ippref)))
+ {
+ clib_warning ("source and destination EIDs are not"
+ " in the same IP family!");
+ goto done;
+ }
- if (is_add && (~0 == action)
- && 0 == vec_len (rlocs))
- {
- clib_warning ("no action set for negative map-reply!");
- goto done;
+ if (is_add && (~0 == action)
+ && 0 == vec_len (rlocs))
+ {
+ clib_warning ("no action set for negative map-reply!");
+ goto done;
+ }
}
int rv = vnet_lisp_add_del_remote_mapping (&deid, &seid, rlocs,
- action, is_add);
+ action, is_add, del_all);
if (rv)
clib_warning ("failed to %s remote mapping!",
is_add ? "add" : "delete");
@@ -604,7 +658,7 @@ done:
VLIB_CLI_COMMAND (lisp_add_del_remote_mapping_command) = {
.path = "lisp remote-mapping",
- .short_help = "lisp remote-mapping add|del vni <vni>"
+ .short_help = "lisp remote-mapping add|del [del-all] vni <vni>"
"deid <dest-eid> seid <src-eid> [action <no-action|natively-forward|"
"send-map-request|drop>] rloc <dst-locator> [rloc <dst-locator> ... ]",
.function = lisp_add_del_remote_mapping_command_fn,
diff --git a/vnet/vnet/lisp-cp/control.h b/vnet/vnet/lisp-cp/control.h
index fe5f5974821..a81dd2846b4 100644
--- a/vnet/vnet/lisp-cp/control.h
+++ b/vnet/vnet/lisp-cp/control.h
@@ -180,9 +180,12 @@ u8 vnet_lisp_enable_disable_status (void);
int
vnet_lisp_add_del_remote_mapping (gid_address_t * deid, gid_address_t * seid,
- ip_address_t * dlocs, u8 action, u8 is_add);
+ ip_address_t * dlocs, u8 action, u8 is_add,
+ u8 del_all);
int
vnet_lisp_pitr_set_locator_set (u8 * locator_set_name, u8 is_add);
+int vnet_lisp_clear_all_remote_mappings (void);
+
#endif /* VNET_CONTROL_H_ */
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index c342bcdc2dc..0fb7d1f8185 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -10194,13 +10194,15 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
ip6_address_t seid6, deid6, rloc6;
u32 seid_len = 0, deid_len = 0, len;
u8 deid_is_ip4 = 0, seid_is_ip4 = 0;
- u8 is_add = 1;
+ u8 is_add = 1, del_all = 0;
u32 action = ~0;
rloc_t * rlocs = 0, rloc;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
- if (unformat(input, "del")) {
+ if (unformat(input, "del-all")) {
+ del_all = 1;
+ } else if (unformat(input, "del")) {
is_add = 0;
} else if (unformat(input, "add")) {
is_add = 1;
@@ -10264,6 +10266,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
mp->seid_len = seid_len;
mp->action = (u8) action;
mp->deid_len = deid_len;
+ mp->del_all = del_all;
if (seid_is_ip4) {
mp->eid_is_ip4 = 1;
clib_memcpy (mp->seid, &seid4, sizeof (seid4));
diff --git a/vpp/api/api.c b/vpp/api/api.c
index 8603ec88fd1..ea14bffb6bc 100644
--- a/vpp/api/api.c
+++ b/vpp/api/api.c
@@ -4994,8 +4994,8 @@ vl_api_lisp_add_del_remote_mapping_t_handler (
vec_add1 (rlocs, rloc);
}
- rv = vnet_lisp_add_del_remote_mapping (deid, seid, rlocs,
- mp->action, mp->is_add);
+ rv = vnet_lisp_add_del_remote_mapping (deid, seid, rlocs, mp->action,
+ mp->is_add, mp->del_all);
vec_free (rlocs);
REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
}
diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api
index 9ae4987fd53..9a639c61f8d 100644
--- a/vpp/api/vpe.api
+++ b/vpp/api/vpe.api
@@ -2369,6 +2369,7 @@ define lisp_pitr_set_locator_set_reply {
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero, else delete
+ @param del_all - if set, delete all remote mappings
@param vni - virtual network instance
@param action - negative map-reply action
@param eid_is_ip4 - ipv4/6 of source and destination EIDs
@@ -2381,6 +2382,7 @@ define lisp_add_del_remote_mapping {
u32 client_index;
u32 context;
u8 is_add;
+ u8 del_all;
u32 vni;
u8 action;
u8 eid_is_ip4;