Skip to content

Commit 0dc8ee7

Browse files
committed
bgpd: Display best path selection reason
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 <[email protected]>
1 parent fdf81fa commit 0dc8ee7

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

bgpd/bgp_route.c

+80-1
Original file line numberDiff line numberDiff line change
@@ -7868,6 +7868,79 @@ static void route_vty_out_tx_ids(struct vty *vty,
78687868
}
78697869
}
78707870

7871+
static const char *bgp_path_selection_reason2str(
7872+
enum bgp_path_selection_reason reason)
7873+
{
7874+
switch (reason) {
7875+
case bgp_path_selection_none:
7876+
return "Nothing to Select";
7877+
break;
7878+
case bgp_path_selection_first:
7879+
return "First path received";
7880+
break;
7881+
case bgp_path_selection_evpn_sticky_mac:
7882+
return "EVPN Sticky Mac";
7883+
break;
7884+
case bgp_path_selection_evpn_seq:
7885+
return "EVPN sequence number";
7886+
break;
7887+
case bgp_path_selection_evpn_lower_ip:
7888+
return "EVPN lower IP";
7889+
break;
7890+
case bgp_path_selection_weight:
7891+
return "Weight";
7892+
break;
7893+
case bgp_path_selection_local_pref:
7894+
return "Local Pref";
7895+
break;
7896+
case bgp_path_selection_local_route:
7897+
return "Local Route";
7898+
break;
7899+
case bgp_path_selection_confed_as_path:
7900+
return "Confederation based AS Path";
7901+
break;
7902+
case bgp_path_selection_as_path:
7903+
return "AS Path";
7904+
break;
7905+
case bgp_path_selection_origin:
7906+
return "Origin";
7907+
break;
7908+
case bgp_path_selection_med:
7909+
return "MED";
7910+
break;
7911+
case bgp_path_selection_peer:
7912+
return "Peer Type";
7913+
break;
7914+
case bgp_path_selection_confed:
7915+
return "Confed Peer Type";
7916+
break;
7917+
case bgp_path_selection_igp_metric:
7918+
return "IGP Metric";
7919+
break;
7920+
case bgp_path_selection_older:
7921+
return "Older Path";
7922+
break;
7923+
case bgp_path_selection_router_id:
7924+
return "Router ID";
7925+
break;
7926+
case bgp_path_selection_cluster_length:
7927+
return "Cluser length";
7928+
break;
7929+
case bgp_path_selection_stale:
7930+
return "Path Staleness";
7931+
break;
7932+
case bgp_path_selection_local_configured:
7933+
return "Locally configured route";
7934+
break;
7935+
case bgp_path_selection_neighbor_ip:
7936+
return "Neighbor IP";
7937+
break;
7938+
case bgp_path_selection_default:
7939+
return "Nothing left to compare";
7940+
break;
7941+
}
7942+
}
7943+
78717944
void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
78727945
struct bgp_node *bn, struct bgp_path_info *path,
78737946
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,
84638536
json_object_new_object();
84648537
json_object_boolean_true_add(json_bestpath,
84658538
"overall");
8466-
} else
8539+
json_object_string_add(json_bestpath,
8540+
"selectionReason",
8541+
bgp_path_selection_reason2str(bn->reason));
8542+
} else {
84678543
vty_out(vty, ", best");
8544+
vty_out(vty, " (%s)",
8545+
bgp_path_selection_reason2str(bn->reason));
8546+
}
84688547
}
84698548

84708549
if (json_bestpath)

0 commit comments

Comments
 (0)