vnet_lisp_add_del_locator_set (ls_args, 0);
/* return old mapping index */
- res_map_index[0] = mi;
+ if (res_map_index)
+ res_map_index[0] = mi;
}
/* success */
unformat_input_t _line_input, * line_input = &_line_input;
u8 is_add = 1, del_all = 0;
locator_t rloc, * rlocs = 0, * curr_rloc = 0;
- ip_prefix_t * deid_ippref, * seid_ippref;
- gid_address_t seid, deid;
- u8 * dmac = gid_address_mac (&deid);
- u8 * smac = gid_address_mac (&seid);
- u8 deid_set = 0, seid_set = 0;
+ ip_prefix_t * eid_ippref;
+ gid_address_t eid;
+ u8 * dmac = gid_address_mac (&eid);
+ u8 eid_set = 0;
u8 * s = 0;
u32 vni, action = ~0, p, w;
int rv;
if (! unformat_user (input, unformat_line_input, line_input))
return 0;
- memset(&deid, 0, sizeof(deid));
- memset(&seid, 0, sizeof(seid));
+ memset(&eid, 0, sizeof(eid));
memset(&rloc, 0, sizeof(rloc));
- seid_ippref = &gid_address_ippref(&seid);
- deid_ippref = &gid_address_ippref(&deid);
+ eid_ippref = &gid_address_ippref(&eid);
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
is_add = 0;
else if (unformat (line_input, "add"))
;
- else if (unformat (line_input, "deid %U",
- unformat_ip_prefix, deid_ippref))
+ else if (unformat (line_input, "eid %U",
+ unformat_ip_prefix, eid_ippref))
{
- gid_address_type (&deid) = GID_ADDR_IP_PREFIX;
- deid_set = 1;
+ gid_address_type (&eid) = GID_ADDR_IP_PREFIX;
+ eid_set = 1;
}
- else if (unformat (line_input, "deid %U",
+ else if (unformat (line_input, "eid %U",
unformat_mac_address, dmac))
{
- gid_address_type (&deid) = GID_ADDR_MAC;
- deid_set = 1;
+ gid_address_type (&eid) = GID_ADDR_MAC;
+ eid_set = 1;
}
else if (unformat (line_input, "vni %u", &vni))
{
- gid_address_vni (&seid) = vni;
- gid_address_vni (&deid) = vni;
- }
- else if (unformat (line_input, "seid %U",
- unformat_ip_prefix, seid_ippref))
- {
- gid_address_type (&seid) = GID_ADDR_IP_PREFIX;
- seid_set = 1;
- }
- else if (unformat (line_input, "seid %U",
- unformat_mac_address, smac))
- {
- gid_address_type (&seid) = GID_ADDR_MAC;
- seid_set = 1;
+ gid_address_vni (&eid) = vni;
}
else if (unformat (line_input, "p %d w %d", &p, &w))
{
}
}
- if (!del_all)
+ if (!eid_set)
{
- if (!deid_set)
- {
- clib_warning ("missing deid!");
- goto done;
- }
+ clib_warning ("missing eid!");
+ goto done;
+ }
- if (GID_ADDR_IP_PREFIX == gid_address_type (&deid))
- {
- /* if seid not set, make sure the ip version is the same as that
- * of the deid. This ensures the seid to be configured will be
- * either 0/0 or ::/0 */
- if (!seid_set)
- ip_prefix_version(seid_ippref) = ip_prefix_version(deid_ippref);
+ if (!del_all)
+ {
- 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))
if (!is_add)
{
lisp_cp_main_t * lcm = vnet_lisp_cp_get_main ();
- rv = lisp_add_del_adjacency (lcm, 0, &deid, /* is_add */ 0);
- }
- else
- {
- /* add as static remote mapping, i.e., not authoritative and infinite
- * ttl */
- rv = vnet_lisp_add_del_mapping (&deid, rlocs, action, 0, ~0, is_add, 0);
+ rv = lisp_add_del_adjacency (lcm, 0, &eid, /* is_add */ 0);
+ if (rv)
+ {
+ goto done;
+ }
}
+ /* 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);
+
if (rv)
clib_warning("failed to %s remote mapping!", is_add ? "add" : "delete");
VLIB_CLI_COMMAND (lisp_add_del_remote_mapping_command) = {
.path = "lisp remote-mapping",
- .short_help = "lisp remote-mapping add|del [del-all] vni <vni>"
- "deid <dest-eid> seid <src-eid> [action <no-action|natively-forward|"
+ .short_help = "lisp remote-mapping add|del [del-all] vni <vni> "
+ "eid <est-eid> [action <no-action|natively-forward|"
"send-map-request|drop>] rloc <dst-locator> [rloc <dst-locator> ... ]",
.function = lisp_add_del_remote_mapping_command_fn,
};
{
vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
lisp_cp_main_t * lcm = va_arg (*args, lisp_cp_main_t *);
- gid_address_t * gid = va_arg (*args, gid_address_t *);
+ mapping_t * mapit = va_arg (*args, mapping_t *);
locator_set_t * ls = va_arg (*args, locator_set_t *);
+ gid_address_t * gid = &mapit->eid;
+ u32 ttl = mapit->ttl;
+ u8 aut = mapit->authoritative;
u32 * loc_index;
u8 first_line = 1;
u8 * loc;
if (vec_len (ls->locator_indices) == 0)
{
- s = format (s, "%-35U%-20s", format_gid_address, gid, type);
+ s = format (s, "%-35U%-30s%-20u%-u", format_gid_address, gid,
+ type, ttl, aut);
}
else
{
if (first_line)
{
- s = format (s, "%-35U%-20s%-v\n", format_gid_address,
- gid, type, loc);
+ s = format (s, "%-35U%-20s%-30v%-20u%-u\n", format_gid_address,
+ gid, type, loc, ttl, aut);
first_line = 0;
}
else
u32 mi;
gid_address_t eid;
u8 print_all = 1;
+ u8 filter = 0;
memset (&eid, 0, sizeof(eid));
{
if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
print_all = 0;
+ else if (unformat (line_input, "local"))
+ filter = 1;
+ else if (unformat(line_input, "remote"))
+ filter = 2;
else
return clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
}
- vlib_cli_output (vm, "%-35s%-20s%-s", "EID", "type", "locators");
+ vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
+ "EID", "type", "locators", "ttl", "autoritative");
if (print_all)
{
({
locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
mapit->locator_set_index);
+ if (filter && !((1 == filter && ls->local) ||
+ (2 == filter && !ls->local)))
+ {
+ continue;
+ }
vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
- lcm, &mapit->eid, ls);
+ lcm, mapit, ls);
}));
}
else
mapit = pool_elt_at_index (lcm->mapping_pool, mi);
locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
mapit->locator_set_index);
- vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
- lcm, &mapit->eid, ls);
+
+ if (filter && !((1 == filter && ls->local) ||
+ (2 == filter && !ls->local)))
+ {
+ return 0;
+ }
+
+ vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
+ lcm, mapit, ls);
}
return 0;
addr = ip_interface_address_get_address (&lcm->im4->lookup_main, ia);
ip_address_set (rloc, addr, IP4);
ip_prefix_len (ippref) = 32;
+ ip_prefix_normalize (ippref);
vec_add1 (rlocs, gid[0]);
}));
addr = ip_interface_address_get_address (&lcm->im6->lookup_main, ia);
ip_address_set (rloc, addr, IP6);
ip_prefix_len (ippref) = 128;
+ ip_prefix_normalize (ippref);
vec_add1 (rlocs, gid[0]);
}));
}