aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-10-26 23:57:09 -0700
committerFlorin Coras <florin.coras@gmail.com>2017-10-30 14:36:50 +0000
commit9d286a47017c3cb641e62586929ec4dbac04a2d4 (patch)
treeaa6f22e0cfdee08302cfd1e5662498944a463cec
parent7008da2667d2876bc58aa5ae57c4a9de48cc756b (diff)
LISP: improve updating the dataplne when locators change
Change-Id: Ifc0296834e25ddbdd0ad8283c061f309801b053c Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--src/vnet/lisp-cp/control.c76
-rw-r--r--src/vnet/lisp-cp/lisp_api.c9
-rw-r--r--src/vnet/lisp-cp/lisp_cli.c3
-rw-r--r--src/vnet/lisp-cp/one_api.c6
-rw-r--r--src/vnet/lisp-cp/one_cli.c8
5 files changed, 74 insertions, 28 deletions
diff --git a/src/vnet/lisp-cp/control.c b/src/vnet/lisp-cp/control.c
index aeea72c90a1..907e9a0f677 100644
--- a/src/vnet/lisp-cp/control.c
+++ b/src/vnet/lisp-cp/control.c
@@ -1823,39 +1823,70 @@ is_locator_in_locator_set (lisp_cp_main_t * lcm, locator_set_t * ls,
}
static void
-update_adjacencies_by_map_index (lisp_cp_main_t * lcm, u8 is_local,
+update_adjacencies_by_map_index (lisp_cp_main_t * lcm,
u32 mapping_index, u8 remove_only)
{
fwd_entry_t *fwd;
mapping_t *map;
+ uword *fei = 0, *rmts_idxp = 0;
+ u32 **rmts = 0, *remote_idxp = 0, *rmts_copy = 0;
vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
+ memset (a, 0, sizeof (*a));
map = pool_elt_at_index (lcm->mapping_pool, mapping_index);
- /* *INDENT-OFF* */
- pool_foreach(fwd, lcm->fwd_entry_pool,
- ({
- if ((is_local && 0 == gid_address_cmp (&map->eid, &fwd->leid)) ||
- (!is_local && 0 == gid_address_cmp (&map->eid, &fwd->reid)))
- {
- a->is_add = 0;
- gid_address_copy (&a->leid, &fwd->leid);
- gid_address_copy (&a->reid, &fwd->reid);
+ if (map->local)
+ {
+ rmts_idxp = hash_get (lcm->lcl_to_rmt_adjs_by_lcl_idx, mapping_index);
+ if (rmts_idxp)
+ {
+ rmts =
+ pool_elt_at_index (lcm->lcl_to_rmt_adjacencies, rmts_idxp[0]);
+ rmts_copy = vec_dup (rmts[0]);
- vnet_lisp_add_del_adjacency (a);
+ vec_foreach (remote_idxp, rmts_copy)
+ {
+ fei = hash_get (lcm->fwd_entry_by_mapping_index, remote_idxp[0]);
+ if (!fei)
+ continue;
- if (!remove_only)
- {
- a->is_add = 1;
- vnet_lisp_add_del_adjacency (a);
- }
- }
- }));
- /* *INDENT-ON* */
+ fwd = pool_elt_at_index (lcm->fwd_entry_pool, fei[0]);
+ a->is_add = 0;
+ gid_address_copy (&a->leid, &fwd->leid);
+ gid_address_copy (&a->reid, &fwd->reid);
+ vnet_lisp_add_del_adjacency (a);
+
+ if (!remove_only)
+ {
+ a->is_add = 1;
+ vnet_lisp_add_del_adjacency (a);
+ }
+ }
+ vec_free (rmts_copy);
+ }
+ }
+ else
+ {
+ fei = hash_get (lcm->fwd_entry_by_mapping_index, mapping_index);
+ if (!fei)
+ return;
+
+ fwd = pool_elt_at_index (lcm->fwd_entry_pool, fei[0]);
+ a->is_add = 0;
+ gid_address_copy (&a->leid, &fwd->leid);
+ gid_address_copy (&a->reid, &fwd->reid);
+ vnet_lisp_add_del_adjacency (a);
+
+ if (!remove_only)
+ {
+ a->is_add = 1;
+ vnet_lisp_add_del_adjacency (a);
+ }
+ }
}
static void
-update_fwd_entries_by_locator_set (lisp_cp_main_t * lcm, u8 is_local,
+update_fwd_entries_by_locator_set (lisp_cp_main_t * lcm,
u32 ls_index, u8 remove_only)
{
u32 i, *map_indexp;
@@ -1869,8 +1900,7 @@ update_fwd_entries_by_locator_set (lisp_cp_main_t * lcm, u8 is_local,
for (i = 0; i < vec_len (eid_indexes[0]); i++)
{
map_indexp = vec_elt_at_index (eid_indexes[0], i);
- update_adjacencies_by_map_index (lcm, is_local, map_indexp[0],
- remove_only);
+ update_adjacencies_by_map_index (lcm, map_indexp[0], remove_only);
}
}
@@ -1981,7 +2011,7 @@ vnet_lisp_add_del_locator (vnet_lisp_add_del_locator_set_args_t * a,
if (removed)
{
/* update fwd entries using this locator in DP */
- update_fwd_entries_by_locator_set (lcm, loc->local, ls_index,
+ update_fwd_entries_by_locator_set (lcm, ls_index,
vec_len (ls->locator_indices)
== 0);
}
diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/vnet/lisp-cp/lisp_api.c
index cb2eb0d9171..58235d046c8 100644
--- a/src/vnet/lisp-cp/lisp_api.c
+++ b/src/vnet/lisp-cp/lisp_api.c
@@ -128,7 +128,7 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
memset (a, 0, sizeof (a[0]));
- mp->locator_set_name[63] = 0;
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
locator_name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (locator_name);
@@ -184,7 +184,7 @@ vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp)
locator.local = 1;
vec_add1 (locators, locator);
- mp->locator_set_name[63] = 0;
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
locator_name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (locator_name);
@@ -252,7 +252,7 @@ vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp)
if (rv)
goto out;
- mp->locator_set_name[63] = 0;
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (name);
p = hash_get_mem (lcm->locator_set_index_by_name, name);
@@ -395,6 +395,7 @@ vl_api_lisp_pitr_set_locator_set_t_handler (vl_api_lisp_pitr_set_locator_set_t
int rv = 0;
u8 *ls_name = 0;
+ mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
ls_name = format (0, "%s", mp->ls_name);
vec_terminate_c_string (ls_name);
rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
@@ -483,7 +484,7 @@ static void
u8 *locator_set_name = NULL;
vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
- mp->locator_set_name[63] = 0;
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
locator_set_name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (locator_set_name);
diff --git a/src/vnet/lisp-cp/lisp_cli.c b/src/vnet/lisp-cp/lisp_cli.c
index 509046019ec..738dda7044d 100644
--- a/src/vnet/lisp-cp/lisp_cli.c
+++ b/src/vnet/lisp-cp/lisp_cli.c
@@ -172,6 +172,7 @@ lisp_add_del_local_eid_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
{
+ vec_terminate_c_string (locator_set_name);
p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
if (!p)
{
@@ -672,6 +673,7 @@ lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
clib_warning ("No locator set specified!");
goto done;
}
+ vec_terminate_c_string (locator_set_name);
rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
if (0 != rv)
{
@@ -1438,6 +1440,7 @@ lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
}
}
+ vec_terminate_c_string (locator_set_name);
a->is_add = is_add;
a->locator_set_name = locator_set_name;
rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c
index c9b5dca3aff..33b3a47a352 100644
--- a/src/vnet/lisp-cp/one_api.c
+++ b/src/vnet/lisp-cp/one_api.c
@@ -202,6 +202,7 @@ vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
memset (a, 0, sizeof (a[0]));
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
locator_name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (locator_name);
@@ -257,6 +258,7 @@ vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
locator.local = 1;
vec_add1 (locators, locator);
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
locator_name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (locator_name);
@@ -344,6 +346,7 @@ vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
goto out;
}
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (name);
p = hash_get_mem (lcm->locator_set_index_by_name, name);
@@ -485,6 +488,7 @@ vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
int rv = 0;
u8 *ls_name = 0;
+ mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
ls_name = format (0, "%s", mp->ls_name);
vec_terminate_c_string (ls_name);
rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
@@ -501,6 +505,7 @@ vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
int rv = 0;
u8 *ls_name = 0;
+ mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
ls_name = format (0, "%s", mp->ls_name);
vec_terminate_c_string (ls_name);
rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
@@ -589,6 +594,7 @@ static void
u8 *locator_set_name = NULL;
vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
+ mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
locator_set_name = format (0, "%s", mp->locator_set_name);
vec_terminate_c_string (locator_set_name);
diff --git a/src/vnet/lisp-cp/one_cli.c b/src/vnet/lisp-cp/one_cli.c
index 700bfd66e7a..3b6d1b448af 100644
--- a/src/vnet/lisp-cp/one_cli.c
+++ b/src/vnet/lisp-cp/one_cli.c
@@ -168,6 +168,7 @@ lisp_add_del_local_eid_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
{
+ vec_terminate_c_string (locator_set_name);
p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
if (!p)
{
@@ -867,6 +868,7 @@ lisp_nsh_set_locator_set_command_fn (vlib_main_t * vm,
goto done;
}
+ vec_terminate_c_string (locator_set_name);
rv = vnet_lisp_nsh_set_locator_set (locator_set_name, is_add);
if (0 != rv)
{
@@ -987,6 +989,7 @@ lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
clib_warning ("No locator set specified!");
goto done;
}
+ vec_terminate_c_string (locator_set_name);
rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
if (0 != rv)
{
@@ -1566,6 +1569,7 @@ lisp_add_del_locator_set_command_fn (vlib_main_t * vm,
}
}
+ vec_terminate_c_string (locator_set_name);
a->name = locator_set_name;
a->locators = locators;
a->is_add = is_add;
@@ -1647,6 +1651,7 @@ lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
goto done;
}
+ vec_terminate_c_string (locator_set_name);
a->name = locator_set_name;
a->locators = locators;
a->is_add = is_add;
@@ -1690,7 +1695,7 @@ lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
int next_line = 0;
if (lsit->local)
{
- msg = format (msg, "%v", lsit->name);
+ msg = format (msg, "%s", lsit->name);
}
else
{
@@ -1817,6 +1822,7 @@ lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
}
}
+ vec_terminate_c_string (locator_set_name);
a->is_add = is_add;
a->locator_set_name = locator_set_name;
rv = vnet_lisp_add_del_mreq_itr_rlocs (a);