mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 10:37:29 +00:00
ospfd: add print helper for SPF trees and route tables
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
This commit is contained in:
parent
1d376ff539
commit
3a76b1be88
@ -665,6 +665,37 @@ void ospf_route_table_dump(struct route_table *rt)
|
||||
zlog_debug("========================================");
|
||||
}
|
||||
|
||||
void ospf_route_table_print(struct vty *vty, struct route_table *rt)
|
||||
{
|
||||
struct route_node *rn;
|
||||
struct ospf_route * or ;
|
||||
struct listnode *pnode;
|
||||
struct ospf_path *path;
|
||||
|
||||
vty_out(vty, "========== OSPF routing table ==========\n");
|
||||
for (rn = route_top(rt); rn; rn = route_next(rn))
|
||||
if ((or = rn->info) != NULL) {
|
||||
if (or->type == OSPF_DESTINATION_NETWORK) {
|
||||
vty_out(vty, "N %-18pFX %-15pI4 %s %d\n",
|
||||
&rn->p, & or->u.std.area_id,
|
||||
ospf_path_type_str[or->path_type],
|
||||
or->cost);
|
||||
for (ALL_LIST_ELEMENTS_RO(or->paths, pnode,
|
||||
path))
|
||||
vty_out(vty, " -> %s\n",
|
||||
path->nexthop.s_addr != 0
|
||||
? inet_ntoa(
|
||||
path->nexthop)
|
||||
: "directly connected");
|
||||
} else
|
||||
vty_out(vty, "R %-18pI4 %-15pI4 %s %d\n",
|
||||
&rn->p.u.prefix4, & or->u.std.area_id,
|
||||
ospf_path_type_str[or->path_type],
|
||||
or->cost);
|
||||
}
|
||||
vty_out(vty, "========================================\n");
|
||||
}
|
||||
|
||||
/* This is 16.4.1 implementation.
|
||||
o Intra-area paths using non-backbone areas are always the most preferred.
|
||||
o The other paths, intra-area backbone paths and inter-area paths,
|
||||
|
@ -132,6 +132,7 @@ extern void ospf_route_table_free(struct route_table *);
|
||||
|
||||
extern void ospf_route_install(struct ospf *, struct route_table *);
|
||||
extern void ospf_route_table_dump(struct route_table *);
|
||||
extern void ospf_route_table_print(struct vty *vty, struct route_table *rt);
|
||||
|
||||
extern void ospf_intra_add_router(struct route_table *, struct vertex *,
|
||||
struct ospf_area *);
|
||||
|
@ -994,6 +994,33 @@ static void ospf_spf_dump(struct vertex *v, int i)
|
||||
ospf_spf_dump(v, i);
|
||||
}
|
||||
|
||||
void ospf_spf_print(struct vty *vty, struct vertex *v, int i)
|
||||
{
|
||||
struct listnode *cnode;
|
||||
struct listnode *nnode;
|
||||
struct vertex_parent *parent;
|
||||
|
||||
if (v->type == OSPF_VERTEX_ROUTER) {
|
||||
vty_out(vty, "SPF Result: depth %d [R] %s\n", i,
|
||||
inet_ntoa(v->lsa->id));
|
||||
} else {
|
||||
struct network_lsa *lsa = (struct network_lsa *)v->lsa;
|
||||
vty_out(vty, "SPF Result: depth %d [N] %s/%d\n", i,
|
||||
inet_ntoa(v->lsa->id), ip_masklen(lsa->mask));
|
||||
}
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(v->parents, nnode, parent)) {
|
||||
vty_out(vty, " nexthop %s lsa pos %d\n",
|
||||
inet_ntoa(parent->nexthop->router),
|
||||
parent->nexthop->lsa_pos);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(v->children, cnode, v))
|
||||
ospf_spf_print(vty, v, i);
|
||||
}
|
||||
|
||||
/* Second stage of SPF calculation. */
|
||||
static void ospf_spf_process_stubs(struct ospf_area *area, struct vertex *v,
|
||||
struct route_table *rt, int parent_is_root)
|
||||
|
@ -82,5 +82,7 @@ extern int ospf_spf_calculate_areas(struct ospf *ospf,
|
||||
bool is_dry_run);
|
||||
extern void ospf_rtrs_free(struct route_table *);
|
||||
|
||||
extern void ospf_spf_print(struct vty *vty, struct vertex *v, int i);
|
||||
|
||||
/* void ospf_spf_calculate_timer_add (); */
|
||||
#endif /* _QUAGGA_OSPF_SPF_H */
|
||||
|
Loading…
Reference in New Issue
Block a user