m->ttl = a->ttl;
m->action = a->action;
m->local = a->local;
+ m->is_static = a->is_static;
map_index = m - lcm->mapping_pool;
gid_dictionary_add_del (&lcm->mapping_index_by_gid, &a->eid, map_index,
* @param is_add add mapping if non-zero, delete otherwise
* @param res_map_index the map-index that was created/updated/removed. It is
* set to ~0 if no action is taken.
+ * @param is_static used for distinguishing between statically learned
+ remote mappings and mappings obtained from MR
* @return return code
*/
int
vnet_lisp_add_del_mapping (gid_address_t * eid, locator_t * rlocs, u8 action,
- u8 authoritative, u32 ttl, u8 is_add,
+ u8 authoritative, u32 ttl, u8 is_add, u8 is_static,
u32 * res_map_index)
{
vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
* updated and be done */
if (old_map && gid_address_cmp (&old_map->eid, eid) == 0)
{
+ if (!is_static && (old_map->is_static || old_map->local))
+ {
+ /* do not overwrite local or static remote mappings */
+ clib_warning ("mapping %U rejected due to collision with local "
+ "or static remote mapping!", format_gid_address,
+ &eid);
+ return 0;
+ }
+
locator_set_t *old_ls;
/* update mapping attributes */
m_args->is_add = 1;
m_args->action = action;
m_args->locator_set_index = ls_index;
+ m_args->is_static = is_static;
vnet_lisp_map_cache_add_del (m_args, &dst_map_index);
if (res_map_index)
/* add as static remote mapping, i.e., not authoritative and infinite
* ttl */
- rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add, 0);
+ rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add,
+ 1 /* is_static */ , 0);
if (rv)
clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
vlib_cli_command_t * cmd)
{
hash_pair_t *p;
+ unformat_input_t _line_input, *line_input = &_line_input;
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ uword *vni_table = 0;
+ u8 is_l2 = 0;
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "l2"))
+ {
+ vni_table = lcm->bd_id_by_vni;
+ is_l2 = 1;
+ }
+ else if (unformat (line_input, "l3"))
+ {
+ vni_table = lcm->table_id_by_vni;
+ is_l2 = 0;
+ }
+ else
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ }
+
+ if (!vni_table)
+ {
+ vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
+ return 0;
+ }
- vlib_cli_output (vm, "%=10s%=10s", "VNI", "VRF");
+ vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
/* *INDENT-OFF* */
- hash_foreach_pair (p, lcm->table_id_by_vni,
+ hash_foreach_pair (p, vni_table,
({
vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
}));
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (lisp_show_eid_table_map_command) = {
.path = "show lisp eid-table map",
- .short_help = "show lisp eid-table vni to vrf mappings",
+ .short_help = "show lisp eid-table l2|l3",
.function = lisp_show_eid_table_map_command_fn,
};
/* *INDENT-ON* */
/* insert/update mappings cache */
vnet_lisp_add_del_mapping (&deid, locators, action, authoritative, ttl,
- 1, &dst_map_index);
+ 1, 0 /* is_static */ , &dst_map_index);
/* try to program forwarding only if mapping saved or updated */
if ((u32) ~ 0 != dst_map_index)