]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: display bgp neighbor advertised-routes json warning message 4332/head
authorSarita Patra <saritap@vmware.com>
Tue, 14 May 2019 13:22:19 +0000 (06:22 -0700)
committerSarita Patra <saritap@vmware.com>
Tue, 14 May 2019 19:11:34 +0000 (12:11 -0700)
Issue 1:
Getting an empty json without any warning message, while executing
the command "show ip bgp neighbor <x.x.x.x> advertised-routes
json" when the bgp instance is not present or getting created.

Issue 2:
Getting an empty json without any warning message, while executing
the command "show ip bgp vrf/view <name> advertised-routes json"
when the specified view/vrf is not present.

Fix:
Display warning message while executing the above cli commands, when
the bgp instance, specified vrf is not present.

Signed-off-by: Sarita Patra <saritap@vmware.com>
bgpd/bgp_vty.c

index 6197a6d562cfc2059c398c6ae679ff253fba4ee6..bce6fb48c77a6739c92e6c1e73d8a24aedac5dca 100644 (file)
@@ -295,6 +295,7 @@ int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index,
  * afi  -> The parsed afi if it was included in the show command, returned here
  * safi -> The parsed safi if it was included in the show command, returned here
  * bgp  -> Pointer to the bgp data structure we need to fill in.
+ * use_json -> json is configured or not
  *
  * The function returns the correct location in the parse tree for the
  * last token found.
@@ -329,8 +330,17 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty,
                else {
                        *bgp = bgp_lookup_by_name(vrf_name);
                        if (!*bgp) {
-                               if (use_json)
-                                       vty_out(vty, "{}\n");
+                               if (use_json) {
+                                       json_object *json = NULL;
+                                       json = json_object_new_object();
+                                       json_object_string_add(
+                                         json, "warning",
+                                         "View/Vrf is unknown");
+                                       vty_out(vty, "%s\n",
+                                               json_object_to_json_string_ext(json,
+                                                       JSON_C_TO_STRING_PRETTY));
+                                       json_object_free(json);
+                               }
                                else
                                        vty_out(vty, "View/Vrf %s is unknown\n",
                                                vrf_name);
@@ -341,8 +351,17 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty,
        } else {
                *bgp = bgp_get_default();
                if (!*bgp) {
-                       if (use_json)
-                               vty_out(vty, "{}\n");
+                       if (use_json) {
+                               json_object *json = NULL;
+                               json = json_object_new_object();
+                               json_object_string_add(
+                                       json, "warning",
+                                       "Default BGP instance not found");
+                               vty_out(vty, "%s\n",
+                                       json_object_to_json_string_ext(json,
+                                               JSON_C_TO_STRING_PRETTY));
+                               json_object_free(json);
+                       }
                        else
                                vty_out(vty,
                                        "Default BGP instance not found\n");