]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Add `bestpath-routes` to neighbor command
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 31 Jul 2020 16:12:37 +0000 (12:12 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 3 Aug 2020 14:34:14 +0000 (10:34 -0400)
Add the ability to list the bestpath-routes to the
`show bgp afi safi neighbor X` command.

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

index 5ac595c43655e07c8112225acf6ecf3600ec7b22..6b2a5f55b757ed7e724c58d2340c580f7f9de356 100644 (file)
@@ -12195,6 +12195,27 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
 
                                        bgp_attr_undup(&attr, adj->attr);
                                }
+               } else if (type == bgp_show_adj_route_bestpath) {
+                       struct bgp_path_info *pi;
+
+                       show_adj_route_header(vty, bgp, table, &header1,
+                                             &header2, json, json_scode,
+                                             json_ocode, wide);
+
+                       for (pi = bgp_dest_get_bgp_path_info(dest); pi;
+                            pi = pi->next) {
+                               if (pi->peer != peer)
+                                       continue;
+
+                               if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
+                                       continue;
+
+                               route_vty_out_tmp(vty,
+                                                 bgp_dest_get_prefix(dest),
+                                                 pi->attr, safi, use_json,
+                                                 json_ar, wide);
+                               output_count++;
+                       }
                }
        }
 
@@ -12269,6 +12290,48 @@ static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi,
        return CMD_SUCCESS;
 }
 
+DEFPY (show_ip_bgp_instance_neighbor_bestpath_route,
+       show_ip_bgp_instance_neighbor_bestpath_route_cmd,
+       "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> bestpath-routes [json$uj | wide$wide]",
+       SHOW_STR
+       IP_STR
+       BGP_STR
+       BGP_INSTANCE_HELP_STR
+       BGP_AFI_HELP_STR
+       BGP_SAFI_WITH_LABEL_HELP_STR
+       "Detailed information on TCP and BGP neighbor connections\n"
+       "Neighbor to display information about\n"
+       "Neighbor to display information about\n"
+       "Neighbor on BGP configured interface\n"
+       "Display the routes selected by best path\n"
+       JSON_STR
+       "Increase table width for longer prefixes\n")
+{
+       afi_t afi = AFI_IP6;
+       safi_t safi = SAFI_UNICAST;
+       char *rmap_name = NULL;
+       char *peerstr = NULL;
+       struct bgp *bgp = NULL;
+       struct peer *peer;
+       enum bgp_show_adj_route_type type = bgp_show_adj_route_bestpath;
+       int idx = 0;
+
+       bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
+                                           &bgp, uj);
+
+       if (!idx)
+               return CMD_WARNING;
+
+       argv_find(argv, argc, "neighbors", &idx);
+       peerstr = argv[++idx]->arg;
+
+       peer = peer_lookup_in_view(vty, bgp, peerstr, uj);
+       if (!peer)
+               return CMD_WARNING;
+
+       return peer_adj_routes(vty, peer, afi, safi, type, rmap_name, uj, wide);
+}
+
 DEFPY (show_ip_bgp_instance_neighbor_advertised_route,
        show_ip_bgp_instance_neighbor_advertised_route_cmd,
        "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json$uj | wide$wide]",
@@ -13478,6 +13541,8 @@ void bgp_route_init(void)
 
        install_element(VIEW_NODE,
                        &show_ip_bgp_instance_neighbor_advertised_route_cmd);
+       install_element(VIEW_NODE,
+                       &show_ip_bgp_instance_neighbor_bestpath_route_cmd);
        install_element(VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
        install_element(VIEW_NODE,
                        &show_ip_bgp_neighbor_received_prefix_filter_cmd);
index 0767d2912f2d5ac3ca29fc60eb952a7f80b01a1d..32c65c8facf3964b434bea6a0ff35ecc6946f16a 100644 (file)
@@ -62,6 +62,7 @@ enum bgp_show_adj_route_type {
        bgp_show_adj_route_advertised,
        bgp_show_adj_route_received,
        bgp_show_adj_route_filtered,
+       bgp_show_adj_route_bestpath,
 };