Skip to content

Commit

Permalink
bgpd: Display best path selection reason
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
donaldsharp committed May 16, 2019
1 parent fdf81fa commit 0dc8ee7
Showing 1 changed file with 80 additions and 1 deletion.
81 changes: 80 additions & 1 deletion bgpd/bgp_route.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0dc8ee7

Please sign in to comment.