2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vnet/lisp-cp/control.h>
17 #include <vnet/lisp-gpe/lisp_gpe.h>
20 lisp_show_adjacencies_command_fn (vlib_main_t * vm,
21 unformat_input_t * input,
22 vlib_cli_command_t * cmd)
24 lisp_adjacency_t *adjs, *adj;
25 vlib_cli_output (vm, "%s %40s\n", "leid", "reid");
26 unformat_input_t _line_input, *line_input = &_line_input;
29 /* Get a line of input. */
30 if (!unformat_user (input, unformat_line_input, line_input))
33 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
35 if (unformat (line_input, "vni %d", &vni))
39 vlib_cli_output (vm, "parse error: '%U'",
40 format_unformat_error, line_input);
41 unformat_free (line_input);
45 unformat_free (line_input);
49 vlib_cli_output (vm, "error: no vni specified!");
53 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
55 vec_foreach (adj, adjs)
57 vlib_cli_output (vm, "%U %40U\n", format_gid_address, &adj->leid,
58 format_gid_address, &adj->reid);
66 VLIB_CLI_COMMAND (one_show_adjacencies_command) = {
67 .path = "show one adjacencies",
68 .short_help = "show one adjacencies",
69 .function = lisp_show_adjacencies_command_fn,
74 lisp_add_del_map_server_command_fn (vlib_main_t * vm,
75 unformat_input_t * input,
76 vlib_cli_command_t * cmd)
79 u8 is_add = 1, ip_set = 0;
81 unformat_input_t _line_input, *line_input = &_line_input;
83 /* Get a line of input. */
84 if (!unformat_user (input, unformat_line_input, line_input))
87 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
89 if (unformat (line_input, "add"))
91 else if (unformat (line_input, "del"))
93 else if (unformat (line_input, "%U", unformat_ip_address, &ip))
97 vlib_cli_output (vm, "parse error: '%U'",
98 format_unformat_error, line_input);
99 unformat_free (line_input);
103 unformat_free (line_input);
107 vlib_cli_output (vm, "map-server ip address not set!");
111 rv = vnet_lisp_add_del_map_server (&ip, is_add);
113 vlib_cli_output (vm, "failed to %s map-server!",
114 is_add ? "add" : "delete");
120 VLIB_CLI_COMMAND (one_add_del_map_server_command) = {
121 .path = "one map-server",
122 .short_help = "one map-server add|del <ip>",
123 .function = lisp_add_del_map_server_command_fn,
128 static clib_error_t *
129 lisp_add_del_local_eid_command_fn (vlib_main_t * vm, unformat_input_t * input,
130 vlib_cli_command_t * cmd)
132 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
133 unformat_input_t _line_input, *line_input = &_line_input;
136 gid_address_t *eids = 0;
137 clib_error_t *error = 0;
138 u8 *locator_set_name = 0;
139 u32 locator_set_index = 0, map_index = 0;
141 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
147 memset (&eid, 0, sizeof (eid));
148 memset (a, 0, sizeof (*a));
150 /* Get a line of input. */
151 if (!unformat_user (input, unformat_line_input, line_input))
154 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
156 if (unformat (line_input, "add"))
158 else if (unformat (line_input, "del"))
160 else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
162 else if (unformat (line_input, "vni %d", &vni))
163 gid_address_vni (&eid) = vni;
164 else if (unformat (line_input, "secret-key %_%v%_", &key))
166 else if (unformat (line_input, "key-id %U", unformat_hmac_key_id,
169 else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
171 vec_terminate_c_string (locator_set_name);
172 p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
175 error = clib_error_return (0, "locator-set %s doesn't exist",
179 locator_set_index = p[0];
183 error = unformat_parse_error (line_input);
187 /* XXX treat batch configuration */
189 if (GID_ADDR_SRC_DST == gid_address_type (&eid))
192 clib_error_return (0, "src/dst is not supported for local EIDs!");
196 if (key && (0 == key_id))
198 vlib_cli_output (vm, "invalid key_id!");
202 gid_address_copy (&a->eid, &eid);
204 a->locator_set_index = locator_set_index;
209 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
212 error = clib_error_return (0, "failed to %s local mapping!",
213 is_add ? "add" : "delete");
217 if (locator_set_name)
218 vec_free (locator_set_name);
219 gid_address_free (&a->eid);
221 unformat_free (line_input);
226 VLIB_CLI_COMMAND (one_add_del_local_eid_command) = {
227 .path = "one eid-table",
228 .short_help = "one eid-table add/del [vni <vni>] eid <eid> "
229 "locator-set <locator-set> [key <secret-key> key-id sha1|sha256 ]",
230 .function = lisp_add_del_local_eid_command_fn,
234 static clib_error_t *
235 lisp_eid_table_map_command_fn (vlib_main_t * vm,
236 unformat_input_t * input,
237 vlib_cli_command_t * cmd)
239 u8 is_add = 1, is_l2 = 0;
240 u32 vni = 0, dp_id = 0;
241 unformat_input_t _line_input, *line_input = &_line_input;
242 clib_error_t *error = NULL;
244 /* Get a line of input. */
245 if (!unformat_user (input, unformat_line_input, line_input))
248 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
250 if (unformat (line_input, "del"))
252 else if (unformat (line_input, "vni %d", &vni))
254 else if (unformat (line_input, "vrf %d", &dp_id))
256 else if (unformat (line_input, "bd %d", &dp_id))
260 error = unformat_parse_error (line_input);
264 vnet_lisp_eid_table_map (vni, dp_id, is_l2, is_add);
267 unformat_free (line_input);
273 VLIB_CLI_COMMAND (one_eid_table_map_command) = {
274 .path = "one eid-table map",
275 .short_help = "one eid-table map [del] vni <vni> vrf <vrf> | bd <bdi>",
276 .function = lisp_eid_table_map_command_fn,
280 static clib_error_t *
281 lisp_add_del_ndp_entry_command_fn (vlib_main_t * vm,
282 unformat_input_t * input,
283 vlib_cli_command_t * cmd)
285 unformat_input_t _line_input, *line_input = &_line_input;
286 clib_error_t *error = NULL;
288 u8 hw_addr[6], bd = 0;
290 u32 hw_addr_set = 0, ip_set = 0, is_add = 1;
291 gid_address_t _g, *g = &_g;
293 memset (&ip6, 0, sizeof (ip6));
294 memset (hw_addr, 0, sizeof (hw_addr));
295 memset (g, 0, sizeof (*g));
297 if (!unformat_user (input, unformat_line_input, line_input))
300 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
302 if (unformat (line_input, "mac %U", unformat_mac_address, hw_addr))
304 else if (unformat (line_input, "ip %U", unformat_ip6_address, &ip6))
306 else if (unformat (line_input, "del"))
308 else if (unformat (line_input, "bd %d", &bd))
312 error = clib_error_return (0, "parse error");
317 if (!ip_set || (!hw_addr_set && is_add))
319 vlib_cli_output (vm, "expected IP and MAC addresses!");
323 /* build GID address */
324 ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, IP6);
325 gid_address_ndp_bd (g) = bd;
326 gid_address_type (g) = GID_ADDR_NDP;
327 rc = vnet_lisp_add_del_l2_arp_ndp_entry (g, hw_addr, is_add);
329 clib_warning ("Failed to %s ndp entry!", is_add ? "add" : "delete");
332 unformat_free (line_input);
337 VLIB_CLI_COMMAND (one_add_del_ndp_entry_command) = {
339 .short_help = "one ndp [del] bd <bd> mac <mac> ip <ipv6>",
340 .function = lisp_add_del_ndp_entry_command_fn,
344 static clib_error_t *
345 lisp_add_del_l2_arp_entry_command_fn (vlib_main_t * vm,
346 unformat_input_t * input,
347 vlib_cli_command_t * cmd)
349 unformat_input_t _line_input, *line_input = &_line_input;
350 clib_error_t *error = NULL;
352 u8 hw_addr[6], bd = 0;
354 u32 hw_addr_set = 0, ip_set = 0, is_add = 1;
355 gid_address_t _arp, *arp = &_arp;
357 memset (&ip4, 0, sizeof (ip4));
358 memset (hw_addr, 0, sizeof (hw_addr));
359 memset (arp, 0, sizeof (*arp));
361 if (!unformat_user (input, unformat_line_input, line_input))
364 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
366 if (unformat (line_input, "mac %U", unformat_mac_address, hw_addr))
368 else if (unformat (line_input, "ip %U", unformat_ip4_address, &ip4))
370 else if (unformat (line_input, "del"))
372 else if (unformat (line_input, "bd %d", &bd))
376 error = clib_error_return (0, "parse error");
381 if (!ip_set || (!hw_addr_set && is_add))
383 vlib_cli_output (vm, "expected IP and MAC addresses!");
387 /* build GID address */
388 gid_address_arp_ip4 (arp) = ip4;
389 gid_address_arp_bd (arp) = bd;
390 gid_address_type (arp) = GID_ADDR_ARP;
391 rc = vnet_lisp_add_del_l2_arp_ndp_entry (arp, hw_addr, is_add);
393 clib_warning ("Failed to %s l2 arp entry!", is_add ? "add" : "delete");
396 unformat_free (line_input);
401 VLIB_CLI_COMMAND (one_add_del_l2_arp_entry_command) = {
402 .path = "one l2 arp",
403 .short_help = "one l2 arp [del] bd <bd> mac <mac> ip <ipv4>",
404 .function = lisp_add_del_l2_arp_entry_command_fn,
408 static clib_error_t *
409 lisp_show_l2_arp_entries_command_fn (vlib_main_t * vm,
410 unformat_input_t * input,
411 vlib_cli_command_t * cmd)
413 u32 *ht = vnet_lisp_l2_arp_bds_get ();
414 lisp_api_l2_arp_entry_t *entries, *e;
418 hash_foreach_pair (p, ht,
420 entries = vnet_lisp_l2_arp_entries_get_by_bd (p->key);
421 vlib_cli_output (vm, "Table: %d", p->key);
423 vec_foreach (e, entries)
425 vlib_cli_output (vm, "\t%U -> %U", format_ip4_address, &e->ip4,
426 format_mac_address, e->mac);
437 VLIB_CLI_COMMAND (one_show_l2_arp_entries_command) = {
438 .path = "show one l2 arp entries",
439 .short_help = "Show ONE L2 ARP entries",
440 .function = lisp_show_l2_arp_entries_command_fn,
444 static clib_error_t *
445 lisp_show_ndp_entries_command_fn (vlib_main_t * vm,
446 unformat_input_t * input,
447 vlib_cli_command_t * cmd)
449 u32 *ht = vnet_lisp_ndp_bds_get ();
450 lisp_api_ndp_entry_t *entries, *e;
454 hash_foreach_pair (p, ht,
456 entries = vnet_lisp_ndp_entries_get_by_bd (p->key);
457 vlib_cli_output (vm, "Table: %d", p->key);
459 vec_foreach (e, entries)
461 vlib_cli_output (vm, "\t%U -> %U", format_ip6_address, &e->ip6,
462 format_mac_address, e->mac);
473 VLIB_CLI_COMMAND (one_show_ndp_entries_command) = {
474 .path = "show one ndp entries",
475 .short_help = "Show ONE NDP entries",
476 .function = lisp_show_ndp_entries_command_fn,
481 * Handler for add/del remote mapping CLI.
483 * @param vm vlib context
484 * @param input input from user
486 * @return pointer to clib error structure
488 static clib_error_t *
489 lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
490 unformat_input_t * input,
491 vlib_cli_command_t * cmd)
493 clib_error_t *error = 0;
494 unformat_input_t _line_input, *line_input = &_line_input;
495 u8 is_add = 1, del_all = 0;
496 locator_t rloc, *rlocs = 0, *curr_rloc = 0;
499 u32 vni, action = ~0, p, w;
502 /* Get a line of input. */
503 if (!unformat_user (input, unformat_line_input, line_input))
506 memset (&eid, 0, sizeof (eid));
507 memset (&rloc, 0, sizeof (rloc));
509 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
511 if (unformat (line_input, "del-all"))
513 else if (unformat (line_input, "del"))
515 else if (unformat (line_input, "add"))
517 else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
519 else if (unformat (line_input, "vni %u", &vni))
521 gid_address_vni (&eid) = vni;
523 else if (unformat (line_input, "p %d w %d", &p, &w))
528 ("No RLOC configured for setting priority/weight!");
531 curr_rloc->priority = p;
532 curr_rloc->weight = w;
534 else if (unformat (line_input, "rloc %U", unformat_ip_address,
535 &gid_address_ip (&rloc.address)))
537 /* since rloc is stored in ip prefix we need to set prefix length */
538 ip_prefix_t *pref = &gid_address_ippref (&rloc.address);
540 u8 version = gid_address_ip_version (&rloc.address);
541 ip_prefix_len (pref) = ip_address_max_len (version);
543 vec_add1 (rlocs, rloc);
544 curr_rloc = &rlocs[vec_len (rlocs) - 1];
546 else if (unformat (line_input, "action %U",
547 unformat_negative_mapping_action, &action))
551 clib_warning ("parse error");
556 if (!del_all && !eid_set)
558 clib_warning ("missing eid!");
564 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
566 clib_warning ("no action set for negative map-reply!");
572 vnet_lisp_clear_all_remote_adjacencies ();
576 /* if it's a delete, clean forwarding */
579 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
580 memset (a, 0, sizeof (a[0]));
581 gid_address_copy (&a->reid, &eid);
582 if (vnet_lisp_add_del_adjacency (a))
584 clib_warning ("failed to delete adjacency!");
589 /* add as static remote mapping, i.e., not authoritative and infinite
593 vnet_lisp_add_del_mapping_args_t _map_args, *map_args = &_map_args;
594 memset (map_args, 0, sizeof (map_args[0]));
595 gid_address_copy (&map_args->eid, &eid);
596 map_args->action = action;
597 map_args->is_static = 1;
598 map_args->authoritative = 0;
600 rv = vnet_lisp_add_mapping (map_args, rlocs, NULL, NULL);
603 rv = vnet_lisp_del_mapping (&eid, NULL);
606 clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
610 unformat_free (line_input);
615 VLIB_CLI_COMMAND (one_add_del_remote_mapping_command) = {
616 .path = "one remote-mapping",
618 "one remote-mapping add|del [del-all] vni <vni> "
619 "eid <est-eid> [action <no-action|natively-forward|"
620 "send-map-request|drop>] rloc <dst-locator> p <prio> w <weight> "
621 "[rloc <dst-locator> ... ]",
622 .function = lisp_add_del_remote_mapping_command_fn,
627 * Handler for add/del adjacency CLI.
629 static clib_error_t *
630 lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input,
631 vlib_cli_command_t * cmd)
633 clib_error_t *error = 0;
634 unformat_input_t _line_input, *line_input = &_line_input;
635 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
637 ip_prefix_t *reid_ippref, *leid_ippref;
638 gid_address_t leid, reid;
639 u8 *dmac = gid_address_mac (&reid);
640 u8 *smac = gid_address_mac (&leid);
641 u8 reid_set = 0, leid_set = 0;
644 /* Get a line of input. */
645 if (!unformat_user (input, unformat_line_input, line_input))
648 memset (&reid, 0, sizeof (reid));
649 memset (&leid, 0, sizeof (leid));
651 leid_ippref = &gid_address_ippref (&leid);
652 reid_ippref = &gid_address_ippref (&reid);
654 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
656 if (unformat (line_input, "del"))
658 else if (unformat (line_input, "add"))
660 else if (unformat (line_input, "reid %U",
661 unformat_ip_prefix, reid_ippref))
663 gid_address_type (&reid) = GID_ADDR_IP_PREFIX;
666 else if (unformat (line_input, "reid %U", unformat_mac_address, dmac))
668 gid_address_type (&reid) = GID_ADDR_MAC;
671 else if (unformat (line_input, "vni %u", &vni))
673 gid_address_vni (&leid) = vni;
674 gid_address_vni (&reid) = vni;
676 else if (unformat (line_input, "leid %U",
677 unformat_ip_prefix, leid_ippref))
679 gid_address_type (&leid) = GID_ADDR_IP_PREFIX;
682 else if (unformat (line_input, "leid %U", unformat_mac_address, smac))
684 gid_address_type (&leid) = GID_ADDR_MAC;
689 clib_warning ("parse error");
694 if (!reid_set || !leid_set)
696 clib_warning ("missing remote or local eid!");
700 if ((gid_address_type (&leid) != gid_address_type (&reid))
701 || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX
702 && ip_prefix_version (reid_ippref)
703 != ip_prefix_version (leid_ippref)))
705 clib_warning ("remote and local EIDs are of different types!");
709 memset (a, 0, sizeof (a[0]));
710 gid_address_copy (&a->leid, &leid);
711 gid_address_copy (&a->reid, &reid);
714 if (vnet_lisp_add_del_adjacency (a))
715 clib_warning ("failed to %s adjacency!", is_add ? "add" : "delete");
718 unformat_free (line_input);
723 VLIB_CLI_COMMAND (one_add_del_adjacency_command) = {
724 .path = "one adjacency",
725 .short_help = "one adjacency add|del vni <vni> reid <remote-eid> "
727 .function = lisp_add_del_adjacency_command_fn,
732 static clib_error_t *
733 lisp_map_request_mode_command_fn (vlib_main_t * vm,
734 unformat_input_t * input,
735 vlib_cli_command_t * cmd)
737 unformat_input_t _i, *i = &_i;
738 map_request_mode_t mr_mode = _MR_MODE_MAX;
740 /* Get a line of input. */
741 if (!unformat_user (input, unformat_line_input, i))
744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
746 if (unformat (i, "dst-only"))
747 mr_mode = MR_MODE_DST_ONLY;
748 else if (unformat (i, "src-dst"))
749 mr_mode = MR_MODE_SRC_DST;
752 clib_warning ("parse error '%U'", format_unformat_error, i);
757 if (_MR_MODE_MAX == mr_mode)
759 clib_warning ("No map request mode entered!");
763 vnet_lisp_set_map_request_mode (mr_mode);
772 VLIB_CLI_COMMAND (one_map_request_mode_command) = {
773 .path = "one map-request mode",
774 .short_help = "one map-request mode dst-only|src-dst",
775 .function = lisp_map_request_mode_command_fn,
781 format_lisp_map_request_mode (u8 * s, va_list * args)
783 u32 mode = va_arg (*args, u32);
788 return format (0, "dst-only");
790 return format (0, "src-dst");
795 static clib_error_t *
796 lisp_show_map_request_mode_command_fn (vlib_main_t * vm,
797 unformat_input_t * input,
798 vlib_cli_command_t * cmd)
800 vlib_cli_output (vm, "map-request mode: %U", format_lisp_map_request_mode,
801 vnet_lisp_get_map_request_mode ());
806 VLIB_CLI_COMMAND (one_show_map_request_mode_command) = {
807 .path = "show one map-request mode",
808 .short_help = "show one map-request mode",
809 .function = lisp_show_map_request_mode_command_fn,
813 static clib_error_t *
814 lisp_show_map_resolvers_command_fn (vlib_main_t * vm,
815 unformat_input_t * input,
816 vlib_cli_command_t * cmd)
819 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
821 vec_foreach (mr, lcm->map_resolvers)
823 vlib_cli_output (vm, "%U", format_ip_address, &mr->address);
829 VLIB_CLI_COMMAND (one_show_map_resolvers_command) = {
830 .path = "show one map-resolvers",
831 .short_help = "show one map-resolvers",
832 .function = lisp_show_map_resolvers_command_fn,
836 static clib_error_t *
837 lisp_nsh_set_locator_set_command_fn (vlib_main_t * vm,
838 unformat_input_t * input,
839 vlib_cli_command_t * cmd)
841 u8 locator_name_set = 0;
842 u8 *locator_set_name = 0;
844 unformat_input_t _line_input, *line_input = &_line_input;
845 clib_error_t *error = 0;
848 /* Get a line of input. */
849 if (!unformat_user (input, unformat_line_input, line_input))
852 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
854 if (unformat (line_input, "ls %_%v%_", &locator_set_name))
855 locator_name_set = 1;
856 else if (unformat (line_input, "disable"))
860 error = clib_error_return (0, "parse error");
865 if (!locator_name_set)
867 clib_warning ("No locator set specified!");
871 vec_terminate_c_string (locator_set_name);
872 rv = vnet_lisp_nsh_set_locator_set (locator_set_name, is_add);
875 error = clib_error_return (0, "failed to %s NSH mapping!",
876 is_add ? "add" : "delete");
880 vec_free (locator_set_name);
881 unformat_free (line_input);
886 VLIB_CLI_COMMAND (one_nsh_set_locator_set_command) = {
887 .path = "one nsh-mapping",
888 .short_help = "one nsh-mapping [del] ls <locator-set-name>",
889 .function = lisp_nsh_set_locator_set_command_fn,
893 static clib_error_t *
894 lisp_map_register_fallback_threshold_show_command_fn (vlib_main_t * vm,
900 u32 val = vnet_lisp_map_register_fallback_threshold_get ();
901 vlib_cli_output (vm, "map register fallback treshold value: %d", val);
906 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_show_command) = {
907 .path = "show one map-register fallback-threshold",
908 .short_help = "show one map-register fallback-threshold",
909 .function = lisp_map_register_fallback_threshold_show_command_fn,
914 static clib_error_t *
915 lisp_map_register_fallback_threshold_command_fn (vlib_main_t * vm,
916 unformat_input_t * input,
917 vlib_cli_command_t * cmd)
919 unformat_input_t _line_input, *line_input = &_line_input;
920 clib_error_t *error = 0;
924 /* Get a line of input. */
925 if (!unformat_user (input, unformat_line_input, line_input))
928 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
930 if (unformat (line_input, "%d", &val))
934 error = clib_error_return (0, "parse error");
939 rv = vnet_lisp_map_register_fallback_threshold_set (val);
942 error = clib_error_return (0, "setting fallback threshold failed!");
946 unformat_free (line_input);
951 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_command) = {
952 .path = "one map-register fallback-threshold",
953 .short_help = "one map-register fallback-threshold <count>",
954 .function = lisp_map_register_fallback_threshold_command_fn,
958 static clib_error_t *
959 lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
960 unformat_input_t * input,
961 vlib_cli_command_t * cmd)
963 u8 locator_name_set = 0;
964 u8 *locator_set_name = 0;
966 unformat_input_t _line_input, *line_input = &_line_input;
967 clib_error_t *error = 0;
970 /* Get a line of input. */
971 if (!unformat_user (input, unformat_line_input, line_input))
974 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
976 if (unformat (line_input, "ls %_%v%_", &locator_set_name))
977 locator_name_set = 1;
978 else if (unformat (line_input, "disable"))
982 error = clib_error_return (0, "parse error");
987 if (!locator_name_set)
989 clib_warning ("No locator set specified!");
992 vec_terminate_c_string (locator_set_name);
993 rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
996 error = clib_error_return (0, "failed to %s pitr!",
997 is_add ? "add" : "delete");
1001 if (locator_set_name)
1002 vec_free (locator_set_name);
1003 unformat_free (line_input);
1008 VLIB_CLI_COMMAND (one_pitr_set_locator_set_command) = {
1010 .short_help = "one pitr [disable] ls <locator-set-name>",
1011 .function = lisp_pitr_set_locator_set_command_fn,
1015 static clib_error_t *
1016 lisp_show_pitr_command_fn (vlib_main_t * vm,
1017 unformat_input_t * input, vlib_cli_command_t * cmd)
1019 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1023 u8 status = lcm->flags & LISP_FLAG_PITR_MODE;
1025 vlib_cli_output (vm, "%=20s%=16s", "pitr", status ? "locator-set" : "");
1029 vlib_cli_output (vm, "%=20s", "disable");
1033 if (~0 == lcm->pitr_map_index)
1035 tmp_str = format (0, "N/A");
1039 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1040 if (~0 != m->locator_set_index)
1043 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1044 tmp_str = format (0, "%s", ls->name);
1048 tmp_str = format (0, "N/A");
1051 vec_add1 (tmp_str, 0);
1053 vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
1061 VLIB_CLI_COMMAND (one_show_pitr_command) = {
1062 .path = "show one pitr",
1063 .short_help = "Show pitr",
1064 .function = lisp_show_pitr_command_fn,
1069 format_eid_entry (u8 * s, va_list * args)
1071 vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
1072 lisp_cp_main_t *lcm = va_arg (*args, lisp_cp_main_t *);
1073 mapping_t *mapit = va_arg (*args, mapping_t *);
1074 locator_set_t *ls = va_arg (*args, locator_set_t *);
1075 gid_address_t *gid = &mapit->eid;
1076 u32 ttl = mapit->ttl;
1077 u8 aut = mapit->authoritative;
1082 u8 *type = ls->local ? format (0, "local(%s)", ls->name)
1083 : format (0, "remote");
1085 if (vec_len (ls->locator_indices) == 0)
1087 s = format (s, "%-35U%-20saction:%-30U%-20u%-u", format_gid_address,
1088 gid, type, format_negative_mapping_action, mapit->action,
1093 vec_foreach (loc_index, ls->locator_indices)
1095 locator_t *l = pool_elt_at_index (lcm->locator_pool, loc_index[0]);
1097 loc = format (0, "%U", format_vnet_sw_if_index_name, vnm,
1100 loc = format (0, "%U", format_ip_address,
1101 &gid_address_ip (&l->address));
1105 s = format (s, "%-35U%-20s%-30v%-20u%-u\n", format_gid_address,
1106 gid, type, loc, ttl, aut);
1110 s = format (s, "%55s%v\n", "", loc);
1116 static clib_error_t *
1117 lisp_show_eid_table_command_fn (vlib_main_t * vm,
1118 unformat_input_t * input,
1119 vlib_cli_command_t * cmd)
1121 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1123 unformat_input_t _line_input, *line_input = &_line_input;
1128 clib_error_t *error = NULL;
1130 memset (&eid, 0, sizeof (eid));
1132 /* Get a line of input. */
1133 if (!unformat_user (input, unformat_line_input, line_input))
1136 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1138 if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
1140 else if (unformat (line_input, "local"))
1142 else if (unformat (line_input, "remote"))
1146 error = clib_error_return (0, "parse error: '%U'",
1147 format_unformat_error, line_input);
1152 vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
1153 "EID", "type", "locators", "ttl", "autoritative");
1158 pool_foreach (mapit, lcm->mapping_pool,
1160 if (mapit->pitr_set || mapit->nsh_set)
1163 locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
1164 mapit->locator_set_index);
1165 if (filter && !((1 == filter && ls->local) ||
1166 (2 == filter && !ls->local)))
1170 vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
1177 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
1178 if ((u32) ~ 0 == mi)
1181 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
1182 locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool,
1183 mapit->locator_set_index);
1185 if (filter && !((1 == filter && ls->local) ||
1186 (2 == filter && !ls->local)))
1191 vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
1196 unformat_free (line_input);
1202 VLIB_CLI_COMMAND (one_cp_show_eid_table_command) = {
1203 .path = "show one eid-table",
1204 .short_help = "Shows EID table",
1205 .function = lisp_show_eid_table_command_fn,
1209 static clib_error_t *
1210 lisp_enable_disable_pitr_mode_command_fn (vlib_main_t * vm,
1211 unformat_input_t * input,
1212 vlib_cli_command_t * cmd)
1214 unformat_input_t _line_input, *line_input = &_line_input;
1217 clib_error_t *error = NULL;
1219 /* Get a line of input. */
1220 if (!unformat_user (input, unformat_line_input, line_input))
1223 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1225 if (unformat (line_input, "enable"))
1230 else if (unformat (line_input, "disable"))
1234 error = clib_error_return (0, "parse error: '%U'",
1235 format_unformat_error, line_input);
1242 error = clib_error_return (0, "state not set");
1246 vnet_lisp_enable_disable_pitr_mode (is_enabled);
1249 unformat_free (line_input);
1255 VLIB_CLI_COMMAND (one_cp_enable_disable_pitr_mode_command) = {
1256 .path = "one pitr mode",
1257 .short_help = "one pitr mode [enable|disable]",
1258 .function = lisp_enable_disable_pitr_mode_command_fn,
1263 static clib_error_t *
1264 lisp_enable_disable_petr_mode_command_fn (vlib_main_t * vm,
1265 unformat_input_t * input,
1266 vlib_cli_command_t * cmd)
1268 unformat_input_t _line_input, *line_input = &_line_input;
1271 clib_error_t *error = NULL;
1273 /* Get a line of input. */
1274 if (!unformat_user (input, unformat_line_input, line_input))
1277 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1279 if (unformat (line_input, "enable"))
1284 else if (unformat (line_input, "disable"))
1288 error = clib_error_return (0, "parse error: '%U'",
1289 format_unformat_error, line_input);
1296 error = clib_error_return (0, "state not set");
1300 vnet_lisp_enable_disable_petr_mode (is_enabled);
1303 unformat_free (line_input);
1309 VLIB_CLI_COMMAND (one_cp_enable_disable_petr_mode_command) = {
1310 .path = "one petr mode",
1311 .short_help = "one petr mode [enable|disable]",
1312 .function = lisp_enable_disable_petr_mode_command_fn,
1316 static clib_error_t *
1317 lisp_enable_disable_xtr_mode_command_fn (vlib_main_t * vm,
1318 unformat_input_t * input,
1319 vlib_cli_command_t * cmd)
1321 unformat_input_t _line_input, *line_input = &_line_input;
1324 clib_error_t *error = NULL;
1326 /* Get a line of input. */
1327 if (!unformat_user (input, unformat_line_input, line_input))
1330 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1332 if (unformat (line_input, "enable"))
1337 else if (unformat (line_input, "disable"))
1341 error = clib_error_return (0, "parse error: '%U'",
1342 format_unformat_error, line_input);
1349 error = clib_error_return (0, "state not set");
1353 vnet_lisp_enable_disable_xtr_mode (is_enabled);
1356 unformat_free (line_input);
1362 VLIB_CLI_COMMAND (one_cp_enable_disable_xtr_mode_command) = {
1363 .path = "one xtr mode",
1364 .short_help = "one xtr mode [enable|disable]",
1365 .function = lisp_enable_disable_xtr_mode_command_fn,
1369 static clib_error_t *
1370 lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
1371 vlib_cli_command_t * cmd)
1373 unformat_input_t _line_input, *line_input = &_line_input;
1376 clib_error_t *error = NULL;
1378 /* Get a line of input. */
1379 if (!unformat_user (input, unformat_line_input, line_input))
1382 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1384 if (unformat (line_input, "enable"))
1389 else if (unformat (line_input, "disable"))
1393 error = clib_error_return (0, "parse error: '%U'",
1394 format_unformat_error, line_input);
1401 error = clib_error_return (0, "state not set");
1405 vnet_lisp_enable_disable (is_enabled);
1408 unformat_free (line_input);
1414 VLIB_CLI_COMMAND (one_cp_enable_disable_command) = {
1416 .short_help = "one [enable|disable]",
1417 .function = lisp_enable_disable_command_fn,
1421 static clib_error_t *
1422 lisp_map_register_set_ttl_command_fn (vlib_main_t * vm,
1423 unformat_input_t * input,
1424 vlib_cli_command_t * cmd)
1426 unformat_input_t _line_input, *line_input = &_line_input;
1429 clib_error_t *error = NULL;
1431 /* Get a line of input. */
1432 if (!unformat_user (input, unformat_line_input, line_input))
1435 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1437 if (unformat (line_input, "%u", &ttl))
1441 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1449 vlib_cli_output (vm, "expected integer value for TTL!");
1453 vnet_lisp_map_register_set_ttl (ttl);
1456 unformat_free (line_input);
1461 VLIB_CLI_COMMAND (one_map_register_set_ttl_command) = {
1462 .path = "one map-register ttl",
1463 .short_help = "one map-register ttl",
1464 .function = lisp_map_register_set_ttl_command_fn,
1468 static clib_error_t *
1469 lisp_map_register_show_ttl_command_fn (vlib_main_t * vm,
1470 unformat_input_t * input,
1471 vlib_cli_command_t * cmd)
1473 u32 ttl = vnet_lisp_map_register_get_ttl ();
1475 vlib_cli_output (vm, "map-register TTL: %u", ttl);
1480 VLIB_CLI_COMMAND (one_map_register_show_ttl_command) = {
1481 .path = "show one map-register ttl",
1482 .short_help = "show one map-register ttl",
1483 .function = lisp_map_register_show_ttl_command_fn,
1488 static clib_error_t *
1489 lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
1490 unformat_input_t * input,
1491 vlib_cli_command_t * cmd)
1493 unformat_input_t _line_input, *line_input = &_line_input;
1496 clib_error_t *error = NULL;
1498 /* Get a line of input. */
1499 if (!unformat_user (input, unformat_line_input, line_input))
1502 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1504 if (unformat (line_input, "enable"))
1509 else if (unformat (line_input, "disable"))
1513 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1521 vlib_cli_output (vm, "state not set!");
1525 vnet_lisp_map_register_enable_disable (is_enabled);
1528 unformat_free (line_input);
1534 VLIB_CLI_COMMAND (one_map_register_enable_disable_command) = {
1535 .path = "one map-register",
1536 .short_help = "one map-register [enable|disable]",
1537 .function = lisp_map_register_enable_disable_command_fn,
1541 static clib_error_t *
1542 lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
1543 unformat_input_t * input,
1544 vlib_cli_command_t * cmd)
1546 unformat_input_t _line_input, *line_input = &_line_input;
1549 clib_error_t *error = NULL;
1551 /* Get a line of input. */
1552 if (!unformat_user (input, unformat_line_input, line_input))
1555 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1557 if (unformat (line_input, "enable"))
1562 else if (unformat (line_input, "disable"))
1566 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1574 vlib_cli_output (vm, "state not set!");
1578 vnet_lisp_rloc_probe_enable_disable (is_enabled);
1581 unformat_free (line_input);
1587 VLIB_CLI_COMMAND (one_rloc_probe_enable_disable_command) = {
1588 .path = "one rloc-probe",
1589 .short_help = "one rloc-probe [enable|disable]",
1590 .function = lisp_rloc_probe_enable_disable_command_fn,
1595 format_lisp_status (u8 * s, va_list * args)
1597 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1598 return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
1601 static clib_error_t *
1602 lisp_show_status_command_fn (vlib_main_t * vm, unformat_input_t * input,
1603 vlib_cli_command_t * cmd)
1606 msg = format (msg, "feature: %U\ngpe: %U\n",
1607 format_lisp_status, format_vnet_lisp_gpe_status);
1608 vlib_cli_output (vm, "%v", msg);
1614 VLIB_CLI_COMMAND (one_show_status_command) = {
1615 .path = "show one status",
1616 .short_help = "show one status",
1617 .function = lisp_show_status_command_fn,
1621 static clib_error_t *
1622 lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
1623 unformat_input_t * input,
1624 vlib_cli_command_t * cmd)
1627 unformat_input_t _line_input, *line_input = &_line_input;
1628 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1629 uword *vni_table = 0;
1631 clib_error_t *error = NULL;
1633 /* Get a line of input. */
1634 if (!unformat_user (input, unformat_line_input, line_input))
1637 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1639 if (unformat (line_input, "l2"))
1641 vni_table = lcm->bd_id_by_vni;
1644 else if (unformat (line_input, "l3"))
1646 vni_table = lcm->table_id_by_vni;
1651 error = clib_error_return (0, "parse error: '%U'",
1652 format_unformat_error, line_input);
1659 vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
1663 vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
1666 hash_foreach_pair (p, vni_table,
1668 vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
1673 unformat_free (line_input);
1679 VLIB_CLI_COMMAND (one_show_eid_table_map_command) = {
1680 .path = "show one eid-table map",
1681 .short_help = "show one eid-table l2|l3",
1682 .function = lisp_show_eid_table_map_command_fn,
1687 static clib_error_t *
1688 lisp_add_del_locator_set_command_fn (vlib_main_t * vm,
1689 unformat_input_t * input,
1690 vlib_cli_command_t * cmd)
1692 lisp_gpe_main_t *lgm = &lisp_gpe_main;
1693 vnet_main_t *vnm = lgm->vnet_main;
1694 unformat_input_t _line_input, *line_input = &_line_input;
1696 clib_error_t *error = 0;
1697 u8 *locator_set_name = 0;
1698 locator_t locator, *locators = 0;
1699 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
1703 memset (&locator, 0, sizeof (locator));
1704 memset (a, 0, sizeof (a[0]));
1706 /* Get a line of input. */
1707 if (!unformat_user (input, unformat_line_input, line_input))
1710 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1712 if (unformat (line_input, "add %_%v%_", &locator_set_name))
1714 else if (unformat (line_input, "del %_%v%_", &locator_set_name))
1716 else if (unformat (line_input, "iface %U p %d w %d",
1717 unformat_vnet_sw_interface, vnm,
1718 &locator.sw_if_index, &locator.priority,
1722 vec_add1 (locators, locator);
1726 error = unformat_parse_error (line_input);
1731 vec_terminate_c_string (locator_set_name);
1732 a->name = locator_set_name;
1733 a->locators = locators;
1737 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
1740 error = clib_error_return (0, "failed to %s locator-set!",
1741 is_add ? "add" : "delete");
1745 vec_free (locators);
1746 if (locator_set_name)
1747 vec_free (locator_set_name);
1748 unformat_free (line_input);
1753 VLIB_CLI_COMMAND (one_cp_add_del_locator_set_command) = {
1754 .path = "one locator-set",
1755 .short_help = "one locator-set add/del <name> [iface <iface-name> "
1756 "p <priority> w <weight>]",
1757 .function = lisp_add_del_locator_set_command_fn,
1761 static clib_error_t *
1762 lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
1763 unformat_input_t * input,
1764 vlib_cli_command_t * cmd)
1766 lisp_gpe_main_t *lgm = &lisp_gpe_main;
1767 vnet_main_t *vnm = lgm->vnet_main;
1768 unformat_input_t _line_input, *line_input = &_line_input;
1770 clib_error_t *error = 0;
1771 u8 *locator_set_name = 0;
1772 u8 locator_set_name_set = 0;
1773 locator_t locator, *locators = 0;
1774 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
1777 memset (&locator, 0, sizeof (locator));
1778 memset (a, 0, sizeof (a[0]));
1780 /* Get a line of input. */
1781 if (!unformat_user (input, unformat_line_input, line_input))
1784 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1786 if (unformat (line_input, "add"))
1788 else if (unformat (line_input, "del"))
1790 else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
1791 locator_set_name_set = 1;
1792 else if (unformat (line_input, "iface %U p %d w %d",
1793 unformat_vnet_sw_interface, vnm,
1794 &locator.sw_if_index, &locator.priority,
1798 vec_add1 (locators, locator);
1802 error = unformat_parse_error (line_input);
1807 if (!locator_set_name_set)
1809 error = clib_error_return (0, "locator_set name not set!");
1813 vec_terminate_c_string (locator_set_name);
1814 a->name = locator_set_name;
1815 a->locators = locators;
1819 vnet_lisp_add_del_locator (a, 0, &ls_index);
1822 vec_free (locators);
1823 vec_free (locator_set_name);
1824 unformat_free (line_input);
1829 VLIB_CLI_COMMAND (one_cp_add_del_locator_in_set_command) = {
1830 .path = "one locator",
1831 .short_help = "one locator add/del locator-set <name> iface <iface-name> "
1832 "p <priority> w <weight>",
1833 .function = lisp_add_del_locator_in_set_command_fn,
1837 static clib_error_t *
1838 lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
1839 unformat_input_t * input,
1840 vlib_cli_command_t * cmd)
1842 locator_set_t *lsit;
1845 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1847 vlib_cli_output (vm, "%s%=16s%=16s%=16s", "Locator-set", "Locator",
1848 "Priority", "Weight");
1851 pool_foreach (lsit, lcm->locator_set_pool,
1857 msg = format (msg, "%s", lsit->name);
1861 msg = format (msg, "<%s-%d>", "remote", lsit - lcm->locator_set_pool);
1863 vec_foreach (locit, lsit->locator_indices)
1867 msg = format (msg, "%16s", " ");
1869 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
1871 msg = format (msg, "%16d%16d%16d\n", loc->sw_if_index, loc->priority,
1874 msg = format (msg, "%16U%16d%16d\n", format_ip_address,
1875 &gid_address_ip(&loc->address), loc->priority,
1879 vlib_cli_output (vm, "%v", msg);
1887 VLIB_CLI_COMMAND (one_cp_show_locator_sets_command) = {
1888 .path = "show one locator-set",
1889 .short_help = "Shows locator-sets",
1890 .function = lisp_cp_show_locator_sets_command_fn,
1895 static clib_error_t *
1896 lisp_add_del_map_resolver_command_fn (vlib_main_t * vm,
1897 unformat_input_t * input,
1898 vlib_cli_command_t * cmd)
1900 unformat_input_t _line_input, *line_input = &_line_input;
1901 u8 is_add = 1, addr_set = 0;
1902 ip_address_t ip_addr;
1903 clib_error_t *error = 0;
1905 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
1907 /* Get a line of input. */
1908 if (!unformat_user (input, unformat_line_input, line_input))
1911 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1913 if (unformat (line_input, "add"))
1915 else if (unformat (line_input, "del"))
1917 else if (unformat (line_input, "%U", unformat_ip_address, &ip_addr))
1921 error = unformat_parse_error (line_input);
1928 error = clib_error_return (0, "Map-resolver address must be set!");
1933 a->address = ip_addr;
1934 rv = vnet_lisp_add_del_map_resolver (a);
1937 error = clib_error_return (0, "failed to %s map-resolver!",
1938 is_add ? "add" : "delete");
1942 unformat_free (line_input);
1947 VLIB_CLI_COMMAND (one_add_del_map_resolver_command) = {
1948 .path = "one map-resolver",
1949 .short_help = "one map-resolver add/del <ip_address>",
1950 .function = lisp_add_del_map_resolver_command_fn,
1955 static clib_error_t *
1956 lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
1957 unformat_input_t * input,
1958 vlib_cli_command_t * cmd)
1960 unformat_input_t _line_input, *line_input = &_line_input;
1962 u8 *locator_set_name = 0;
1963 clib_error_t *error = 0;
1965 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
1967 /* Get a line of input. */
1968 if (!unformat_user (input, unformat_line_input, line_input))
1971 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1973 if (unformat (line_input, "del"))
1975 else if (unformat (line_input, "add %_%v%_", &locator_set_name))
1979 error = unformat_parse_error (line_input);
1984 vec_terminate_c_string (locator_set_name);
1986 a->locator_set_name = locator_set_name;
1987 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
1990 error = clib_error_return (0, "failed to %s map-request itr-rlocs!",
1991 is_add ? "add" : "delete");
1995 vec_free (locator_set_name);
1996 unformat_free (line_input);
2002 VLIB_CLI_COMMAND (one_add_del_map_request_command) = {
2003 .path = "one map-request itr-rlocs",
2004 .short_help = "one map-request itr-rlocs add/del <locator_set_name>",
2005 .function = lisp_add_del_mreq_itr_rlocs_command_fn,
2009 static clib_error_t *
2010 lisp_show_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
2011 unformat_input_t * input,
2012 vlib_cli_command_t * cmd)
2014 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
2015 locator_set_t *loc_set;
2017 vlib_cli_output (vm, "%=20s", "itr-rlocs");
2019 if (~0 == lcm->mreq_itr_rlocs)
2024 loc_set = pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
2026 vlib_cli_output (vm, "%=20s", loc_set->name);
2032 VLIB_CLI_COMMAND (one_show_map_request_command) = {
2033 .path = "show one map-request itr-rlocs",
2034 .short_help = "Shows map-request itr-rlocs",
2035 .function = lisp_show_mreq_itr_rlocs_command_fn,
2039 static clib_error_t *
2040 lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm,
2041 unformat_input_t * input,
2042 vlib_cli_command_t * cmd)
2044 u8 is_add = 1, ip_set = 0;
2045 unformat_input_t _line_input, *line_input = &_line_input;
2046 clib_error_t *error = 0;
2049 /* Get a line of input. */
2050 if (!unformat_user (input, unformat_line_input, line_input))
2053 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2055 if (unformat (line_input, "%U", unformat_ip_address, &ip))
2057 else if (unformat (line_input, "disable"))
2061 error = clib_error_return (0, "parse error");
2068 clib_warning ("No petr IP specified!");
2072 if (vnet_lisp_use_petr (&ip, is_add))
2074 error = clib_error_return (0, "failed to %s petr!",
2075 is_add ? "add" : "delete");
2079 unformat_free (line_input);
2084 VLIB_CLI_COMMAND (one_use_petr_set_locator_set_command) = {
2085 .path = "one use-petr",
2086 .short_help = "one use-petr [disable] <petr-ip>",
2087 .function = lisp_use_petr_set_locator_set_command_fn,
2090 static clib_error_t *
2091 lisp_show_petr_command_fn (vlib_main_t * vm,
2092 unformat_input_t * input, vlib_cli_command_t * cmd)
2094 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
2099 u8 use_petr = lcm->flags & LISP_FLAG_USE_PETR;
2100 vlib_cli_output (vm, "%=20s%=16s", "petr", use_petr ? "ip" : "");
2104 vlib_cli_output (vm, "%=20s", "disable");
2108 if (~0 == lcm->petr_map_index)
2110 tmp_str = format (0, "N/A");
2114 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
2115 if (~0 != m->locator_set_index)
2117 ls = pool_elt_at_index(lcm->locator_set_pool, m->locator_set_index);
2118 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
2119 tmp_str = format (0, "%U", format_ip_address, &loc->address);
2123 tmp_str = format (0, "N/A");
2126 vec_add1 (tmp_str, 0);
2128 vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
2136 VLIB_CLI_COMMAND (one_show_petr_command) = {
2137 .path = "show one petr",
2138 .short_help = "Show petr",
2139 .function = lisp_show_petr_command_fn,
2143 static clib_error_t *
2144 lisp_show_map_servers_command_fn (vlib_main_t * vm,
2145 unformat_input_t * input,
2146 vlib_cli_command_t * cmd)
2149 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
2151 vec_foreach (ms, lcm->map_servers)
2153 vlib_cli_output (vm, "%U", format_ip_address, &ms->address);
2159 VLIB_CLI_COMMAND (one_show_map_servers_command) = {
2160 .path = "show one map-servers",
2161 .short_help = "show one map servers",
2162 .function = lisp_show_map_servers_command_fn,
2166 static clib_error_t *
2167 lisp_show_map_register_state_command_fn (vlib_main_t * vm,
2168 unformat_input_t * input,
2169 vlib_cli_command_t * cmd)
2172 u8 is_enabled = vnet_lisp_map_register_state_get ();
2174 msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
2175 vlib_cli_output (vm, "%v", msg);
2181 VLIB_CLI_COMMAND (one_show_map_register_state_command) = {
2182 .path = "show one map-register state",
2183 .short_help = "show one map-register state",
2184 .function = lisp_show_map_register_state_command_fn,
2188 static clib_error_t *
2189 lisp_show_rloc_probe_state_command_fn (vlib_main_t * vm,
2190 unformat_input_t * input,
2191 vlib_cli_command_t * cmd)
2194 u8 is_enabled = vnet_lisp_rloc_probe_state_get ();
2196 msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
2197 vlib_cli_output (vm, "%v", msg);
2203 VLIB_CLI_COMMAND (one_show_rloc_probe_state_command) = {
2204 .path = "show one rloc state",
2205 .short_help = "show one RLOC state",
2206 .function = lisp_show_rloc_probe_state_command_fn,
2210 static clib_error_t *
2211 lisp_show_stats_command_fn (vlib_main_t * vm,
2212 unformat_input_t * input,
2213 vlib_cli_command_t * cmd)
2215 u8 is_enabled = vnet_lisp_stats_enable_disable_state ();
2216 vlib_cli_output (vm, "%s\n", is_enabled ? "enabled" : "disabled");
2221 VLIB_CLI_COMMAND (one_show_stats_command) = {
2222 .path = "show one statistics status",
2223 .short_help = "show ONE statistics enable/disable status",
2224 .function = lisp_show_stats_command_fn,
2228 static clib_error_t *
2229 lisp_show_stats_details_command_fn (vlib_main_t * vm,
2230 unformat_input_t * input,
2231 vlib_cli_command_t * cmd)
2233 lisp_api_stats_t *stat, *stats = vnet_lisp_get_stats ();
2235 if (vec_len (stats) > 0)
2236 vlib_cli_output (vm,
2237 "[src-EID, dst-EID] [loc-rloc, rmt-rloc] count bytes\n");
2239 vlib_cli_output (vm, "No statistics found.\n");
2241 vec_foreach (stat, stats)
2243 vlib_cli_output (vm, "[%U, %U] [%U, %U] %7u %7u\n",
2244 format_fid_address, &stat->seid,
2245 format_fid_address, &stat->deid,
2246 format_ip_address, &stat->loc_rloc,
2247 format_ip_address, &stat->rmt_rloc,
2248 stat->counters.packets, stat->counters.bytes);
2255 VLIB_CLI_COMMAND (one_show_stats_details_command) = {
2256 .path = "show one statistics details",
2257 .short_help = "show ONE statistics",
2258 .function = lisp_show_stats_details_command_fn,
2262 static clib_error_t *
2263 lisp_stats_enable_disable_command_fn (vlib_main_t * vm,
2264 unformat_input_t * input,
2265 vlib_cli_command_t * cmd)
2267 unformat_input_t _line_input, *line_input = &_line_input;
2270 /* Get a line of input. */
2271 if (!unformat_user (input, unformat_line_input, line_input))
2274 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2276 if (unformat (line_input, "enable"))
2278 else if (unformat (line_input, "disable"))
2282 clib_warning ("Error: expected enable/disable!");
2286 vnet_lisp_stats_enable_disable (enable);
2288 unformat_free (line_input);
2293 VLIB_CLI_COMMAND (one_stats_enable_disable_command) = {
2294 .path = "one statistics",
2295 .short_help = "enable/disable ONE statistics collecting",
2296 .function = lisp_stats_enable_disable_command_fn,
2300 static clib_error_t *
2301 lisp_stats_flush_command_fn (vlib_main_t * vm,
2302 unformat_input_t * input,
2303 vlib_cli_command_t * cmd)
2305 vnet_lisp_flush_stats ();
2310 VLIB_CLI_COMMAND (one_stats_flush_command) = {
2311 .path = "one statistics flush",
2312 .short_help = "Flush ONE statistics",
2313 .function = lisp_stats_flush_command_fn,
2317 static clib_error_t *
2318 lisp_show_one_modes_command_fn (vlib_main_t * vm,
2319 unformat_input_t * input,
2320 vlib_cli_command_t * cmd)
2322 u8 pitr_mode = vnet_lisp_get_pitr_mode ();
2323 u8 petr_mode = vnet_lisp_get_petr_mode ();
2324 u8 xtr_mode = vnet_lisp_get_xtr_mode ();
2326 vlib_cli_output (vm, "xTR: %s\n", xtr_mode ? "enabled" : "disabled");
2327 vlib_cli_output (vm, "P-ITR: %s\n", pitr_mode ? "enabled" : "disabled");
2328 vlib_cli_output (vm, "P-ETR: %s\n", petr_mode ? "enabled" : "disabled");
2334 VLIB_CLI_COMMAND (one_cp_show_one_modes_modes_command) = {
2335 .path = "show one modes",
2336 .short_help = "show one modes",
2337 .function = lisp_show_one_modes_command_fn,
2342 * fd.io coding-style-patch-verification: ON
2345 * eval: (c-set-style "gnu")