diff options
Diffstat (limited to 'bgpd/bgp_evpn_vty.c')
-rw-r--r-- | bgpd/bgp_evpn_vty.c | 3028 |
1 files changed, 1448 insertions, 1580 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index b5a58f014..4b39ee862 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -42,305 +42,289 @@ /* * Context for VNI hash walk - used by callbacks. */ -struct vni_walk_ctx -{ - struct bgp *bgp; - struct vty *vty; - struct in_addr vtep_ip; +struct vni_walk_ctx { + struct bgp *bgp; + struct vty *vty; + struct in_addr vtep_ip; }; -struct evpn_config_write -{ - int write; - struct vty *vty; +struct evpn_config_write { + int write; + struct vty *vty; }; -#if defined (HAVE_CUMULUS) -static void -display_import_rt (struct vty *vty, struct irt_node *irt) +#if defined(HAVE_CUMULUS) +static void display_import_rt(struct vty *vty, struct irt_node *irt) +{ + u_char *pnt; + u_char type, sub_type; + struct ecommunity_as { + as_t as; + u_int32_t val; + } eas; + struct ecommunity_ip { + struct in_addr ip; + u_int16_t val; + } eip; + struct listnode *node, *nnode; + struct bgpevpn *tmp_vpn; + + + /* TODO: This needs to go into a function */ + + pnt = (u_char *)&irt->rt.val; + type = *pnt++; + sub_type = *pnt++; + if (sub_type != ECOMMUNITY_ROUTE_TARGET) + return; + + switch (type) { + case ECOMMUNITY_ENCODE_AS: + eas.as = (*pnt++ << 8); + eas.as |= (*pnt++); + + eas.val = (*pnt++ << 24); + eas.val |= (*pnt++ << 16); + eas.val |= (*pnt++ << 8); + eas.val |= (*pnt++); + + vty_out(vty, "Route-target: %u:%u", eas.as, eas.val); + break; + + case ECOMMUNITY_ENCODE_IP: + memcpy(&eip.ip, pnt, 4); + pnt += 4; + eip.val = (*pnt++ << 8); + eip.val |= (*pnt++); + + vty_out(vty, "Route-target: %s:%u", inet_ntoa(eip.ip), eip.val); + break; + + case ECOMMUNITY_ENCODE_AS4: + eas.as = (*pnt++ << 24); + eas.as |= (*pnt++ << 16); + eas.as |= (*pnt++ << 8); + eas.as |= (*pnt++); + + eas.val = (*pnt++ << 8); + eas.val |= (*pnt++); + + vty_out(vty, "Route-target: %u:%u", eas.as, eas.val); + break; + + default: + return; + } + + vty_out(vty, "\n"); + vty_out(vty, "List of VNIs importing routes with this route-target:\n"); + + for (ALL_LIST_ELEMENTS(irt->vnis, node, nnode, tmp_vpn)) + vty_out(vty, " %u\n", tmp_vpn->vni); +} + +static void show_import_rt_entry(struct hash_backet *backet, struct vty *vty) { - u_char *pnt; - u_char type, sub_type; - struct ecommunity_as - { - as_t as; - u_int32_t val; - } eas; - struct ecommunity_ip - { - struct in_addr ip; - u_int16_t val; - } eip; - struct listnode *node, *nnode; - struct bgpevpn *tmp_vpn; + struct irt_node *irt = (struct irt_node *)backet->data; + display_import_rt(vty, irt); +} +static void bgp_evpn_show_route_rd_header(struct vty *vty, + struct bgp_node *rd_rn) +{ + u_int16_t type; + struct rd_as rd_as; + struct rd_ip rd_ip; + u_char *pnt; - /* TODO: This needs to go into a function */ + pnt = rd_rn->p.u.val; - pnt = (u_char *)&irt->rt.val; - type = *pnt++; - sub_type = *pnt++; - if (sub_type != ECOMMUNITY_ROUTE_TARGET) - return; + /* Decode RD type. */ + type = decode_rd_type(pnt); - switch (type) - { - case ECOMMUNITY_ENCODE_AS: - eas.as = (*pnt++ << 8); - eas.as |= (*pnt++); + vty_out(vty, "Route Distinguisher: "); - eas.val = (*pnt++ << 24); - eas.val |= (*pnt++ << 16); - eas.val |= (*pnt++ << 8); - eas.val |= (*pnt++); + switch (type) { + case RD_TYPE_AS: + decode_rd_as(pnt + 2, &rd_as); + vty_out(vty, "%u:%d", rd_as.as, rd_as.val); + break; - vty_out (vty, "Route-target: %u:%u", eas.as, eas.val); - break; + case RD_TYPE_IP: + decode_rd_ip(pnt + 2, &rd_ip); + vty_out(vty, "%s:%d", inet_ntoa(rd_ip.ip), rd_ip.val); + break; - case ECOMMUNITY_ENCODE_IP: - memcpy (&eip.ip, pnt, 4); - pnt += 4; - eip.val = (*pnt++ << 8); - eip.val |= (*pnt++); + default: + vty_out(vty, "Unknown RD type"); + break; + } + + vty_out(vty, "\n"); +} + +static void bgp_evpn_show_route_header(struct vty *vty, struct bgp *bgp) +{ + char ri_header[] = + " Network Next Hop Metric LocPrf Weight Path\n"; - vty_out (vty, "Route-target: %s:%u", - inet_ntoa (eip.ip), eip.val); - break; + vty_out(vty, "BGP table version is 0, local router ID is %s\n", + inet_ntoa(bgp->router_id)); + vty_out(vty, + "Status codes: s suppressed, d damped, h history, " + "* valid, > best, i - internal\n"); + vty_out(vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n"); + vty_out(vty, + "EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]\n"); + vty_out(vty, "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]\n\n"); + vty_out(vty, "%s", ri_header); +} - case ECOMMUNITY_ENCODE_AS4: - eas.as = (*pnt++ << 24); - eas.as |= (*pnt++ << 16); - eas.as |= (*pnt++ << 8); - eas.as |= (*pnt++); +static void display_vni(struct vty *vty, struct bgpevpn *vpn) +{ + char buf1[INET6_ADDRSTRLEN]; + char *ecom_str; + struct listnode *node, *nnode; + struct ecommunity *ecom; - eas.val = (*pnt++ << 8); - eas.val |= (*pnt++); + vty_out(vty, "VNI: %d", vpn->vni); + if (is_vni_live(vpn)) + vty_out(vty, " (known to the kernel)"); + vty_out(vty, "\n"); - vty_out (vty, "Route-target: %u:%u", eas.as, eas.val); - break; - - default: - return; - } + vty_out(vty, " RD: %s\n", + prefix_rd2str(&vpn->prd, buf1, RD_ADDRSTRLEN)); + vty_out(vty, " Originator IP: %s\n", inet_ntoa(vpn->originator_ip)); - vty_out (vty, "\n"); - vty_out (vty, "List of VNIs importing routes with this route-target:\n"); + vty_out(vty, " Import Route Target:\n"); + for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) { + ecom_str = ecommunity_ecom2str(ecom, + ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out(vty, " %s\n", ecom_str); + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + } - for (ALL_LIST_ELEMENTS (irt->vnis, node, nnode, tmp_vpn)) - vty_out (vty, " %u\n", tmp_vpn->vni); + vty_out(vty, " Export Route Target:\n"); + for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom)) { + ecom_str = ecommunity_ecom2str(ecom, + ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out(vty, " %s\n", ecom_str); + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + } } - -static void -show_import_rt_entry (struct hash_backet *backet, struct vty *vty) + +static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, + struct vty *vty, struct in_addr vtep_ip) { - struct irt_node *irt = (struct irt_node *) backet->data; - display_import_rt (vty, irt); + struct bgp_node *rn; + struct bgp_info *ri; + int header = 1; + u_int32_t prefix_cnt, path_cnt; + + prefix_cnt = path_cnt = 0; + + for (rn = bgp_table_top(vpn->route_table); rn; + rn = bgp_route_next(rn)) { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (type && evp->prefix.route_type != type) + continue; + + if (rn->info) { + /* Overall header/legend displayed once. */ + if (header) { + bgp_evpn_show_route_header(vty, bgp); + header = 0; + } + + prefix_cnt++; + } + + /* For EVPN, the prefix is displayed for each path (to fit in + * with code that already exists). + */ + for (ri = rn->info; ri; ri = ri->next) { + if (vtep_ip.s_addr + && !IPV4_ADDR_SAME(&(vtep_ip), + &(ri->attr->nexthop))) + continue; + + path_cnt++; + route_vty_out(vty, &rn->p, ri, 0, SAFI_EVPN, NULL); + } + } + + if (prefix_cnt == 0) + vty_out(vty, "No EVPN prefixes %sexist for this VNI\n", + type ? "(of requested type) " : ""); + else + vty_out(vty, "\nDisplayed %u prefixes (%u paths)%s\n", + prefix_cnt, path_cnt, + type ? " (of requested type)" : ""); } -static void -bgp_evpn_show_route_rd_header (struct vty *vty, struct bgp_node *rd_rn) +static void show_vni_routes_hash(struct hash_backet *backet, void *arg) { - u_int16_t type; - struct rd_as rd_as; - struct rd_ip rd_ip; - u_char *pnt; + struct bgpevpn *vpn = (struct bgpevpn *)backet->data; + struct vni_walk_ctx *wctx = arg; + struct vty *vty = wctx->vty; - pnt = rd_rn->p.u.val; - - /* Decode RD type. */ - type = decode_rd_type (pnt); - - vty_out (vty, "Route Distinguisher: "); - - switch (type) - { - case RD_TYPE_AS: - decode_rd_as (pnt + 2, &rd_as); - vty_out (vty, "%u:%d", rd_as.as, rd_as.val); - break; - - case RD_TYPE_IP: - decode_rd_ip (pnt + 2, &rd_ip); - vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val); - break; - - default: - vty_out (vty, "Unknown RD type"); - break; - } - - vty_out (vty, "\n"); -} - -static void -bgp_evpn_show_route_header (struct vty *vty, struct bgp *bgp) -{ - char ri_header[] = " Network Next Hop Metric LocPrf Weight Path\n"; - - vty_out (vty, "BGP table version is 0, local router ID is %s\n", - inet_ntoa (bgp->router_id)); - vty_out (vty, "Status codes: s suppressed, d damped, h history, " - "* valid, > best, i - internal\n"); - vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n"); - vty_out (vty, "EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]\n"); - vty_out (vty, "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]\n\n"); - vty_out (vty, "%s", ri_header); + vty_out(vty, "\nVNI: %d\n\n", vpn->vni); + show_vni_routes(wctx->bgp, vpn, 0, wctx->vty, wctx->vtep_ip); } -static void -display_vni (struct vty *vty, struct bgpevpn *vpn) +static void show_vni_entry(struct hash_backet *backet, struct vty *vty) { - char buf1[INET6_ADDRSTRLEN]; - char *ecom_str; - struct listnode *node, *nnode; - struct ecommunity *ecom; + struct bgpevpn *vpn = (struct bgpevpn *)backet->data; + char buf1[10]; + char buf2[INET6_ADDRSTRLEN]; + char rt_buf[25]; + char *ecom_str; + struct listnode *node, *nnode; + struct ecommunity *ecom; - vty_out (vty, "VNI: %d", vpn->vni); - if (is_vni_live (vpn)) - vty_out (vty, " (known to the kernel)"); - vty_out (vty, "\n"); + buf1[0] = '\0'; + if (is_vni_live(vpn)) + sprintf(buf1, "*"); - vty_out (vty, " RD: %s\n", - prefix_rd2str (&vpn->prd, buf1, RD_ADDRSTRLEN)); - vty_out (vty, " Originator IP: %s\n", - inet_ntoa(vpn->originator_ip)); + vty_out(vty, "%-1s %-10u %-15s %-21s", buf1, vpn->vni, + inet_ntoa(vpn->originator_ip), + prefix_rd2str(&vpn->prd, buf2, RD_ADDRSTRLEN)); - vty_out (vty, " Import Route Target:\n"); - for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) - { - ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - vty_out (vty, " %s\n", ecom_str); - XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); - } + for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) { + ecom_str = ecommunity_ecom2str(ecom, + ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - vty_out (vty, " Export Route Target:\n"); - for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) - { - ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - vty_out (vty, " %s\n", ecom_str); - XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); - } -} + if (listcount(vpn->import_rtl) > 1) + sprintf(rt_buf, "%s, ...", ecom_str); + else + sprintf(rt_buf, "%s", ecom_str); + vty_out(vty, " %-25s", rt_buf); -static void -show_vni_routes (struct bgp *bgp, struct bgpevpn *vpn, int type, - struct vty *vty, struct in_addr vtep_ip) -{ - struct bgp_node *rn; - struct bgp_info *ri; - int header = 1; - u_int32_t prefix_cnt, path_cnt; - - prefix_cnt = path_cnt = 0; - - for (rn = bgp_table_top (vpn->route_table); rn; rn = bgp_route_next (rn)) - { - struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; - - if (type && - evp->prefix.route_type != type) - continue; - - if (rn->info) - { - /* Overall header/legend displayed once. */ - if (header) - { - bgp_evpn_show_route_header (vty, bgp); - header = 0; - } - - prefix_cnt++; - } - - /* For EVPN, the prefix is displayed for each path (to fit in - * with code that already exists). - */ - for (ri = rn->info; ri; ri = ri->next) - { - if (vtep_ip.s_addr && - !IPV4_ADDR_SAME(&(vtep_ip), &(ri->attr->nexthop))) - continue; - - path_cnt++; - route_vty_out (vty, &rn->p, ri, 0, SAFI_EVPN, NULL); - } - } - - if (prefix_cnt == 0) - vty_out (vty, "No EVPN prefixes %sexist for this VNI\n", - type ? "(of requested type) " : ""); - else - vty_out (vty, "\nDisplayed %u prefixes (%u paths)%s\n", - prefix_cnt, path_cnt, - type ? " (of requested type)" : ""); -} - -static void -show_vni_routes_hash (struct hash_backet *backet, void *arg) -{ - struct bgpevpn *vpn = (struct bgpevpn *) backet->data; - struct vni_walk_ctx *wctx = arg; - struct vty *vty = wctx->vty; - - vty_out (vty, "\nVNI: %d\n\n", vpn->vni); - show_vni_routes (wctx->bgp, vpn, 0, wctx->vty, wctx->vtep_ip); -} - -static void -show_vni_entry (struct hash_backet *backet, struct vty *vty) -{ - struct bgpevpn *vpn = (struct bgpevpn *) backet->data; - char buf1[10]; - char buf2[INET6_ADDRSTRLEN]; - char rt_buf[25]; - char *ecom_str; - struct listnode *node, *nnode; - struct ecommunity *ecom; - - buf1[0] = '\0'; - if (is_vni_live (vpn)) - sprintf (buf1, "*"); - - vty_out(vty, "%-1s %-10u %-15s %-21s", - buf1, vpn->vni, inet_ntoa(vpn->originator_ip), - prefix_rd2str (&vpn->prd, buf2, RD_ADDRSTRLEN)); - - for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) - { - ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - - if (listcount(vpn->import_rtl) > 1) - sprintf (rt_buf, "%s, ...", ecom_str); - else - sprintf (rt_buf, "%s", ecom_str); - vty_out (vty, " %-25s", rt_buf); - - XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); - break; - } - - for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) - { - ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - - if (listcount(vpn->export_rtl) > 1) - sprintf (rt_buf, "%s, ...", ecom_str); - else - sprintf (rt_buf, "%s", ecom_str); - vty_out (vty, " %-25s", rt_buf); - - XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); - break; - } - vty_out (vty, "\n"); + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + break; + } + + for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom)) { + ecom_str = ecommunity_ecom2str(ecom, + ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + + if (listcount(vpn->export_rtl) > 1) + sprintf(rt_buf, "%s, ...", ecom_str); + else + sprintf(rt_buf, "%s", ecom_str); + vty_out(vty, " %-25s", rt_buf); + + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + break; + } + vty_out(vty, "\n"); } #endif /* HAVE_CUMULUS */ -static int -bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, - enum bgp_show_type type, void *output_arg, int option, - u_char use_json) +static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, + enum bgp_show_type type, void *output_arg, + int option, u_char use_json) { afi_t afi = AFI_L2VPN; struct bgp *bgp; @@ -362,7 +346,7 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, bgp = bgp_get_default(); if (bgp == NULL) { if (!use_json) - vty_out (vty,"No BGP process is configured\n"); + vty_out(vty, "No BGP process is configured\n"); return CMD_WARNING; } @@ -387,7 +371,7 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, for (rn = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); rn; rn = bgp_route_next(rn)) { if (use_json) - continue; /* XXX json TODO */ + continue; /* XXX json TODO */ if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) continue; @@ -401,54 +385,57 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, total_count++; if (type == bgp_show_type_neighbor) { union sockunion *su = - output_arg; + output_arg; if (ri->peer->su_remote == NULL - || !sockunion_same(ri-> - peer-> - su_remote, - su)) + || !sockunion_same( + ri->peer->su_remote, + su)) continue; } if (header == 0) { if (use_json) { - if (option == - SHOW_DISPLAY_TAGS) { - json_object_int_add - (json, - "bgpTableVersion", - 0); - json_object_string_add - (json, - "bgpLocalRouterId", - inet_ntoa - (bgp-> - router_id)); - json_object_object_add - (json, - "bgpStatusCodes", - json_scode); - json_object_object_add - (json, - "bgpOriginCodes", - json_ocode); + if (option + == SHOW_DISPLAY_TAGS) { + json_object_int_add( + json, + "bgpTableVersion", + 0); + json_object_string_add( + json, + "bgpLocalRouterId", + inet_ntoa( + bgp->router_id)); + json_object_object_add( + json, + "bgpStatusCodes", + json_scode); + json_object_object_add( + json, + "bgpOriginCodes", + json_ocode); } } else { - if (option == - SHOW_DISPLAY_TAGS) - vty_out(vty, V4_HEADER_TAG); - else if (option == - SHOW_DISPLAY_OVERLAY) - vty_out(vty, V4_HEADER_OVERLAY); + if (option + == SHOW_DISPLAY_TAGS) + vty_out(vty, + V4_HEADER_TAG); + else if ( + option + == SHOW_DISPLAY_OVERLAY) + vty_out(vty, + V4_HEADER_OVERLAY); else { - vty_out (vty, + vty_out(vty, "BGP table version is 0, local router ID is %s\n", - inet_ntoa(bgp->router_id)); - vty_out (vty, + inet_ntoa( + bgp->router_id)); + vty_out(vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n"); - vty_out (vty, + vty_out(vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n"); - vty_out(vty, V4_HEADER); + vty_out(vty, + V4_HEADER); } } header = 0; @@ -476,73 +463,60 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, if (use_json) { char buffer[BUFSIZ]; if (type == RD_TYPE_AS - || type == - RD_TYPE_AS4) + || type == RD_TYPE_AS4) sprintf(buffer, "%u:%d", - rd_as. - as, - rd_as. - val); - else if (type == - RD_TYPE_IP) + rd_as.as, + rd_as.val); + else if (type + == RD_TYPE_IP) sprintf(buffer, "%s:%d", - inet_ntoa - (rd_ip. - ip), - rd_ip. - val); - json_object_string_add - (json_nroute, - "routeDistinguisher", - buffer); + inet_ntoa( + rd_ip.ip), + rd_ip.val); + json_object_string_add( + json_nroute, + "routeDistinguisher", + buffer); } else { vty_out(vty, "Route Distinguisher: "); if (type == RD_TYPE_AS) vty_out(vty, "as2 %u:%d", - rd_as. - as, - rd_as. - val); - else if (type == - RD_TYPE_AS4) + rd_as.as, + rd_as.val); + else if (type + == RD_TYPE_AS4) vty_out(vty, "as4 %u:%d", - rd_as. - as, - rd_as. - val); - else if (type == - RD_TYPE_IP) + rd_as.as, + rd_as.val); + else if (type + == RD_TYPE_IP) vty_out(vty, "ip %s:%d", - inet_ntoa - (rd_ip. - ip), - rd_ip. - val); - vty_out (vty, "\n\n"); + inet_ntoa( + rd_ip.ip), + rd_ip.val); + vty_out(vty, "\n\n"); } rd_header = 0; } if (use_json) json_array = - json_object_new_array(); + json_object_new_array(); else json_array = NULL; if (option == SHOW_DISPLAY_TAGS) - route_vty_out_tag(vty, &rm->p, - ri, 0, - SAFI_EVPN, - json_array); + route_vty_out_tag( + vty, &rm->p, ri, 0, + SAFI_EVPN, json_array); else if (option == SHOW_DISPLAY_OVERLAY) - route_vty_out_overlay(vty, - &rm->p, - ri, 0, - json_array); + route_vty_out_overlay( + vty, &rm->p, ri, 0, + json_array); else route_vty_out(vty, &rm->p, ri, 0, SAFI_EVPN, @@ -553,10 +527,10 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, } } if (output_count == 0) - vty_out (vty, "No prefixes displayed, %ld exist\n", - total_count); + vty_out(vty, "No prefixes displayed, %ld exist\n", total_count); else - vty_out (vty, "\nDisplayed %ld out of %ld total prefixes\n", output_count, total_count); + vty_out(vty, "\nDisplayed %ld out of %ld total prefixes\n", + output_count, total_count); return CMD_SUCCESS; } @@ -584,11 +558,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd, int ret; struct prefix_rd prd; - argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find(argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_out (vty, "%% Malformed Route Distinguisher\n"); + vty_out(vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 0, @@ -625,11 +599,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_tags, int ret; struct prefix_rd prd; - argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find(argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_out (vty, "%% Malformed Route Distinguisher\n"); + vty_out(vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 1, @@ -655,7 +629,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, int ret; u_char uj = use_json(argc, argv); - argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + argv_find(argv, argc, "A.B.C.D", &idx_ipv4); ret = str2sockunion(argv[idx_ipv4]->arg, &su); if (ret < 0) { @@ -664,11 +638,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s\n", + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s\n", + vty_out(vty, "Malformed address: %s\n", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -678,14 +652,14 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, if (uj) { json_object *json_no = NULL; json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", - "No such neighbor or address family"); - vty_out (vty, "%s\n", + json_object_string_add( + json_no, "warning", + "No such neighbor or address family"); + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, - "%% No such neighbor or address family\n"); + vty_out(vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -715,8 +689,8 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, struct prefix_rd prd; u_char uj = use_json(argc, argv); - argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); - argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + argv_find(argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find(argv, argc, "A.B.C.D", &idx_ipv4); ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { @@ -725,11 +699,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out (vty, "%s\n", + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty,"%% Malformed Route Distinguisher\n"); + vty_out(vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -740,11 +714,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s\n", + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s\n", + vty_out(vty, "Malformed address: %s\n", argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -754,14 +728,14 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, if (uj) { json_object *json_no = NULL; json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", - "No such neighbor or address family"); - vty_out (vty, "%s\n", + json_object_string_add( + json_no, "warning", + "No such neighbor or address family"); + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, - "%% No such neighbor or address family\n"); + vty_out(vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -788,7 +762,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, union sockunion su; u_char uj = use_json(argc, argv); - argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + argv_find(argv, argc, "A.B.C.D", &idx_ipv4); ret = str2sockunion(argv[idx_ipv4]->arg, &su); if (ret < 0) { @@ -797,11 +771,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s\n", + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s\n", + vty_out(vty, "Malformed address: %s\n", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -810,14 +784,14 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, if (uj) { json_object *json_no = NULL; json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", - "No such neighbor or address family"); - vty_out (vty, "%s\n", + json_object_string_add( + json_no, "warning", + "No such neighbor or address family"); + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, - "%% No such neighbor or address family\n"); + vty_out(vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -846,8 +820,8 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, union sockunion su; u_char uj = use_json(argc, argv); - argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); - argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + argv_find(argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find(argv, argc, "A.B.C.D", &idx_ipv4); ret = str2sockunion(argv[idx_ipv4]->arg, &su); if (ret < 0) { @@ -856,11 +830,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s\n", + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s\n", + vty_out(vty, "Malformed address: %s\n", argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -869,14 +843,14 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, if (uj) { json_object *json_no = NULL; json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", - "No such neighbor or address family"); - vty_out (vty, "%s\n", + json_object_string_add( + json_no, "warning", + "No such neighbor or address family"); + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty, - "%% No such neighbor or address family\n"); + vty_out(vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -887,11 +861,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out (vty, "%s\n", + vty_out(vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out (vty,"%% Malformed Route Distinguisher\n"); + vty_out(vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -910,8 +884,8 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_overlay, "Display BGP Overlay Information for prefixes\n") { return bgp_show_ethernet_vpn(vty, NULL, bgp_show_type_normal, NULL, - SHOW_DISPLAY_OVERLAY, use_json(argc, - argv)); + SHOW_DISPLAY_OVERLAY, + use_json(argc, argv)); } DEFUN(show_ip_bgp_evpn_rd_overlay, @@ -930,16 +904,16 @@ DEFUN(show_ip_bgp_evpn_rd_overlay, int ret; struct prefix_rd prd; - argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find(argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_out (vty, "%% Malformed Route Distinguisher\n"); + vty_out(vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, - SHOW_DISPLAY_OVERLAY, use_json(argc, - argv)); + SHOW_DISPLAY_OVERLAY, + use_json(argc, argv)); } /* For testing purpose, static route of MPLS-VPN. */ @@ -973,14 +947,13 @@ DEFUN(evpnrt5_network, int idx_ethtag = 5; int idx_routermac = 13; int idx_rmap = 15; - return bgp_static_set_safi(AFI_L2VPN, SAFI_EVPN, vty, - argv[idx_ipv4_prefixlen]->arg, - argv[idx_ext_community]->arg, - argv[idx_word]->arg, - argv[idx_rmap] ? argv[idx_gwip]->arg : NULL, - BGP_EVPN_IP_PREFIX_ROUTE, argv[idx_esi]->arg, - argv[idx_gwip]->arg, argv[idx_ethtag]->arg, - argv[idx_routermac]->arg); + return bgp_static_set_safi( + AFI_L2VPN, SAFI_EVPN, vty, argv[idx_ipv4_prefixlen]->arg, + argv[idx_ext_community]->arg, argv[idx_word]->arg, + argv[idx_rmap] ? argv[idx_gwip]->arg : NULL, + BGP_EVPN_IP_PREFIX_ROUTE, argv[idx_esi]->arg, + argv[idx_gwip]->arg, argv[idx_ethtag]->arg, + argv[idx_routermac]->arg); } /* For testing purpose, static route of MPLS-VPN. */ @@ -1007,147 +980,135 @@ DEFUN(no_evpnrt5_network, int idx_ethtag = 6; int idx_esi = 10; int idx_gwip = 12; - return bgp_static_unset_safi(AFI_L2VPN, SAFI_EVPN, vty, - argv[idx_ipv4_prefixlen]->arg, - argv[idx_ext_community]->arg, - argv[idx_label]->arg, BGP_EVPN_IP_PREFIX_ROUTE, - argv[idx_esi]->arg, argv[idx_gwip]->arg, - argv[idx_ethtag]->arg); + return bgp_static_unset_safi( + AFI_L2VPN, SAFI_EVPN, vty, argv[idx_ipv4_prefixlen]->arg, + argv[idx_ext_community]->arg, argv[idx_label]->arg, + BGP_EVPN_IP_PREFIX_ROUTE, argv[idx_esi]->arg, + argv[idx_gwip]->arg, argv[idx_ethtag]->arg); } #if defined(HAVE_CUMULUS) -static void -evpn_rt_delete_auto (struct bgp *bgp, struct bgpevpn *vpn, struct list *rtl) +static void evpn_rt_delete_auto(struct bgp *bgp, struct bgpevpn *vpn, + struct list *rtl) { - struct listnode *node, *nnode, *node_to_del; - struct ecommunity *ecom, *ecom_auto; - struct ecommunity_val eval; + struct listnode *node, *nnode, *node_to_del; + struct ecommunity *ecom, *ecom_auto; + struct ecommunity_val eval; - encode_route_target_as ((bgp->as & 0xFFFF), vpn->vni, &eval); + encode_route_target_as((bgp->as & 0xFFFF), vpn->vni, &eval); - ecom_auto = ecommunity_new (); - ecommunity_add_val (ecom_auto, &eval); - node_to_del = NULL; + ecom_auto = ecommunity_new(); + ecommunity_add_val(ecom_auto, &eval); + node_to_del = NULL; - for (ALL_LIST_ELEMENTS (rtl, node, nnode, ecom)) - { - if (ecommunity_match (ecom, ecom_auto)) - { - ecommunity_free (&ecom); - node_to_del = node; - } - } + for (ALL_LIST_ELEMENTS(rtl, node, nnode, ecom)) { + if (ecommunity_match(ecom, ecom_auto)) { + ecommunity_free(&ecom); + node_to_del = node; + } + } - if (node_to_del) - list_delete_node(rtl, node_to_del); + if (node_to_del) + list_delete_node(rtl, node_to_del); - ecommunity_free(&ecom_auto); + ecommunity_free(&ecom_auto); } -static void -evpn_import_rt_delete_auto (struct bgp *bgp, struct bgpevpn *vpn) +static void evpn_import_rt_delete_auto(struct bgp *bgp, struct bgpevpn *vpn) { - evpn_rt_delete_auto (bgp, vpn, vpn->import_rtl); + evpn_rt_delete_auto(bgp, vpn, vpn->import_rtl); } -static void -evpn_export_rt_delete_auto (struct bgp *bgp, struct bgpevpn *vpn) +static void evpn_export_rt_delete_auto(struct bgp *bgp, struct bgpevpn *vpn) { - evpn_rt_delete_auto (bgp, vpn, vpn->export_rtl); + evpn_rt_delete_auto(bgp, vpn, vpn->export_rtl); } /* * Configure the Import RTs for a VNI (vty handler). Caller expected to * check that this is a change. */ -static void -evpn_configure_import_rt (struct bgp *bgp, struct bgpevpn *vpn, - struct ecommunity *ecomadd) +static void evpn_configure_import_rt(struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomadd) { - /* If the VNI is "live", we need to uninstall routes using the current - * import RT(s) first before we update the import RT, and subsequently - * install routes. - */ - if (is_vni_live (vpn)) - bgp_evpn_uninstall_routes (bgp, vpn); + /* If the VNI is "live", we need to uninstall routes using the current + * import RT(s) first before we update the import RT, and subsequently + * install routes. + */ + if (is_vni_live(vpn)) + bgp_evpn_uninstall_routes(bgp, vpn); - /* Cleanup the RT to VNI mapping and get rid of existing import RT. */ - bgp_evpn_unmap_vni_from_its_rts (bgp, vpn); + /* Cleanup the RT to VNI mapping and get rid of existing import RT. */ + bgp_evpn_unmap_vni_from_its_rts(bgp, vpn); - /* If the auto route-target is in use we must remove it */ - evpn_import_rt_delete_auto(bgp, vpn); + /* If the auto route-target is in use we must remove it */ + evpn_import_rt_delete_auto(bgp, vpn); - /* Add new RT and rebuild the RT to VNI mapping */ - listnode_add_sort (vpn->import_rtl, ecomadd); + /* Add new RT and rebuild the RT to VNI mapping */ + listnode_add_sort(vpn->import_rtl, ecomadd); - SET_FLAG (vpn->flags, VNI_FLAG_IMPRT_CFGD); - bgp_evpn_map_vni_to_its_rts (bgp, vpn); + SET_FLAG(vpn->flags, VNI_FLAG_IMPRT_CFGD); + bgp_evpn_map_vni_to_its_rts(bgp, vpn); - /* Install routes that match new import RT */ - if (is_vni_live (vpn)) - bgp_evpn_install_routes (bgp, vpn); + /* Install routes that match new import RT */ + if (is_vni_live(vpn)) + bgp_evpn_install_routes(bgp, vpn); } /* * Unconfigure Import RT(s) for a VNI (vty handler). */ -static void -evpn_unconfigure_import_rt (struct bgp *bgp, struct bgpevpn *vpn, - struct ecommunity *ecomdel) -{ - struct listnode *node, *nnode, *node_to_del; - struct ecommunity *ecom; - - /* Along the lines of "configure" except we have to reset to the - * automatic value. - */ - if (is_vni_live (vpn)) - bgp_evpn_uninstall_routes (bgp, vpn); - - /* Cleanup the RT to VNI mapping and get rid of existing import RT. */ - bgp_evpn_unmap_vni_from_its_rts (bgp, vpn); - - /* Delete all import RTs */ - if (ecomdel == NULL) - { - for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) - ecommunity_free (&ecom); - - list_delete_all_node(vpn->import_rtl); - } - - /* Delete a specific import RT */ - else - { - node_to_del = NULL; - - for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) - { - if (ecommunity_match (ecom, ecomdel)) - { - ecommunity_free (&ecom); - node_to_del = node; - break; - } - } - - if (node_to_del) - list_delete_node(vpn->import_rtl, node_to_del); - } - - /* Reset to auto RT - this also rebuilds the RT to VNI mapping */ - if (list_isempty(vpn->import_rtl)) - { - UNSET_FLAG (vpn->flags, VNI_FLAG_IMPRT_CFGD); - bgp_evpn_derive_auto_rt_import (bgp, vpn); - } - /* Rebuild the RT to VNI mapping */ - else - bgp_evpn_map_vni_to_its_rts (bgp, vpn); - - /* Install routes that match new import RT */ - if (is_vni_live (vpn)) - bgp_evpn_install_routes (bgp, vpn); +static void evpn_unconfigure_import_rt(struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomdel) +{ + struct listnode *node, *nnode, *node_to_del; + struct ecommunity *ecom; + + /* Along the lines of "configure" except we have to reset to the + * automatic value. + */ + if (is_vni_live(vpn)) + bgp_evpn_uninstall_routes(bgp, vpn); + + /* Cleanup the RT to VNI mapping and get rid of existing import RT. */ + bgp_evpn_unmap_vni_from_its_rts(bgp, vpn); + + /* Delete all import RTs */ + if (ecomdel == NULL) { + for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) + ecommunity_free(&ecom); + + list_delete_all_node(vpn->import_rtl); + } + + /* Delete a specific import RT */ + else { + node_to_del = NULL; + + for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) { + if (ecommunity_match(ecom, ecomdel)) { + ecommunity_free(&ecom); + node_to_del = node; + break; + } + } + + if (node_to_del) + list_delete_node(vpn->import_rtl, node_to_del); + } + + /* Reset to auto RT - this also rebuilds the RT to VNI mapping */ + if (list_isempty(vpn->import_rtl)) { + UNSET_FLAG(vpn->flags, VNI_FLAG_IMPRT_CFGD); + bgp_evpn_derive_auto_rt_import(bgp, vpn); + } + /* Rebuild the RT to VNI mapping */ + else + bgp_evpn_map_vni_to_its_rts(bgp, vpn); + + /* Install routes that match new import RT */ + if (is_vni_live(vpn)) + bgp_evpn_install_routes(bgp, vpn); } /* @@ -1156,137 +1117,126 @@ evpn_unconfigure_import_rt (struct bgp *bgp, struct bgpevpn *vpn, * allowed for a VNI and any change to configuration is implemented as * a "replace" (similar to other configuration). */ -static void -evpn_configure_export_rt (struct bgp *bgp, struct bgpevpn *vpn, - struct ecommunity *ecomadd) +static void evpn_configure_export_rt(struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomadd) { - /* If the auto route-target is in use we must remove it */ - evpn_export_rt_delete_auto (bgp, vpn); + /* If the auto route-target is in use we must remove it */ + evpn_export_rt_delete_auto(bgp, vpn); - listnode_add_sort (vpn->export_rtl, ecomadd); - SET_FLAG (vpn->flags, VNI_FLAG_EXPRT_CFGD); + listnode_add_sort(vpn->export_rtl, ecomadd); + SET_FLAG(vpn->flags, VNI_FLAG_EXPRT_CFGD); - if (is_vni_live (vpn)) - bgp_evpn_handle_export_rt_change (bgp, vpn); + if (is_vni_live(vpn)) + bgp_evpn_handle_export_rt_change(bgp, vpn); } /* * Unconfigure the Export RT for a VNI (vty handler) */ -static void -evpn_unconfigure_export_rt (struct bgp *bgp, struct bgpevpn *vpn, - struct ecommunity *ecomdel) -{ - struct listnode *node, *nnode, *node_to_del; - struct ecommunity *ecom; - - /* Delete all export RTs */ - if (ecomdel == NULL) - { - /* Reset to default and process all routes. */ - for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) - ecommunity_free (&ecom); - - list_delete_all_node(vpn->export_rtl); - } - - /* Delete a specific export RT */ - else - { - node_to_del = NULL; - - for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) - { - if (ecommunity_match (ecom, ecomdel)) - { - ecommunity_free (&ecom); - node_to_del = node; - break; - } - } - - if (node_to_del) - list_delete_node(vpn->export_rtl, node_to_del); - } - - if (list_isempty(vpn->export_rtl)) - { - UNSET_FLAG (vpn->flags, VNI_FLAG_EXPRT_CFGD); - bgp_evpn_derive_auto_rt_export (bgp, vpn); - } - - if (is_vni_live (vpn)) - bgp_evpn_handle_export_rt_change (bgp, vpn); +static void evpn_unconfigure_export_rt(struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomdel) +{ + struct listnode *node, *nnode, *node_to_del; + struct ecommunity *ecom; + + /* Delete all export RTs */ + if (ecomdel == NULL) { + /* Reset to default and process all routes. */ + for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom)) + ecommunity_free(&ecom); + + list_delete_all_node(vpn->export_rtl); + } + + /* Delete a specific export RT */ + else { + node_to_del = NULL; + + for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom)) { + if (ecommunity_match(ecom, ecomdel)) { + ecommunity_free(&ecom); + node_to_del = node; + break; + } + } + + if (node_to_del) + list_delete_node(vpn->export_rtl, node_to_del); + } + + if (list_isempty(vpn->export_rtl)) { + UNSET_FLAG(vpn->flags, VNI_FLAG_EXPRT_CFGD); + bgp_evpn_derive_auto_rt_export(bgp, vpn); + } + + if (is_vni_live(vpn)) + bgp_evpn_handle_export_rt_change(bgp, vpn); } /* * Configure RD for a VNI (vty handler) */ -static void -evpn_configure_rd (struct bgp *bgp, struct bgpevpn *vpn, - struct prefix_rd *rd) +static void evpn_configure_rd(struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_rd *rd) { - /* If the VNI is "live", we need to delete and withdraw this VNI's - * local routes with the prior RD first. Then, after updating RD, - * need to re-advertise. - */ - if (is_vni_live (vpn)) - bgp_evpn_handle_rd_change (bgp, vpn, 1); + /* If the VNI is "live", we need to delete and withdraw this VNI's + * local routes with the prior RD first. Then, after updating RD, + * need to re-advertise. + */ + if (is_vni_live(vpn)) + bgp_evpn_handle_rd_change(bgp, vpn, 1); - /* update RD */ - memcpy(&vpn->prd, rd, sizeof (struct prefix_rd)); - SET_FLAG (vpn->flags, VNI_FLAG_RD_CFGD); + /* update RD */ + memcpy(&vpn->prd, rd, sizeof(struct prefix_rd)); + SET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD); - if (is_vni_live (vpn)) - bgp_evpn_handle_rd_change (bgp, vpn, 0); + if (is_vni_live(vpn)) + bgp_evpn_handle_rd_change(bgp, vpn, 0); } /* * Unconfigure RD for a VNI (vty handler) */ -static void -evpn_unconfigure_rd (struct bgp *bgp, struct bgpevpn *vpn) +static void evpn_unconfigure_rd(struct bgp *bgp, struct bgpevpn *vpn) { - /* If the VNI is "live", we need to delete and withdraw this VNI's - * local routes with the prior RD first. Then, after resetting RD - * to automatic value, need to re-advertise. - */ - if (is_vni_live (vpn)) - bgp_evpn_handle_rd_change (bgp, vpn, 1); + /* If the VNI is "live", we need to delete and withdraw this VNI's + * local routes with the prior RD first. Then, after resetting RD + * to automatic value, need to re-advertise. + */ + if (is_vni_live(vpn)) + bgp_evpn_handle_rd_change(bgp, vpn, 1); - /* reset RD to default */ - bgp_evpn_derive_auto_rd (bgp, vpn); + /* reset RD to default */ + bgp_evpn_derive_auto_rd(bgp, vpn); - if (is_vni_live (vpn)) - bgp_evpn_handle_rd_change (bgp, vpn, 0); + if (is_vni_live(vpn)) + bgp_evpn_handle_rd_change(bgp, vpn, 0); } /* * Create VNI, if not already present (VTY handler). Mark as configured. */ -static struct bgpevpn * -evpn_create_update_vni (struct bgp *bgp, vni_t vni) +static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni) { - struct bgpevpn *vpn; + struct bgpevpn *vpn; - if (!bgp->vnihash) - return NULL; + if (!bgp->vnihash) + return NULL; - vpn = bgp_evpn_lookup_vni (bgp, vni); - if (!vpn) - { - vpn = bgp_evpn_new (bgp, vni, bgp->router_id); - if (!vpn) - { - zlog_err ("%u: Failed to allocate VNI entry for VNI %u - at Config", - bgp->vrf_id, vni); - return NULL; - } - } + vpn = bgp_evpn_lookup_vni(bgp, vni); + if (!vpn) { + vpn = bgp_evpn_new(bgp, vni, bgp->router_id); + if (!vpn) { + zlog_err( + "%u: Failed to allocate VNI entry for VNI %u - at Config", + bgp->vrf_id, vni); + return NULL; + } + } - /* Mark as configured. */ - SET_FLAG (vpn->flags, VNI_FLAG_CFGD); - return vpn; + /* Mark as configured. */ + SET_FLAG(vpn->flags, VNI_FLAG_CFGD); + return vpn; } /* @@ -1296,166 +1246,154 @@ evpn_create_update_vni (struct bgp *bgp, vni_t vni) * appropriate action) and the VNI marked as unconfigured; the * VNI will continue to exist, purely as a "learnt" entity. */ -static int -evpn_delete_vni (struct bgp *bgp, struct bgpevpn *vpn) +static int evpn_delete_vni(struct bgp *bgp, struct bgpevpn *vpn) { - assert (bgp->vnihash); + assert(bgp->vnihash); - if (!is_vni_live (vpn)) - { - bgp_evpn_free (bgp, vpn); - return 0; - } + if (!is_vni_live(vpn)) { + bgp_evpn_free(bgp, vpn); + return 0; + } - /* We need to take the unconfigure action for each parameter of this VNI - * that is configured. Some optimization is possible, but not worth the - * additional code for an operation that should be pretty rare. - */ - UNSET_FLAG (vpn->flags, VNI_FLAG_CFGD); + /* We need to take the unconfigure action for each parameter of this VNI + * that is configured. Some optimization is possible, but not worth the + * additional code for an operation that should be pretty rare. + */ + UNSET_FLAG(vpn->flags, VNI_FLAG_CFGD); - /* First, deal with the export side - RD and export RT changes. */ - if (is_rd_configured (vpn)) - evpn_unconfigure_rd (bgp, vpn); - if (is_export_rt_configured (vpn)) - evpn_unconfigure_export_rt (bgp, vpn, NULL); + /* First, deal with the export side - RD and export RT changes. */ + if (is_rd_configured(vpn)) + evpn_unconfigure_rd(bgp, vpn); + if (is_export_rt_configured(vpn)) + evpn_unconfigure_export_rt(bgp, vpn, NULL); - /* Next, deal with the import side. */ - if (is_import_rt_configured (vpn)) - evpn_unconfigure_import_rt (bgp, vpn, NULL); + /* Next, deal with the import side. */ + if (is_import_rt_configured(vpn)) + evpn_unconfigure_import_rt(bgp, vpn, NULL); - return 0; + return 0; } /* * Display import RT mapping to VNIs (vty handler) */ -static void -evpn_show_import_rts (struct vty *vty, struct bgp *bgp) +static void evpn_show_import_rts(struct vty *vty, struct bgp *bgp) { - hash_iterate (bgp->import_rt_hash, - (void (*) (struct hash_backet *, void *)) - show_import_rt_entry, vty); + hash_iterate( + bgp->import_rt_hash, + (void (*)(struct hash_backet *, void *))show_import_rt_entry, + vty); } /* * Display EVPN routes for all VNIs - vty handler. */ -static void -evpn_show_routes_vni_all (struct vty *vty, struct bgp *bgp, struct in_addr vtep_ip) +static void evpn_show_routes_vni_all(struct vty *vty, struct bgp *bgp, + struct in_addr vtep_ip) { - u_int32_t num_vnis; - struct vni_walk_ctx wctx; + u_int32_t num_vnis; + struct vni_walk_ctx wctx; - num_vnis = hashcount(bgp->vnihash); - if (!num_vnis) - return; - memset (&wctx, 0, sizeof (struct vni_walk_ctx)); - wctx.bgp = bgp; - wctx.vty = vty; - wctx.vtep_ip = vtep_ip; - hash_iterate (bgp->vnihash, - (void (*) (struct hash_backet *, void *)) - show_vni_routes_hash, &wctx); + num_vnis = hashcount(bgp->vnihash); + if (!num_vnis) + return; + memset(&wctx, 0, sizeof(struct vni_walk_ctx)); + wctx.bgp = bgp; + wctx.vty = vty; + wctx.vtep_ip = vtep_ip; + hash_iterate(bgp->vnihash, (void (*)(struct hash_backet *, + void *))show_vni_routes_hash, + &wctx); } /* * Display EVPN routes for a VNI -- for specific type-3 route (vty handler). */ -static void -evpn_show_route_vni_multicast (struct vty *vty, struct bgp *bgp, - vni_t vni, struct in_addr orig_ip) -{ - struct bgpevpn *vpn; - struct prefix_evpn p; - struct bgp_node *rn; - struct bgp_info *ri; - u_int32_t path_cnt = 0; - afi_t afi; - safi_t safi; - - afi = AFI_L2VPN; - safi = SAFI_EVPN; - - /* Locate VNI. */ - vpn = bgp_evpn_lookup_vni (bgp, vni); - if (!vpn) - { - vty_out (vty, "VNI not found\n"); - return; - } - - /* See if route exists. */ - build_evpn_type3_prefix (&p, orig_ip); - rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p); - if (!rn || !rn->info) - { - vty_out (vty, "%% Network not in table\n"); - return; - } - - /* Prefix and num paths displayed once per prefix. */ - route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, NULL); - - /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) - { - route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); - path_cnt++; - } - - vty_out (vty, "\nDisplayed %u paths for requested prefix\n", - path_cnt); +static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp, + vni_t vni, struct in_addr orig_ip) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + struct bgp_node *rn; + struct bgp_info *ri; + u_int32_t path_cnt = 0; + afi_t afi; + safi_t safi; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* Locate VNI. */ + vpn = bgp_evpn_lookup_vni(bgp, vni); + if (!vpn) { + vty_out(vty, "VNI not found\n"); + return; + } + + /* See if route exists. */ + build_evpn_type3_prefix(&p, orig_ip); + rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p); + if (!rn || !rn->info) { + vty_out(vty, "%% Network not in table\n"); + return; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, NULL); + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) { + route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + + vty_out(vty, "\nDisplayed %u paths for requested prefix\n", path_cnt); } /* * Display EVPN routes for a VNI -- for specific MAC and/or IP (vty handler). * By definition, only matching type-2 route will be displayed. */ -static void -evpn_show_route_vni_macip (struct vty *vty, struct bgp *bgp, - vni_t vni, struct ethaddr *mac, - struct ipaddr *ip) -{ - struct bgpevpn *vpn; - struct prefix_evpn p; - struct bgp_node *rn; - struct bgp_info *ri; - u_int32_t path_cnt = 0; - afi_t afi; - safi_t safi; - - afi = AFI_L2VPN; - safi = SAFI_EVPN; - - /* Locate VNI. */ - vpn = bgp_evpn_lookup_vni (bgp, vni); - if (!vpn) - { - vty_out (vty, "VNI not found\n"); - return; - } - - /* See if route exists. Look for both non-sticky and sticky. */ - build_evpn_type2_prefix (&p, mac, ip); - rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p); - if (!rn || !rn->info) - { - vty_out (vty, "%% Network not in table\n"); - return; - } - - /* Prefix and num paths displayed once per prefix. */ - route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, NULL); - - /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) - { - route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); - path_cnt++; - } - - vty_out (vty, "\nDisplayed %u paths for requested prefix\n", - path_cnt); +static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp, + vni_t vni, struct ethaddr *mac, + struct ipaddr *ip) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + struct bgp_node *rn; + struct bgp_info *ri; + u_int32_t path_cnt = 0; + afi_t afi; + safi_t safi; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* Locate VNI. */ + vpn = bgp_evpn_lookup_vni(bgp, vni); + if (!vpn) { + vty_out(vty, "VNI not found\n"); + return; + } + + /* See if route exists. Look for both non-sticky and sticky. */ + build_evpn_type2_prefix(&p, mac, ip); + rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p); + if (!rn || !rn->info) { + vty_out(vty, "%% Network not in table\n"); + return; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, NULL); + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) { + route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + + vty_out(vty, "\nDisplayed %u paths for requested prefix\n", path_cnt); } /* @@ -1463,22 +1401,20 @@ evpn_show_route_vni_macip (struct vty *vty, struct bgp *bgp, * If 'type' is non-zero, only routes matching that type are shown. * If the vtep_ip is non zero, only routes behind that vtep are shown */ -static void -evpn_show_routes_vni (struct vty *vty, struct bgp *bgp, - vni_t vni, int type, struct in_addr vtep_ip) +static void evpn_show_routes_vni(struct vty *vty, struct bgp *bgp, vni_t vni, + int type, struct in_addr vtep_ip) { - struct bgpevpn *vpn; + struct bgpevpn *vpn; - /* Locate VNI. */ - vpn = bgp_evpn_lookup_vni (bgp, vni); - if (!vpn) - { - vty_out (vty, "VNI not found\n"); - return; - } + /* Locate VNI. */ + vpn = bgp_evpn_lookup_vni(bgp, vni); + if (!vpn) { + vty_out(vty, "VNI not found\n"); + return; + } - /* Walk this VNI's route table and display appropriate routes. */ - show_vni_routes (bgp, vpn, type, vty, vtep_ip); + /* Walk this VNI's route table and display appropriate routes. */ + show_vni_routes(bgp, vpn, type, vty, vtep_ip); } /* @@ -1486,321 +1422,305 @@ evpn_show_routes_vni (struct vty *vty, struct bgp *bgp, * IP (vty handler). By definition, only matching type-2 route will be * displayed. */ -static void -evpn_show_route_rd_macip (struct vty *vty, struct bgp *bgp, - struct prefix_rd *prd, struct ethaddr *mac, - struct ipaddr *ip) -{ - struct prefix_evpn p; - struct bgp_node *rn; - struct bgp_info *ri; - afi_t afi; - safi_t safi; - u_int32_t path_cnt = 0; - - afi = AFI_L2VPN; - safi = SAFI_EVPN; - - /* See if route exists. Look for both non-sticky and sticky. */ - build_evpn_type2_prefix (&p, mac, ip); - rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi, - (struct prefix *)&p, prd); - if (!rn || !rn->info) - { - vty_out (vty, "%% Network not in table\n"); - return; - } - - /* Prefix and num paths displayed once per prefix. */ - route_vty_out_detail_header (vty, bgp, rn, prd, afi, safi, NULL); - - /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) - { - route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); - path_cnt++; - } - - vty_out (vty, "\nDisplayed %u paths for requested prefix\n", - path_cnt); +static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, + struct prefix_rd *prd, struct ethaddr *mac, + struct ipaddr *ip) +{ + struct prefix_evpn p; + struct bgp_node *rn; + struct bgp_info *ri; + afi_t afi; + safi_t safi; + u_int32_t path_cnt = 0; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* See if route exists. Look for both non-sticky and sticky. */ + build_evpn_type2_prefix(&p, mac, ip); + rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, + (struct prefix *)&p, prd); + if (!rn || !rn->info) { + vty_out(vty, "%% Network not in table\n"); + return; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header(vty, bgp, rn, prd, afi, safi, NULL); + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) { + route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + + vty_out(vty, "\nDisplayed %u paths for requested prefix\n", path_cnt); } /* * Display BGP EVPN routing table -- for specific RD (vty handler) * If 'type' is non-zero, only routes matching that type are shown. */ -static void -evpn_show_route_rd (struct vty *vty, struct bgp *bgp, - struct prefix_rd *prd, int type) -{ - struct bgp_node *rd_rn; - struct bgp_table *table; - struct bgp_node *rn; - struct bgp_info *ri; - int rd_header = 1; - afi_t afi; - safi_t safi; - u_int32_t prefix_cnt, path_cnt; - - afi = AFI_L2VPN; - safi = SAFI_EVPN; - prefix_cnt = path_cnt = 0; - - rd_rn = bgp_node_lookup (bgp->rib[afi][safi], (struct prefix *) prd); - if (!rd_rn) - return; - table = (struct bgp_table *)rd_rn->info; - if (table == NULL) - return; - - /* Display all prefixes with this RD. */ - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) - { - struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; - - if (type && - evp->prefix.route_type != type) - continue; - - if (rn->info) - { - /* RD header and legend - once overall. */ - if (rd_header) - { - vty_out (vty, "EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:" - "[MAC]\n"); - vty_out (vty, "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:" - "[OrigIP]\n\n"); - rd_header = 0; - } - - /* Prefix and num paths displayed once per prefix. */ - route_vty_out_detail_header (vty, bgp, rn, prd, afi, safi, NULL); - - prefix_cnt++; - } - - /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) - { - route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); - path_cnt++; - } - } - - if (prefix_cnt == 0) - vty_out (vty, "No prefixes exist with this RD%s\n", - type ? " (of requested type)" : ""); - else - vty_out (vty, "\nDisplayed %u prefixes (%u paths) with this RD%s\n", - prefix_cnt, path_cnt, - type ? " (of requested type)" : ""); +static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, + struct prefix_rd *prd, int type) +{ + struct bgp_node *rd_rn; + struct bgp_table *table; + struct bgp_node *rn; + struct bgp_info *ri; + int rd_header = 1; + afi_t afi; + safi_t safi; + u_int32_t prefix_cnt, path_cnt; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + prefix_cnt = path_cnt = 0; + + rd_rn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd); + if (!rd_rn) + return; + table = (struct bgp_table *)rd_rn->info; + if (table == NULL) + return; + + /* Display all prefixes with this RD. */ + for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (type && evp->prefix.route_type != type) + continue; + + if (rn->info) { + /* RD header and legend - once overall. */ + if (rd_header) { + vty_out(vty, + "EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:" + "[MAC]\n"); + vty_out(vty, + "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:" + "[OrigIP]\n\n"); + rd_header = 0; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header(vty, bgp, rn, prd, afi, + safi, NULL); + + prefix_cnt++; + } + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) { + route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, + NULL); + path_cnt++; + } + } + + if (prefix_cnt == 0) + vty_out(vty, "No prefixes exist with this RD%s\n", + type ? " (of requested type)" : ""); + else + vty_out(vty, + "\nDisplayed %u prefixes (%u paths) with this RD%s\n", + prefix_cnt, path_cnt, + type ? " (of requested type)" : ""); } /* * Display BGP EVPN routing table - all routes (vty handler). * 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) -{ - struct bgp_node *rd_rn; - struct bgp_table *table; - struct bgp_node *rn; - struct bgp_info *ri; - int header = 1; - int rd_header; - afi_t afi; - safi_t safi; - u_int32_t prefix_cnt, path_cnt; - - afi = AFI_L2VPN; - safi = SAFI_EVPN; - prefix_cnt = path_cnt = 0; - - /* EVPN routing table is a 2-level table with the first level being - * the RD. - */ - for (rd_rn = bgp_table_top (bgp->rib[afi][safi]); rd_rn; - rd_rn = bgp_route_next (rd_rn)) - { - table = (struct bgp_table *)rd_rn->info; - if (table == NULL) - continue; - - rd_header = 1; - - /* Display all prefixes for an RD */ - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) - { - struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; - - if (type && - evp->prefix.route_type != type) - continue; - - if (rn->info) - { - /* Overall header/legend displayed once. */ - if (header) - { - bgp_evpn_show_route_header (vty, bgp); - header = 0; - } - - /* RD header - per RD. */ - if (rd_header) - { - bgp_evpn_show_route_rd_header (vty, rd_rn); - rd_header = 0; - } - - prefix_cnt++; - } - - /* For EVPN, the prefix is displayed for each path (to fit in - * with code that already exists). - */ - for (ri = rn->info; ri; ri = ri->next) - { - path_cnt++; - route_vty_out (vty, &rn->p, ri, 0, SAFI_EVPN, NULL); - } - } - } - - if (prefix_cnt == 0) - vty_out (vty, "No EVPN prefixes %sexist\n", - type ? "(of requested type) " : ""); - else - vty_out (vty, "\nDisplayed %u prefixes (%u paths)%s\n", - prefix_cnt, path_cnt, - type ? " (of requested type)" : ""); +static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type) +{ + struct bgp_node *rd_rn; + struct bgp_table *table; + struct bgp_node *rn; + struct bgp_info *ri; + int header = 1; + int rd_header; + afi_t afi; + safi_t safi; + u_int32_t prefix_cnt, path_cnt; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + prefix_cnt = path_cnt = 0; + + /* EVPN routing table is a 2-level table with the first level being + * the RD. + */ + for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn; + rd_rn = bgp_route_next(rd_rn)) { + table = (struct bgp_table *)rd_rn->info; + if (table == NULL) + continue; + + rd_header = 1; + + /* Display all prefixes for an RD */ + for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (type && evp->prefix.route_type != type) + continue; + + if (rn->info) { + /* Overall header/legend displayed once. */ + if (header) { + bgp_evpn_show_route_header(vty, bgp); + header = 0; + } + + /* RD header - per RD. */ + if (rd_header) { + bgp_evpn_show_route_rd_header(vty, + rd_rn); + rd_header = 0; + } + + prefix_cnt++; + } + + /* For EVPN, the prefix is displayed for each path (to + * fit in + * with code that already exists). + */ + for (ri = rn->info; ri; ri = ri->next) { + path_cnt++; + route_vty_out(vty, &rn->p, ri, 0, SAFI_EVPN, + NULL); + } + } + } + + if (prefix_cnt == 0) + vty_out(vty, "No EVPN prefixes %sexist\n", + type ? "(of requested type) " : ""); + else + vty_out(vty, "\nDisplayed %u prefixes (%u paths)%s\n", + prefix_cnt, path_cnt, + type ? " (of requested type)" : ""); } /* * Display specified VNI (vty handler) */ -static void -evpn_show_vni (struct vty *vty, struct bgp *bgp, vni_t vni) +static void evpn_show_vni(struct vty *vty, struct bgp *bgp, vni_t vni) { - struct bgpevpn *vpn; + struct bgpevpn *vpn; - vpn = bgp_evpn_lookup_vni (bgp, vni); - if (!vpn) - { - vty_out (vty, "VNI not found\n"); - return; - } + vpn = bgp_evpn_lookup_vni(bgp, vni); + if (!vpn) { + vty_out(vty, "VNI not found\n"); + return; + } - display_vni (vty, vpn); + display_vni(vty, vpn); } /* * Display a VNI (upon user query). */ -static void -evpn_show_all_vnis (struct vty *vty, struct bgp *bgp) +static void evpn_show_all_vnis(struct vty *vty, struct bgp *bgp) { - u_int32_t num_vnis; + u_int32_t num_vnis; - num_vnis = hashcount(bgp->vnihash); - if (!num_vnis) - return; - vty_out(vty, "Number of VNIs: %u\n", num_vnis); - vty_out(vty, "Flags: * - Kernel \n"); - vty_out(vty, " %-10s %-15s %-21s %-25s %-25s\n", - "VNI", "Orig IP", "RD", "Import RT", "Export RT"); - hash_iterate (bgp->vnihash, - (void (*) (struct hash_backet *, void *)) - show_vni_entry, vty); + num_vnis = hashcount(bgp->vnihash); + if (!num_vnis) + return; + vty_out(vty, "Number of VNIs: %u\n", num_vnis); + vty_out(vty, "Flags: * - Kernel \n"); + vty_out(vty, " %-10s %-15s %-21s %-25s %-25s\n", "VNI", "Orig IP", + "RD", "Import RT", "Export RT"); + hash_iterate(bgp->vnihash, + (void (*)(struct hash_backet *, void *))show_vni_entry, + vty); } /* * EVPN (VNI advertisement) enabled. Register with zebra. */ -static void -evpn_set_advertise_all_vni (struct bgp *bgp) +static void evpn_set_advertise_all_vni(struct bgp *bgp) { - bgp->advertise_all_vni = 1; - bgp_zebra_advertise_all_vni (bgp, bgp->advertise_all_vni); + bgp->advertise_all_vni = 1; + bgp_zebra_advertise_all_vni(bgp, bgp->advertise_all_vni); } /* * EVPN (VNI advertisement) disabled. De-register with zebra. Cleanup VNI * cache, EVPN routes (delete and withdraw from peers). */ -static void -evpn_unset_advertise_all_vni (struct bgp *bgp) +static void evpn_unset_advertise_all_vni(struct bgp *bgp) { - bgp->advertise_all_vni = 0; - bgp_zebra_advertise_all_vni (bgp, bgp->advertise_all_vni); - bgp_evpn_cleanup_on_disable (bgp); + bgp->advertise_all_vni = 0; + bgp_zebra_advertise_all_vni(bgp, bgp->advertise_all_vni); + bgp_evpn_cleanup_on_disable(bgp); } #endif /* HAVE_CUMULUS */ -static void -write_vni_config (struct vty *vty, struct bgpevpn *vpn, int *write) -{ - char buf1[INET6_ADDRSTRLEN]; - afi_t afi = AFI_L2VPN; - safi_t safi = SAFI_EVPN; - char *ecom_str; - struct listnode *node, *nnode; - struct ecommunity *ecom; - - if (is_vni_configured (vpn)) - { - bgp_config_write_family_header (vty, afi, safi, write); - vty_out (vty, " vni %d\n", vpn->vni); - if (is_rd_configured (vpn)) - vty_out (vty, " rd %s\n", - prefix_rd2str (&vpn->prd, buf1, RD_ADDRSTRLEN)); - - if (is_import_rt_configured (vpn)) - { - for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) - { - ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - vty_out (vty, " route-target import %s\n", ecom_str); - XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); - } - } - - if (is_export_rt_configured (vpn)) - { - for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) - { - ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - vty_out (vty, " route-target export %s\n", ecom_str); - XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); - } - } - - vty_out (vty, " exit-vni\n"); - } -} - -static void -write_vni_config_for_entry (struct hash_backet *backet, - struct evpn_config_write *cfg) -{ - struct bgpevpn *vpn = (struct bgpevpn *) backet->data; - write_vni_config (cfg->vty, vpn, &cfg->write); -} - -#if defined (HAVE_CUMULUS) +static void write_vni_config(struct vty *vty, struct bgpevpn *vpn, int *write) +{ + char buf1[INET6_ADDRSTRLEN]; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + char *ecom_str; + struct listnode *node, *nnode; + struct ecommunity *ecom; + + if (is_vni_configured(vpn)) { + bgp_config_write_family_header(vty, afi, safi, write); + vty_out(vty, " vni %d\n", vpn->vni); + if (is_rd_configured(vpn)) + vty_out(vty, " rd %s\n", + prefix_rd2str(&vpn->prd, buf1, RD_ADDRSTRLEN)); + + if (is_import_rt_configured(vpn)) { + for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, + ecom)) { + ecom_str = ecommunity_ecom2str( + ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out(vty, " route-target import %s\n", + ecom_str); + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + } + } + + if (is_export_rt_configured(vpn)) { + for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, + ecom)) { + ecom_str = ecommunity_ecom2str( + ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out(vty, " route-target export %s\n", + ecom_str); + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + } + } + + vty_out(vty, " exit-vni\n"); + } +} + +static void write_vni_config_for_entry(struct hash_backet *backet, + struct evpn_config_write *cfg) +{ + struct bgpevpn *vpn = (struct bgpevpn *)backet->data; + write_vni_config(cfg->vty, vpn, &cfg->write); +} + +#if defined(HAVE_CUMULUS) DEFUN (bgp_evpn_advertise_all_vni, bgp_evpn_advertise_all_vni_cmd, "advertise-all-vni", "Advertise All local VNIs\n") { - struct bgp *bgp = VTY_GET_CONTEXT(bgp); + struct bgp *bgp = VTY_GET_CONTEXT(bgp); - if (!bgp) - return CMD_WARNING; - evpn_set_advertise_all_vni (bgp); - return CMD_SUCCESS; + if (!bgp) + return CMD_WARNING; + evpn_set_advertise_all_vni(bgp); + return CMD_SUCCESS; } DEFUN (no_bgp_evpn_advertise_all_vni, @@ -1809,12 +1729,12 @@ DEFUN (no_bgp_evpn_advertise_all_vni, NO_STR "Advertise All local VNIs\n") { - struct bgp *bgp = VTY_GET_CONTEXT(bgp); + struct bgp *bgp = VTY_GET_CONTEXT(bgp); - if (!bgp) - return CMD_WARNING; - evpn_unset_advertise_all_vni (bgp); - return CMD_SUCCESS; + if (!bgp) + return CMD_WARNING; + evpn_unset_advertise_all_vni(bgp); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_vni, @@ -1825,17 +1745,17 @@ DEFUN (show_bgp_evpn_vni, EVPN_HELP_STR "Show VNI\n") { - struct bgp *bgp; + struct bgp *bgp; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - vty_out (vty, "Advertise All VNI flag: %s\n", - bgp->advertise_all_vni? "Enabled" : "Disabled"); + vty_out(vty, "Advertise All VNI flag: %s\n", + bgp->advertise_all_vni ? "Enabled" : "Disabled"); - evpn_show_all_vnis (vty, bgp); - return CMD_SUCCESS; + evpn_show_all_vnis(vty, bgp); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_vni_num, @@ -1847,17 +1767,17 @@ DEFUN (show_bgp_evpn_vni_num, "Show VNI\n" "VNI number\n") { - vni_t vni; - struct bgp *bgp; + vni_t vni; + struct bgp *bgp; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - vni = strtoul(argv[4]->arg, NULL, 10); + vni = strtoul(argv[4]->arg, NULL, 10); - evpn_show_vni (vty, bgp, vni); - return CMD_SUCCESS; + evpn_show_vni(vty, bgp, vni); + return CMD_SUCCESS; } /* `show bgp evpn summary' commands. */ @@ -1870,8 +1790,8 @@ DEFUN (show_bgp_evpn_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_L2VPN, SAFI_EVPN, uj); + u_char uj = use_json(argc, argv); + return bgp_show_summary_vty(vty, NULL, AFI_L2VPN, SAFI_EVPN, uj); } /* Show bgp evpn route */ @@ -1886,25 +1806,24 @@ DEFUN (show_bgp_evpn_route, "MAC-IP (Type-2) route\n" "Multicast (Type-3) route\n") { - struct bgp *bgp; - int type = 0; + struct bgp *bgp; + int type = 0; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - if (argc == 6) - { - if (strncmp (argv[5]->arg, "ma", 2) == 0) - type = BGP_EVPN_MAC_IP_ROUTE; - else if (strncmp (argv[5]->arg, "mu", 2) == 0) - type = BGP_EVPN_IMET_ROUTE; - else - return CMD_WARNING; - } + if (argc == 6) { + if (strncmp(argv[5]->arg, "ma", 2) == 0) + type = BGP_EVPN_MAC_IP_ROUTE; + else if (strncmp(argv[5]->arg, "mu", 2) == 0) + type = BGP_EVPN_IMET_ROUTE; + else + return CMD_WARNING; + } - evpn_show_all_routes (vty, bgp, type); - return CMD_SUCCESS; + evpn_show_all_routes(vty, bgp, type); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_route_rd, @@ -1920,34 +1839,32 @@ DEFUN (show_bgp_evpn_route_rd, "MAC-IP (Type-2) route\n" "Multicast (Type-3) route\n") { - struct bgp *bgp; - int ret; - struct prefix_rd prd; - int type = 0; + struct bgp *bgp; + int ret; + struct prefix_rd prd; + int type = 0; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - ret = str2prefix_rd (argv[5]->arg, &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher\n"); - return CMD_WARNING; - } + ret = str2prefix_rd(argv[5]->arg, &prd); + if (!ret) { + vty_out(vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } - if (argc == 8) - { - if (strncmp (argv[7]->arg, "ma", 2) == 0) - type = BGP_EVPN_MAC_IP_ROUTE; - else if (strncmp (argv[7]->arg, "mu", 2) == 0) - type = BGP_EVPN_IMET_ROUTE; - else - return CMD_WARNING; - } + if (argc == 8) { + if (strncmp(argv[7]->arg, "ma", 2) == 0) + type = BGP_EVPN_MAC_IP_ROUTE; + else if (strncmp(argv[7]->arg, "mu", 2) == 0) + type = BGP_EVPN_IMET_ROUTE; + else + return CMD_WARNING; + } - evpn_show_route_rd (vty, bgp, &prd, type); - return CMD_SUCCESS; + evpn_show_route_rd(vty, bgp, &prd, type); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_route_rd_macip, @@ -1964,39 +1881,35 @@ DEFUN (show_bgp_evpn_route_rd_macip, "IP\n" "IP address (IPv4 or IPv6)\n") { - struct bgp *bgp; - int ret; - struct prefix_rd prd; - struct ethaddr mac; - struct ipaddr ip; - - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; - - ret = str2prefix_rd (argv[5]->arg, &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher\n"); - return CMD_WARNING; - } - if (!prefix_str2mac (argv[7]->arg, &mac)) - { - vty_out (vty, "%% Malformed MAC address\n"); - return CMD_WARNING; - } - memset (&ip, 0, sizeof (ip)); - if (argc == 10 && argv[9]->arg != NULL) - { - if (str2ipaddr (argv[9]->arg, &ip) != 0) - { - vty_out (vty, "%% Malformed IP address\n"); - return CMD_WARNING; - } - } - - evpn_show_route_rd_macip (vty, bgp, &prd, &mac, &ip); - return CMD_SUCCESS; + struct bgp *bgp; + int ret; + struct prefix_rd prd; + struct ethaddr mac; + struct ipaddr ip; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + ret = str2prefix_rd(argv[5]->arg, &prd); + if (!ret) { + vty_out(vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } + if (!prefix_str2mac(argv[7]->arg, &mac)) { + vty_out(vty, "%% Malformed MAC address\n"); + return CMD_WARNING; + } + memset(&ip, 0, sizeof(ip)); + if (argc == 10 && argv[9]->arg != NULL) { + if (str2ipaddr(argv[9]->arg, &ip) != 0) { + vty_out(vty, "%% Malformed IP address\n"); + return CMD_WARNING; + } + } + + evpn_show_route_rd_macip(vty, bgp, &prd, &mac, &ip); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_route_vni, @@ -2014,44 +1927,38 @@ DEFUN (show_bgp_evpn_route_vni, "Remote VTEP\n" "Remote VTEP IP address\n") { - vni_t vni; - struct bgp *bgp; - struct in_addr vtep_ip; - int type = 0; - - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; - - vtep_ip.s_addr = 0; - - vni = strtoul(argv[5]->arg, NULL, 10); - - if (argc == 8 && argv[6]->arg) - { - if (strncmp (argv[6]->arg, "type", 4) == 0) - { - if (strncmp (argv[7]->arg, "ma", 2) == 0) - type = BGP_EVPN_MAC_IP_ROUTE; - else if (strncmp (argv[7]->arg, "mu", 2) == 0) - type = BGP_EVPN_IMET_ROUTE; - else - return CMD_WARNING; - } - else if (strncmp (argv[6]->arg, "vtep", 4) == 0) - { - if (!inet_aton (argv[7]->arg, &vtep_ip)) - { - vty_out (vty, "%% Malformed VTEP IP address\n"); - return CMD_WARNING; - } - } - else - return CMD_WARNING; - } - - evpn_show_routes_vni (vty, bgp, vni, type, vtep_ip); - return CMD_SUCCESS; + vni_t vni; + struct bgp *bgp; + struct in_addr vtep_ip; + int type = 0; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vtep_ip.s_addr = 0; + + vni = strtoul(argv[5]->arg, NULL, 10); + + if (argc == 8 && argv[6]->arg) { + if (strncmp(argv[6]->arg, "type", 4) == 0) { + if (strncmp(argv[7]->arg, "ma", 2) == 0) + type = BGP_EVPN_MAC_IP_ROUTE; + else if (strncmp(argv[7]->arg, "mu", 2) == 0) + type = BGP_EVPN_IMET_ROUTE; + else + return CMD_WARNING; + } else if (strncmp(argv[6]->arg, "vtep", 4) == 0) { + if (!inet_aton(argv[7]->arg, &vtep_ip)) { + vty_out(vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; + } + } else + return CMD_WARNING; + } + + evpn_show_routes_vni(vty, bgp, vni, type, vtep_ip); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_route_vni_macip, @@ -2068,33 +1975,30 @@ DEFUN (show_bgp_evpn_route_vni_macip, "IP\n" "IP address (IPv4 or IPv6)\n") { - vni_t vni; - struct bgp *bgp; - struct ethaddr mac; - struct ipaddr ip; - - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; - - vni = strtoul(argv[5]->arg, NULL, 10); - if (!prefix_str2mac (argv[7]->arg, &mac)) - { - vty_out (vty, "%% Malformed MAC address\n"); - return CMD_WARNING; - } - memset (&ip, 0, sizeof (ip)); - if (argc == 10 && argv[9]->arg != NULL) - { - if (str2ipaddr (argv[9]->arg, &ip) != 0) - { - vty_out (vty, "%% Malformed IP address\n"); - return CMD_WARNING; - } - } - - evpn_show_route_vni_macip (vty, bgp, vni, &mac, &ip); - return CMD_SUCCESS; + vni_t vni; + struct bgp *bgp; + struct ethaddr mac; + struct ipaddr ip; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vni = strtoul(argv[5]->arg, NULL, 10); + if (!prefix_str2mac(argv[7]->arg, &mac)) { + vty_out(vty, "%% Malformed MAC address\n"); + return CMD_WARNING; + } + memset(&ip, 0, sizeof(ip)); + if (argc == 10 && argv[9]->arg != NULL) { + if (str2ipaddr(argv[9]->arg, &ip) != 0) { + vty_out(vty, "%% Malformed IP address\n"); + return CMD_WARNING; + } + } + + evpn_show_route_vni_macip(vty, bgp, vni, &mac, &ip); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_route_vni_multicast, @@ -2109,25 +2013,24 @@ DEFUN (show_bgp_evpn_route_vni_multicast, "Multicast (Type-3) route\n" "Originating Router IP address\n") { - vni_t vni; - struct bgp *bgp; - int ret; - struct in_addr orig_ip; + vni_t vni; + struct bgp *bgp; + int ret; + struct in_addr orig_ip; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - vni = strtoul(argv[5]->arg, NULL, 10); - ret = inet_aton (argv[7]->arg, &orig_ip); - if (!ret) - { - vty_out (vty, "%% Malformed Originating Router IP address\n"); - return CMD_WARNING; - } + vni = strtoul(argv[5]->arg, NULL, 10); + ret = inet_aton(argv[7]->arg, &orig_ip); + if (!ret) { + vty_out(vty, "%% Malformed Originating Router IP address\n"); + return CMD_WARNING; + } - evpn_show_route_vni_multicast (vty, bgp, vni, orig_ip); - return CMD_SUCCESS; + evpn_show_route_vni_multicast(vty, bgp, vni, orig_ip); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_route_vni_all, @@ -2142,25 +2045,23 @@ DEFUN (show_bgp_evpn_route_vni_all, "Remote VTEP\n" "Remote VTEP IP address\n") { - struct bgp *bgp; - struct in_addr vtep_ip; + struct bgp *bgp; + struct in_addr vtep_ip; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - vtep_ip.s_addr = 0; - if (argc == 8 && argv[7]->arg) - { - if (!inet_aton (argv[7]->arg, &vtep_ip)) - { - vty_out (vty, "%% Malformed VTEP IP address\n"); - return CMD_WARNING; - } - } + vtep_ip.s_addr = 0; + if (argc == 8 && argv[7]->arg) { + if (!inet_aton(argv[7]->arg, &vtep_ip)) { + vty_out(vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; + } + } - evpn_show_routes_vni_all (vty, bgp, vtep_ip); - return CMD_SUCCESS; + evpn_show_routes_vni_all(vty, bgp, vtep_ip); + return CMD_SUCCESS; } DEFUN (show_bgp_evpn_import_rt, @@ -2171,14 +2072,14 @@ DEFUN (show_bgp_evpn_import_rt, "Address family modifier\n" "Show import route target\n") { - struct bgp *bgp; + struct bgp *bgp; - bgp = bgp_get_default(); - if (!bgp) - return CMD_WARNING; + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; - evpn_show_import_rts (vty, bgp); - return CMD_SUCCESS; + evpn_show_import_rts(vty, bgp); + return CMD_SUCCESS; } DEFUN_NOSH (bgp_evpn_vni, @@ -2187,25 +2088,24 @@ DEFUN_NOSH (bgp_evpn_vni, "VXLAN Network Identifier\n" "VNI number\n") { - vni_t vni; - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - struct bgpevpn *vpn; + vni_t vni; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + struct bgpevpn *vpn; - if (!bgp) - return CMD_WARNING; + if (!bgp) + return CMD_WARNING; - vni = strtoul(argv[1]->arg, NULL, 10); + vni = strtoul(argv[1]->arg, NULL, 10); - /* Create VNI, or mark as configured. */ - vpn = evpn_create_update_vni (bgp, vni); - if (!vpn) - { - vty_out (vty, "%% Failed to create VNI \n"); - return CMD_WARNING; - } + /* Create VNI, or mark as configured. */ + vpn = evpn_create_update_vni(bgp, vni); + if (!vpn) { + vty_out(vty, "%% Failed to create VNI \n"); + return CMD_WARNING; + } - VTY_PUSH_CONTEXT_SUB (BGP_EVPN_VNI_NODE, vpn); - return CMD_SUCCESS; + VTY_PUSH_CONTEXT_SUB(BGP_EVPN_VNI_NODE, vpn); + return CMD_SUCCESS; } DEFUN (no_bgp_evpn_vni, @@ -2215,30 +2115,28 @@ DEFUN (no_bgp_evpn_vni, "VXLAN Network Identifier\n" "VNI number\n") { - vni_t vni; - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - struct bgpevpn *vpn; + vni_t vni; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + struct bgpevpn *vpn; - if (!bgp) - return CMD_WARNING; + if (!bgp) + return CMD_WARNING; - vni = strtoul(argv[2]->arg, NULL, 10); + vni = strtoul(argv[2]->arg, NULL, 10); - /* Check if we should disallow. */ - vpn = bgp_evpn_lookup_vni (bgp, vni); - if (!vpn) - { - vty_out (vty, "%% Specified VNI does not exist\n"); - return CMD_WARNING; - } - if (!is_vni_configured (vpn)) - { - vty_out (vty, "%% Specified VNI is not configured\n"); - return CMD_WARNING; - } + /* Check if we should disallow. */ + vpn = bgp_evpn_lookup_vni(bgp, vni); + if (!vpn) { + vty_out(vty, "%% Specified VNI does not exist\n"); + return CMD_WARNING; + } + if (!is_vni_configured(vpn)) { + vty_out(vty, "%% Specified VNI is not configured\n"); + return CMD_WARNING; + } - evpn_delete_vni (bgp, vpn); - return CMD_SUCCESS; + evpn_delete_vni(bgp, vpn); + return CMD_SUCCESS; } DEFUN_NOSH (exit_vni, @@ -2246,9 +2144,9 @@ DEFUN_NOSH (exit_vni, "exit-vni", "Exit from VNI mode\n") { - if (vty->node == BGP_EVPN_VNI_NODE) - vty->node = BGP_EVPN_NODE; - return CMD_SUCCESS; + if (vty->node == BGP_EVPN_VNI_NODE) + vty->node = BGP_EVPN_NODE; + return CMD_SUCCESS; } DEFUN (bgp_evpn_vni_rd, @@ -2257,28 +2155,27 @@ DEFUN (bgp_evpn_vni_rd, "Route Distinguisher\n" "ASN:XX or A.B.C.D:XX\n") { - struct prefix_rd prd; - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); - int ret; + struct prefix_rd prd; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int ret; - if (!bgp || !vpn) - return CMD_WARNING; + if (!bgp || !vpn) + return CMD_WARNING; - ret = str2prefix_rd (argv[1]->arg, &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher\n"); - return CMD_WARNING; - } + ret = str2prefix_rd(argv[1]->arg, &prd); + if (!ret) { + vty_out(vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } - /* If same as existing value, there is nothing more to do. */ - if (bgp_evpn_rd_matches_existing (vpn, &prd)) - return CMD_SUCCESS; + /* If same as existing value, there is nothing more to do. */ + if (bgp_evpn_rd_matches_existing(vpn, &prd)) + return CMD_SUCCESS; - /* Configure or update the RD. */ - evpn_configure_rd (bgp, vpn, &prd); - return CMD_SUCCESS; + /* Configure or update the RD. */ + evpn_configure_rd(bgp, vpn, &prd); + return CMD_SUCCESS; } DEFUN (no_bgp_evpn_vni_rd, @@ -2288,36 +2185,34 @@ DEFUN (no_bgp_evpn_vni_rd, "Route Distinguisher\n" "ASN:XX or A.B.C.D:XX\n") { - struct prefix_rd prd; - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); - int ret; + struct prefix_rd prd; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int ret; - if (!bgp || !vpn) - return CMD_WARNING; + if (!bgp || !vpn) + return CMD_WARNING; - ret = str2prefix_rd (argv[2]->arg, &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher\n"); - return CMD_WARNING; - } + ret = str2prefix_rd(argv[2]->arg, &prd); + if (!ret) { + vty_out(vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } - /* Check if we should disallow. */ - if (!is_rd_configured (vpn)) - { - vty_out (vty, "%% RD is not configured for this VNI\n"); - return CMD_WARNING; - } + /* Check if we should disallow. */ + if (!is_rd_configured(vpn)) { + vty_out(vty, "%% RD is not configured for this VNI\n"); + return CMD_WARNING; + } - if (!bgp_evpn_rd_matches_existing(vpn, &prd)) - { - vty_out (vty, "%% RD specified does not match configuration for this VNI\n"); - return CMD_WARNING; - } + if (!bgp_evpn_rd_matches_existing(vpn, &prd)) { + vty_out(vty, + "%% RD specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } - evpn_unconfigure_rd (bgp, vpn); - return CMD_SUCCESS; + evpn_unconfigure_rd(bgp, vpn); + return CMD_SUCCESS; } DEFUN (no_bgp_evpn_vni_rd_without_val, @@ -2326,41 +2221,38 @@ DEFUN (no_bgp_evpn_vni_rd_without_val, NO_STR "Route Distinguisher\n") { - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); - if (!bgp || !vpn) - return CMD_WARNING; + if (!bgp || !vpn) + return CMD_WARNING; - /* Check if we should disallow. */ - if (!is_rd_configured (vpn)) - { - vty_out (vty, "%% RD is not configured for this VNI\n"); - return CMD_WARNING; - } + /* Check if we should disallow. */ + if (!is_rd_configured(vpn)) { + vty_out(vty, "%% RD is not configured for this VNI\n"); + return CMD_WARNING; + } - evpn_unconfigure_rd (bgp, vpn); - return CMD_SUCCESS; + evpn_unconfigure_rd(bgp, vpn); + return CMD_SUCCESS; } /* * Loop over all extended-communities in the route-target list rtl and * return 1 if we find ecomtarget */ -static int -bgp_evpn_rt_matches_existing (struct list *rtl, - struct ecommunity *ecomtarget) +static int bgp_evpn_rt_matches_existing(struct list *rtl, + struct ecommunity *ecomtarget) { - struct listnode *node, *nnode; - struct ecommunity *ecom; + struct listnode *node, *nnode; + struct ecommunity *ecom; - for (ALL_LIST_ELEMENTS (rtl, node, nnode, ecom)) - { - if (ecommunity_match (ecom, ecomtarget)) - return 1; - } + for (ALL_LIST_ELEMENTS(rtl, node, nnode, ecom)) { + if (ecommunity_match(ecom, ecomtarget)) + return 1; + } - return 0; + return 0; } @@ -2373,61 +2265,56 @@ DEFUN (bgp_evpn_vni_rt, "export\n" "Route target (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") { - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); - int rt_type; - struct ecommunity *ecomadd = NULL; - - if (!bgp || !vpn) - return CMD_WARNING; - - if (!strcmp (argv[1]->arg, "import")) - rt_type = RT_TYPE_IMPORT; - else if (!strcmp (argv[1]->arg, "export")) - rt_type = RT_TYPE_EXPORT; - else if (!strcmp (argv[1]->arg, "both")) - rt_type = RT_TYPE_BOTH; - else - { - vty_out (vty, "%% Invalid Route Target type\n"); - return CMD_WARNING; - } - - /* Add/update the import route-target */ - if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_IMPORT) - { - ecomadd = ecommunity_str2com (argv[2]->arg, - ECOMMUNITY_ROUTE_TARGET, 0); - ecommunity_str(ecomadd); - if (!ecomadd) - { - vty_out (vty, "%% Malformed Route Target list\n"); - return CMD_WARNING; - } - - /* Do nothing if we already have this import route-target */ - if (! bgp_evpn_rt_matches_existing (vpn->import_rtl, ecomadd)) - evpn_configure_import_rt (bgp, vpn, ecomadd); - } - - /* Add/update the export route-target */ - if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_EXPORT) - { - ecomadd = ecommunity_str2com (argv[2]->arg, - ECOMMUNITY_ROUTE_TARGET, 0); - ecommunity_str(ecomadd); - if (!ecomadd) - { - vty_out (vty, "%% Malformed Route Target list\n"); - return CMD_WARNING; - } - - /* Do nothing if we already have this export route-target */ - if (! bgp_evpn_rt_matches_existing (vpn->export_rtl, ecomadd)) - evpn_configure_export_rt (bgp, vpn, ecomadd); - } - - return CMD_SUCCESS; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int rt_type; + struct ecommunity *ecomadd = NULL; + + if (!bgp || !vpn) + return CMD_WARNING; + + if (!strcmp(argv[1]->arg, "import")) + rt_type = RT_TYPE_IMPORT; + else if (!strcmp(argv[1]->arg, "export")) + rt_type = RT_TYPE_EXPORT; + else if (!strcmp(argv[1]->arg, "both")) + rt_type = RT_TYPE_BOTH; + else { + vty_out(vty, "%% Invalid Route Target type\n"); + return CMD_WARNING; + } + + /* Add/update the import route-target */ + if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_IMPORT) { + ecomadd = ecommunity_str2com(argv[2]->arg, + ECOMMUNITY_ROUTE_TARGET, 0); + ecommunity_str(ecomadd); + if (!ecomadd) { + vty_out(vty, "%% Malformed Route Target list\n"); + return CMD_WARNING; + } + + /* Do nothing if we already have this import route-target */ + if (!bgp_evpn_rt_matches_existing(vpn->import_rtl, ecomadd)) + evpn_configure_import_rt(bgp, vpn, ecomadd); + } + + /* Add/update the export route-target */ + if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_EXPORT) { + ecomadd = ecommunity_str2com(argv[2]->arg, + ECOMMUNITY_ROUTE_TARGET, 0); + ecommunity_str(ecomadd); + if (!ecomadd) { + vty_out(vty, "%% Malformed Route Target list\n"); + return CMD_WARNING; + } + + /* Do nothing if we already have this export route-target */ + if (!bgp_evpn_rt_matches_existing(vpn->export_rtl, ecomadd)) + evpn_configure_export_rt(bgp, vpn, ecomadd); + } + + return CMD_SUCCESS; } DEFUN (no_bgp_evpn_vni_rt, @@ -2440,103 +2327,90 @@ DEFUN (no_bgp_evpn_vni_rt, "export\n" "ASN:XX or A.B.C.D:XX\n") { - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); - int rt_type, found_ecomdel; - struct ecommunity *ecomdel = NULL; - - if (!bgp || !vpn) - return CMD_WARNING; - - if (!strcmp (argv[2]->arg, "import")) - rt_type = RT_TYPE_IMPORT; - else if (!strcmp (argv[2]->arg, "export")) - rt_type = RT_TYPE_EXPORT; - else if (!strcmp (argv[2]->arg, "both")) - rt_type = RT_TYPE_BOTH; - else - { - vty_out (vty, "%% Invalid Route Target type\n"); - return CMD_WARNING; - } - - /* The user did "no route-target import", check to see if there are any - * import route-targets configured. */ - if (rt_type == RT_TYPE_IMPORT) - { - if (!is_import_rt_configured (vpn)) - { - vty_out (vty, "%% Import RT is not configured for this VNI\n"); - return CMD_WARNING; - } - } - else if (rt_type == RT_TYPE_EXPORT) - { - if (!is_export_rt_configured (vpn)) - { - vty_out (vty, "%% Export RT is not configured for this VNI\n"); - return CMD_WARNING; - } - } - else if (rt_type == RT_TYPE_BOTH) - { - if (!is_import_rt_configured (vpn) && !is_export_rt_configured (vpn)) - { - vty_out (vty, "%% Import/Export RT is not configured for this VNI\n"); - return CMD_WARNING; - } - } - - ecomdel = ecommunity_str2com (argv[3]->arg, ECOMMUNITY_ROUTE_TARGET, 0); - ecommunity_str(ecomdel); - if (!ecomdel) - { - vty_out (vty, "%% Malformed Route Target list\n"); - return CMD_WARNING; - } - - if (rt_type == RT_TYPE_IMPORT) - { - if (!bgp_evpn_rt_matches_existing (vpn->import_rtl, ecomdel)) - { - vty_out (vty, "%% RT specified does not match configuration for this VNI\n"); - return CMD_WARNING; - } - evpn_unconfigure_import_rt (bgp, vpn, ecomdel); - } - else if (rt_type == RT_TYPE_EXPORT) - { - if (!bgp_evpn_rt_matches_existing (vpn->export_rtl, ecomdel)) - { - vty_out (vty, "%% RT specified does not match configuration for this VNI\n"); - return CMD_WARNING; - } - evpn_unconfigure_export_rt (bgp, vpn, ecomdel); - } - else if (rt_type == RT_TYPE_BOTH) - { - found_ecomdel = 0; - - if (bgp_evpn_rt_matches_existing (vpn->import_rtl, ecomdel)) - { - evpn_unconfigure_import_rt (bgp, vpn, ecomdel); - found_ecomdel = 1; - } - - if (bgp_evpn_rt_matches_existing (vpn->export_rtl, ecomdel)) - { - evpn_unconfigure_export_rt (bgp, vpn, ecomdel); - found_ecomdel = 1; - } - - if (! found_ecomdel) - { - vty_out (vty, "%% RT specified does not match configuration for this VNI\n"); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int rt_type, found_ecomdel; + struct ecommunity *ecomdel = NULL; + + if (!bgp || !vpn) + return CMD_WARNING; + + if (!strcmp(argv[2]->arg, "import")) + rt_type = RT_TYPE_IMPORT; + else if (!strcmp(argv[2]->arg, "export")) + rt_type = RT_TYPE_EXPORT; + else if (!strcmp(argv[2]->arg, "both")) + rt_type = RT_TYPE_BOTH; + else { + vty_out(vty, "%% Invalid Route Target type\n"); + return CMD_WARNING; + } + + /* The user did "no route-target import", check to see if there are any + * import route-targets configured. */ + if (rt_type == RT_TYPE_IMPORT) { + if (!is_import_rt_configured(vpn)) { + vty_out(vty, + "%% Import RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } else if (rt_type == RT_TYPE_EXPORT) { + if (!is_export_rt_configured(vpn)) { + vty_out(vty, + "%% Export RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } else if (rt_type == RT_TYPE_BOTH) { + if (!is_import_rt_configured(vpn) + && !is_export_rt_configured(vpn)) { + vty_out(vty, + "%% Import/Export RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + + ecomdel = ecommunity_str2com(argv[3]->arg, ECOMMUNITY_ROUTE_TARGET, 0); + ecommunity_str(ecomdel); + if (!ecomdel) { + vty_out(vty, "%% Malformed Route Target list\n"); + return CMD_WARNING; + } + + if (rt_type == RT_TYPE_IMPORT) { + if (!bgp_evpn_rt_matches_existing(vpn->import_rtl, ecomdel)) { + vty_out(vty, + "%% RT specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + evpn_unconfigure_import_rt(bgp, vpn, ecomdel); + } else if (rt_type == RT_TYPE_EXPORT) { + if (!bgp_evpn_rt_matches_existing(vpn->export_rtl, ecomdel)) { + vty_out(vty, + "%% RT specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + evpn_unconfigure_export_rt(bgp, vpn, ecomdel); + } else if (rt_type == RT_TYPE_BOTH) { + found_ecomdel = 0; + + if (bgp_evpn_rt_matches_existing(vpn->import_rtl, ecomdel)) { + evpn_unconfigure_import_rt(bgp, vpn, ecomdel); + found_ecomdel = 1; + } + + if (bgp_evpn_rt_matches_existing(vpn->export_rtl, ecomdel)) { + evpn_unconfigure_export_rt(bgp, vpn, ecomdel); + found_ecomdel = 1; + } + + if (!found_ecomdel) { + vty_out(vty, + "%% RT specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + } + + return CMD_SUCCESS; } DEFUN (no_bgp_evpn_vni_rt_without_val, @@ -2547,120 +2421,114 @@ DEFUN (no_bgp_evpn_vni_rt_without_val, "import\n" "export\n") { - struct bgp *bgp = VTY_GET_CONTEXT(bgp); - VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); - int rt_type; - - if (!bgp || !vpn) - return CMD_WARNING; - - if (!strcmp (argv[2]->arg, "import")) - { - rt_type = RT_TYPE_IMPORT; - } - else if (!strcmp (argv[2]->arg, "export")) - { - rt_type = RT_TYPE_EXPORT; - } - else - { - vty_out (vty, "%% Invalid Route Target type\n"); - return CMD_WARNING; - } - - /* Check if we should disallow. */ - if (rt_type == RT_TYPE_IMPORT) - { - if (!is_import_rt_configured (vpn)) - { - vty_out (vty, "%% Import RT is not configured for this VNI\n"); - return CMD_WARNING; - } - } - else - { - if (!is_export_rt_configured (vpn)) - { - vty_out (vty, "%% Export RT is not configured for this VNI\n"); - return CMD_WARNING; - } - } - - /* Unconfigure the RT. */ - if (rt_type == RT_TYPE_IMPORT) - evpn_unconfigure_import_rt (bgp, vpn, NULL); - else - evpn_unconfigure_export_rt (bgp, vpn, NULL); - return CMD_SUCCESS; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int rt_type; + + if (!bgp || !vpn) + return CMD_WARNING; + + if (!strcmp(argv[2]->arg, "import")) { + rt_type = RT_TYPE_IMPORT; + } else if (!strcmp(argv[2]->arg, "export")) { + rt_type = RT_TYPE_EXPORT; + } else { + vty_out(vty, "%% Invalid Route Target type\n"); + return CMD_WARNING; + } + + /* Check if we should disallow. */ + if (rt_type == RT_TYPE_IMPORT) { + if (!is_import_rt_configured(vpn)) { + vty_out(vty, + "%% Import RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } else { + if (!is_export_rt_configured(vpn)) { + vty_out(vty, + "%% Export RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + + /* Unconfigure the RT. */ + if (rt_type == RT_TYPE_IMPORT) + evpn_unconfigure_import_rt(bgp, vpn, NULL); + else + evpn_unconfigure_export_rt(bgp, vpn, NULL); + return CMD_SUCCESS; } #endif /* * Output EVPN configuration information. */ -void -bgp_config_write_evpn_info (struct vty *vty, struct bgp *bgp, afi_t afi, - safi_t safi, int *write) -{ - struct evpn_config_write cfg; - - if (bgp->vnihash) - { - cfg.write = *write; - cfg.vty = vty; - hash_iterate (bgp->vnihash, - (void (*) (struct hash_backet *, void *)) - write_vni_config_for_entry, &cfg); - *write = cfg.write; - } +void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi, + safi_t safi, int *write) +{ + struct evpn_config_write cfg; + + if (bgp->vnihash) { + cfg.write = *write; + cfg.vty = vty; + hash_iterate(bgp->vnihash, + (void (*)(struct hash_backet *, + void *))write_vni_config_for_entry, + &cfg); + *write = cfg.write; + } - if (bgp->advertise_all_vni) - { - bgp_config_write_family_header (vty, afi, safi, write); - vty_out (vty, " advertise-all-vni\n"); - } + if (bgp->advertise_all_vni) { + bgp_config_write_family_header(vty, afi, safi, write); + vty_out(vty, " advertise-all-vni\n"); + } } void bgp_ethernetvpn_init(void) { - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_tags_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_tags_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_neighbor_routes_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_neighbor_routes_cmd); - install_element(VIEW_NODE, - &show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd); - install_element(VIEW_NODE, - &show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd); - install_element(VIEW_NODE, &show_ip_bgp_evpn_rd_overlay_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_overlay_cmd); - install_element(BGP_EVPN_NODE, &no_evpnrt5_network_cmd); - install_element(BGP_EVPN_NODE, &evpnrt5_network_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_tags_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_tags_cmd); + install_element(VIEW_NODE, + &show_ip_bgp_l2vpn_evpn_all_neighbor_routes_cmd); + install_element(VIEW_NODE, + &show_ip_bgp_l2vpn_evpn_rd_neighbor_routes_cmd); + install_element( + VIEW_NODE, + &show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd); + install_element( + VIEW_NODE, + &show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd); + install_element(VIEW_NODE, &show_ip_bgp_evpn_rd_overlay_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_overlay_cmd); + install_element(BGP_EVPN_NODE, &no_evpnrt5_network_cmd); + install_element(BGP_EVPN_NODE, &evpnrt5_network_cmd); #if defined(HAVE_CUMULUS) - install_element (BGP_EVPN_NODE, &bgp_evpn_advertise_all_vni_cmd); - install_element (BGP_EVPN_NODE, &no_bgp_evpn_advertise_all_vni_cmd); - - /* "show bgp evpn" commands. */ - install_element (VIEW_NODE, &show_bgp_evpn_vni_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_vni_num_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_summary_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_rd_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_rd_macip_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_vni_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_vni_multicast_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_vni_macip_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_route_vni_all_cmd); - install_element (VIEW_NODE, &show_bgp_evpn_import_rt_cmd); - - install_element (BGP_EVPN_NODE, &bgp_evpn_vni_cmd); - install_element (BGP_EVPN_NODE, &no_bgp_evpn_vni_cmd); - install_element (BGP_EVPN_VNI_NODE, &exit_vni_cmd); - install_element (BGP_EVPN_VNI_NODE, &bgp_evpn_vni_rd_cmd); - install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rd_cmd); - install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rd_without_val_cmd); - install_element (BGP_EVPN_VNI_NODE, &bgp_evpn_vni_rt_cmd); - install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rt_cmd); - install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rt_without_val_cmd); + install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_all_vni_cmd); + install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_all_vni_cmd); + + /* "show bgp evpn" commands. */ + install_element(VIEW_NODE, &show_bgp_evpn_vni_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_vni_num_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_summary_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_rd_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_rd_macip_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_vni_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_vni_multicast_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_vni_macip_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_route_vni_all_cmd); + install_element(VIEW_NODE, &show_bgp_evpn_import_rt_cmd); + + install_element(BGP_EVPN_NODE, &bgp_evpn_vni_cmd); + install_element(BGP_EVPN_NODE, &no_bgp_evpn_vni_cmd); + install_element(BGP_EVPN_VNI_NODE, &exit_vni_cmd); + install_element(BGP_EVPN_VNI_NODE, &bgp_evpn_vni_rd_cmd); + install_element(BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rd_cmd); + install_element(BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rd_without_val_cmd); + install_element(BGP_EVPN_VNI_NODE, &bgp_evpn_vni_rt_cmd); + install_element(BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rt_cmd); + install_element(BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rt_without_val_cmd); #endif } |