forked from Mirror/frr
isisd: show isis route uses ttable for paths
This is a preliminary commit, so that route paths are visible from json. Before: > IS-IS paths to level-1 routers that speak IPv6 > Vertex Type Metric Next-Hop Interface Parent > rt1 > 2001:db8:1000::1/128 IP6 internal 0 rt1(4) > rt2 TE-IS 10 rt2 eth-rt2 rt1(4) > rt3 TE-IS 10 rt3 eth-rt3 rt1(4) > 2001:db8:1000::2/128 IP6 internal 20 rt2 eth-rt2 rt2(4) > 2001:db8:1000::3/128 IP6 internal 20 rt3 eth-rt3 rt3(4) After: > Vertex Type Metric Next-Hop Interface Parent > ------------------------------------------------------------------------- > rt1 > 2001:db8:1000::1/128 IP6 internal 0 rt1(4) > rt2 TE-IS 10 rt2 eth-rt2 rt1(4) > rt3 TE-IS 10 rt3 eth-rt3 rt1(4) > 2001:db8:1000::2/128 IP6 internal 20 rt2 eth-rt2 rt2(4) > 2001:db8:1000::3/128 IP6 internal 20 rt3 eth-rt3 rt3(4) Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
bf5f0f19eb
commit
df723ccfb7
|
@ -2232,16 +2232,30 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct isis_vertex *vertex;
|
struct isis_vertex *vertex;
|
||||||
char buff[VID2STR_BUFFER];
|
char buff[VID2STR_BUFFER];
|
||||||
|
char vertex_name[VID2STR_BUFFER];
|
||||||
|
char vertex_typestr[VID2STR_BUFFER];
|
||||||
|
char vertex_interface[VID2STR_BUFFER];
|
||||||
|
char vertex_parent[VID2STR_BUFFER + 11];
|
||||||
|
char vertex_nexthop[VID2STR_BUFFER];
|
||||||
|
char vertex_metricstr[20];
|
||||||
|
struct ttable *tt;
|
||||||
|
char *table;
|
||||||
|
|
||||||
vty_out(vty,
|
/* Prepare table. */
|
||||||
"Vertex Type Metric Next-Hop Interface Parent\n");
|
tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
|
||||||
|
ttable_add_row(tt, "Vertex|Type|Metric|Next-Hop|Interface|Parent");
|
||||||
|
tt->style.cell.rpad = 2;
|
||||||
|
tt->style.corner = '+';
|
||||||
|
ttable_restyle(tt);
|
||||||
|
ttable_rowseps(tt, 0, BOTTOM, true, '-');
|
||||||
|
|
||||||
for (ALL_QUEUE_ELEMENTS_RO(queue, node, vertex)) {
|
for (ALL_QUEUE_ELEMENTS_RO(queue, node, vertex)) {
|
||||||
if (VTYPE_IS(vertex->type)
|
if (VTYPE_IS(vertex->type)
|
||||||
&& memcmp(vertex->N.id, root_sysid, ISIS_SYS_ID_LEN) == 0) {
|
&& memcmp(vertex->N.id, root_sysid, ISIS_SYS_ID_LEN) == 0) {
|
||||||
vty_out(vty, "%-20s %-12s %-6s",
|
/* display here */
|
||||||
print_sys_hostname(root_sysid), "", "");
|
ttable_add_row(tt, "%s|%s|%s|%s|%s|%s",
|
||||||
vty_out(vty, "%-30s\n", "");
|
print_sys_hostname(root_sysid), "", "",
|
||||||
|
"", "", "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2251,9 +2265,12 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
|
||||||
struct isis_vertex_adj *vadj;
|
struct isis_vertex_adj *vadj;
|
||||||
struct isis_vertex *pvertex;
|
struct isis_vertex *pvertex;
|
||||||
|
|
||||||
vty_out(vty, "%-20s %-12s %-6u ",
|
snprintf(vertex_name, sizeof(vertex_name), "%s",
|
||||||
vid2string(vertex, buff, sizeof(buff)),
|
vid2string(vertex, buff, sizeof(buff)));
|
||||||
vtype2string(vertex->type), vertex->d_N);
|
snprintf(vertex_typestr, sizeof(vertex_typestr), "%s",
|
||||||
|
vtype2string(vertex->type));
|
||||||
|
snprintf(vertex_metricstr, sizeof(vertex_metricstr), "%u",
|
||||||
|
vertex->d_N);
|
||||||
for (unsigned int i = 0;
|
for (unsigned int i = 0;
|
||||||
i < MAX(vertex->Adj_N ? listcount(vertex->Adj_N) : 0,
|
i < MAX(vertex->Adj_N ? listcount(vertex->Adj_N) : 0,
|
||||||
vertex->parents ? listcount(vertex->parents) : 0);
|
vertex->parents ? listcount(vertex->parents) : 0);
|
||||||
|
@ -2273,33 +2290,51 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rows) {
|
if (rows) {
|
||||||
vty_out(vty, "\n");
|
/* display here */
|
||||||
vty_out(vty, "%-20s %-12s %-6s ", "", "", "");
|
ttable_add_row(tt, "%s|%s|%s|%s|%s|%s",
|
||||||
|
vertex_name, vertex_typestr,
|
||||||
|
vertex_metricstr, vertex_nexthop,
|
||||||
|
vertex_interface, vertex_parent);
|
||||||
|
|
||||||
|
/* store the first 3 elements */
|
||||||
|
vertex_name[0] = '\0';
|
||||||
|
vertex_typestr[0] = '\0';
|
||||||
|
vertex_metricstr[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vadj) {
|
if (vadj) {
|
||||||
struct isis_spf_adj *sadj = vadj->sadj;
|
struct isis_spf_adj *sadj = vadj->sadj;
|
||||||
|
|
||||||
vty_out(vty, "%-20s %-9s ",
|
snprintf(vertex_nexthop, sizeof(vertex_nexthop),
|
||||||
print_sys_hostname(sadj->id),
|
"%s", print_sys_hostname(sadj->id));
|
||||||
|
snprintf(vertex_interface,
|
||||||
|
sizeof(vertex_interface), "%s",
|
||||||
sadj->adj ? sadj->adj->circuit
|
sadj->adj ? sadj->adj->circuit
|
||||||
->interface->name
|
->interface->name
|
||||||
: "-");
|
: "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pvertex) {
|
if (pvertex) {
|
||||||
if (!vadj)
|
if (!vadj) {
|
||||||
vty_out(vty, "%-20s %-9s ", "", "");
|
vertex_nexthop[0] = '\0';
|
||||||
|
vertex_interface[0] = '\0';
|
||||||
vty_out(vty, "%s(%d)",
|
}
|
||||||
|
snprintf(vertex_parent, sizeof(vertex_parent),
|
||||||
|
"%s(%d)",
|
||||||
vid2string(pvertex, buff, sizeof(buff)),
|
vid2string(pvertex, buff, sizeof(buff)),
|
||||||
pvertex->type);
|
pvertex->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
++rows;
|
++rows;
|
||||||
}
|
}
|
||||||
vty_out(vty, "\n");
|
ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", vertex_name,
|
||||||
|
vertex_typestr, vertex_metricstr, vertex_nexthop,
|
||||||
|
vertex_interface, vertex_parent);
|
||||||
}
|
}
|
||||||
|
table = ttable_dump(tt, "\n");
|
||||||
|
vty_out(vty, "%s\n", table);
|
||||||
|
XFREE(MTYPE_TMP, table);
|
||||||
|
ttable_del(tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree)
|
void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue