static int
static_lsp_uninstall_all (struct zebra_vrf *zvrf, mpls_label_t in_label);
static void
+nhlfe_print (zebra_nhlfe_t *nhlfe, struct vty *vty);
+static void
+lsp_print (zebra_lsp_t *lsp, void *ctxt);
+static void
+lsp_print_hash (struct hash_backet *backet, void *ctxt);
+static void
lsp_config_write (struct hash_backet *backet, void *ctxt);
static void *
slsp_alloc (void *p);
return 0;
}
+/*
+ * Print the NHLFE for a LSP forwarding entry.
+ */
+static void
+nhlfe_print (zebra_nhlfe_t *nhlfe, struct vty *vty)
+{
+ struct nexthop *nexthop;
+ char buf[BUFSIZ];
+
+ nexthop = nhlfe->nexthop;
+ if (!nexthop || !nexthop->nh_label) // unexpected
+ return;
+
+ vty_out(vty, " type: %s remote label: %s distance: %d%s",
+ nhlfe_type2str(nhlfe->type),
+ label2str(nexthop->nh_label->label[0], buf, BUFSIZ),
+ nhlfe->distance, VTY_NEWLINE);
+ switch (nexthop->type)
+ {
+ case NEXTHOP_TYPE_IPV4:
+ vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
+ break;
+ case NEXTHOP_TYPE_IPV6:
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ vty_out (vty, " via %s",
+ inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
+ if (nexthop->ifindex)
+ vty_out (vty, " dev %s", ifindex2ifname (nexthop->ifindex));
+ break;
+ default:
+ break;
+ }
+ vty_out(vty, "%s", CHECK_FLAG (nhlfe->flags, NHLFE_FLAG_INSTALLED) ?
+ " (installed)" : "");
+ vty_out(vty, "%s", VTY_NEWLINE);
+}
+
+/*
+ * Print an LSP forwarding entry.
+ */
+static void
+lsp_print (zebra_lsp_t *lsp, void *ctxt)
+{
+ zebra_nhlfe_t *nhlfe;
+ struct vty *vty;
+
+ vty = (struct vty *) ctxt;
+
+ vty_out(vty, "Local label: %u%s%s",
+ lsp->ile.in_label,
+ CHECK_FLAG (lsp->flags, LSP_FLAG_INSTALLED) ? " (installed)" : "",
+ VTY_NEWLINE);
+
+ for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next)
+ nhlfe_print (nhlfe, vty);
+}
+
+/*
+ * Print an LSP forwarding hash entry.
+ */
+static void
+lsp_print_hash (struct hash_backet *backet, void *ctxt)
+{
+ zebra_lsp_t *lsp;
+
+ lsp = (zebra_lsp_t *) backet->data;
+ if (!lsp)
+ return;
+
+ lsp_print (lsp, ctxt);
+}
+
/*
* Write out static LSP configuration.
*/
hash_iterate(zvrf->lsp_table, lsp_schedule, NULL);
}
+/*
+ * Display MPLS label forwarding table for a specific LSP
+ * (VTY command handler).
+ */
+void
+zebra_mpls_print_lsp (struct vty *vty, struct zebra_vrf *zvrf, mpls_label_t label)
+{
+ struct hash *lsp_table;
+ zebra_lsp_t *lsp;
+ zebra_ile_t tmp_ile;
+
+ /* Lookup table. */
+ lsp_table = zvrf->lsp_table;
+ if (!lsp_table)
+ return;
+
+ /* If entry is not present, exit. */
+ tmp_ile.in_label = label;
+ lsp = hash_lookup (lsp_table, &tmp_ile);
+ if (!lsp)
+ return;
+
+ lsp_print (lsp, (void *)vty);
+}
+
+/*
+ * Display MPLS label forwarding table (VTY command handler).
+ */
+void
+zebra_mpls_print_lsp_table (struct vty *vty, struct zebra_vrf *zvrf)
+{
+ hash_iterate(zvrf->lsp_table, lsp_print_hash, vty);
+}
+
/*
* Display MPLS LSP configuration of all static LSPs (VTY command handler).
*/
void
zebra_mpls_lsp_schedule (struct zebra_vrf *zvrf);
+/*
+ * Display MPLS label forwarding table for a specific LSP
+ * (VTY command handler).
+ */
+void
+zebra_mpls_print_lsp (struct vty *vty, struct zebra_vrf *zvrf, mpls_label_t label);
+
+/*
+ * Display MPLS label forwarding table (VTY command handler).
+ */
+void
+zebra_mpls_print_lsp_table (struct vty *vty, struct zebra_vrf *zvrf);
+
/*
* Display MPLS LSP configuration of all static LSPs (VTY command handler).
*/
}
}
+/* NHLFE type as printable string. */
+static inline const char *
+nhlfe_type2str(enum lsp_types_t lsp_type)
+{
+ switch (lsp_type)
+ {
+ case ZEBRA_LSP_STATIC:
+ return "Static";
+ default:
+ return "Unknown";
+ }
+}
+
#endif /*_ZEBRA_MPLS_H */
return write;
}
+DEFUN (show_mpls_table,
+ show_mpls_table_cmd,
+ "show mpls table",
+ SHOW_STR
+ MPLS_STR
+ "MPLS table\n")
+{
+ struct zebra_vrf *zvrf;
+
+ zvrf = vrf_info_lookup(VRF_DEFAULT);
+ zebra_mpls_print_lsp_table(vty, zvrf);
+ return CMD_SUCCESS;
+}
+
+DEFUN (show_mpls_table_lsp,
+ show_mpls_table_lsp_cmd,
+ "show mpls table <16-1048575>",
+ SHOW_STR
+ MPLS_STR
+ "MPLS table\n"
+ "LSP to display information about\n")
+{
+ u_int32_t label;
+ struct zebra_vrf *zvrf;
+
+ zvrf = vrf_info_lookup(VRF_DEFAULT);
+ label = atoi(argv[0]);
+ zebra_mpls_print_lsp (vty, zvrf, label);
+ return CMD_SUCCESS;
+}
+
DEFUN (ip_zebra_import_table_distance,
ip_zebra_import_table_distance_cmd,
"ip import-table <1-252> distance <1-255>",
install_element (CONFIG_NODE, &no_mpls_transit_lsp_cmd);
install_element (CONFIG_NODE, &no_mpls_transit_lsp_out_label_cmd);
install_element (CONFIG_NODE, &no_mpls_transit_lsp_all_cmd);
+
+ install_element (VIEW_NODE, &show_mpls_table_cmd);
+ install_element (ENABLE_NODE, &show_mpls_table_cmd);
+ install_element (VIEW_NODE, &show_mpls_table_lsp_cmd);
+ install_element (ENABLE_NODE, &show_mpls_table_lsp_cmd);
}