Merge pull request #12805 from karlquan/kquan_self_orig

bgpd: BGP troubleshooting - Add a keyword self-originate to display o…
This commit is contained in:
Russ White 2023-02-21 08:38:07 -05:00 committed by GitHub
commit eb9f54b872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 5 deletions

View File

@ -3034,7 +3034,7 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp,
* If 'type' is non-zero, only routes matching that type are shown. * If 'type' is non-zero, only routes matching that type are shown.
*/ */
static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
json_object *json, int detail) json_object *json, int detail, bool self_orig)
{ {
struct bgp_dest *rd_dest; struct bgp_dest *rd_dest;
struct bgp_table *table; struct bgp_table *table;
@ -3092,6 +3092,9 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
pi = bgp_dest_get_bgp_path_info(dest); pi = bgp_dest_get_bgp_path_info(dest);
if (pi) { if (pi) {
if (self_orig && (pi->peer != bgp->peer_self))
continue;
/* Overall header/legend displayed once. */ /* Overall header/legend displayed once. */
if (header) { if (header) {
bgp_evpn_show_route_header(vty, bgp, bgp_evpn_show_route_header(vty, bgp,
@ -3211,7 +3214,7 @@ int bgp_evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
if (use_json) if (use_json)
json = json_object_new_object(); json = json_object_new_object();
evpn_show_all_routes(vty, bgp, type, json, detail); evpn_show_all_routes(vty, bgp, type, json, detail, false);
if (use_json) if (use_json)
vty_json(vty, json); vty_json(vty, json);
@ -4784,7 +4787,7 @@ int bgp_evpn_cli_parse_type(int *type, struct cmd_token **argv, int argc)
*/ */
DEFUN(show_bgp_l2vpn_evpn_route, DEFUN(show_bgp_l2vpn_evpn_route,
show_bgp_l2vpn_evpn_route_cmd, show_bgp_l2vpn_evpn_route_cmd,
"show bgp l2vpn evpn route [detail] [type "EVPN_TYPE_ALL_LIST"] [json]", "show bgp l2vpn evpn route [detail] [type "EVPN_TYPE_ALL_LIST"] ["BGP_SELF_ORIG_CMD_STR"] [json]",
SHOW_STR SHOW_STR
BGP_STR BGP_STR
L2VPN_HELP_STR L2VPN_HELP_STR
@ -4793,12 +4796,15 @@ DEFUN(show_bgp_l2vpn_evpn_route,
"Display Detailed Information\n" "Display Detailed Information\n"
EVPN_TYPE_HELP_STR EVPN_TYPE_HELP_STR
EVPN_TYPE_ALL_LIST_HELP_STR EVPN_TYPE_ALL_LIST_HELP_STR
BGP_SELF_ORIG_HELP_STR
JSON_STR) JSON_STR)
{ {
struct bgp *bgp; struct bgp *bgp;
int detail = 0; int detail = 0;
int type = 0; int type = 0;
bool uj = false; bool uj = false;
int arg_idx = 0;
bool self_orig = false;
json_object *json = NULL; json_object *json = NULL;
uj = use_json(argc, argv); uj = use_json(argc, argv);
@ -4816,7 +4822,10 @@ DEFUN(show_bgp_l2vpn_evpn_route,
if (argv_find(argv, argc, "detail", &detail)) if (argv_find(argv, argc, "detail", &detail))
detail = 1; detail = 1;
evpn_show_all_routes(vty, bgp, type, json, detail); if (argv_find(argv, argc, BGP_SELF_ORIG_CMD_STR, &arg_idx))
self_orig = true;
evpn_show_all_routes(vty, bgp, type, json, detail, self_orig);
/* /*
* This is an extremely expensive operation at scale * This is an extremely expensive operation at scale
@ -4882,7 +4891,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd,
return CMD_WARNING; return CMD_WARNING;
if (rd_all) if (rd_all)
evpn_show_all_routes(vty, bgp, type, json, 1); evpn_show_all_routes(vty, bgp, type, json, 1, false);
else else
evpn_show_route_rd(vty, bgp, &prd, type, json); evpn_show_route_rd(vty, bgp, &prd, type, json);

View File

@ -11474,6 +11474,10 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|| CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) || CHECK_FLAG(pi->flags, BGP_PATH_HISTORY))
continue; continue;
} }
if (type == bgp_show_type_self_originated) {
if (pi->peer != bgp->peer_self)
continue;
}
if (!use_json && header) { if (!use_json && header) {
vty_out(vty, vty_out(vty,
@ -12650,6 +12654,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
|alias ALIAS_NAME\ |alias ALIAS_NAME\
|A.B.C.D/M longer-prefixes\ |A.B.C.D/M longer-prefixes\
|X:X::X:X/M longer-prefixes\ |X:X::X:X/M longer-prefixes\
|"BGP_SELF_ORIG_CMD_STR"\
|detail-routes$detail_routes\ |detail-routes$detail_routes\
] [json$uj [detail$detail_json] | wide$wide]", ] [json$uj [detail$detail_json] | wide$wide]",
SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
@ -12699,6 +12704,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
"Display route and more specific routes\n" "Display route and more specific routes\n"
"IPv6 prefix\n" "IPv6 prefix\n"
"Display route and more specific routes\n" "Display route and more specific routes\n"
BGP_SELF_ORIG_HELP_STR
"Display detailed version of all routes\n" "Display detailed version of all routes\n"
JSON_STR JSON_STR
"Display detailed version of JSON output\n" "Display detailed version of JSON output\n"
@ -12893,6 +12899,10 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
output_arg = &p; output_arg = &p;
} }
/* self originated only */
if (argv_find(argv, argc, BGP_SELF_ORIG_CMD_STR, &idx))
sh_type = bgp_show_type_self_originated;
if (!all) { if (!all) {
/* show bgp: AFI_IP6, show ip bgp: AFI_IP */ /* show bgp: AFI_IP6, show ip bgp: AFI_IP */
if (community) if (community)

View File

@ -46,6 +46,7 @@ enum bgp_show_type {
bgp_show_type_detail, bgp_show_type_detail,
bgp_show_type_rpki, bgp_show_type_rpki,
bgp_show_type_prefix_version, bgp_show_type_prefix_version,
bgp_show_type_self_originated,
}; };
enum bgp_show_adj_route_type { enum bgp_show_adj_route_type {

View File

@ -28,6 +28,9 @@ struct bgp;
BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR \ BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR \
BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR
#define BGP_SELF_ORIG_CMD_STR "self-originate"
#define BGP_SELF_ORIG_HELP_STR "Display only self-originated routes\n"
#define SHOW_GR_HEADER \ #define SHOW_GR_HEADER \
"Codes: GR - Graceful Restart," \ "Codes: GR - Graceful Restart," \
" * - Inheriting Global GR Config,\n" \ " * - Inheriting Global GR Config,\n" \

View File

@ -3900,6 +3900,10 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`.
EVPN prefixes can also be filtered by EVPN route type. EVPN prefixes can also be filtered by EVPN route type.
.. clicmd:: show bgp l2vpn evpn route [detail] [type <ead|1|macip|2|multicast|3|es|4|prefix|5>] self-originate [json]
Display self-originated EVPN prefixes which can also be filtered by EVPN route type.
.. clicmd:: show bgp vni <all|VNI> [vtep VTEP] [type <ead|1|macip|2|multicast|3>] [<detail|json>] .. clicmd:: show bgp vni <all|VNI> [vtep VTEP] [type <ead|1|macip|2|multicast|3>] [<detail|json>]
Display per-VNI EVPN routing table in bgp. Filter route-type, vtep, or VNI. Display per-VNI EVPN routing table in bgp. Filter route-type, vtep, or VNI.
@ -4056,6 +4060,15 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`.
If the ``json`` option is specified, output is displayed in JSON format. If the ``json`` option is specified, output is displayed in JSON format.
.. clicmd:: show [ip] bgp [afi] [safi] [all] self-originate [wide|json]
Display self-originated routes.
If ``wide`` option is specified, then the prefix table's width is increased
to fully display the prefix and the nexthop.
If the ``json`` option is specified, output is displayed in JSON format.
.. clicmd:: show [ip] bgp [afi] [safi] [all] neighbors A.B.C.D [advertised-routes|received-routes|filtered-routes] [<A.B.C.D/M|X:X::X:X/M> | detail] [json|wide] .. clicmd:: show [ip] bgp [afi] [safi] [all] neighbors A.B.C.D [advertised-routes|received-routes|filtered-routes] [<A.B.C.D/M|X:X::X:X/M> | detail] [json|wide]
Display the routes advertised to a BGP neighbor or received routes Display the routes advertised to a BGP neighbor or received routes