diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 33b7bc1251..330e7ed52e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7925,6 +7925,101 @@ bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom, return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity_list, list, uj); } +DEFUN (show_ip_bgp_large_community_list, + show_ip_bgp_large_community_list_cmd, + "show [ip] bgp [ WORD] [ []] large-community-list <(1-500)|WORD> [json]", + SHOW_STR + IP_STR + BGP_STR + BGP_INSTANCE_HELP_STR + "Address Family\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Display routes matching the large-community-list\n" + "large-community-list number\n" + "large-community-list name\n" + JSON_STR) +{ + char *vrf = NULL; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + int idx = 0; + + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = bgp_vty_safi_from_arg (argv[idx]->text); + } + + int uj = use_json (argc, argv); + + struct bgp *bgp = bgp_lookup_by_name (vrf); + if (bgp == NULL) + { + vty_out (vty, "Can't find BGP instance %s%s", vrf, VTY_NEWLINE); + return CMD_WARNING; + } + + argv_find (argv, argc, "large-community-list", &idx); + return bgp_show_lcommunity_list (vty, bgp, argv[idx+1]->arg, afi, safi, uj); +} +DEFUN (show_ip_bgp_large_community, + show_ip_bgp_large_community_cmd, + "show [ip] bgp [ WORD] [ []] large-community [AA:BB:CC] [json]", + SHOW_STR + IP_STR + BGP_STR + BGP_INSTANCE_HELP_STR + "Address Family\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Display routes matching the large-communities\n" + "List of large-community numbers\n" + JSON_STR) +{ + char *vrf = NULL; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + int idx = 0; + + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + { + afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; + if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) + safi = bgp_vty_safi_from_arg (argv[idx]->text); + } + + int uj = use_json (argc, argv); + + struct bgp *bgp = bgp_lookup_by_name (vrf); + if (bgp == NULL) + { + vty_out (vty, "Can't find BGP instance %s%s", vrf, VTY_NEWLINE); + return CMD_WARNING; + } + + argv_find (argv, argc, "large-community", &idx); + if (strmatch(argv[idx+1]->text, "AA:BB:CC")) + return bgp_show_lcommunity (vty, bgp, argc, argv, afi, safi, uj); + else + return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity_all, NULL, uj); +} + /* BGP route print out function. */ DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, @@ -7937,8 +8032,6 @@ DEFUN (show_ip_bgp_ipv4, |filter-list WORD\ |community [ [exact-match]]\ |community-list <(1-500)|WORD> [exact-match]\ - |large-community [...]\ - |large-community-list <(1-500)|WORD>\ |A.B.C.D/M longer-prefixes\ |X:X::X:X/M longer-prefixes>\ ] [json]", @@ -7973,14 +8066,6 @@ DEFUN (show_ip_bgp_ipv4, "community-list number\n" "community-list name\n" "Exact match of the communities\n" - "Display routes matching the large-communities\n" - "large-community number\n" - "large-community number\n" - "large-community number\n" - "large-community number\n" - "Display routes matching the large-community-list\n" - "large-community-list number\n" - "large-community-list name\n" "IPv4 prefix\n" "Display route and more specific routes\n" "IPv6 prefix\n" @@ -8070,17 +8155,6 @@ DEFUN (show_ip_bgp_ipv4, exact_match = 1; return bgp_show_community_list (vty, vrf, clist_number_or_name, exact_match, afi, safi); } - else if (strmatch(argv[idx]->text, "large-community")) - { - if (strmatch(argv[idx+1]->text, "")) - return bgp_show_lcommunity (vty, bgp, argc, argv, afi, safi, uj); - else - return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity_all, NULL, uj); - } - else if (strmatch(argv[idx]->text, "large-community-list")) - { - return bgp_show_lcommunity_list (vty, bgp, argv[idx+1]->arg, afi, safi, uj); - } /* prefix-longer */ else if (argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV6_TKN) return bgp_show_prefix_longer (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer); @@ -10720,6 +10794,10 @@ bgp_route_init (void) /* IPv4 Multicast Mode */ install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); + + /* Large Communities */ + install_element (VIEW_NODE, &show_ip_bgp_large_community_list_cmd); + install_element (VIEW_NODE, &show_ip_bgp_large_community_cmd); } void diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index c4b3ddee36..693a807c89 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3410,7 +3410,7 @@ DEFUN (no_match_community, DEFUN (match_lcommunity, match_lcommunity_cmd, - "match large-community [(1-99)|(100-500)|WORD]", + "match large-community [<(1-99)|(100-500)|WORD>]", MATCH_STR "Match BGP large community list\n" "Large Community-list number (standard)\n" @@ -3423,7 +3423,7 @@ DEFUN (match_lcommunity, DEFUN (no_match_lcommunity, no_match_lcommunity_cmd, - "no match large-community [(1-99)|(100-500)|WORD]", + "no match large-community [<(1-99)|(100-500)|WORD>]", NO_STR MATCH_STR "Match BGP large community list\n" @@ -3896,18 +3896,27 @@ DEFUN (set_lcommunity_none, DEFUN (no_set_lcommunity, no_set_lcommunity_cmd, - "no set large-community ", + "no set large-community none", NO_STR SET_STR "BGP large community attribute\n" - "No community attribute\n" - "Large community\n" - "Large community in AA:BB:CC... format or additive\n") + "No community attribute\n") { return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), "large-community", NULL); } +DEFUN (no_set_lcommunity1, + no_set_lcommunity1_cmd, + "no set large-community AA:BB:CC...", + NO_STR + SET_STR + "BGP large community attribute\n" + "Large community in AA:BB:CC... format or additive\n") +{ + return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), + "large-community", NULL); +} DEFUN (set_lcommunity_delete, set_lcommunity_delete_cmd, @@ -3934,7 +3943,7 @@ DEFUN (set_lcommunity_delete, DEFUN (no_set_lcommunity_delete, no_set_lcommunity_delete_cmd, - "no set large-comm-list [<(1-99|(100-500)|word)> delete]", + "no set large-comm-list <(1-99|(100-500)|WORD)> [delete]", NO_STR SET_STR "set BGP large community list (for deletion)\n" @@ -4478,6 +4487,7 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &set_lcommunity_cmd); install_element (RMAP_NODE, &set_lcommunity_none_cmd); install_element (RMAP_NODE, &no_set_lcommunity_cmd); + install_element (RMAP_NODE, &no_set_lcommunity1_cmd); install_element (RMAP_NODE, &set_lcommunity_delete_cmd); install_element (RMAP_NODE, &no_set_lcommunity_delete_cmd); install_element (RMAP_NODE, &set_ecommunity_rt_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0797756f65..b3eaaaf111 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11240,7 +11240,20 @@ lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, DEFUN (ip_lcommunity_list_standard, ip_lcommunity_list_standard_cmd, - "ip large-community-list (1-99) [AA:BB:CC...]", + "ip large-community-list (1-99) ", + IP_STR + LCOMMUNITY_LIST_STR + "Large Community list number (standard)\n" + "Specify large community to reject\n" + "Specify large community to accept\n" + LCOMMUNITY_VAL_STR) +{ + return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); +} + +DEFUN (ip_lcommunity_list_standard1, + ip_lcommunity_list_standard1_cmd, + "ip large-community-list (1-99) AA:BB:CC...", IP_STR LCOMMUNITY_LIST_STR "Large Community list number (standard)\n" @@ -11266,7 +11279,20 @@ DEFUN (ip_lcommunity_list_expanded, DEFUN (ip_lcommunity_list_name_standard, ip_lcommunity_list_name_standard_cmd, - "ip large-community-list standard WORD [AA:BB.CC...]", + "ip large-community-list standard WORD ", + IP_STR + LCOMMUNITY_LIST_STR + "Specify standard large-community-list\n" + "Large Community list name\n" + "Specify large community to reject\n" + "Specify large community to accept\n") +{ + return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); +} + +DEFUN (ip_lcommunity_list_name_standard1, + ip_lcommunity_list_name_standard1_cmd, + "ip large-community-list standard WORD AA:BB:CC...", IP_STR LCOMMUNITY_LIST_STR "Specify standard large-community-list\n" @@ -11819,8 +11845,10 @@ community_list_vty (void) /* Large Community List */ install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); + install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); + install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd);