diff options
-rw-r--r-- | bgpd/bgp_route.c | 62 | ||||
-rw-r--r-- | bgpd/bgp_route.h | 2 | ||||
-rw-r--r-- | doc/user/bgp.rst | 41 |
3 files changed, 91 insertions, 14 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4ae018698..d2231c396 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -9168,6 +9168,15 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, lcom)) continue; } + + if (type == bgp_show_type_lcommunity_exact) { + struct lcommunity *lcom = output_arg; + + if (!pi->attr->lcommunity + || !lcommunity_cmp(pi->attr->lcommunity, + lcom)) + continue; + } if (type == bgp_show_type_lcommunity_list) { struct community_list *list = output_arg; @@ -9175,6 +9184,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, list)) continue; } + if (type + == bgp_show_type_lcommunity_list_exact) { + struct community_list *list = output_arg; + + if (!lcommunity_list_exact_match( + pi->attr->lcommunity, list)) + continue; + } if (type == bgp_show_type_lcommunity_all) { if (!pi->attr->lcommunity) continue; @@ -9798,8 +9815,8 @@ static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str, } static int bgp_show_lcommunity(struct vty *vty, struct bgp *bgp, int argc, - struct cmd_token **argv, afi_t afi, safi_t safi, - bool uj) + struct cmd_token **argv, bool exact, afi_t afi, + safi_t safi, bool uj) { struct lcommunity *lcom; struct buffer *b; @@ -9830,13 +9847,15 @@ static int bgp_show_lcommunity(struct vty *vty, struct bgp *bgp, int argc, return CMD_WARNING; } - return bgp_show(vty, bgp, afi, safi, bgp_show_type_lcommunity, lcom, - uj); + return bgp_show(vty, bgp, afi, safi, + (exact ? bgp_show_type_lcommunity_exact + : bgp_show_type_lcommunity), + lcom, uj); } static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp, - const char *lcom, afi_t afi, safi_t safi, - bool uj) + const char *lcom, bool exact, afi_t afi, + safi_t safi, bool uj) { struct community_list *list; @@ -9848,13 +9867,15 @@ static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp, return CMD_WARNING; } - return bgp_show(vty, bgp, afi, safi, bgp_show_type_lcommunity_list, + return bgp_show(vty, bgp, afi, safi, + (exact ? bgp_show_type_lcommunity_list_exact + : bgp_show_type_lcommunity_list), list, uj); } DEFUN (show_ip_bgp_large_community_list, show_ip_bgp_large_community_list_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community-list <(1-500)|WORD> [json]", + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community-list <(1-500)|WORD> [exact-match] [json]", SHOW_STR IP_STR BGP_STR @@ -9864,12 +9885,14 @@ DEFUN (show_ip_bgp_large_community_list, "Display routes matching the large-community-list\n" "large-community-list number\n" "large-community-list name\n" + "Exact match of the large-communities\n" JSON_STR) { char *vrf = NULL; afi_t afi = AFI_IP6; safi_t safi = SAFI_UNICAST; int idx = 0; + bool exact_match = 0; if (argv_find(argv, argc, "ip", &idx)) afi = AFI_IP; @@ -9893,12 +9916,18 @@ DEFUN (show_ip_bgp_large_community_list, } argv_find(argv, argc, "large-community-list", &idx); - return bgp_show_lcommunity_list(vty, bgp, argv[idx + 1]->arg, afi, safi, - uj); + + const char *clist_number_or_name = argv[++idx]->arg; + + if (++idx < argc && strmatch(argv[idx]->text, "exact-match")) + exact_match = 1; + + return bgp_show_lcommunity_list(vty, bgp, clist_number_or_name, + exact_match, afi, safi, uj); } DEFUN (show_ip_bgp_large_community, show_ip_bgp_large_community_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community [AA:BB:CC] [json]", + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community [<AA:BB:CC> [exact-match]] [json]", SHOW_STR IP_STR BGP_STR @@ -9907,12 +9936,14 @@ DEFUN (show_ip_bgp_large_community, BGP_SAFI_WITH_LABEL_HELP_STR "Display routes matching the large-communities\n" "List of large-community numbers\n" + "Exact match of the large-communities\n" JSON_STR) { char *vrf = NULL; afi_t afi = AFI_IP6; safi_t safi = SAFI_UNICAST; int idx = 0; + bool exact_match = 0; if (argv_find(argv, argc, "ip", &idx)) afi = AFI_IP; @@ -9935,9 +9966,12 @@ DEFUN (show_ip_bgp_large_community, return CMD_WARNING; } - if (argv_find(argv, argc, "AA:BB:CC", &idx)) - return bgp_show_lcommunity(vty, bgp, argc, argv, afi, safi, uj); - else + if (argv_find(argv, argc, "AA:BB:CC", &idx)) { + if (argv_find(argv, argc, "exact-match", &idx)) + exact_match = 1; + return bgp_show_lcommunity(vty, bgp, argc, argv, + exact_match, afi, safi, uj); + } else return bgp_show(vty, bgp, afi, safi, bgp_show_type_lcommunity_all, NULL, uj); } diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index f71508445..0f2363dc6 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -45,7 +45,9 @@ enum bgp_show_type { bgp_show_type_community_list_exact, bgp_show_type_lcommunity_all, bgp_show_type_lcommunity, + bgp_show_type_lcommunity_exact, bgp_show_type_lcommunity_list, + bgp_show_type_lcommunity_list_exact, bgp_show_type_flap_statistics, bgp_show_type_flap_neighbor, bgp_show_type_dampend_paths, diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 843d4f4ae..cea6e9754 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -2298,8 +2298,49 @@ attribute. match the specified community list. When `exact-match` is specified, it displays only routes that have an exact match. +.. _bgp-display-routes-by-lcommunity: + +Displaying Routes by Large Community Attribute +---------------------------------------------- + +The following commands allow displaying routes based on their +large community attribute. + +.. index:: show [ip] bgp <ipv4|ipv6> large-community +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community + +.. index:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY + +.. index:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY exact-match +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY exact-match + +.. index:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY json +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY json + + These commands display BGP routes which have the large community attribute. + attribute. When ``LARGE-COMMUNITY`` is specified, BGP routes that match that + large community are displayed. When `exact-match` is specified, it display + only routes that have an exact match. When `json` is specified, it display + routes in json format. + +.. index:: show [ip] bgp <ipv4|ipv6> large-community-list WORD +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community-list WORD + +.. index:: show [ip] bgp <ipv4|ipv6> large-community-list WORD exact-match +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community-list WORD exact-match + +.. index:: show [ip] bgp <ipv4|ipv6> large-community-list WORD json +.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community-list WORD json + + These commands display BGP routes for the address family specified that + match the specified large community list. When `exact-match` is specified, + it displays only routes that have an exact match. When `json` is specified, + it display routes in json format. + .. _bgp-display-routes-by-as-path: + Displaying Routes by AS Path ---------------------------- |