diff options
| -rw-r--r-- | bgpd/bgp_evpn.c | 189 | ||||
| -rw-r--r-- | bgpd/bgp_evpn_private.h | 14 | ||||
| -rw-r--r-- | bgpd/bgp_evpn_vty.c | 97 |
3 files changed, 192 insertions, 108 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 0642c966eb..d2cb39656b 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -62,6 +62,7 @@ DEFINE_QOBJ_TYPE(bgpevpn); DEFINE_QOBJ_TYPE(bgp_evpn_es); +DEFINE_MTYPE_STATIC(BGPD, VRF_ROUTE_TARGET, "L3 Route Target"); /* * Static function declarations @@ -340,6 +341,15 @@ int bgp_evpn_route_target_cmp(struct ecommunity *ecom1, return strcmp(ecom1->str, ecom2->str); } +/* + * Compare L3 Route Targets. + */ +static int evpn_vrf_route_target_cmp(struct vrf_route_target *rt1, + struct vrf_route_target *rt2) +{ + return bgp_evpn_route_target_cmp(rt1->ecom, rt2->ecom); +} + void bgp_evpn_xxport_delete_ecomm(void *val) { struct ecommunity *ecomm = val; @@ -347,6 +357,32 @@ void bgp_evpn_xxport_delete_ecomm(void *val) } /* + * Delete l3 Route Target. + */ +static void evpn_vrf_rt_del(void *val) +{ + struct vrf_route_target *l3rt = val; + + ecommunity_free(&l3rt->ecom); + + XFREE(MTYPE_VRF_ROUTE_TARGET, l3rt); +} + +/* + * Allocate a new l3 Route Target. + */ +static struct vrf_route_target *evpn_vrf_rt_new(struct ecommunity *ecom) +{ + struct vrf_route_target *l3rt; + + l3rt = XCALLOC(MTYPE_VRF_ROUTE_TARGET, sizeof(struct vrf_route_target)); + + l3rt->ecom = ecom; + + return l3rt; +} + +/* * Mask off global-admin field of specified extended community (RT), * just retain the local-admin field. */ @@ -498,7 +534,9 @@ static void bgp_evpn_get_rmac_nexthop(struct bgpevpn *vpn, static void form_auto_rt(struct bgp *bgp, vni_t vni, struct list *rtl) { struct ecommunity_val eval; - struct ecommunity *ecomadd, *ecom; + struct ecommunity *ecomadd; + struct vrf_route_target *l3rt; + struct vrf_route_target *newrt; bool ecom_found = false; struct listnode *node; @@ -508,15 +546,16 @@ static void form_auto_rt(struct bgp *bgp, vni_t vni, struct list *rtl) ecomadd = ecommunity_new(); ecommunity_add_val(ecomadd, &eval, false, false); - for (ALL_LIST_ELEMENTS_RO(rtl, node, ecom)) - if (ecommunity_cmp(ecomadd, ecom)) { + for (ALL_LIST_ELEMENTS_RO(rtl, node, l3rt)) + if (ecommunity_cmp(ecomadd, l3rt->ecom)) { ecom_found = true; break; } - if (!ecom_found) - listnode_add_sort(rtl, ecomadd); - else + if (!ecom_found) { + newrt = evpn_vrf_rt_new(ecomadd); + listnode_add_sort(rtl, newrt); + } else ecommunity_free(&ecomadd); } @@ -714,8 +753,9 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf, struct ecommunity_val eval_rmac; bgp_encap_types tnl_type; struct listnode *node, *nnode; - struct ecommunity *ecom; + struct vrf_route_target *l3rt; struct ecommunity *old_ecom; + struct ecommunity *ecom; struct list *vrf_export_rtl = NULL; /* Encap */ @@ -739,10 +779,10 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf, /* Add the export RTs for L3VNI/VRF */ vrf_export_rtl = bgp_vrf->vrf_export_rtl; - for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, ecom)) + for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, l3rt)) bgp_attr_set_ecommunity( - attr, - ecommunity_merge(bgp_attr_get_ecommunity(attr), ecom)); + attr, ecommunity_merge(bgp_attr_get_ecommunity(attr), + l3rt->ecom)); /* add the router mac extended community */ if (!is_zero_mac(&attr->rmac)) { @@ -779,6 +819,7 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr, bgp_encap_types tnl_type; struct listnode *node, *nnode; struct ecommunity *ecom; + struct vrf_route_target *l3rt; uint32_t seqnum; struct list *vrf_export_rtl = NULL; @@ -807,12 +848,12 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr, vrf_export_rtl = bgpevpn_get_vrf_export_rtl(vpn); if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) { for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, - ecom)) + l3rt)) bgp_attr_set_ecommunity( attr, ecommunity_merge( bgp_attr_get_ecommunity(attr), - ecom)); + l3rt->ecom)); } } @@ -4266,7 +4307,8 @@ static void evpn_auto_rt_import_add_for_vrf(struct bgp *bgp_vrf) */ static void evpn_auto_rt_import_delete_for_vrf(struct bgp *bgp_vrf) { - evpn_rt_delete_auto(bgp_vrf, bgp_vrf->l3vni, bgp_vrf->vrf_import_rtl); + evpn_rt_delete_auto(bgp_vrf, bgp_vrf->l3vni, bgp_vrf->vrf_import_rtl, + true); } /* @@ -4283,7 +4325,8 @@ static void evpn_auto_rt_export_add_for_vrf(struct bgp *bgp_vrf) */ static void evpn_auto_rt_export_delete_for_vrf(struct bgp *bgp_vrf) { - evpn_rt_delete_auto(bgp_vrf, bgp_vrf->l3vni, bgp_vrf->vrf_export_rtl); + evpn_rt_delete_auto(bgp_vrf, bgp_vrf->l3vni, bgp_vrf->vrf_export_rtl, + true); } static void bgp_evpn_handle_export_rt_change_for_vrf(struct bgp *bgp_vrf) @@ -4526,10 +4569,41 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi, } } -void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl) +static void rt_list_remove_node(struct list *rt_list, + struct ecommunity *ecomdel, bool is_l3) { - struct listnode *node, *nnode, *node_to_del; - struct ecommunity *ecom, *ecom_auto; + struct listnode *node = NULL, *nnode = NULL, *node_to_del = NULL; + struct vrf_route_target *l3rt = NULL; + struct ecommunity *ecom = NULL; + + /* remove the RT from the RT list */ + + if (is_l3) { + for (ALL_LIST_ELEMENTS(rt_list, node, nnode, l3rt)) { + if (ecommunity_match(l3rt->ecom, ecomdel)) { + evpn_vrf_rt_del(l3rt); + node_to_del = node; + break; + } + } + } else { + for (ALL_LIST_ELEMENTS(rt_list, node, nnode, ecom)) { + if (ecommunity_match(ecom, ecomdel)) { + ecommunity_free(&ecom); + node_to_del = node; + break; + } + } + } + + if (node_to_del) + list_delete_node(rt_list, node_to_del); +} + +void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl, + bool is_l3) +{ + struct ecommunity *ecom_auto; struct ecommunity_val eval; if (bgp->advertise_autort_rfc8365) @@ -4538,18 +4612,9 @@ void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl) ecom_auto = ecommunity_new(); ecommunity_add_val(ecom_auto, &eval, false, false); - 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; - break; - } - } - - if (node_to_del) - list_delete_node(rtl, node_to_del); + /* Remove rt */ + rt_list_remove_node(rtl, ecom_auto, is_l3); ecommunity_free(&ecom_auto); } @@ -4557,6 +4622,10 @@ void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl) void bgp_evpn_configure_import_rt_for_vrf(struct bgp *bgp_vrf, struct ecommunity *ecomadd) { + struct vrf_route_target *newrt; + + newrt = evpn_vrf_rt_new(ecomadd); + /* uninstall routes from vrf */ if (is_l3vni_live(bgp_vrf)) uninstall_routes_for_vrf(bgp_vrf); @@ -4568,7 +4637,7 @@ void bgp_evpn_configure_import_rt_for_vrf(struct bgp *bgp_vrf, evpn_auto_rt_import_delete_for_vrf(bgp_vrf); /* Add the newly configured RT to RT list */ - listnode_add_sort(bgp_vrf->vrf_import_rtl, ecomadd); + listnode_add_sort(bgp_vrf->vrf_import_rtl, newrt); SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD); /* map VRF to its RTs and install routes matching the new RTs */ @@ -4581,9 +4650,6 @@ void bgp_evpn_configure_import_rt_for_vrf(struct bgp *bgp_vrf, void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf, struct ecommunity *ecomdel) { - struct listnode *node = NULL, *nnode = NULL, *node_to_del = NULL; - struct ecommunity *ecom = NULL; - /* uninstall routes from vrf */ if (is_l3vni_live(bgp_vrf)) uninstall_routes_for_vrf(bgp_vrf); @@ -4591,17 +4657,8 @@ void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf, /* Cleanup the RT to VRF mapping */ bgp_evpn_unmap_vrf_from_its_rts(bgp_vrf); - /* remove the RT from the RT list */ - for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_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(bgp_vrf->vrf_import_rtl, node_to_del); + /* Remove rt */ + rt_list_remove_node(bgp_vrf->vrf_import_rtl, ecomdel, true); assert(bgp_vrf->vrf_import_rtl); /* fallback to auto import rt, if this was the last RT */ @@ -4621,11 +4678,15 @@ void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf, void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf, struct ecommunity *ecomadd) { + struct vrf_route_target *newrt; + + newrt = evpn_vrf_rt_new(ecomadd); + /* remove auto-generated RT */ evpn_auto_rt_export_delete_for_vrf(bgp_vrf); /* Add the new RT to the RT list */ - listnode_add_sort(bgp_vrf->vrf_export_rtl, ecomadd); + listnode_add_sort(bgp_vrf->vrf_export_rtl, newrt); SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_EXPORT_RT_CFGD); if (is_l3vni_live(bgp_vrf)) @@ -4635,20 +4696,8 @@ void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf, void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp *bgp_vrf, struct ecommunity *ecomdel) { - struct listnode *node = NULL, *nnode = NULL, *node_to_del = NULL; - struct ecommunity *ecom = NULL; - - /* Remove the RT from the RT list */ - for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_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(bgp_vrf->vrf_export_rtl, node_to_del); + /* Remove rt */ + rt_list_remove_node(bgp_vrf->vrf_export_rtl, ecomdel, true); /* * Temporary assert to make SA happy. @@ -5100,11 +5149,11 @@ void bgp_evpn_map_vrf_to_its_rts(struct bgp *bgp_vrf) uint32_t i = 0; struct ecommunity_val *eval = NULL; struct listnode *node = NULL, *nnode = NULL; - struct ecommunity *ecom = NULL; + struct vrf_route_target *l3rt; - for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_import_rtl, node, nnode, ecom)) { - for (i = 0; i < ecom->size; i++) { - eval = (struct ecommunity_val *)(ecom->val + for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_import_rtl, node, nnode, l3rt)) { + for (i = 0; i < l3rt->ecom->size; i++) { + eval = (struct ecommunity_val *)(l3rt->ecom->val + (i * ECOMMUNITY_SIZE)); map_vrf_to_rt(bgp_vrf, eval); @@ -5120,14 +5169,14 @@ void bgp_evpn_unmap_vrf_from_its_rts(struct bgp *bgp_vrf) uint32_t i; struct ecommunity_val *eval; struct listnode *node, *nnode; - struct ecommunity *ecom; + struct vrf_route_target *l3rt; - for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_import_rtl, node, nnode, ecom)) { - for (i = 0; i < ecom->size; i++) { + for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_import_rtl, node, nnode, l3rt)) { + for (i = 0; i < l3rt->ecom->size; i++) { struct vrf_irt_node *irt; struct ecommunity_val eval_tmp; - eval = (struct ecommunity_val *)(ecom->val + eval = (struct ecommunity_val *)(l3rt->ecom->val + (i * ECOMMUNITY_SIZE)); /* If using "automatic" RT, we only care about the @@ -6000,12 +6049,12 @@ void bgp_evpn_init(struct bgp *bgp) "BGP VRF Import RT Hash"); bgp->vrf_import_rtl = list_new(); bgp->vrf_import_rtl->cmp = - (int (*)(void *, void *))bgp_evpn_route_target_cmp; - bgp->vrf_import_rtl->del = bgp_evpn_xxport_delete_ecomm; + (int (*)(void *, void *))evpn_vrf_route_target_cmp; + bgp->vrf_import_rtl->del = evpn_vrf_rt_del; bgp->vrf_export_rtl = list_new(); bgp->vrf_export_rtl->cmp = - (int (*)(void *, void *))bgp_evpn_route_target_cmp; - bgp->vrf_export_rtl->del = bgp_evpn_xxport_delete_ecomm; + (int (*)(void *, void *))evpn_vrf_route_target_cmp; + bgp->vrf_export_rtl->del = evpn_vrf_rt_del; bgp->l2vnis = list_new(); bgp->l2vnis->cmp = vni_list_cmp; /* By default Duplicate Address Dection is enabled. diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index 64fdc29704..f8cd20f24f 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -194,6 +194,17 @@ struct evpn_remote_ip { struct list *macip_path_list; }; +/* + * Wrapper struct for l3 RT's + */ +struct vrf_route_target { + /* flags based on config to determine how RTs are handled */ + uint8_t flags; +#define BGP_VRF_RT_AUTO (1 << 0) + + struct ecommunity *ecom; +}; + static inline int is_vrf_rd_configured(struct bgp *bgp_vrf) { return (CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD)); @@ -590,7 +601,8 @@ extern struct zclient *zclient; extern void bgp_evpn_install_uninstall_default_route(struct bgp *bgp_vrf, afi_t afi, safi_t safi, bool add); -extern void evpn_rt_delete_auto(struct bgp *, vni_t, struct list *); +extern void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl, + bool is_l3); extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf, struct ecommunity *ecomadd); extern void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp *bgp_vrf, diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index a0d39c30ca..500fa6ea8d 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -373,7 +373,7 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf, char buf1[INET6_ADDRSTRLEN]; char *ecom_str; struct listnode *node, *nnode; - struct ecommunity *ecom; + struct vrf_route_target *l3rt; json_object *json_import_rtl = NULL; json_object *json_export_rtl = NULL; char buf2[ETHER_ADDR_STRLEN]; @@ -434,8 +434,8 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf, if (!json) vty_out(vty, " Import Route Target:\n"); - for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_import_rtl, node, nnode, ecom)) { - ecom_str = ecommunity_ecom2str(ecom, + for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_import_rtl, node, nnode, l3rt)) { + ecom_str = ecommunity_ecom2str(l3rt->ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); if (json) @@ -452,8 +452,8 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf, else vty_out(vty, " Export Route Target:\n"); - for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_export_rtl, node, nnode, ecom)) { - ecom_str = ecommunity_ecom2str(ecom, + for (ALL_LIST_ELEMENTS(bgp_vrf->vrf_export_rtl, node, nnode, l3rt)) { + ecom_str = ecommunity_ecom2str(l3rt->ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); if (json) @@ -928,7 +928,7 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp, char rt_buf[25]; char *ecom_str; struct listnode *node, *nnode; - struct ecommunity *ecom; + struct vrf_route_target *l3rt; if (!bgp->l3vni) return; @@ -971,8 +971,8 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp, prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN)); } - for (ALL_LIST_ELEMENTS(bgp->vrf_import_rtl, node, nnode, ecom)) { - ecom_str = ecommunity_ecom2str(ecom, + for (ALL_LIST_ELEMENTS(bgp->vrf_import_rtl, node, nnode, l3rt)) { + ecom_str = ecommunity_ecom2str(l3rt->ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); if (json) { @@ -999,8 +999,8 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp, if (json) json_object_object_add(json_vni, "importRTs", json_import_rtl); - for (ALL_LIST_ELEMENTS(bgp->vrf_export_rtl, node, nnode, ecom)) { - ecom_str = ecommunity_ecom2str(ecom, + for (ALL_LIST_ELEMENTS(bgp->vrf_export_rtl, node, nnode, l3rt)) { + ecom_str = ecommunity_ecom2str(l3rt->ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); if (json) { @@ -2009,12 +2009,12 @@ DEFUN(no_evpnrt5_network, static void evpn_import_rt_delete_auto(struct bgp *bgp, struct bgpevpn *vpn) { - evpn_rt_delete_auto(bgp, vpn->vni, vpn->import_rtl); + evpn_rt_delete_auto(bgp, vpn->vni, vpn->import_rtl, false); } static void evpn_export_rt_delete_auto(struct bgp *bgp, struct bgpevpn *vpn) { - evpn_rt_delete_auto(bgp, vpn->vni, vpn->export_rtl); + evpn_rt_delete_auto(bgp, vpn->vni, vpn->export_rtl, false); } /* @@ -5698,18 +5698,35 @@ DEFUN (no_bgp_evpn_vni_rd_without_val, * 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 bool bgp_evpn_rt_matches_existing(struct list *rtl, + struct ecommunity *ecomtarget) { - struct listnode *node, *nnode; + struct listnode *node; struct ecommunity *ecom; - for (ALL_LIST_ELEMENTS(rtl, node, nnode, ecom)) { + for (ALL_LIST_ELEMENTS_RO(rtl, node, ecom)) { if (ecommunity_match(ecom, ecomtarget)) - return 1; + return true; } - return 0; + return false; +} + +/* + * L3 RT version of above. + */ +static bool bgp_evpn_vrf_rt_matches_existing(struct list *rtl, + struct ecommunity *ecomtarget) +{ + struct listnode *node; + struct vrf_route_target *l3rt; + + for (ALL_LIST_ELEMENTS_RO(rtl, node, l3rt)) { + if (ecommunity_match(l3rt->ecom, ecomtarget)) + return true; + } + + return false; } /* display L3VNI related info for a VRF instance */ @@ -5730,7 +5747,7 @@ DEFUN (show_bgp_vrf_l3vni_info, struct bgp *bgp = NULL; struct listnode *node = NULL; struct bgpevpn *vpn = NULL; - struct ecommunity *ecom = NULL; + struct vrf_route_target *l3rt; json_object *json = NULL; json_object *json_vnis = NULL; json_object *json_export_rts = NULL; @@ -5780,13 +5797,13 @@ DEFUN (show_bgp_vrf_l3vni_info, vty_out(vty, "\n"); vty_out(vty, " Export-RTs:\n"); vty_out(vty, " "); - for (ALL_LIST_ELEMENTS_RO(bgp->vrf_export_rtl, node, ecom)) - vty_out(vty, "%s ", ecommunity_str(ecom)); + for (ALL_LIST_ELEMENTS_RO(bgp->vrf_export_rtl, node, l3rt)) + vty_out(vty, "%s ", ecommunity_str(l3rt->ecom)); vty_out(vty, "\n"); vty_out(vty, " Import-RTs:\n"); vty_out(vty, " "); - for (ALL_LIST_ELEMENTS_RO(bgp->vrf_import_rtl, node, ecom)) - vty_out(vty, "%s ", ecommunity_str(ecom)); + for (ALL_LIST_ELEMENTS_RO(bgp->vrf_import_rtl, node, l3rt)) + vty_out(vty, "%s ", ecommunity_str(l3rt->ecom)); vty_out(vty, "\n"); vty_out(vty, " RD: %s\n", prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN)); @@ -5811,17 +5828,19 @@ DEFUN (show_bgp_vrf_l3vni_info, json_object_object_add(json, "l2vnis", json_vnis); /* export rts */ - for (ALL_LIST_ELEMENTS_RO(bgp->vrf_export_rtl, node, ecom)) + for (ALL_LIST_ELEMENTS_RO(bgp->vrf_export_rtl, node, l3rt)) json_object_array_add( json_export_rts, - json_object_new_string(ecommunity_str(ecom))); + json_object_new_string( + ecommunity_str(l3rt->ecom))); json_object_object_add(json, "export-rts", json_export_rts); /* import rts */ - for (ALL_LIST_ELEMENTS_RO(bgp->vrf_import_rtl, node, ecom)) + for (ALL_LIST_ELEMENTS_RO(bgp->vrf_import_rtl, node, l3rt)) json_object_array_add( json_import_rts, - json_object_new_string(ecommunity_str(ecom))); + json_object_new_string( + ecommunity_str(l3rt->ecom))); json_object_object_add(json, "import-rts", json_import_rts); json_object_string_add( json, "rd", @@ -5837,12 +5856,14 @@ static int add_rt(struct bgp *bgp, struct ecommunity *ecom, bool is_import) { /* Do nothing if we already have this route-target */ if (is_import) { - if (!bgp_evpn_rt_matches_existing(bgp->vrf_import_rtl, ecom)) + if (!bgp_evpn_vrf_rt_matches_existing(bgp->vrf_import_rtl, + ecom)) bgp_evpn_configure_import_rt_for_vrf(bgp, ecom); else return -1; } else { - if (!bgp_evpn_rt_matches_existing(bgp->vrf_export_rtl, ecom)) + if (!bgp_evpn_vrf_rt_matches_existing(bgp->vrf_export_rtl, + ecom)) bgp_evpn_configure_export_rt_for_vrf(bgp, ecom); else return -1; @@ -5855,12 +5876,14 @@ static int del_rt(struct bgp *bgp, struct ecommunity *ecom, bool is_import) { /* Verify we already have this route-target */ if (is_import) { - if (!bgp_evpn_rt_matches_existing(bgp->vrf_import_rtl, ecom)) + if (!bgp_evpn_vrf_rt_matches_existing(bgp->vrf_import_rtl, + ecom)) return -1; bgp_evpn_unconfigure_import_rt_for_vrf(bgp, ecom); } else { - if (!bgp_evpn_rt_matches_existing(bgp->vrf_export_rtl, ecom)) + if (!bgp_evpn_vrf_rt_matches_existing(bgp->vrf_export_rtl, + ecom)) return -1; bgp_evpn_unconfigure_export_rt_for_vrf(bgp, ecom); @@ -6532,12 +6555,12 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi, if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_IMPORT_RT_CFGD)) { char *ecom_str; struct listnode *node, *nnode; - struct ecommunity *ecom; + struct vrf_route_target *l3rt; for (ALL_LIST_ELEMENTS(bgp->vrf_import_rtl, node, nnode, - ecom)) { + l3rt)) { ecom_str = ecommunity_ecom2str( - ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + l3rt->ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); vty_out(vty, " route-target import %s\n", ecom_str); XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); } @@ -6547,12 +6570,12 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi, if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_EXPORT_RT_CFGD)) { char *ecom_str; struct listnode *node, *nnode; - struct ecommunity *ecom; + struct vrf_route_target *l3rt; for (ALL_LIST_ELEMENTS(bgp->vrf_export_rtl, node, nnode, - ecom)) { + l3rt)) { ecom_str = ecommunity_ecom2str( - ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + l3rt->ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); vty_out(vty, " route-target export %s\n", ecom_str); XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); } |
