]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Display best path selection reason 4349/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 16 May 2019 01:11:02 +0000 (21:11 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 16 May 2019 01:47:51 +0000 (21:47 -0400)
As part of detailed bgp route detail, include the
reason why a route was selected as best path.

robot# show bgp ipv4 uni 223.255.254.0
BGP routing table entry for 223.255.254.0/24
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  annie(192.168.201.136)
  64539 15096 6939 7473 3758 55415
    192.168.201.136 from annie(192.168.201.136) (192.168.201.136)
      Origin IGP, valid, external, bestpath-from-AS 64539, best (First path received)
      Last update: Wed May 15 21:15:48 2019

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

index d24a152f138578820a64257cb7b83aa4ef0fe883..f3a69d4b25a4acf2fbc1cb8d6de9874854f129ea 100644 (file)
@@ -7868,6 +7868,79 @@ static void route_vty_out_tx_ids(struct vty *vty,
        }
 }
 
+static const char *bgp_path_selection_reason2str(
+       enum bgp_path_selection_reason reason)
+{
+       switch (reason) {
+       case bgp_path_selection_none:
+               return "Nothing to Select";
+               break;
+       case bgp_path_selection_first:
+               return "First path received";
+               break;
+       case bgp_path_selection_evpn_sticky_mac:
+               return "EVPN Sticky Mac";
+               break;
+       case bgp_path_selection_evpn_seq:
+               return "EVPN sequence number";
+               break;
+       case bgp_path_selection_evpn_lower_ip:
+               return "EVPN lower IP";
+               break;
+       case bgp_path_selection_weight:
+               return "Weight";
+               break;
+       case bgp_path_selection_local_pref:
+               return "Local Pref";
+               break;
+       case bgp_path_selection_local_route:
+               return "Local Route";
+               break;
+       case bgp_path_selection_confed_as_path:
+               return "Confederation based AS Path";
+               break;
+       case bgp_path_selection_as_path:
+               return "AS Path";
+               break;
+       case bgp_path_selection_origin:
+               return "Origin";
+               break;
+       case bgp_path_selection_med:
+               return "MED";
+               break;
+       case bgp_path_selection_peer:
+               return "Peer Type";
+               break;
+       case bgp_path_selection_confed:
+               return "Confed Peer Type";
+               break;
+       case bgp_path_selection_igp_metric:
+               return "IGP Metric";
+               break;
+       case bgp_path_selection_older:
+               return "Older Path";
+               break;
+       case bgp_path_selection_router_id:
+               return "Router ID";
+               break;
+       case bgp_path_selection_cluster_length:
+               return "Cluser length";
+               break;
+       case bgp_path_selection_stale:
+               return "Path Staleness";
+               break;
+       case bgp_path_selection_local_configured:
+               return "Locally configured route";
+               break;
+       case bgp_path_selection_neighbor_ip:
+               return "Neighbor IP";
+               break;
+       case bgp_path_selection_default:
+               return "Nothing left to compare";
+               break;
+       }
+}
+
 void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
                          struct bgp_node *bn, struct bgp_path_info *path,
                          afi_t afi, safi_t safi, json_object *json_paths)
@@ -8463,8 +8536,14 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
                                                json_object_new_object();
                                json_object_boolean_true_add(json_bestpath,
                                                             "overall");
-                       } else
+                               json_object_string_add(json_bestpath,
+                                                      "selectionReason",
+                                                      bgp_path_selection_reason2str(bn->reason));
+                       } else {
                                vty_out(vty, ", best");
+                               vty_out(vty, " (%s)",
+                                       bgp_path_selection_reason2str(bn->reason));
+                       }
                }
 
                if (json_bestpath)