]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add json support when "show zebra mpls" returns nothing
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 3 Mar 2023 12:21:00 +0000 (13:21 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 9 Mar 2023 08:44:14 +0000 (09:44 +0100)
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>
zebra/zebra_mpls.c

index d25505839c2a15f19b155dfe0f04bc90c7dbfc93..4c2d54612690a69935e9e41f597582d4db926db7 100644 (file)
@@ -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);