summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_mpls.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2023-03-03 13:21:00 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2023-03-09 09:44:14 +0100
commit060c7d7073f233d570961a917d64d5aa8d7229a1 (patch)
tree85b0338626ceb7d2181d264645874eae3df9eb99 /zebra/zebra_mpls.c
parentMerge pull request #12942 from LabNConsulting/chopps/fixpause (diff)
downloadfrr-060c7d7073f233d570961a917d64d5aa8d7229a1.tar.xz
frr-060c7d7073f233d570961a917d64d5aa8d7229a1.zip
zebra: add json support when "show zebra mpls" returns nothing
The "show zebra mpls .. json" vty command may return empty information in case the MPLS database is empty or a given label entry is not available. When those errors occur, add the braces to return a valid json format. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'zebra/zebra_mpls.c')
-rw-r--r--zebra/zebra_mpls.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index d25505839..4c2d54612 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -3730,14 +3730,20 @@ void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf,
/* Lookup table. */
lsp_table = zvrf->lsp_table;
- if (!lsp_table)
+ if (!lsp_table) {
+ if (use_json)
+ vty_out(vty, "{}\n");
return;
+ }
/* If entry is not present, exit. */
tmp_ile.in_label = label;
lsp = hash_lookup(lsp_table, &tmp_ile);
- if (!lsp)
+ if (!lsp) {
+ if (use_json)
+ vty_out(vty, "{}\n");
return;
+ }
if (use_json) {
json = lsp_json(lsp);