#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_errors.h"
#include "bgpd/bgp_ecommunity.h"
+#include "bgpd/bgp_lcommunity.h"
+#include "bgpd/bgp_community.h"
#define SHOW_DISPLAY_STANDARD 0
#define SHOW_DISPLAY_TAGS 1
if (peer_cmp(peer, pi->peer) != 0)
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) {
+ struct lcommunity *lcom = output_arg;
+
+ if (!pi->attr->lcommunity ||
+ !lcommunity_match(
+ pi->attr->lcommunity, lcom))
+ continue;
+ }
+ if (type == bgp_show_type_community) {
+ struct community *com = output_arg;
+
+ if (!pi->attr->community ||
+ !community_match(
+ pi->attr->community, com))
+ continue;
+ }
+ if (type == bgp_show_type_community_exact) {
+ struct community *com = output_arg;
+
+ if (!pi->attr->community ||
+ !community_cmp(
+ pi->attr->community, com))
+ continue;
+ }
if (header) {
if (use_json) {
json_object_int_add(
use_json(argc, argv));
}
+DEFUN(show_bgp_l2vpn_evpn_com,
+ show_bgp_l2vpn_evpn_com_cmd,
+ "show bgp l2vpn evpn \
+ <community AA:NN|large-community AA:BB:CC> \
+ [exact-match] [json]",
+ SHOW_STR
+ BGP_STR
+ L2VPN_HELP_STR
+ EVPN_HELP_STR
+ "Display routes matching the community\n"
+ "Community number where AA and NN are (0-65535)\n"
+ "Display routes matching the large-community\n"
+ "List of large-community numbers\n"
+ "Exact match of the communities\n"
+ JSON_STR)
+{
+ int idx = 0;
+ int ret = 0;
+ const char *clist_number_or_name;
+ int show_type = bgp_show_type_normal;
+ struct community *com;
+ struct lcommunity *lcom;
+
+ if (argv_find(argv, argc, "large-community", &idx)) {
+ clist_number_or_name = argv[++idx]->arg;
+ show_type = bgp_show_type_lcommunity;
+
+ if (++idx < argc && strmatch(argv[idx]->text, "exact-match"))
+ show_type = bgp_show_type_lcommunity_exact;
+
+ lcom = lcommunity_str2com(clist_number_or_name);
+ if (!lcom) {
+ vty_out(vty, "%% Large-community malformed\n");
+ return CMD_WARNING;
+ }
+
+ ret = bgp_show_ethernet_vpn(vty, NULL, show_type, lcom,
+ SHOW_DISPLAY_STANDARD,
+ use_json(argc, argv));
+
+ lcommunity_free(&lcom);
+ } else if (argv_find(argv, argc, "community", &idx)) {
+ clist_number_or_name = argv[++idx]->arg;
+ show_type = bgp_show_type_community;
+
+ if (++idx < argc && strmatch(argv[idx]->text, "exact-match"))
+ show_type = bgp_show_type_community_exact;
+
+ com = community_str2com(clist_number_or_name);
+
+ if (!com) {
+ vty_out(vty, "%% Community malformed: %s\n",
+ clist_number_or_name);
+ return CMD_WARNING;
+ }
+
+ ret = bgp_show_ethernet_vpn(vty, NULL, show_type, com,
+ SHOW_DISPLAY_STANDARD,
+ use_json(argc, argv));
+ community_free(&com);
+ }
+
+ return ret;
+}
+
/* For testing purpose, static route of EVPN RT-5. */
DEFUN(evpnrt5_network,
evpnrt5_network_cmd,
install_element(VIEW_NODE, &show_bgp_evpn_route_vni_all_cmd);
install_element(VIEW_NODE, &show_bgp_evpn_import_rt_cmd);
install_element(VIEW_NODE, &show_bgp_vrf_l3vni_info_cmd);
+ install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_com_cmd);
install_element(BGP_EVPN_NODE, &bgp_evpn_vni_cmd);
install_element(BGP_EVPN_NODE, &no_bgp_evpn_vni_cmd);