diff options
author | Neale Ranns <neale@graphiant.com> | 2021-06-15 12:43:12 +0000 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2021-06-17 07:58:41 +0000 |
commit | de0b3b5718309cb1f6df3693564ba9c05a193ecb (patch) | |
tree | 8266129493fee093e440f0e1c36555b3a244c458 /src/vnet/mpls/interface.c | |
parent | 8eb8d50ecfd7507aae340cb05a0fb07a790e4303 (diff) |
mpls: CLI to show the MPLS forwarding state of an interface
Type: improvement
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I28b98154bbff36e8391a09a2b30302dda4349946
Diffstat (limited to 'src/vnet/mpls/interface.c')
-rw-r--r-- | src/vnet/mpls/interface.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/vnet/mpls/interface.c b/src/vnet/mpls/interface.c index 1d10cabb1e3..fd075c92d3d 100644 --- a/src/vnet/mpls/interface.c +++ b/src/vnet/mpls/interface.c @@ -140,3 +140,72 @@ VLIB_CLI_COMMAND (set_interface_ip_table_command, static) = { .function = mpls_interface_enable_disable, .short_help = "Enable/Disable an interface for MPLS forwarding", }; + +static void +show_mpls_one_interface (vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index, + bool verbose) +{ + mpls_main_t *mm = &mpls_main; + u8 enabled; + + enabled = mm->mpls_enabled_by_sw_if_index[sw_if_index]; + + if (enabled) + { + vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnm, + sw_if_index); + vlib_cli_output (vm, " MPLS enabled"); + } + else if (verbose) + { + vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnm, + sw_if_index); + vlib_cli_output (vm, " MPLS disabled"); + } +} + +static walk_rc_t +show_mpls_interface_walk (vnet_main_t *vnm, vnet_sw_interface_t *si, void *ctx) +{ + show_mpls_one_interface (vnm, ctx, si->sw_if_index, false); + + return (WALK_CONTINUE); +} + +static clib_error_t * +show_mpls_interface (vlib_main_t *vm, unformat_input_t *input, + vlib_cli_command_t *cmd) +{ + vnet_main_t *vnm = vnet_get_main (); + u32 sw_if_index; + + sw_if_index = ~0; + + if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index)) + ; + + if (~0 == sw_if_index) + { + vnet_sw_interface_walk (vnm, show_mpls_interface_walk, vm); + } + else + { + show_mpls_one_interface (vnm, vm, sw_if_index, true); + } + + return NULL; +} + +/*? + * This command displays the MPLS forwarding state of an interface + * + * @cliexpar + * @cliexstart{show mpls interface} + * set mpls interface GigEthernet0/8/0 + * @cliexend + ?*/ +VLIB_CLI_COMMAND (show_mpls_interface_command, static) = { + .path = "show mpls interface", + .function = show_mpls_interface, + .short_help = "Show MPLS interface forwarding", +}; |