]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Add ability to display information about bestpath in json 1324/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 10 Oct 2017 20:30:36 +0000 (16:30 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 11 Oct 2017 12:16:51 +0000 (08:16 -0400)
When retrieving information about neighbors or summary in json
add some information about what bestPath particulars we have for
this bgp session.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_vty.c

index 355d1037b8b472985f0175b281c7f13c639bcf97..ea6632bf1329768274fef90be86349492aed7cb9 100644 (file)
@@ -6652,6 +6652,48 @@ DEFUN (show_bgp_memory,
        return CMD_SUCCESS;
 }
 
+static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json)
+{
+       json_object *bestpath = json_object_new_object();
+
+       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE))
+               json_object_string_add(bestpath, "asPath", "ignore");
+
+       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED))
+               json_object_string_add(bestpath, "asPath", "confed");
+
+       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
+               if (bgp_flag_check(bgp,
+                                  BGP_FLAG_MULTIPATH_RELAX_AS_SET))
+                       json_object_string_add(bestpath,
+                                              "multiPathRelax",
+                                              "as-set");
+               else
+                       json_object_string_add(bestpath,
+                                              "multiPathRelax",
+                                              "true");
+       } else
+               json_object_string_add(bestpath,
+                                      "multiPathRelax",
+                                      "false");
+
+       if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID))
+               json_object_string_add(bestpath, "compareRouterId", "true");
+       if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)
+           || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) {
+               if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED))
+                       json_object_string_add(bestpath, "med",
+                                              "confed");
+               if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST))
+                       json_object_string_add(bestpath, "med",
+                                              "missing-as-worst");
+               else
+                       json_object_string_add(bestpath, "med", "true");
+       }
+
+       json_object_object_add(json, "bestPath", bestpath);
+}
+
 /* Show BGP peer's summary information. */
 static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                            u_char use_json, json_object *json)
@@ -7048,6 +7090,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                json_object_int_add(json, "totalPeers", count);
                json_object_int_add(json, "dynamicPeers", dn_count);
 
+               bgp_show_bestpath_json(bgp, json);
+
                vty_out(vty, "%s\n", json_object_to_json_string_ext(
                                             json, JSON_C_TO_STRING_PRETTY));
                json_object_free(json);
@@ -9745,6 +9789,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
        }
 
        if (use_json) {
+               bgp_show_bestpath_json(bgp, json);
                vty_out(vty, "%s\n", json_object_to_json_string_ext(
                                             json, JSON_C_TO_STRING_PRETTY));
                json_object_free(json);