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_l2_arp_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 _arp, *arp = &_arp;
292 memset (&ip4, 0, sizeof (ip4));
293 memset (hw_addr, 0, sizeof (hw_addr));
294 memset (arp, 0, sizeof (*arp));
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_ip4_address, &ip4))
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 gid_address_arp_ip4 (arp) = ip4;
324 gid_address_arp_bd (arp) = bd;
325 gid_address_type (arp) = GID_ADDR_ARP;
326 rc = vnet_lisp_add_del_l2_arp_entry (arp, hw_addr, is_add);
328 clib_warning ("Failed to %s l2 arp entry!", is_add ? "add" : "delete");
331 unformat_free (line_input);
336 VLIB_CLI_COMMAND (one_add_del_l2_arp_entry_command) = {
337 .path = "one l2 arp",
338 .short_help = "one l2 arp [del] bd <bd> mac <mac> ip <ipv4>",
339 .function = lisp_add_del_l2_arp_entry_command_fn,
343 static clib_error_t *
344 lisp_show_l2_arp_entries_command_fn (vlib_main_t * vm,
345 unformat_input_t * input,
346 vlib_cli_command_t * cmd)
348 u32 *ht = vnet_lisp_l2_arp_bds_get ();
349 lisp_api_l2_arp_entry_t *entries, *e;
353 hash_foreach_pair (p, ht,
355 entries = vnet_lisp_l2_arp_entries_get_by_bd (p->key);
356 vlib_cli_output (vm, "Table: %d", p->key);
358 vec_foreach (e, entries)
360 vlib_cli_output (vm, "\t%U -> %U", format_ip4_address, &e->ip4,
361 format_mac_address, e->mac);
372 VLIB_CLI_COMMAND (one_show_l2_arp_entries_command) = {
373 .path = "show one l2 arp entries",
374 .short_help = "Show ONE L2 ARP entries",
375 .function = lisp_show_l2_arp_entries_command_fn,
380 * Handler for add/del remote mapping CLI.
382 * @param vm vlib context
383 * @param input input from user
385 * @return pointer to clib error structure
387 static clib_error_t *
388 lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
389 unformat_input_t * input,
390 vlib_cli_command_t * cmd)
392 clib_error_t *error = 0;
393 unformat_input_t _line_input, *line_input = &_line_input;
394 u8 is_add = 1, del_all = 0;
395 locator_t rloc, *rlocs = 0, *curr_rloc = 0;
398 u32 vni, action = ~0, p, w;
401 /* Get a line of input. */
402 if (!unformat_user (input, unformat_line_input, line_input))
405 memset (&eid, 0, sizeof (eid));
406 memset (&rloc, 0, sizeof (rloc));
408 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
410 if (unformat (line_input, "del-all"))
412 else if (unformat (line_input, "del"))
414 else if (unformat (line_input, "add"))
416 else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
418 else if (unformat (line_input, "vni %u", &vni))
420 gid_address_vni (&eid) = vni;
422 else if (unformat (line_input, "p %d w %d", &p, &w))
427 ("No RLOC configured for setting priority/weight!");
430 curr_rloc->priority = p;
431 curr_rloc->weight = w;
433 else if (unformat (line_input, "rloc %U", unformat_ip_address,
434 &gid_address_ip (&rloc.address)))
436 /* since rloc is stored in ip prefix we need to set prefix length */
437 ip_prefix_t *pref = &gid_address_ippref (&rloc.address);
439 u8 version = gid_address_ip_version (&rloc.address);
440 ip_prefix_len (pref) = ip_address_max_len (version);
442 vec_add1 (rlocs, rloc);
443 curr_rloc = &rlocs[vec_len (rlocs) - 1];
445 else if (unformat (line_input, "action %U",
446 unformat_negative_mapping_action, &action))
450 clib_warning ("parse error");
455 if (!del_all && !eid_set)
457 clib_warning ("missing eid!");
463 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
465 clib_warning ("no action set for negative map-reply!");
471 vnet_lisp_clear_all_remote_adjacencies ();
475 /* if it's a delete, clean forwarding */
478 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
479 memset (a, 0, sizeof (a[0]));
480 gid_address_copy (&a->reid, &eid);
481 if (vnet_lisp_add_del_adjacency (a))
483 clib_warning ("failed to delete adjacency!");
488 /* add as static remote mapping, i.e., not authoritative and infinite
492 vnet_lisp_add_del_mapping_args_t _map_args, *map_args = &_map_args;
493 memset (map_args, 0, sizeof (map_args[0]));
494 gid_address_copy (&map_args->eid, &eid);
495 map_args->action = action;
496 map_args->is_static = 1;
497 map_args->authoritative = 0;
499 rv = vnet_lisp_add_mapping (map_args, rlocs, NULL, NULL);
502 rv = vnet_lisp_del_mapping (&eid, NULL);
505 clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
509 unformat_free (line_input);
514 VLIB_CLI_COMMAND (one_add_del_remote_mapping_command) = {
515 .path = "one remote-mapping",
517 "one remote-mapping add|del [del-all] vni <vni> "
518 "eid <est-eid> [action <no-action|natively-forward|"
519 "send-map-request|drop>] rloc <dst-locator> p <prio> w <weight> "
520 "[rloc <dst-locator> ... ]",
521 .function = lisp_add_del_remote_mapping_command_fn,
526 * Handler for add/del adjacency CLI.
528 static clib_error_t *
529 lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input,
530 vlib_cli_command_t * cmd)
532 clib_error_t *error = 0;
533 unformat_input_t _line_input, *line_input = &_line_input;
534 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
536 ip_prefix_t *reid_ippref, *leid_ippref;
537 gid_address_t leid, reid;
538 u8 *dmac = gid_address_mac (&reid);
539 u8 *smac = gid_address_mac (&leid);
540 u8 reid_set = 0, leid_set = 0;
543 /* Get a line of input. */
544 if (!unformat_user (input, unformat_line_input, line_input))
547 memset (&reid, 0, sizeof (reid));
548 memset (&leid, 0, sizeof (leid));
550 leid_ippref = &gid_address_ippref (&leid);
551 reid_ippref = &gid_address_ippref (&reid);
553 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
555 if (unformat (line_input, "del"))
557 else if (unformat (line_input, "add"))
559 else if (unformat (line_input, "reid %U",
560 unformat_ip_prefix, reid_ippref))
562 gid_address_type (&reid) = GID_ADDR_IP_PREFIX;
565 else if (unformat (line_input, "reid %U", unformat_mac_address, dmac))
567 gid_address_type (&reid) = GID_ADDR_MAC;
570 else if (unformat (line_input, "vni %u", &vni))
572 gid_address_vni (&leid) = vni;
573 gid_address_vni (&reid) = vni;
575 else if (unformat (line_input, "leid %U",
576 unformat_ip_prefix, leid_ippref))
578 gid_address_type (&leid) = GID_ADDR_IP_PREFIX;
581 else if (unformat (line_input, "leid %U", unformat_mac_address, smac))
583 gid_address_type (&leid) = GID_ADDR_MAC;
588 clib_warning ("parse error");
593 if (!reid_set || !leid_set)
595 clib_warning ("missing remote or local eid!");
599 if ((gid_address_type (&leid) != gid_address_type (&reid))
600 || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX
601 && ip_prefix_version (reid_ippref)
602 != ip_prefix_version (leid_ippref)))
604 clib_warning ("remote and local EIDs are of different types!");
608 memset (a, 0, sizeof (a[0]));
609 gid_address_copy (&a->leid, &leid);
610 gid_address_copy (&a->reid, &reid);
613 if (vnet_lisp_add_del_adjacency (a))
614 clib_warning ("failed to %s adjacency!", is_add ? "add" : "delete");
617 unformat_free (line_input);
622 VLIB_CLI_COMMAND (one_add_del_adjacency_command) = {
623 .path = "one adjacency",
624 .short_help = "one adjacency add|del vni <vni> reid <remote-eid> "
626 .function = lisp_add_del_adjacency_command_fn,
631 static clib_error_t *
632 lisp_map_request_mode_command_fn (vlib_main_t * vm,
633 unformat_input_t * input,
634 vlib_cli_command_t * cmd)
636 unformat_input_t _i, *i = &_i;
637 map_request_mode_t mr_mode = _MR_MODE_MAX;
639 /* Get a line of input. */
640 if (!unformat_user (input, unformat_line_input, i))
643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
645 if (unformat (i, "dst-only"))
646 mr_mode = MR_MODE_DST_ONLY;
647 else if (unformat (i, "src-dst"))
648 mr_mode = MR_MODE_SRC_DST;
651 clib_warning ("parse error '%U'", format_unformat_error, i);
656 if (_MR_MODE_MAX == mr_mode)
658 clib_warning ("No map request mode entered!");
662 vnet_lisp_set_map_request_mode (mr_mode);
671 VLIB_CLI_COMMAND (one_map_request_mode_command) = {
672 .path = "one map-request mode",
673 .short_help = "one map-request mode dst-only|src-dst",
674 .function = lisp_map_request_mode_command_fn,
680 format_lisp_map_request_mode (u8 * s, va_list * args)
682 u32 mode = va_arg (*args, u32);
687 return format (0, "dst-only");
689 return format (0, "src-dst");
694 static clib_error_t *
695 lisp_show_map_request_mode_command_fn (vlib_main_t * vm,
696 unformat_input_t * input,
697 vlib_cli_command_t * cmd)
699 vlib_cli_output (vm, "map-request mode: %U", format_lisp_map_request_mode,
700 vnet_lisp_get_map_request_mode ());
705 VLIB_CLI_COMMAND (one_show_map_request_mode_command) = {
706 .path = "show one map-request mode",
707 .short_help = "show one map-request mode",
708 .function = lisp_show_map_request_mode_command_fn,
712 static clib_error_t *
713 lisp_show_map_resolvers_command_fn (vlib_main_t * vm,
714 unformat_input_t * input,
715 vlib_cli_command_t * cmd)
718 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
720 vec_foreach (mr, lcm->map_resolvers)
722 vlib_cli_output (vm, "%U", format_ip_address, &mr->address);
728 VLIB_CLI_COMMAND (one_show_map_resolvers_command) = {
729 .path = "show one map-resolvers",
730 .short_help = "show one map-resolvers",
731 .function = lisp_show_map_resolvers_command_fn,
735 static clib_error_t *
736 lisp_nsh_set_locator_set_command_fn (vlib_main_t * vm,
737 unformat_input_t * input,
738 vlib_cli_command_t * cmd)
740 u8 locator_name_set = 0;
741 u8 *locator_set_name = 0;
743 unformat_input_t _line_input, *line_input = &_line_input;
744 clib_error_t *error = 0;
747 /* Get a line of input. */
748 if (!unformat_user (input, unformat_line_input, line_input))
751 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
753 if (unformat (line_input, "ls %_%v%_", &locator_set_name))
754 locator_name_set = 1;
755 else if (unformat (line_input, "disable"))
759 error = clib_error_return (0, "parse error");
764 if (!locator_name_set)
766 clib_warning ("No locator set specified!");
770 rv = vnet_lisp_nsh_set_locator_set (locator_set_name, is_add);
773 error = clib_error_return (0, "failed to %s NSH mapping!",
774 is_add ? "add" : "delete");
778 vec_free (locator_set_name);
779 unformat_free (line_input);
784 VLIB_CLI_COMMAND (one_nsh_set_locator_set_command) = {
785 .path = "one nsh-mapping",
786 .short_help = "one nsh-mapping [del] ls <locator-set-name>",
787 .function = lisp_nsh_set_locator_set_command_fn,
791 static clib_error_t *
792 lisp_map_register_fallback_threshold_show_command_fn (vlib_main_t * vm,
798 u32 val = vnet_lisp_map_register_fallback_threshold_get ();
799 vlib_cli_output (vm, "map register fallback treshold value: %d", val);
804 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_show_command) = {
805 .path = "show one map-register fallback-threshold",
806 .short_help = "show one map-register fallback-threshold",
807 .function = lisp_map_register_fallback_threshold_show_command_fn,
812 static clib_error_t *
813 lisp_map_register_fallback_threshold_command_fn (vlib_main_t * vm,
814 unformat_input_t * input,
815 vlib_cli_command_t * cmd)
817 unformat_input_t _line_input, *line_input = &_line_input;
818 clib_error_t *error = 0;
822 /* Get a line of input. */
823 if (!unformat_user (input, unformat_line_input, line_input))
826 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
828 if (unformat (line_input, "%d", &val))
832 error = clib_error_return (0, "parse error");
837 rv = vnet_lisp_map_register_fallback_threshold_set (val);
840 error = clib_error_return (0, "setting fallback threshold failed!");
844 unformat_free (line_input);
849 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_command) = {
850 .path = "one map-register fallback-threshold",
851 .short_help = "one map-register fallback-threshold <count>",
852 .function = lisp_map_register_fallback_threshold_command_fn,
856 static clib_error_t *
857 lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
858 unformat_input_t * input,
859 vlib_cli_command_t * cmd)
861 u8 locator_name_set = 0;
862 u8 *locator_set_name = 0;
864 unformat_input_t _line_input, *line_input = &_line_input;
865 clib_error_t *error = 0;
868 /* Get a line of input. */
869 if (!unformat_user (input, unformat_line_input, line_input))
872 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
874 if (unformat (line_input, "ls %_%v%_", &locator_set_name))
875 locator_name_set = 1;
876 else if (unformat (line_input, "disable"))
880 error = clib_error_return (0, "parse error");
885 if (!locator_name_set)
887 clib_warning ("No locator set specified!");
890 rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
893 error = clib_error_return (0, "failed to %s pitr!",
894 is_add ? "add" : "delete");
898 if (locator_set_name)
899 vec_free (locator_set_name);
900 unformat_free (line_input);
905 VLIB_CLI_COMMAND (one_pitr_set_locator_set_command) = {
907 .short_help = "one pitr [disable] ls <locator-set-name>",
908 .function = lisp_pitr_set_locator_set_command_fn,
912 static clib_error_t *
913 lisp_show_pitr_command_fn (vlib_main_t * vm,
914 unformat_input_t * input, vlib_cli_command_t * cmd)
916 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
921 vlib_cli_output (vm, "%=20s%=16s",
922 "pitr", lcm->lisp_pitr ? "locator-set" : "");
926 vlib_cli_output (vm, "%=20s", "disable");
930 if (~0 == lcm->pitr_map_index)
932 tmp_str = format (0, "N/A");
936 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
937 if (~0 != m->locator_set_index)
940 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
941 tmp_str = format (0, "%s", ls->name);
945 tmp_str = format (0, "N/A");
948 vec_add1 (tmp_str, 0);
950 vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
958 VLIB_CLI_COMMAND (one_show_pitr_command) = {
959 .path = "show one pitr",
960 .short_help = "Show pitr",
961 .function = lisp_show_pitr_command_fn,
966 format_eid_entry (u8 * s, va_list * args)
968 vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
969 lisp_cp_main_t *lcm = va_arg (*args, lisp_cp_main_t *);
970 mapping_t *mapit = va_arg (*args, mapping_t *);
971 locator_set_t *ls = va_arg (*args, locator_set_t *);
972 gid_address_t *gid = &mapit->eid;
973 u32 ttl = mapit->ttl;
974 u8 aut = mapit->authoritative;
979 u8 *type = ls->local ? format (0, "local(%s)", ls->name)
980 : format (0, "remote");
982 if (vec_len (ls->locator_indices) == 0)
984 s = format (s, "%-35U%-20saction:%-30U%-20u%-u", format_gid_address,
985 gid, type, format_negative_mapping_action, mapit->action,
990 vec_foreach (loc_index, ls->locator_indices)
992 locator_t *l = pool_elt_at_index (lcm->locator_pool, loc_index[0]);
994 loc = format (0, "%U", format_vnet_sw_if_index_name, vnm,
997 loc = format (0, "%U", format_ip_address,
998 &gid_address_ip (&l->address));
1002 s = format (s, "%-35U%-20s%-30v%-20u%-u\n", format_gid_address,
1003 gid, type, loc, ttl, aut);
1007 s = format (s, "%55s%v\n", "", loc);
1013 static clib_error_t *
1014 lisp_show_eid_table_command_fn (vlib_main_t * vm,
1015 unformat_input_t * input,
1016 vlib_cli_command_t * cmd)
1018 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1020 unformat_input_t _line_input, *line_input = &_line_input;
1025 clib_error_t *error = NULL;
1027 memset (&eid, 0, sizeof (eid));
1029 /* Get a line of input. */
1030 if (!unformat_user (input, unformat_line_input, line_input))
1033 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1035 if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
1037 else if (unformat (line_input, "local"))
1039 else if (unformat (line_input, "remote"))
1043 error = clib_error_return (0, "parse error: '%U'",
1044 format_unformat_error, line_input);
1049 vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
1050 "EID", "type", "locators", "ttl", "autoritative");
1055 pool_foreach (mapit, lcm->mapping_pool,
1057 if (mapit->pitr_set || mapit->nsh_set)
1060 locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
1061 mapit->locator_set_index);
1062 if (filter && !((1 == filter && ls->local) ||
1063 (2 == filter && !ls->local)))
1067 vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
1074 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
1075 if ((u32) ~ 0 == mi)
1078 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
1079 locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool,
1080 mapit->locator_set_index);
1082 if (filter && !((1 == filter && ls->local) ||
1083 (2 == filter && !ls->local)))
1088 vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
1093 unformat_free (line_input);
1099 VLIB_CLI_COMMAND (one_cp_show_eid_table_command) = {
1100 .path = "show one eid-table",
1101 .short_help = "Shows EID table",
1102 .function = lisp_show_eid_table_command_fn,
1107 static clib_error_t *
1108 lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
1109 vlib_cli_command_t * cmd)
1111 unformat_input_t _line_input, *line_input = &_line_input;
1114 clib_error_t *error = NULL;
1116 /* Get a line of input. */
1117 if (!unformat_user (input, unformat_line_input, line_input))
1120 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1122 if (unformat (line_input, "enable"))
1127 else if (unformat (line_input, "disable"))
1131 error = clib_error_return (0, "parse error: '%U'",
1132 format_unformat_error, line_input);
1139 error = clib_error_return (0, "state not set");
1143 vnet_lisp_enable_disable (is_enabled);
1146 unformat_free (line_input);
1152 VLIB_CLI_COMMAND (one_cp_enable_disable_command) = {
1154 .short_help = "one [enable|disable]",
1155 .function = lisp_enable_disable_command_fn,
1159 static clib_error_t *
1160 lisp_map_register_set_ttl_command_fn (vlib_main_t * vm,
1161 unformat_input_t * input,
1162 vlib_cli_command_t * cmd)
1164 unformat_input_t _line_input, *line_input = &_line_input;
1167 clib_error_t *error = NULL;
1169 /* Get a line of input. */
1170 if (!unformat_user (input, unformat_line_input, line_input))
1173 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1175 if (unformat (line_input, "%u", &ttl))
1179 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1187 vlib_cli_output (vm, "expected integer value for TTL!");
1191 vnet_lisp_map_register_set_ttl (ttl);
1194 unformat_free (line_input);
1199 VLIB_CLI_COMMAND (one_map_register_set_ttl_command) = {
1200 .path = "one map-register ttl",
1201 .short_help = "one map-register ttl",
1202 .function = lisp_map_register_set_ttl_command_fn,
1206 static clib_error_t *
1207 lisp_map_register_show_ttl_command_fn (vlib_main_t * vm,
1208 unformat_input_t * input,
1209 vlib_cli_command_t * cmd)
1211 u32 ttl = vnet_lisp_map_register_get_ttl ();
1213 vlib_cli_output (vm, "map-register TTL: %u", ttl);
1218 VLIB_CLI_COMMAND (one_map_register_show_ttl_command) = {
1219 .path = "show one map-register ttl",
1220 .short_help = "show one map-register ttl",
1221 .function = lisp_map_register_show_ttl_command_fn,
1226 static clib_error_t *
1227 lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
1228 unformat_input_t * input,
1229 vlib_cli_command_t * cmd)
1231 unformat_input_t _line_input, *line_input = &_line_input;
1234 clib_error_t *error = NULL;
1236 /* Get a line of input. */
1237 if (!unformat_user (input, unformat_line_input, line_input))
1240 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1242 if (unformat (line_input, "enable"))
1247 else if (unformat (line_input, "disable"))
1251 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1259 vlib_cli_output (vm, "state not set!");
1263 vnet_lisp_map_register_enable_disable (is_enabled);
1266 unformat_free (line_input);
1272 VLIB_CLI_COMMAND (one_map_register_enable_disable_command) = {
1273 .path = "one map-register",
1274 .short_help = "one map-register [enable|disable]",
1275 .function = lisp_map_register_enable_disable_command_fn,
1279 static clib_error_t *
1280 lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
1281 unformat_input_t * input,
1282 vlib_cli_command_t * cmd)
1284 unformat_input_t _line_input, *line_input = &_line_input;
1287 clib_error_t *error = NULL;
1289 /* Get a line of input. */
1290 if (!unformat_user (input, unformat_line_input, line_input))
1293 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1295 if (unformat (line_input, "enable"))
1300 else if (unformat (line_input, "disable"))
1304 vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1312 vlib_cli_output (vm, "state not set!");
1316 vnet_lisp_rloc_probe_enable_disable (is_enabled);
1319 unformat_free (line_input);
1325 VLIB_CLI_COMMAND (one_rloc_probe_enable_disable_command) = {
1326 .path = "one rloc-probe",
1327 .short_help = "one rloc-probe [enable|disable]",
1328 .function = lisp_rloc_probe_enable_disable_command_fn,
1333 format_lisp_status (u8 * s, va_list * args)
1335 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1336 return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
1339 static clib_error_t *
1340 lisp_show_status_command_fn (vlib_main_t * vm, unformat_input_t * input,
1341 vlib_cli_command_t * cmd)
1344 msg = format (msg, "feature: %U\ngpe: %U\n",
1345 format_lisp_status, format_vnet_lisp_gpe_status);
1346 vlib_cli_output (vm, "%v", msg);
1352 VLIB_CLI_COMMAND (one_show_status_command) = {
1353 .path = "show one status",
1354 .short_help = "show one status",
1355 .function = lisp_show_status_command_fn,
1359 static clib_error_t *
1360 lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
1361 unformat_input_t * input,
1362 vlib_cli_command_t * cmd)
1365 unformat_input_t _line_input, *line_input = &_line_input;
1366 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1367 uword *vni_table = 0;
1369 clib_error_t *error = NULL;
1371 /* Get a line of input. */
1372 if (!unformat_user (input, unformat_line_input, line_input))
1375 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1377 if (unformat (line_input, "l2"))
1379 vni_table = lcm->bd_id_by_vni;
1382 else if (unformat (line_input, "l3"))
1384 vni_table = lcm->table_id_by_vni;
1389 error = clib_error_return (0, "parse error: '%U'",
1390 format_unformat_error, line_input);
1397 vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
1401 vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
1404 hash_foreach_pair (p, vni_table,
1406 vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
1411 unformat_free (line_input);
1417 VLIB_CLI_COMMAND (one_show_eid_table_map_command) = {
1418 .path = "show one eid-table map",
1419 .short_help = "show one eid-table l2|l3",
1420 .function = lisp_show_eid_table_map_command_fn,
1425 static clib_error_t *
1426 lisp_add_del_locator_set_command_fn (vlib_main_t * vm,
1427 unformat_input_t * input,
1428 vlib_cli_command_t * cmd)
1430 lisp_gpe_main_t *lgm = &lisp_gpe_main;
1431 vnet_main_t *vnm = lgm->vnet_main;
1432 unformat_input_t _line_input, *line_input = &_line_input;
1434 clib_error_t *error = 0;
1435 u8 *locator_set_name = 0;
1436 locator_t locator, *locators = 0;
1437 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
1441 memset (&locator, 0, sizeof (locator));
1442 memset (a, 0, sizeof (a[0]));
1444 /* Get a line of input. */
1445 if (!unformat_user (input, unformat_line_input, line_input))
1448 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1450 if (unformat (line_input, "add %_%v%_", &locator_set_name))
1452 else if (unformat (line_input, "del %_%v%_", &locator_set_name))
1454 else if (unformat (line_input, "iface %U p %d w %d",
1455 unformat_vnet_sw_interface, vnm,
1456 &locator.sw_if_index, &locator.priority,
1460 vec_add1 (locators, locator);
1464 error = unformat_parse_error (line_input);
1469 a->name = locator_set_name;
1470 a->locators = locators;
1474 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
1477 error = clib_error_return (0, "failed to %s locator-set!",
1478 is_add ? "add" : "delete");
1482 vec_free (locators);
1483 if (locator_set_name)
1484 vec_free (locator_set_name);
1485 unformat_free (line_input);
1490 VLIB_CLI_COMMAND (one_cp_add_del_locator_set_command) = {
1491 .path = "one locator-set",
1492 .short_help = "one locator-set add/del <name> [iface <iface-name> "
1493 "p <priority> w <weight>]",
1494 .function = lisp_add_del_locator_set_command_fn,
1498 static clib_error_t *
1499 lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
1500 unformat_input_t * input,
1501 vlib_cli_command_t * cmd)
1503 lisp_gpe_main_t *lgm = &lisp_gpe_main;
1504 vnet_main_t *vnm = lgm->vnet_main;
1505 unformat_input_t _line_input, *line_input = &_line_input;
1507 clib_error_t *error = 0;
1508 u8 *locator_set_name = 0;
1509 u8 locator_set_name_set = 0;
1510 locator_t locator, *locators = 0;
1511 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
1514 memset (&locator, 0, sizeof (locator));
1515 memset (a, 0, sizeof (a[0]));
1517 /* Get a line of input. */
1518 if (!unformat_user (input, unformat_line_input, line_input))
1521 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1523 if (unformat (line_input, "add"))
1525 else if (unformat (line_input, "del"))
1527 else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
1528 locator_set_name_set = 1;
1529 else if (unformat (line_input, "iface %U p %d w %d",
1530 unformat_vnet_sw_interface, vnm,
1531 &locator.sw_if_index, &locator.priority,
1535 vec_add1 (locators, locator);
1539 error = unformat_parse_error (line_input);
1544 if (!locator_set_name_set)
1546 error = clib_error_return (0, "locator_set name not set!");
1550 a->name = locator_set_name;
1551 a->locators = locators;
1555 vnet_lisp_add_del_locator (a, 0, &ls_index);
1558 vec_free (locators);
1559 vec_free (locator_set_name);
1560 unformat_free (line_input);
1565 VLIB_CLI_COMMAND (one_cp_add_del_locator_in_set_command) = {
1566 .path = "one locator",
1567 .short_help = "one locator add/del locator-set <name> iface <iface-name> "
1568 "p <priority> w <weight>",
1569 .function = lisp_add_del_locator_in_set_command_fn,
1573 static clib_error_t *
1574 lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
1575 unformat_input_t * input,
1576 vlib_cli_command_t * cmd)
1578 locator_set_t *lsit;
1581 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1583 vlib_cli_output (vm, "%s%=16s%=16s%=16s", "Locator-set", "Locator",
1584 "Priority", "Weight");
1587 pool_foreach (lsit, lcm->locator_set_pool,
1593 msg = format (msg, "%v", lsit->name);
1597 msg = format (msg, "<%s-%d>", "remote", lsit - lcm->locator_set_pool);
1599 vec_foreach (locit, lsit->locator_indices)
1603 msg = format (msg, "%16s", " ");
1605 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
1607 msg = format (msg, "%16d%16d%16d\n", loc->sw_if_index, loc->priority,
1610 msg = format (msg, "%16U%16d%16d\n", format_ip_address,
1611 &gid_address_ip(&loc->address), loc->priority,
1615 vlib_cli_output (vm, "%v", msg);
1623 VLIB_CLI_COMMAND (one_cp_show_locator_sets_command) = {
1624 .path = "show one locator-set",
1625 .short_help = "Shows locator-sets",
1626 .function = lisp_cp_show_locator_sets_command_fn,
1631 static clib_error_t *
1632 lisp_add_del_map_resolver_command_fn (vlib_main_t * vm,
1633 unformat_input_t * input,
1634 vlib_cli_command_t * cmd)
1636 unformat_input_t _line_input, *line_input = &_line_input;
1637 u8 is_add = 1, addr_set = 0;
1638 ip_address_t ip_addr;
1639 clib_error_t *error = 0;
1641 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
1643 /* Get a line of input. */
1644 if (!unformat_user (input, unformat_line_input, line_input))
1647 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1649 if (unformat (line_input, "add"))
1651 else if (unformat (line_input, "del"))
1653 else if (unformat (line_input, "%U", unformat_ip_address, &ip_addr))
1657 error = unformat_parse_error (line_input);
1664 error = clib_error_return (0, "Map-resolver address must be set!");
1669 a->address = ip_addr;
1670 rv = vnet_lisp_add_del_map_resolver (a);
1673 error = clib_error_return (0, "failed to %s map-resolver!",
1674 is_add ? "add" : "delete");
1678 unformat_free (line_input);
1683 VLIB_CLI_COMMAND (one_add_del_map_resolver_command) = {
1684 .path = "one map-resolver",
1685 .short_help = "one map-resolver add/del <ip_address>",
1686 .function = lisp_add_del_map_resolver_command_fn,
1691 static clib_error_t *
1692 lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
1693 unformat_input_t * input,
1694 vlib_cli_command_t * cmd)
1696 unformat_input_t _line_input, *line_input = &_line_input;
1698 u8 *locator_set_name = 0;
1699 clib_error_t *error = 0;
1701 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
1703 /* Get a line of input. */
1704 if (!unformat_user (input, unformat_line_input, line_input))
1707 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1709 if (unformat (line_input, "del"))
1711 else if (unformat (line_input, "add %_%v%_", &locator_set_name))
1715 error = unformat_parse_error (line_input);
1721 a->locator_set_name = locator_set_name;
1722 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
1725 error = clib_error_return (0, "failed to %s map-request itr-rlocs!",
1726 is_add ? "add" : "delete");
1730 vec_free (locator_set_name);
1731 unformat_free (line_input);
1737 VLIB_CLI_COMMAND (one_add_del_map_request_command) = {
1738 .path = "one map-request itr-rlocs",
1739 .short_help = "one map-request itr-rlocs add/del <locator_set_name>",
1740 .function = lisp_add_del_mreq_itr_rlocs_command_fn,
1744 static clib_error_t *
1745 lisp_show_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
1746 unformat_input_t * input,
1747 vlib_cli_command_t * cmd)
1749 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1750 locator_set_t *loc_set;
1752 vlib_cli_output (vm, "%=20s", "itr-rlocs");
1754 if (~0 == lcm->mreq_itr_rlocs)
1759 loc_set = pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1761 vlib_cli_output (vm, "%=20s", loc_set->name);
1767 VLIB_CLI_COMMAND (one_show_map_request_command) = {
1768 .path = "show one map-request itr-rlocs",
1769 .short_help = "Shows map-request itr-rlocs",
1770 .function = lisp_show_mreq_itr_rlocs_command_fn,
1774 static clib_error_t *
1775 lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm,
1776 unformat_input_t * input,
1777 vlib_cli_command_t * cmd)
1779 u8 is_add = 1, ip_set = 0;
1780 unformat_input_t _line_input, *line_input = &_line_input;
1781 clib_error_t *error = 0;
1784 /* Get a line of input. */
1785 if (!unformat_user (input, unformat_line_input, line_input))
1788 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1790 if (unformat (line_input, "%U", unformat_ip_address, &ip))
1792 else if (unformat (line_input, "disable"))
1796 error = clib_error_return (0, "parse error");
1803 clib_warning ("No petr IP specified!");
1807 if (vnet_lisp_use_petr (&ip, is_add))
1809 error = clib_error_return (0, "failed to %s petr!",
1810 is_add ? "add" : "delete");
1814 unformat_free (line_input);
1819 VLIB_CLI_COMMAND (one_use_petr_set_locator_set_command) = {
1820 .path = "one use-petr",
1821 .short_help = "one use-petr [disable] <petr-ip>",
1822 .function = lisp_use_petr_set_locator_set_command_fn,
1825 static clib_error_t *
1826 lisp_show_petr_command_fn (vlib_main_t * vm,
1827 unformat_input_t * input, vlib_cli_command_t * cmd)
1829 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1834 u8 use_petr = lcm->flags & LISP_FLAG_USE_PETR;
1835 vlib_cli_output (vm, "%=20s%=16s", "petr", use_petr ? "ip" : "");
1839 vlib_cli_output (vm, "%=20s", "disable");
1843 if (~0 == lcm->petr_map_index)
1845 tmp_str = format (0, "N/A");
1849 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
1850 if (~0 != m->locator_set_index)
1852 ls = pool_elt_at_index(lcm->locator_set_pool, m->locator_set_index);
1853 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
1854 tmp_str = format (0, "%U", format_ip_address, &loc->address);
1858 tmp_str = format (0, "N/A");
1861 vec_add1 (tmp_str, 0);
1863 vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
1871 VLIB_CLI_COMMAND (one_show_petr_command) = {
1872 .path = "show one petr",
1873 .short_help = "Show petr",
1874 .function = lisp_show_petr_command_fn,
1878 static clib_error_t *
1879 lisp_show_map_servers_command_fn (vlib_main_t * vm,
1880 unformat_input_t * input,
1881 vlib_cli_command_t * cmd)
1884 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1886 vec_foreach (ms, lcm->map_servers)
1888 vlib_cli_output (vm, "%U", format_ip_address, &ms->address);
1894 VLIB_CLI_COMMAND (one_show_map_servers_command) = {
1895 .path = "show one map-servers",
1896 .short_help = "show one map servers",
1897 .function = lisp_show_map_servers_command_fn,
1901 static clib_error_t *
1902 lisp_show_map_register_state_command_fn (vlib_main_t * vm,
1903 unformat_input_t * input,
1904 vlib_cli_command_t * cmd)
1907 u8 is_enabled = vnet_lisp_map_register_state_get ();
1909 msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
1910 vlib_cli_output (vm, "%v", msg);
1916 VLIB_CLI_COMMAND (one_show_map_register_state_command) = {
1917 .path = "show one map-register state",
1918 .short_help = "show one map-register state",
1919 .function = lisp_show_map_register_state_command_fn,
1923 static clib_error_t *
1924 lisp_show_rloc_probe_state_command_fn (vlib_main_t * vm,
1925 unformat_input_t * input,
1926 vlib_cli_command_t * cmd)
1929 u8 is_enabled = vnet_lisp_rloc_probe_state_get ();
1931 msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
1932 vlib_cli_output (vm, "%v", msg);
1938 VLIB_CLI_COMMAND (one_show_rloc_probe_state_command) = {
1939 .path = "show one rloc state",
1940 .short_help = "show one RLOC state",
1941 .function = lisp_show_rloc_probe_state_command_fn,
1945 static clib_error_t *
1946 lisp_show_stats_command_fn (vlib_main_t * vm,
1947 unformat_input_t * input,
1948 vlib_cli_command_t * cmd)
1950 u8 is_enabled = vnet_lisp_stats_enable_disable_state ();
1951 vlib_cli_output (vm, "%s\n", is_enabled ? "enabled" : "disabled");
1956 VLIB_CLI_COMMAND (one_show_stats_command) = {
1957 .path = "show one statistics status",
1958 .short_help = "show ONE statistics enable/disable status",
1959 .function = lisp_show_stats_command_fn,
1963 static clib_error_t *
1964 lisp_show_stats_details_command_fn (vlib_main_t * vm,
1965 unformat_input_t * input,
1966 vlib_cli_command_t * cmd)
1968 lisp_api_stats_t *stat, *stats = vnet_lisp_get_stats ();
1970 if (vec_len (stats) > 0)
1971 vlib_cli_output (vm,
1972 "[src-EID, dst-EID] [loc-rloc, rmt-rloc] count bytes\n");
1974 vlib_cli_output (vm, "No statistics found.\n");
1976 vec_foreach (stat, stats)
1978 vlib_cli_output (vm, "[%U, %U] [%U, %U] %7u %7u\n",
1979 format_fid_address, &stat->seid,
1980 format_fid_address, &stat->deid,
1981 format_ip_address, &stat->loc_rloc,
1982 format_ip_address, &stat->rmt_rloc,
1983 stat->counters.packets, stat->counters.bytes);
1990 VLIB_CLI_COMMAND (one_show_stats_details_command) = {
1991 .path = "show one statistics details",
1992 .short_help = "show ONE statistics",
1993 .function = lisp_show_stats_details_command_fn,
1997 static clib_error_t *
1998 lisp_stats_enable_disable_command_fn (vlib_main_t * vm,
1999 unformat_input_t * input,
2000 vlib_cli_command_t * cmd)
2002 unformat_input_t _line_input, *line_input = &_line_input;
2005 /* Get a line of input. */
2006 if (!unformat_user (input, unformat_line_input, line_input))
2009 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2011 if (unformat (line_input, "enable"))
2013 else if (unformat (line_input, "disable"))
2017 clib_warning ("Error: expected enable/disable!");
2021 vnet_lisp_stats_enable_disable (enable);
2023 unformat_free (line_input);
2028 VLIB_CLI_COMMAND (one_stats_enable_disable_command) = {
2029 .path = "one statistics",
2030 .short_help = "enable/disable ONE statistics collecting",
2031 .function = lisp_stats_enable_disable_command_fn,
2035 static clib_error_t *
2036 lisp_stats_flush_command_fn (vlib_main_t * vm,
2037 unformat_input_t * input,
2038 vlib_cli_command_t * cmd)
2040 vnet_lisp_flush_stats ();
2045 VLIB_CLI_COMMAND (one_stats_flush_command) = {
2046 .path = "one statistics flush",
2047 .short_help = "Flush ONE statistics",
2048 .function = lisp_stats_flush_command_fn,
2053 * fd.io coding-style-patch-verification: ON
2056 * eval: (c-set-style "gnu")