- hash_free (lcm->fwd_entry_by_mapping_index);
- pool_free (lcm->fwd_entry_pool);
- }
-
- /* update global flag */
- lcm->is_enabled = is_enable;
-
- return 0;
-}
-
-static clib_error_t *
-lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_enabled = 0;
- u8 is_set = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "enable"))
- {
- is_set = 1;
- is_enabled = 1;
- }
- else if (unformat (line_input, "disable"))
- is_set = 1;
- else
- {
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- }
- }
-
- if (!is_set)
- return clib_error_return (0, "state not set");
-
- vnet_lisp_enable_disable (is_enabled);
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_cp_enable_disable_command) = {
- .path = "lisp",
- .short_help = "lisp [enable|disable]",
- .function = lisp_enable_disable_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_enabled = 0;
- u8 is_set = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "enable"))
- {
- is_set = 1;
- is_enabled = 1;
- }
- else if (unformat (line_input, "disable"))
- is_set = 1;
- else
- {
- vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
- line_input);
- return 0;
- }
- }
-
- if (!is_set)
- {
- vlib_cli_output (vm, "state not set!");
- return 0;
- }
-
- vnet_lisp_map_register_enable_disable (is_enabled);
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_map_register_enable_disable_command) = {
- .path = "lisp map-register",
- .short_help = "lisp map-register [enable|disable]",
- .function = lisp_map_register_enable_disable_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_enabled = 0;
- u8 is_set = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "enable"))
- {
- is_set = 1;
- is_enabled = 1;
- }
- else if (unformat (line_input, "disable"))
- is_set = 1;
- else
- {
- vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
- line_input);
- return 0;
- }
- }
-
- if (!is_set)
- {
- vlib_cli_output (vm, "state not set!");
- return 0;
- }
-
- vnet_lisp_rloc_probe_enable_disable (is_enabled);
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_rloc_probe_enable_disable_command) = {
- .path = "lisp rloc-probe",
- .short_help = "lisp rloc-probe [enable|disable]",
- .function = lisp_rloc_probe_enable_disable_command_fn,
-};
-/* *INDENT-ON* */
-
-u8
-vnet_lisp_enable_disable_status (void)
-{
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- return lcm->is_enabled;
-}
-
-static u8 *
-format_lisp_status (u8 * s, va_list * args)
-{
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
-}
-
-static clib_error_t *
-lisp_show_status_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- u8 *msg = 0;
- msg = format (msg, "feature: %U\ngpe: %U\n",
- format_lisp_status, format_vnet_lisp_gpe_status);
- vlib_cli_output (vm, "%v", msg);
- vec_free (msg);
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_show_status_command) = {
- .path = "show lisp status",
- .short_help = "show lisp status",
- .function = lisp_show_status_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- hash_pair_t *p;
- unformat_input_t _line_input, *line_input = &_line_input;
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- uword *vni_table = 0;
- u8 is_l2 = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "l2"))
- {
- vni_table = lcm->bd_id_by_vni;
- is_l2 = 1;
- }
- else if (unformat (line_input, "l3"))
- {
- vni_table = lcm->table_id_by_vni;
- is_l2 = 0;
- }
- else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- }
-
- if (!vni_table)
- {
- vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
- return 0;
- }
-
- vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
-
- /* *INDENT-OFF* */
- hash_foreach_pair (p, vni_table,
- ({
- vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
- }));
- /* *INDENT-ON* */
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_show_eid_table_map_command) = {
- .path = "show lisp eid-table map",
- .short_help = "show lisp eid-table l2|l3",
- .function = lisp_show_eid_table_map_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_add_del_locator_set_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- vnet_main_t *vnm = lgm->vnet_main;
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_add = 1;
- clib_error_t *error = 0;
- u8 *locator_set_name = 0;
- locator_t locator, *locators = 0;
- vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
- u32 ls_index = 0;
- int rv = 0;
-
- memset (&locator, 0, sizeof (locator));
- memset (a, 0, sizeof (a[0]));
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "add %_%v%_", &locator_set_name))
- is_add = 1;
- else if (unformat (line_input, "del %_%v%_", &locator_set_name))
- is_add = 0;
- else if (unformat (line_input, "iface %U p %d w %d",
- unformat_vnet_sw_interface, vnm,
- &locator.sw_if_index, &locator.priority,
- &locator.weight))
- {
- locator.local = 1;
- vec_add1 (locators, locator);
- }
- else
- {
- error = unformat_parse_error (line_input);
- goto done;
- }
- }
-
- a->name = locator_set_name;
- a->locators = locators;
- a->is_add = is_add;
- a->local = 1;
-
- rv = vnet_lisp_add_del_locator_set (a, &ls_index);
- if (0 != rv)
- {
- error = clib_error_return (0, "failed to %s locator-set!",
- is_add ? "add" : "delete");
- }
-
-done:
- vec_free (locators);
- if (locator_set_name)
- vec_free (locator_set_name);
- return error;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_cp_add_del_locator_set_command) = {
- .path = "lisp locator-set",
- .short_help = "lisp locator-set add/del <name> [iface <iface-name> "
- "p <priority> w <weight>]",
- .function = lisp_add_del_locator_set_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- vnet_main_t *vnm = lgm->vnet_main;
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_add = 1;
- clib_error_t *error = 0;
- u8 *locator_set_name = 0;
- u8 locator_set_name_set = 0;
- locator_t locator, *locators = 0;
- vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
- u32 ls_index = 0;
-
- memset (&locator, 0, sizeof (locator));
- memset (a, 0, sizeof (a[0]));
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "add"))
- is_add = 1;
- else if (unformat (line_input, "del"))
- is_add = 0;
- else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
- locator_set_name_set = 1;
- else if (unformat (line_input, "iface %U p %d w %d",
- unformat_vnet_sw_interface, vnm,
- &locator.sw_if_index, &locator.priority,
- &locator.weight))
- {
- locator.local = 1;
- vec_add1 (locators, locator);
- }
- else
- {
- error = unformat_parse_error (line_input);
- goto done;
- }
- }
-
- if (!locator_set_name_set)
- {
- error = clib_error_return (0, "locator_set name not set!");
- goto done;
- }
-
- a->name = locator_set_name;
- a->locators = locators;
- a->is_add = is_add;
- a->local = 1;
-
- vnet_lisp_add_del_locator (a, 0, &ls_index);
-
-done:
- vec_free (locators);
- vec_free (locator_set_name);
- return error;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_cp_add_del_locator_in_set_command) = {
- .path = "lisp locator",
- .short_help = "lisp locator add/del locator-set <name> iface <iface-name> "
- "p <priority> w <weight>",
- .function = lisp_add_del_locator_in_set_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- locator_set_t *lsit;
- locator_t *loc;
- u32 *locit;
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();