- {
- lsi = vec_elt(lcm->local_locator_set_indexes, it);
- if (lsi == p[0])
- {
- vec_del1(lcm->local_locator_set_indexes, it);
- break;
- }
- }
- hash_unset_mem(lcm->locator_set_index_by_name, ls->name);
- vec_free(ls->name);
- }
- pool_put(lcm->locator_set_pool, ls);
- }
- return 0;
-}
-
-int
-vnet_lisp_add_del_locator (vnet_lisp_add_del_locator_set_args_t *a,
- u32 *ls_result)
-{
- lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
- locator_set_t *ls = NULL;
- locator_t *loc = NULL, *itloc = NULL;
- uword _p = (u32)~0, * p = &_p;
- u32 loc_index = ~0, ls_index = ~0, *locit = NULL, **ls_indexes = NULL;
- u32 i = ~0;
-
- ASSERT(a != NULL);
- ASSERT(ls_result != NULL);
-
- p = vnet_lisp_get_locator(a, p);
- if (!p) {
- clib_warning("locator-set %v doesn't exists", a->name);
- return VNET_API_ERROR_INVALID_ARGUMENT;
- }
-
- ls_index = p[0];
-
- if (a->is_add)
- {
- ls = pool_elt_at_index(lcm->locator_set_pool, p[0]);
- if (!ls)
- {
- clib_warning("locator-set %d to be overwritten doesn't exist!",
- p[0]);
- return VNET_API_ERROR_INVALID_ARGUMENT;
- }
-
- if (ls_result)
- ls_result[0] = p[0];
-
- /* allocate locators */
- itloc = a->locators;
- pool_get(lcm->locator_pool, loc);
- loc[0] = itloc[0];
- loc_index = loc - lcm->locator_pool;
-
- vec_add1(ls->locator_indices, loc_index);
-
- vec_validate (lcm->locator_to_locator_sets, loc_index);
- ls_indexes = vec_elt_at_index(lcm->locator_to_locator_sets,
- loc_index);
- vec_add1(ls_indexes[0], ls_index);
- }
- else
- {
- ls = pool_elt_at_index(lcm->locator_set_pool, p[0]);
- if (!ls)
- {
- clib_warning("locator-set with index %d doesn't exists", p[0]);
- return VNET_API_ERROR_INVALID_ARGUMENT;
- }
-
- if (ls->local)
- {
- itloc = a->locators;
- i = 0;
- vec_foreach (locit, ls->locator_indices)