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 p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
174 error = clib_error_return (0, "locator-set %s doesn't exist",
178 locator_set_index = p[0];
182 error = unformat_parse_error (line_input);
186 /* XXX treat batch configuration */
188 if (GID_ADDR_SRC_DST == gid_address_type (&eid))
191 clib_error_return (0, "src/dst is not supported for local EIDs!");
195 if (key && (0 == key_id))
197 vlib_cli_output (vm, "invalid key_id!");
201 gid_address_copy (&a->eid, &eid);
203 a->locator_set_index = locator_set_index;
208 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
211 error = clib_error_return (0, "failed to %s local mapping!",
212 is_add ? "add" : "delete");
216 if (locator_set_name)
217 vec_free (locator_set_name);
218 gid_address_free (&a->eid);
220 unformat_free (line_input);
225 VLIB_CLI_COMMAND (one_add_del_local_eid_command) = {
226 .path = "one eid-table",
227 .short_help = "one eid-table add/del [vni <vni>] eid <eid> "
228 "locator-set <locator-set> [key <secret-key> key-id sha1|sha256 ]",
229 .function = lisp_add_del_local_eid_command_fn,
233 static clib_error_t *
234 lisp_eid_table_map_command_fn (vlib_main_t * vm,
235 unformat_input_t * input,
236 vlib_cli_command_t * cmd)
238 u8 is_add = 1, is_l2 = 0;
239 u32 vni = 0, dp_id = 0;
240 unformat_input_t _line_input, *line_input = &_line_input;
241 clib_error_t *error = NULL;
243 /* Get a line of input. */
244 if (!unformat_user (input, unformat_line_input, line_input))
247 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
249 if (unformat (line_input, "del"))
251 else if (unformat (line_input, "vni %d", &vni))
253 else if (unformat (line_input, "vrf %d", &dp_id))
255 else if (unformat (line_input, "bd %d", &dp_id))
259 error = unformat_parse_error (line_input);
263 vnet_lisp_eid_table_map (vni, dp_id, is_l2, is_add);
266 unformat_free (line_input);
272 VLIB_CLI_COMMAND (one_eid_table_map_command) = {
273 .path = "one eid-table map",
274 .short_help = "one eid-table map [del] vni <vni> vrf <vrf> | bd <bdi>",
275 .function = lisp_eid_table_map_command_fn,
279 static clib_error_t *
280 lisp_add_del_ndp_entry_command_fn (vlib_main_t * vm,
281 unformat_input_t * input,
282 vlib_cli_command_t * cmd)
284 unformat_input_t _line_input, *line_input = &_line_input;
285 clib_error_t *error = NULL;
287 u8 hw_addr[6], bd = 0;
289 u32 hw_addr_set = 0, ip_set = 0, is_add = 1;
290 gid_address_t _g, *g = &_g;
292 memset (&ip6, 0, sizeof (ip6));
293 memset (hw_addr, 0, sizeof (hw_addr));
294 memset (g, 0, sizeof (*g));
296 if (!unformat_user (input, unformat_line_input, line_input))
299 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
301 if (unformat (line_input, "mac %U", unformat_mac_address, hw_addr))
303 else if (unformat (line_input, "ip %U", unformat_ip6_address, &ip6))
305 else if (unformat (line_input, "del"))
307 else if (unformat (line_input, "bd %d", &bd))
311 error = clib_error_return (0, "parse error");
316 if (!ip_set || (!hw_addr_set && is_add))
318 vlib_cli_output (vm, "expected IP and MAC addresses!");
322 /* build GID address */
323 ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, IP6);
324 gid_address_ndp_bd (g) = bd;
325 gid_address_type (g) = GID_ADDR_NDP;
326 rc = vnet_lisp_add_del_l2_arp_ndp_entry (g, hw_addr, is_add);
328 clib_warning ("Failed to %s ndp entry!", is_add ? "add" : "delete");
331 unformat_free (line_input);
336 VLIB_CLI_COMMAND (one_add_del_ndp_entry_command) = {
338 .short_help = "one ndp [del] bd <bd> mac <mac> ip <ipv6>",
339 .function = lisp_add_del_ndp_entry_command_fn,
343 static clib_error_t *
344 lisp_add_del_l2_arp_entry_command_fn (vlib_main_t * vm,
345 unformat_input_t * input,
346 vlib_cli_command_t * cmd)
348 unformat_input_t _line_input, *line_input = &_line_input;
349 clib_error_t *error = NULL;
351 u8 hw_addr[6], bd = 0;
353 u32 hw_addr_set = 0, ip_set = 0, is_add = 1;
354 gid_address_t _arp, *arp = &_arp;
356 memset (&ip4, 0, sizeof (ip4));
357 memset (hw_addr, 0, sizeof (hw_addr));
358 memset (arp, 0, sizeof (*arp));
360 if (!unformat_user (input, unformat_line_input, line_input))
363 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
365 if (unformat (line_input, "mac %U", unformat_mac_address, hw_addr))
367 else if (unformat (line_input, "ip %U", unformat_ip4_address, &ip4))
369 else if (unformat (line_input, "del"))
371 else if (unformat (line_input, "bd %d", &bd))
375 error = clib_error_return (0, "parse error");
380 if (!ip_set || (!hw_addr_set && is_add))
382 vlib_cli_output (vm, "expected IP and MAC addresses!");
386 /* build GID address */
387 gid_address_arp_ip4 (arp) = ip4;
388 gid_address_arp_bd (arp) = bd;
389 gid_address_type (arp) = GID_ADDR_ARP;
390 rc = vnet_lisp_add_del_l2_arp_ndp_entry (arp, hw_addr, is_add);
392 clib_warning ("Failed to %s l2 arp entry!", is_add ? "add" : "delete");
395 unformat_free (line_input);
400 VLIB_CLI_COMMAND (one_add_del_l2_arp_entry_command) = {
401 .path = "one l2 arp",
402 .short_help = "one l2 arp [del] bd <bd> mac <mac> ip <ipv4>",
403 .function = lisp_add_del_l2_arp_entry_command_fn,
407 static clib_error_t *
408 lisp_show_l2_arp_entries_command_fn (vlib_main_t * vm,
409 unformat_input_t * input,
410 vlib_cli_command_t * cmd)
412 u32 *ht = vnet_lisp_l2_arp_bds_get ();
413 lisp_api_l2_arp_entry_t *entries, *e;
417 hash_foreach_pair (p, ht,
419 entries = vnet_lisp_l2_arp_entries_get_by_bd (p->key);
420 vlib_cli_output (vm, "Table: %d", p->key);
422 vec_foreach (e, entries)
424 vlib_cli_output (vm, "\t%U -> %U", format_ip4_address, &e->ip4,
425 format_mac_address, e->mac);
436 VLIB_CLI_COMMAND (one_show_l2_arp_entries_command) = {
437 .path = "show one l2 arp entries",
438 .short_help = "Show ONE L2 ARP entries",
439 .function = lisp_show_l2_arp_entries_command_fn,
443 static clib_error_t *
444 lisp_show_ndp_entries_command_fn (vlib_main_t * vm,
445 unformat_input_t * input,
446 vlib_cli_command_t * cmd)
448 u32 *ht = vnet_lisp_ndp_bds_get ();
449 lisp_api_ndp_entry_t *entries, *e;
453 hash_foreach_pair (p, ht,
455 entries = vnet_lisp_ndp_entries_get_by_bd (p->key);
456 vlib_cli_output (vm, "Table: %d", p->key);
458 vec_foreach (e, entries)
460 vlib_cli_output (vm, "\t%U -> %U", format_ip6_address, &e->ip6,
461 format_mac_address, e->mac);
472 VLIB_CLI_COMMAND (one_show_ndp_entries_command) = {
473 .path = "show one ndp entries",
474 .short_help = "Show ONE NDP entries",
475 .function = lisp_show_ndp_entries_command_fn,
480 * Handler for add/del remote mapping CLI.
482 * @param vm vlib context
483 * @param input input from user
485 * @return pointer to clib error structure
487 static clib_error_t *
488 lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
489 unformat_input_t * input,
490 vlib_cli_command_t * cmd)
492 clib_error_t *error = 0;
493 unformat_input_t _line_input, *line_input = &_line_input;
494 u8 is_add = 1, del_all = 0;
495 locator_t rloc, *rlocs = 0, *curr_rloc = 0;
498 u32 vni, action = ~0, p, w;
501 /* Get a line of input. */
502 if (!unformat_user (input, unformat_line_input, line_input))
505 memset (&eid, 0, sizeof (eid));
506 memset (&rloc, 0, sizeof (rloc));
508 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
510 if (unformat (line_input, "del-all"))
512 else if (unformat (line_input, "del"))
514 else if (unformat (line_input, "add"))
516 else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
518 else if (unformat (line_input, "vni %u", &vni))
520 gid_address_vni (&eid) = vni;
522 else if (unformat (line_input, "p %d w %d", &p, &w))
527 ("No RLOC configured for setting priority/weight!");
530 curr_rloc->priority = p;
531 curr_rloc->weight = w;
533 else if (unformat (line_input, "rloc %U", unformat_ip_address,
534 &gid_address_ip (&rloc.address)))
536 /* since rloc is stored in ip prefix we need to set prefix length */
537 ip_prefix_t *pref = &gid_address_ippref (&rloc.address);
539 u8 version = gid_address_ip_version (&rloc.address);
540 ip_prefix_len (pref) = ip_address_max_len (version);
542 vec_add1 (rlocs, rloc);
543 curr_rloc = &rlocs[vec_len (rlocs) - 1];
545 else if (unformat (line_input, "action %U",
546 unformat_negative_mapping_action, &action))
550 clib_warning ("parse error");
555 if (!del_all && !eid_set)
557 clib_warning ("missing eid!");
563 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
565 clib_warning ("no action set for negative map-reply!");
571 vnet_lisp_clear_all_remote_adjacencies ();
575 /* if it's a delete, clean forwarding */
578 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
579 memset (a, 0, sizeof (a[0]));
580 gid_address_copy (&a->reid, &eid);
581 if (vnet_lisp_add_del_adjacency (a))
583 clib_warning ("failed to delete adjacency!");
588 /* add as static remote mapping, i.e., not authoritative and infinite
592 vnet_lisp_add_del_mapping_args_t _map_args, *map_args = &_map_args;
593 memset (map_args, 0, sizeof (map_args[0]));
594 gid_address_copy (&map_args->eid, &eid);
595 map_args->action = action;
596 map_args->is_static = 1;
597 map_args->authoritative = 0;
599 rv = vnet_lisp_add_mapping (map_args, rlocs, NULL, NULL);
602 rv = vnet_lisp_del_mapping (&eid, NULL);
605 clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
609 unformat_free (line_input);
614 VLIB_CLI_COMMAND (one_add_del_remote_mapping_command) = {
615 .path = "one remote-mapping",
617 "one remote-mapping add|del [del-all] vni <vni> "
618 "eid <est-eid> [action <no-action|natively-forward|"
619 "send-map-request|drop>] rloc <dst-locator> p <prio> w <weight> "
620 "[rloc <dst-locator> ... ]",
621 .function = lisp_add_del_remote_mapping_command_fn,
626 * Handler for add/del adjacency CLI.
628 static clib_error_t *
629 lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input,
630 vlib_cli_command_t * cmd)
632 clib_error_t *error = 0;
633 unformat_input_t _line_input, *line_input = &_line_input;
634 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
636 ip_prefix_t *reid_ippref, *leid_ippref;
637 gid_address_t leid, reid;
638 u8 *dmac = gid_address_mac (&reid);
639 u8 *smac = gid_address_mac (&leid);
640 u8 reid_set = 0, leid_set = 0;
643 /* Get a line of input. */
644 if (!unformat_user (input, unformat_line_input, line_input))
647 memset (&reid, 0, sizeof (reid));
648 memset (&leid, 0, sizeof (leid));
650 leid_ippref = &gid_address_ippref (&leid);
651 reid_ippref = &gid_address_ippref (&reid);
653 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
655 if (unformat (line_input, "del"))
657 else if (unformat (line_input, "add"))
659 else if (unformat (line_input, "reid %U",
660 unformat_ip_prefix, reid_ippref))
662 gid_address_type (&reid) = GID_ADDR_IP_PREFIX;
665 else if (unformat (line_input, "reid %U", unformat_mac_address, dmac))
667 gid_address_type (&reid) = GID_ADDR_MAC;
670 else if (unformat (line_input, "vni %u", &vni))
672 gid_address_vni (&leid) = vni;
673 gid_address_vni (&reid) = vni;
675 else if (unformat (line_input, "leid %U",
676 unformat_ip_prefix, leid_ippref))
678 gid_address_type (&leid) = GID_ADDR_IP_PREFIX;
681 else if (unformat (line_input, "leid %U", unformat_mac_address, smac))
683 gid_address_type (&leid) = GID_ADDR_MAC;
688 clib_warning ("parse error");
693 if (!reid_set || !leid_set)
695 clib_warning ("missing remote or local eid!");
699 if ((gid_address_type (&leid) != gid_address_type (&reid))
700 || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX
701 && ip_prefix_version (reid_ippref)
702 != ip_prefix_version (leid_ippref)))
704 clib_warning ("remote and local EIDs are of different types!");
708 memset (a, 0, sizeof (a[0]));
709 gid_address_copy (&a->leid, &leid);
710 gid_address_copy (&a->reid, &reid);
713 if (vnet_lisp_add_del_adjacency (a))
714 clib_warning ("failed to %s adjacency!", is_add ? "add" : "delete");
717 unformat_free (line_input);
722 VLIB_CLI_COMMAND (one_add_del_adjacency_command) = {
723 .path = "one adjacency",
724 .short_help = "one adjacency add|del vni <vni> reid <remote-eid> "
726 .function = lisp_add_del_adjacency_command_fn,
731 static clib_error_t *
732 lisp_map_request_mode_command_fn (vlib_main_t * vm,
733 unformat_input_t * input,
734 vlib_cli_command_t * cmd)
736 unformat_input_t _i, *i = &_i;
737 map_request_mode_t mr_mode = _MR_MODE_MAX;
739 /* Get a line of input. */
740 if (!unformat_user (input, unformat_line_input, i))
743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
745 if (unformat (i, "dst-only"))
746 mr_mode = MR_MODE_DST_ONLY;
747 else if (unformat (i, "src-dst"))
748 mr_mode = MR_MODE_SRC_DST;
751 clib_warning ("parse error '%U'", format_unformat_error, i);
756 if (_MR_MODE_MAX == mr_mode)
758 clib_warning ("No map request mode entered!");
762 vnet_lisp_set_map_request_mode (mr_mode);
771 VLIB_CLI_COMMAND (one_map_request_mode_command) = {
772 .path = "one map-request mode",
773 .short_help = "one map-request mode dst-only|src-dst",
774 .function = lisp_map_request_mode_command_fn,
780 format_lisp_map_request_mode (u8 * s, va_list * args)
782 u32 mode = va_arg (*args, u32);
787 return format (0, "dst-only");
789 return format (0, "src-dst");
794 static clib_error_t *
795 lisp_show_map_request_mode_command_fn (vlib_main_t * vm,
796 unformat_input_t * input,
797 vlib_cli_command_t * cmd)
799 vlib_cli_output (vm, "map-request mode: %U", format_lisp_map_request_mode,
800 vnet_lisp_get_map_request_mode ());
805 VLIB_CLI_COMMAND (one_show_map_request_mode_command) = {
806 .path = "show one map-request mode",
807 .short_help = "show one map-request mode",
808 .function = lisp_show_map_request_mode_command_fn,
812 static clib_error_t *
813 lisp_show_map_resolvers_command_fn (vlib_main_t * vm,
814 unformat_input_t * input,
815 vlib_cli_command_t * cmd)
818 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
820 vec_foreach (mr, lcm->map_resolvers)
822 vlib_cli_output (vm, "%U", format_ip_address, &mr->address);
828 VLIB_CLI_COMMAND (one_show_map_resolvers_command) = {
829 .path = "show one map-resolvers",
830 .short_help = "show one map-resolvers",
831 .function = lisp_show_map_resolvers_command_fn,
835 static clib_error_t *
836 lisp_nsh_set_locator_set_command_fn (vlib_main_t * vm,
837 unformat_input_t * input,
838 vlib_cli_command_t * cmd)
840 u8 locator_name_set = 0;
841 u8 *locator_set_name = 0;
843 unformat_input_t _line_input, *line_input = &_line_input;
844 clib_error_t *error = 0;
847 /* Get a line of input. */
848 if (!unformat_user (input, unformat_line_input, line_input))
851 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
853 if (unformat (line_input, "ls %_%v%_", &locator_set_name))
854 locator_name_set = 1;
855 else if (unformat (line_input, "disable"))
859 error = clib_error_return (0, "parse error");
864 if (!locator_name_set)
866 clib_warning ("No locator set specified!");
870 rv = vnet_lisp_nsh_set_locator_set (locator_set_name, is_add);
873 error = clib_error_return (0, "failed to %s NSH mapping!",
874 is_add ? "add" : "delete");
878 vec_free (locator_set_name);
879 unformat_free (line_input);
884 VLIB_CLI_COMMAND (one_nsh_set_locator_set_command) = {
885 .path = "one nsh-mapping",
886 .short_help = "one nsh-mapping [del] ls <locator-set-name>",
887 .function = lisp_nsh_set_locator_set_command_fn,
891 static clib_error_t *
892 lisp_map_register_fallback_threshold_show_command_fn (vlib_main_t * vm,
898 u32 val = vnet_lisp_map_register_fallback_threshold_get ();
899 vlib_cli_output (vm, "map register fallback treshold value: %d", val);
904 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_show_command) = {
905 .path = "show one map-register fallback-threshold",
906 .short_help = "show one map-register fallback-threshold",
907 .function = lisp_map_register_fallback_threshold_show_command_fn,
912 static clib_error_t *
913 lisp_map_register_fallback_threshold_command_fn (vlib_main_t * vm,
914 unformat_input_t * input,
915 vlib_cli_command_t * cmd)
917 unformat_input_t _line_input, *line_input = &_line_input;
918 clib_error_t *error = 0;
922 /* Get a line of input. */
923 if (!unformat_user (input, unformat_line_input, line_input))
926 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
928 if (unformat (line_input, "%d", &val))
932 error = clib_error_return (0, "parse error");
937 rv = vnet_lisp_map_register_fallback_threshold_set (val);
940 error = clib_error_return (0, "setting fallback threshold failed!");
944 unformat_free (line_input);
949 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_command) = {
950 .path = "one map-register fallback-threshold",
951 .short_help = "one map-register fallback-threshold <count>",
952 .function = lisp_map_register_fallback_threshold_command_fn,
956 static clib_error_t *
957 lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
958 unformat_input_t * input,
959 vlib_cli_command_t * cmd)
961 u8 locator_name_set = 0;
962 u8 *locator_set_name = 0;
964 unformat_input_t _line_input, *line_input = &_line_input;
965 clib_error_t *error = 0;
968 /* Get a line of input. */
969 if (!unformat_user (input, unformat_line_input, line_input))
972 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
974 if (unformat (line_input, "ls %_%v%_", &locator_set_name))
975 locator_name_set = 1;
976 else if (unformat (line_input, "disable"))
980 error = clib_error_return (0, "parse error");
985 if (!locator_name_set)
987 clib_warning ("No locator set specified!");
990 rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
993 error = clib_error_return (0, "failed to %s pitr!",
994 is_add ? "add" : "delete");
998 if (locator_set_name)
999 vec_free (locator_set_name);
1000 unformat_free (line_input);
1005 VLIB_CLI_COMMAND (one_pitr_set_locator_set_command) = {
1007 .short_help = "one pitr [disable] ls <locator-set-name>",
1008 .function = lisp_pitr_set_locator_set_command_fn,
1012 static clib_error_t *
1013 lisp_show_pitr_command_fn (vlib_main_t * vm,
1014 unformat_input_t * input, vlib_cli_command_t * cmd)
1016 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1021 vlib_cli_output (vm, "%=20s%=16s",
1022 "pitr", lcm->lisp_pitr ? "locator-set" : "");
1024 if (!lcm->lisp_pitr)
1026 vlib_cli_output (vm, "%=20s", "disable");
1030 if (~0 == lcm->pitr_map_index)
1032 tmp_str = format (0, "N/A");
1036 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1037 if (~0 != m->locator_set_index)
1040 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1041 tmp_str = format (0, "%s", ls->name);
1045 tmp_str = format (0, "N/A");
1048 vec_add1 (tmp_str, 0);
1050 vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
1058 VLIB_CLI_COMMAND (one_show_pitr_command) = {
1059 .path = "show one pitr",
1060 .short_help = "Show pitr",
1061 .function = lisp_show_pitr_command_fn,
1066 format_eid_entry (u8 * s, va_list * args)
1068 vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
1069 lisp_cp_main_t *lcm = va_arg (*args, lisp_cp_main_t *);
1070 mapping_t *mapit = va_arg (*args, mapping_t *);
1071 locator_set_t *ls = va_arg (*args, locator_set_t *);
1072 gid_address_t *gid = &mapit->eid;
1073 u32 ttl = mapit->ttl;
1074 u8 aut = mapit->authoritative;
1079 u8 *type = ls->local ? format (0, "local(%s)", ls->name)
1080 : format (0, "remote");
1082 if (vec_len (ls->locator_indices) == 0)
1084 s = format (s, "%-35U%-20saction:%-30U%-20u%-u", format_gid_address,
1085 gid, type, format_negative_mapping_action, mapit->action,
1090 vec_foreach (loc_index, ls->locator_indices)
1092 locator_t *l = pool_elt_at_index (lcm->locator_pool, loc_index[0]);
1094 loc = format (0, "%U", format_vnet_sw_if_index_name, vnm,
1097 loc = format (0, "%U", format_ip_address,
1098 &gid_address_ip (&l->address));
1102 s = format (s, "%-35U%-20s%-30v%-20u%-u\n", format_gid_address,
1103 gid, type, loc, ttl, aut);
1107 s = format (s, "%55s%v\n", "", loc);
1113 static clib_error_t *
1114 lisp_show_eid_table_command_fn (vlib_main_t * vm,
1115 unformat_input_t * input,
1116 vlib_cli_command_t * cmd)
1118 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1120 unformat_input_t _line_input, *line_input = &_line_input;
1125 clib_error_t *error = NULL;
1127 memset (&eid, 0, sizeof (eid));
1129 /* Get a line of input. */
1130 if (!unformat_user (input, unformat_line_input, line_input))
1133 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1135 if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
1137 else if (unformat (line_input, "local"))
1139 else if (unformat (line_input, "remote"))
1143 error = clib_error_return (0, "parse error: '%U'",
1144 format_unformat_error, line_input);
1149 vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
1150 "EID", "type", "locators", "ttl", "autoritative");
1155 pool_foreach (mapit, lcm->mapping_pool,
1157 if (mapit->pitr_set || mapit->nsh_set)
1160 locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
1161 mapit->locator_set_index);
1162 if (filter && !((1 == filter && ls->local) ||
1163 (2 == filter && !ls->local)))
1167 vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
1174 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
1175 if ((u32) ~ 0 == mi)
1178 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
1179 locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool,
1180 mapit->locator_set_index);
1182 if (filter && !((1 == filter && ls->local) ||
1183 (2 == filter && !ls->local)))
1188 vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
1193 unformat_free (line_input);
1199 VLIB_CLI_COMMAND (one_cp_show_eid_table_command) = {
1200 .path = "show one eid-table",
1201 .short_help = "Shows EID table",
1202 .function = lisp_show_eid_table_command_fn,
1207 static clib_error_t *
1208 lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
1209 vlib_cli_command_t * cmd)
1211 unformat_input_t _line_input, *line_input = &_line_input;
1214 clib_error_t *error = NULL;
1216 /* Get a line of input. */
1217 if (!unformat_user (input, unformat_line_input, line_input))
1220 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1222 if (unformat (line_input, "enable"))
1227 else if (unformat (line_input, "disable"))
1231 error = clib_error_return (0, "parse error: '%U'",
1232 format_unformat_error, line_input);
1239 error = clib_error_return (0, "state not set");
1243 vnet_lisp_enable_disable (is_enabled);
1246 unformat_free (line_input);
1252 VLIB_CLI_COMMAND (one_cp_enable_disable_command) = {
1254 .short_help = "one [enable|disable]",
1255 .function = lisp_enable_disable_command_fn,
1259 static clib_error_t *
1260 lisp_map_register_set_ttl_command_fn (vlib_main_t * vm,
1261 unformat_input_t * input,
1262 vlib_cli_command_t * cmd)
1264 unformat_input_t _line_input, *line_input = &_line_input;
1267 clib_error_t *error = NULL;
1269 /* Get a line of input. */
1270 if (!unformat_user (input, unformat_line_input, line_input))
1273 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1275 if (unformat (line_input, "%u", &ttl))
1279 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1287 vlib_cli_output (vm, "expected integer value for TTL!");
1291 vnet_lisp_map_register_set_ttl (ttl);
1294 unformat_free (line_input);
1299 VLIB_CLI_COMMAND (one_map_register_set_ttl_command) = {
1300 .path = "one map-register ttl",
1301 .short_help = "one map-register ttl",
1302 .function = lisp_map_register_set_ttl_command_fn,
1306 static clib_error_t *
1307 lisp_map_register_show_ttl_command_fn (vlib_main_t * vm,
1308 unformat_input_t * input,
1309 vlib_cli_command_t * cmd)
1311 u32 ttl = vnet_lisp_map_register_get_ttl ();
1313 vlib_cli_output (vm, "map-register TTL: %u", ttl);
1318 VLIB_CLI_COMMAND (one_map_register_show_ttl_command) = {
1319 .path = "show one map-register ttl",
1320 .short_help = "show one map-register ttl",
1321 .function = lisp_map_register_show_ttl_command_fn,
1326 static clib_error_t *
1327 lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
1328 unformat_input_t * input,
1329 vlib_cli_command_t * cmd)
1331 unformat_input_t _line_input, *line_input = &_line_input;
1334 clib_error_t *error = NULL;
1336 /* Get a line of input. */
1337 if (!unformat_user (input, unformat_line_input, line_input))
1340 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1342 if (unformat (line_input, "enable"))
1347 else if (unformat (line_input, "disable"))
1351 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1359 vlib_cli_output (vm, "state not set!");
1363 vnet_lisp_map_register_enable_disable (is_enabled);
1366 unformat_free (line_input);
1372 VLIB_CLI_COMMAND (one_map_register_enable_disable_command) = {
1373 .path = "one map-register",
1374 .short_help = "one map-register [enable|disable]",
1375 .function = lisp_map_register_enable_disable_command_fn,
1379 static clib_error_t *
1380 lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
1381 unformat_input_t * input,
1382 vlib_cli_command_t * cmd)
1384 unformat_input_t _line_input, *line_input = &_line_input;
1387 clib_error_t *error = NULL;
1389 /* Get a line of input. */
1390 if (!unformat_user (input, unformat_line_input, line_input))
1393 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1395 if (unformat (line_input, "enable"))
1400 else if (unformat (line_input, "disable"))
1404 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1412 vlib_cli_output (vm, "state not set!");
1416 vnet_lisp_rloc_probe_enable_disable (is_enabled);
1419 unformat_free (line_input);
1425 VLIB_CLI_COMMAND (one_rloc_probe_enable_disable_command) = {
1426 .path = "one rloc-probe",
1427 .short_help = "one rloc-probe [enable|disable]",
1428 .function = lisp_rloc_probe_enable_disable_command_fn,
1433 format_lisp_status (u8 * s, va_list * args)
1435 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1436 return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
1439 static clib_error_t *
1440 lisp_show_status_command_fn (vlib_main_t * vm, unformat_input_t * input,
1441 vlib_cli_command_t * cmd)
1444 msg = format (msg, "feature: %U\ngpe: %U\n",
1445 format_lisp_status, format_vnet_lisp_gpe_status);
1446 vlib_cli_output (vm, "%v", msg);
1452 VLIB_CLI_COMMAND (one_show_status_command) = {
1453 .path = "show one status",
1454 .short_help = "show one status",
1455 .function = lisp_show_status_command_fn,
1459 static clib_error_t *
1460 lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
1461 unformat_input_t * input,
1462 vlib_cli_command_t * cmd)
1465 unformat_input_t _line_input, *line_input = &_line_input;
1466 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1467 uword *vni_table = 0;
1469 clib_error_t *error = NULL;
1471 /* Get a line of input. */
1472 if (!unformat_user (input, unformat_line_input, line_input))
1475 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1477 if (unformat (line_input, "l2"))
1479 vni_table = lcm->bd_id_by_vni;
1482 else if (unformat (line_input, "l3"))
1484 vni_table = lcm->table_id_by_vni;
1489 error = clib_error_return (0, "parse error: '%U'",
1490 format_unformat_error, line_input);
1497 vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
1501 vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
1504 hash_foreach_pair (p, vni_table,
1506 vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
1511 unformat_free (line_input);
1517 VLIB_CLI_COMMAND (one_show_eid_table_map_command) = {
1518 .path = "show one eid-table map",
1519 .short_help = "show one eid-table l2|l3",
1520 .function = lisp_show_eid_table_map_command_fn,
1525 static clib_error_t *
1526 lisp_add_del_locator_set_command_fn (vlib_main_t * vm,
1527 unformat_input_t * input,
1528 vlib_cli_command_t * cmd)
1530 lisp_gpe_main_t *lgm = &lisp_gpe_main;
1531 vnet_main_t *vnm = lgm->vnet_main;
1532 unformat_input_t _line_input, *line_input = &_line_input;
1534 clib_error_t *error = 0;
1535 u8 *locator_set_name = 0;
1536 locator_t locator, *locators = 0;
1537 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
1541 memset (&locator, 0, sizeof (locator));
1542 memset (a, 0, sizeof (a[0]));
1544 /* Get a line of input. */
1545 if (!unformat_user (input, unformat_line_input, line_input))
1548 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1550 if (unformat (line_input, "add %_%v%_", &locator_set_name))
1552 else if (unformat (line_input, "del %_%v%_", &locator_set_name))
1554 else if (unformat (line_input, "iface %U p %d w %d",
1555 unformat_vnet_sw_interface, vnm,
1556 &locator.sw_if_index, &locator.priority,
1560 vec_add1 (locators, locator);
1564 error = unformat_parse_error (line_input);
1569 a->name = locator_set_name;
1570 a->locators = locators;
1574 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
1577 error = clib_error_return (0, "failed to %s locator-set!",
1578 is_add ? "add" : "delete");
1582 vec_free (locators);
1583 if (locator_set_name)
1584 vec_free (locator_set_name);
1585 unformat_free (line_input);
1590 VLIB_CLI_COMMAND (one_cp_add_del_locator_set_command) = {
1591 .path = "one locator-set",
1592 .short_help = "one locator-set add/del <name> [iface <iface-name> "
1593 "p <priority> w <weight>]",
1594 .function = lisp_add_del_locator_set_command_fn,
1598 static clib_error_t *
1599 lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
1600 unformat_input_t * input,
1601 vlib_cli_command_t * cmd)
1603 lisp_gpe_main_t *lgm = &lisp_gpe_main;
1604 vnet_main_t *vnm = lgm->vnet_main;
1605 unformat_input_t _line_input, *line_input = &_line_input;
1607 clib_error_t *error = 0;
1608 u8 *locator_set_name = 0;
1609 u8 locator_set_name_set = 0;
1610 locator_t locator, *locators = 0;
1611 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
1614 memset (&locator, 0, sizeof (locator));
1615 memset (a, 0, sizeof (a[0]));
1617 /* Get a line of input. */
1618 if (!unformat_user (input, unformat_line_input, line_input))
1621 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1623 if (unformat (line_input, "add"))
1625 else if (unformat (line_input, "del"))
1627 else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
1628 locator_set_name_set = 1;
1629 else if (unformat (line_input, "iface %U p %d w %d",
1630 unformat_vnet_sw_interface, vnm,
1631 &locator.sw_if_index, &locator.priority,
1635 vec_add1 (locators, locator);
1639 error = unformat_parse_error (line_input);
1644 if (!locator_set_name_set)
1646 error = clib_error_return (0, "locator_set name not set!");
1650 a->name = locator_set_name;
1651 a->locators = locators;
1655 vnet_lisp_add_del_locator (a, 0, &ls_index);
1658 vec_free (locators);
1659 vec_free (locator_set_name);
1660 unformat_free (line_input);
1665 VLIB_CLI_COMMAND (one_cp_add_del_locator_in_set_command) = {
1666 .path = "one locator",
1667 .short_help = "one locator add/del locator-set <name> iface <iface-name> "
1668 "p <priority> w <weight>",
1669 .function = lisp_add_del_locator_in_set_command_fn,
1673 static clib_error_t *
1674 lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
1675 unformat_input_t * input,
1676 vlib_cli_command_t * cmd)
1678 locator_set_t *lsit;
1681 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1683 vlib_cli_output (vm, "%s%=16s%=16s%=16s", "Locator-set", "Locator",
1684 "Priority", "Weight");
1687 pool_foreach (lsit, lcm->locator_set_pool,
1693 msg = format (msg, "%v", lsit->name);
1697 msg = format (msg, "<%s-%d>", "remote", lsit - lcm->locator_set_pool);
1699 vec_foreach (locit, lsit->locator_indices)
1703 msg = format (msg, "%16s", " ");
1705 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
1707 msg = format (msg, "%16d%16d%16d\n", loc->sw_if_index, loc->priority,
1710 msg = format (msg, "%16U%16d%16d\n", format_ip_address,
1711 &gid_address_ip(&loc->address), loc->priority,
1715 vlib_cli_output (vm, "%v", msg);
1723 VLIB_CLI_COMMAND (one_cp_show_locator_sets_command) = {
1724 .path = "show one locator-set",
1725 .short_help = "Shows locator-sets",
1726 .function = lisp_cp_show_locator_sets_command_fn,
1731 static clib_error_t *
1732 lisp_add_del_map_resolver_command_fn (vlib_main_t * vm,
1733 unformat_input_t * input,
1734 vlib_cli_command_t * cmd)
1736 unformat_input_t _line_input, *line_input = &_line_input;
1737 u8 is_add = 1, addr_set = 0;
1738 ip_address_t ip_addr;
1739 clib_error_t *error = 0;
1741 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
1743 /* Get a line of input. */
1744 if (!unformat_user (input, unformat_line_input, line_input))
1747 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1749 if (unformat (line_input, "add"))
1751 else if (unformat (line_input, "del"))
1753 else if (unformat (line_input, "%U", unformat_ip_address, &ip_addr))
1757 error = unformat_parse_error (line_input);
1764 error = clib_error_return (0, "Map-resolver address must be set!");
1769 a->address = ip_addr;
1770 rv = vnet_lisp_add_del_map_resolver (a);
1773 error = clib_error_return (0, "failed to %s map-resolver!",
1774 is_add ? "add" : "delete");
1778 unformat_free (line_input);
1783 VLIB_CLI_COMMAND (one_add_del_map_resolver_command) = {
1784 .path = "one map-resolver",
1785 .short_help = "one map-resolver add/del <ip_address>",
1786 .function = lisp_add_del_map_resolver_command_fn,
1791 static clib_error_t *
1792 lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
1793 unformat_input_t * input,
1794 vlib_cli_command_t * cmd)
1796 unformat_input_t _line_input, *line_input = &_line_input;
1798 u8 *locator_set_name = 0;
1799 clib_error_t *error = 0;
1801 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
1803 /* Get a line of input. */
1804 if (!unformat_user (input, unformat_line_input, line_input))
1807 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1809 if (unformat (line_input, "del"))
1811 else if (unformat (line_input, "add %_%v%_", &locator_set_name))
1815 error = unformat_parse_error (line_input);
1821 a->locator_set_name = locator_set_name;
1822 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
1825 error = clib_error_return (0, "failed to %s map-request itr-rlocs!",
1826 is_add ? "add" : "delete");
1830 vec_free (locator_set_name);
1831 unformat_free (line_input);
1837 VLIB_CLI_COMMAND (one_add_del_map_request_command) = {
1838 .path = "one map-request itr-rlocs",
1839 .short_help = "one map-request itr-rlocs add/del <locator_set_name>",
1840 .function = lisp_add_del_mreq_itr_rlocs_command_fn,
1844 static clib_error_t *
1845 lisp_show_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
1846 unformat_input_t * input,
1847 vlib_cli_command_t * cmd)
1849 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1850 locator_set_t *loc_set;
1852 vlib_cli_output (vm, "%=20s", "itr-rlocs");
1854 if (~0 == lcm->mreq_itr_rlocs)
1859 loc_set = pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1861 vlib_cli_output (vm, "%=20s", loc_set->name);
1867 VLIB_CLI_COMMAND (one_show_map_request_command) = {
1868 .path = "show one map-request itr-rlocs",
1869 .short_help = "Shows map-request itr-rlocs",
1870 .function = lisp_show_mreq_itr_rlocs_command_fn,
1874 static clib_error_t *
1875 lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm,
1876 unformat_input_t * input,
1877 vlib_cli_command_t * cmd)
1879 u8 is_add = 1, ip_set = 0;
1880 unformat_input_t _line_input, *line_input = &_line_input;
1881 clib_error_t *error = 0;
1884 /* Get a line of input. */
1885 if (!unformat_user (input, unformat_line_input, line_input))
1888 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1890 if (unformat (line_input, "%U", unformat_ip_address, &ip))
1892 else if (unformat (line_input, "disable"))
1896 error = clib_error_return (0, "parse error");
1903 clib_warning ("No petr IP specified!");
1907 if (vnet_lisp_use_petr (&ip, is_add))
1909 error = clib_error_return (0, "failed to %s petr!",
1910 is_add ? "add" : "delete");
1914 unformat_free (line_input);
1919 VLIB_CLI_COMMAND (one_use_petr_set_locator_set_command) = {
1920 .path = "one use-petr",
1921 .short_help = "one use-petr [disable] <petr-ip>",
1922 .function = lisp_use_petr_set_locator_set_command_fn,
1925 static clib_error_t *
1926 lisp_show_petr_command_fn (vlib_main_t * vm,
1927 unformat_input_t * input, vlib_cli_command_t * cmd)
1929 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1934 u8 use_petr = lcm->flags & LISP_FLAG_USE_PETR;
1935 vlib_cli_output (vm, "%=20s%=16s", "petr", use_petr ? "ip" : "");
1939 vlib_cli_output (vm, "%=20s", "disable");
1943 if (~0 == lcm->petr_map_index)
1945 tmp_str = format (0, "N/A");
1949 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
1950 if (~0 != m->locator_set_index)
1952 ls = pool_elt_at_index(lcm->locator_set_pool, m->locator_set_index);
1953 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
1954 tmp_str = format (0, "%U", format_ip_address, &loc->address);
1958 tmp_str = format (0, "N/A");
1961 vec_add1 (tmp_str, 0);
1963 vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
1971 VLIB_CLI_COMMAND (one_show_petr_command) = {
1972 .path = "show one petr",
1973 .short_help = "Show petr",
1974 .function = lisp_show_petr_command_fn,
1978 static clib_error_t *
1979 lisp_show_map_servers_command_fn (vlib_main_t * vm,
1980 unformat_input_t * input,
1981 vlib_cli_command_t * cmd)
1984 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1986 vec_foreach (ms, lcm->map_servers)
1988 vlib_cli_output (vm, "%U", format_ip_address, &ms->address);
1994 VLIB_CLI_COMMAND (one_show_map_servers_command) = {
1995 .path = "show one map-servers",
1996 .short_help = "show one map servers",
1997 .function = lisp_show_map_servers_command_fn,
2001 static clib_error_t *
2002 lisp_show_map_register_state_command_fn (vlib_main_t * vm,
2003 unformat_input_t * input,
2004 vlib_cli_command_t * cmd)
2007 u8 is_enabled = vnet_lisp_map_register_state_get ();
2009 msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
2010 vlib_cli_output (vm, "%v", msg);
2016 VLIB_CLI_COMMAND (one_show_map_register_state_command) = {
2017 .path = "show one map-register state",
2018 .short_help = "show one map-register state",
2019 .function = lisp_show_map_register_state_command_fn,
2023 static clib_error_t *
2024 lisp_show_rloc_probe_state_command_fn (vlib_main_t * vm,
2025 unformat_input_t * input,
2026 vlib_cli_command_t * cmd)
2029 u8 is_enabled = vnet_lisp_rloc_probe_state_get ();
2031 msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
2032 vlib_cli_output (vm, "%v", msg);
2038 VLIB_CLI_COMMAND (one_show_rloc_probe_state_command) = {
2039 .path = "show one rloc state",
2040 .short_help = "show one RLOC state",
2041 .function = lisp_show_rloc_probe_state_command_fn,
2045 static clib_error_t *
2046 lisp_show_stats_command_fn (vlib_main_t * vm,
2047 unformat_input_t * input,
2048 vlib_cli_command_t * cmd)
2050 u8 is_enabled = vnet_lisp_stats_enable_disable_state ();
2051 vlib_cli_output (vm, "%s\n", is_enabled ? "enabled" : "disabled");
2056 VLIB_CLI_COMMAND (one_show_stats_command) = {
2057 .path = "show one statistics status",
2058 .short_help = "show ONE statistics enable/disable status",
2059 .function = lisp_show_stats_command_fn,
2063 static clib_error_t *
2064 lisp_show_stats_details_command_fn (vlib_main_t * vm,
2065 unformat_input_t * input,
2066 vlib_cli_command_t * cmd)
2068 lisp_api_stats_t *stat, *stats = vnet_lisp_get_stats ();
2070 if (vec_len (stats) > 0)
2071 vlib_cli_output (vm,
2072 "[src-EID, dst-EID] [loc-rloc, rmt-rloc] count bytes\n");
2074 vlib_cli_output (vm, "No statistics found.\n");
2076 vec_foreach (stat, stats)
2078 vlib_cli_output (vm, "[%U, %U] [%U, %U] %7u %7u\n",
2079 format_fid_address, &stat->seid,
2080 format_fid_address, &stat->deid,
2081 format_ip_address, &stat->loc_rloc,
2082 format_ip_address, &stat->rmt_rloc,
2083 stat->counters.packets, stat->counters.bytes);
2090 VLIB_CLI_COMMAND (one_show_stats_details_command) = {
2091 .path = "show one statistics details",
2092 .short_help = "show ONE statistics",
2093 .function = lisp_show_stats_details_command_fn,
2097 static clib_error_t *
2098 lisp_stats_enable_disable_command_fn (vlib_main_t * vm,
2099 unformat_input_t * input,
2100 vlib_cli_command_t * cmd)
2102 unformat_input_t _line_input, *line_input = &_line_input;
2105 /* Get a line of input. */
2106 if (!unformat_user (input, unformat_line_input, line_input))
2109 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2111 if (unformat (line_input, "enable"))
2113 else if (unformat (line_input, "disable"))
2117 clib_warning ("Error: expected enable/disable!");
2121 vnet_lisp_stats_enable_disable (enable);
2123 unformat_free (line_input);
2128 VLIB_CLI_COMMAND (one_stats_enable_disable_command) = {
2129 .path = "one statistics",
2130 .short_help = "enable/disable ONE statistics collecting",
2131 .function = lisp_stats_enable_disable_command_fn,
2135 static clib_error_t *
2136 lisp_stats_flush_command_fn (vlib_main_t * vm,
2137 unformat_input_t * input,
2138 vlib_cli_command_t * cmd)
2140 vnet_lisp_flush_stats ();
2145 VLIB_CLI_COMMAND (one_stats_flush_command) = {
2146 .path = "one statistics flush",
2147 .short_help = "Flush ONE statistics",
2148 .function = lisp_stats_flush_command_fn,
2153 * fd.io coding-style-patch-verification: ON
2156 * eval: (c-set-style "gnu")