From 060c7d7073f233d570961a917d64d5aa8d7229a1 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 3 Mar 2023 13:21:00 +0100 Subject: [PATCH] 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 --- zebra/zebra_mpls.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index d25505839c..4c2d546126 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); -- 2.39.5