summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-08-16 19:14:48 +0200
committerBeno�t Ganne <bganne@cisco.com>2021-09-13 13:37:03 +0000
commit14b472e373228be0f4c96f5450f2ecd8aef4ac34 (patch)
tree3de4287af22e3b083d8bfe5c1d02355f93ca9376 /src/vnet/ip
parentae4ed3265f50469b3373a952c39d683945f1d389 (diff)
ip: show ip table CLI
Type: feature Thought this might be useful when using many VRF to get the list of allocated VRFs and corresponding names Change-Id: If9d2c6612d4215e7576315d66d1eb130fcecfa13 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/lookup.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index f674fec4823..1753ffd9232 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -440,6 +440,71 @@ vnet_ip6_table_cmd (vlib_main_t * vm,
return (vnet_ip_table_cmd (vm, main_input, cmd, FIB_PROTOCOL_IP6));
}
+clib_error_t *
+vnet_show_ip_table_cmd (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd, fib_protocol_t fproto)
+{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ fib_table_t *fib, *fibs;
+ clib_error_t *error = NULL;
+ u32 table_id = ~0, fib_index;
+ /* Get a line of input. */
+ if (unformat_user (main_input, unformat_line_input, line_input))
+ {
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "%d", &table_id))
+ ;
+ else
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
+ }
+ unformat_free (line_input);
+ }
+
+ fibs = (fproto == FIB_PROTOCOL_IP4) ? ip4_main.fibs : ip6_main.fibs;
+
+ if (table_id != (u32) ~0)
+ {
+ fib_index = fib_table_find (fproto, table_id);
+ if (fib_index == (u32) ~0)
+ {
+ error = clib_error_return (0, "Couldn't find table with table_id %u",
+ table_id);
+ goto done;
+ }
+
+ fib = fib_table_get (fib_index, fproto);
+ vlib_cli_output (vm, "[%3u] table_id:%3u %v", fib->ft_index,
+ fib->ft_table_id, fib->ft_desc);
+ }
+ else
+ {
+ pool_foreach (fib, fibs)
+ vlib_cli_output (vm, "[%3u] table_id:%3u %v", fib->ft_index,
+ fib->ft_table_id, fib->ft_desc);
+ }
+
+done:
+ return error;
+}
+
+clib_error_t *
+vnet_show_ip4_table_cmd (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
+{
+ return (vnet_show_ip_table_cmd (vm, main_input, cmd, FIB_PROTOCOL_IP4));
+}
+
+clib_error_t *
+vnet_show_ip6_table_cmd (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
+{
+ return (vnet_show_ip_table_cmd (vm, main_input, cmd, FIB_PROTOCOL_IP6));
+}
+
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (vlib_cli_ip_command, static) = {
.path = "ip",
@@ -532,6 +597,18 @@ VLIB_CLI_COMMAND (ip6_table_command, static) = {
.function = vnet_ip6_table_cmd,
};
+VLIB_CLI_COMMAND (show_ip4_table_command, static) = {
+ .path = "show ip table",
+ .short_help = "show ip table <table-id>",
+ .function = vnet_show_ip4_table_cmd,
+};
+
+VLIB_CLI_COMMAND (show_ip6_table_command, static) = {
+ .path = "show ip6 table",
+ .short_help = "show ip6 table <table-id>",
+ .function = vnet_show_ip6_table_cmd,
+};
+
static clib_error_t *
ip_table_bind_cmd (vlib_main_t * vm,
unformat_input_t * input,