summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/mpls/interface.c69
-rw-r--r--test/test_mpls.py7
2 files changed, 76 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",
+};
diff --git a/test/test_mpls.py b/test/test_mpls.py
index f0c3b0f3b95..2c40e8d198e 100644
--- a/test/test_mpls.py
+++ b/test/test_mpls.py
@@ -1594,6 +1594,10 @@ class TestMPLSDisabled(VppTestCase):
def test_mpls_disabled(self):
""" MPLS Disabled """
+ self.logger.info(self.vapi.cli("show mpls interface"))
+ self.logger.info(self.vapi.cli("show mpls interface pg1"))
+ self.logger.info(self.vapi.cli("show mpls interface pg0"))
+
tx = (Ether(src=self.pg1.remote_mac,
dst=self.pg1.local_mac) /
MPLS(label=32, ttl=64) /
@@ -1620,6 +1624,9 @@ class TestMPLSDisabled(VppTestCase):
#
self.pg1.enable_mpls()
+ self.logger.info(self.vapi.cli("show mpls interface"))
+ self.logger.info(self.vapi.cli("show mpls interface pg1"))
+
#
# Now we get packets through
#