diff options
author | vivek <vivek@cumulusnetworks.com> | 2016-04-16 20:23:04 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-09-23 15:30:57 +0200 |
commit | 3ab18ff268c297e7279d71f8f82fc8ce7712c23e (patch) | |
tree | 5cecedf834a9b184c57d35e678f6e78493fbcb4c /zebra | |
parent | Quagga: Install label forwarding entries for statically configured LSPs (diff) | |
download | frr-3ab18ff268c297e7279d71f8f82fc8ce7712c23e.tar.xz frr-3ab18ff268c297e7279d71f8f82fc8ce7712c23e.zip |
Quagga: Display MPLS label forwarding table
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-4084, ...
Reviewed By: CCR-3089
Testing Done: Manual
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/zebra_mpls.c | 112 | ||||
-rw-r--r-- | zebra/zebra_mpls.h | 26 | ||||
-rw-r--r-- | zebra/zebra_mpls_null.c | 10 | ||||
-rw-r--r-- | zebra/zebra_vty.c | 36 |
4 files changed, 184 insertions, 0 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 892aec965..688585d6d 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -108,6 +108,12 @@ static_lsp_uninstall (struct zebra_vrf *zvrf, mpls_label_t in_label, 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); @@ -963,6 +969,78 @@ static_lsp_uninstall_all (struct zebra_vrf *zvrf, mpls_label_t in_label) } /* + * 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. */ static void @@ -1409,6 +1487,40 @@ 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) +{ + 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). */ int diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 5fb481781..7d1f49414 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -198,6 +198,19 @@ 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). */ int @@ -254,4 +267,17 @@ lsp_type_from_rib_type (int rib_type) } } +/* 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 */ diff --git a/zebra/zebra_mpls_null.c b/zebra/zebra_mpls_null.c index 15169f0f2..03b1f5694 100644 --- a/zebra/zebra_mpls_null.c +++ b/zebra/zebra_mpls_null.c @@ -33,6 +33,16 @@ zebra_mpls_lsp_schedule (struct zebra_vrf *zvrf) { } +void +zebra_mpls_print_lsp (struct vty *vty, struct zebra_vrf *zvrf, mpls_label_t label) +{ +} + +void +zebra_mpls_print_lsp_table (struct vty *vty, struct zebra_vrf *zvrf) +{ +} + int zebra_mpls_write_lsp_config (struct vty *vty, struct zebra_vrf *zvrf) { diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 4e0df372b..e5f7c181f 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -5909,6 +5909,37 @@ zebra_mpls_config (struct vty *vty) 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>", @@ -6418,4 +6449,9 @@ zebra_vty_init (void) 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); } |