summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--isisd/isis_spf.c64
-rw-r--r--isisd/isis_spf.h3
-rw-r--r--tests/isisd/test_isis_spf.c10
3 files changed, 52 insertions, 25 deletions
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 4892479ac..c64bf67df 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -2227,7 +2227,7 @@ int _isis_spf_schedule(struct isis_area *area, int level,
}
static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
- uint8_t *root_sysid)
+ uint8_t *root_sysid, struct json_object **json)
{
struct listnode *node;
struct isis_vertex *vertex;
@@ -2331,13 +2331,17 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
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);
+ if (json == NULL) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ } else
+ *json = ttable_json(tt, "ssdsss");
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,
+ struct json_object **json)
{
const char *tree_id_text = NULL;
@@ -2359,10 +2363,13 @@ void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree)
return;
}
- vty_out(vty, "IS-IS paths to level-%d routers %s\n", spftree->level,
- tree_id_text);
- isis_print_paths(vty, &spftree->paths, spftree->sysid);
- vty_out(vty, "\n");
+ if (!json)
+ vty_out(vty, "IS-IS paths to level-%d routers %s\n",
+ spftree->level, tree_id_text);
+
+ isis_print_paths(vty, &spftree->paths, spftree->sysid, json);
+ if (!json)
+ vty_out(vty, "\n");
}
static void show_isis_topology_common(struct vty *vty, int levels,
@@ -2420,7 +2427,7 @@ static void show_isis_topology_common(struct vty *vty, int levels,
spftree = area->spftree[SPFTREE_IPV4]
[level - 1];
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
}
if (area->ipv6_circuits > 0) {
#ifndef FABRICD
@@ -2431,7 +2438,7 @@ static void show_isis_topology_common(struct vty *vty, int levels,
#endif /* ifndef FABRICD */
spftree = area->spftree[SPFTREE_IPV6]
[level - 1];
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
}
if (isis_area_ipv6_dstsrc_enabled(area)) {
#ifndef FABRICD
@@ -2443,14 +2450,15 @@ static void show_isis_topology_common(struct vty *vty, int levels,
#endif /* ifndef FABRICD */
spftree = area->spftree[SPFTREE_DSTSRC]
[level - 1];
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
}
}
if (fabricd_spftree(area)) {
vty_out(vty,
"IS-IS paths to level-2 routers with hop-by-hop metric\n");
- isis_print_paths(vty, &fabricd_spftree(area)->paths, isis->sysid);
+ isis_print_paths(vty, &fabricd_spftree(area)->paths,
+ isis->sysid, NULL);
vty_out(vty, "\n");
}
@@ -3006,8 +3014,14 @@ static void show_isis_route_common(struct vty *vty, int levels,
spftree = area->spftree[SPFTREE_IPV4]
[level - 1];
- if (!json)
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree,
+ json ? &json_val : NULL);
+ if (json && json_val) {
+ json_object_object_add(json_level,
+ "ipv4-paths",
+ json_val);
+ json_val = NULL;
+ }
isis_print_routes(vty, spftree,
json ? &json_val : NULL,
@@ -3028,8 +3042,14 @@ static void show_isis_route_common(struct vty *vty, int levels,
spftree = area->spftree[SPFTREE_IPV6]
[level - 1];
- if (!json)
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree,
+ json ? &json_val : NULL);
+ if (json && json_val) {
+ json_object_object_add(json_level,
+ "ipv6-paths",
+ json_val);
+ json_val = NULL;
+ }
isis_print_routes(vty, spftree,
json ? &json_val : NULL,
@@ -3051,8 +3071,14 @@ static void show_isis_route_common(struct vty *vty, int levels,
spftree = area->spftree[SPFTREE_DSTSRC]
[level - 1];
- if (!json)
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree,
+ json ? &json_val : NULL);
+ if (json && json_val) {
+ json_object_object_add(json_level,
+ "ipv6-dstsrc-paths",
+ json_val);
+ json_val = NULL;
+ }
isis_print_routes(vty, spftree,
json ? &json_val : NULL,
prefix_sid, backup);
diff --git a/isisd/isis_spf.h b/isisd/isis_spf.h
index 7e9754d9b..ee2d29abe 100644
--- a/isisd/isis_spf.h
+++ b/isisd/isis_spf.h
@@ -61,7 +61,8 @@ struct isis_lsp *isis_root_system_lsp(struct lspdb_head *lspdb,
__FILE__, __LINE__)
int _isis_spf_schedule(struct isis_area *area, int level,
const char *func, const char *file, int line);
-void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree);
+void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree,
+ struct json_object **json);
void isis_print_routes(struct vty *vty, struct isis_spftree *spftree,
json_object **json, bool prefix_sid, bool backup);
void isis_spf_init(void);
diff --git a/tests/isisd/test_isis_spf.c b/tests/isisd/test_isis_spf.c
index 4ea28cda2..6fe6993fd 100644
--- a/tests/isisd/test_isis_spf.c
+++ b/tests/isisd/test_isis_spf.c
@@ -55,7 +55,7 @@ static void test_run_spf(struct vty *vty, const struct isis_topology *topology,
isis_run_spf(spftree);
/* Print the SPT and the corresponding routing table. */
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
isis_print_routes(vty, spftree, NULL, false, false);
/* Cleanup SPF tree. */
@@ -85,7 +85,7 @@ static void test_run_lfa(struct vty *vty, const struct isis_topology *topology,
isis_lfa_compute(area, NULL, spftree_self, protected_resource);
/* Print the SPT and the corresponding main/backup routing tables. */
- isis_print_spftree(vty, spftree_self);
+ isis_print_spftree(vty, spftree_self, NULL);
vty_out(vty, "Main:\n");
isis_print_routes(vty, spftree_self, NULL, false, false);
vty_out(vty, "Backup:\n");
@@ -148,7 +148,7 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology,
vty_out(vty, "\n");
/* Print the post-convergence SPT. */
- isis_print_spftree(vty, spftree_pc);
+ isis_print_spftree(vty, spftree_pc, NULL);
/*
* Activate the computed RLFAs (if any) using artificial LDP labels for
@@ -164,7 +164,7 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology,
}
/* Print the SPT and the corresponding main/backup routing tables. */
- isis_print_spftree(vty, spftree_self);
+ isis_print_spftree(vty, spftree_self, NULL);
vty_out(vty, "Main:\n");
isis_print_routes(vty, spftree_self, NULL, false, false);
vty_out(vty, "Backup:\n");
@@ -228,7 +228,7 @@ static void test_run_ti_lfa(struct vty *vty,
/*
* Print the post-convergence SPT and the corresponding routing table.
*/
- isis_print_spftree(vty, spftree_pc);
+ isis_print_spftree(vty, spftree_pc, NULL);
isis_print_routes(vty, spftree_self, NULL, false, true);
/* Cleanup everything. */