struct bgp_path_info *local_pi = NULL;
local_pi = NULL;
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
struct bgp_path_info *local_pi;
local_pi = NULL;
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
evp = (struct prefix_evpn *)&rn->p;
/* locate the local and remote entries if any */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
remote_pi = tmp_pi;
}
- /* we don't expect to see a remote_pi at this point.
+ /* we don't expect to see a remote_ri at this point.
* An ES route has esi + vtep_ip as the key,
* We shouldn't see the same route from any other vtep.
*/
*route_changed = 0;
/* locate the local route entry if any */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp_def->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
/* See if this is an update of an existing route, or a new add. */
local_pi = NULL;
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
bgp_path_info_reap(rn, local_pi);
/* tell zebra to re-add the best remote path */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn);
+ tmp_pi; tmp_pi = tmp_pi->next) {
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_SELECTED)) {
curr_select = tmp_pi;
break;
*pi = NULL;
/* Now, find matching route. */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next)
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next)
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
continue;
/* Identify local route. */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
safi = SAFI_EVPN;
rdrn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd);
- if (rdrn && rdrn->info) {
- table = (struct bgp_table *)rdrn->info;
+ if (rdrn && bgp_node_has_bgp_path_info_data(rdrn)) {
+ table = bgp_node_get_bgp_table_info(rdrn);
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
/* Walk this ES's route table and delete all routes. */
for (rn = bgp_table_top(es->route_table); rn;
rn = bgp_route_next(rn)) {
- for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
+ for (pi = bgp_node_get_bgp_path_info(rn);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
bgp_path_info_delete(rn, pi);
bgp_path_info_reap(rn, pi);
}
/* Walk this VNI's route table and delete all routes. */
for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(rn)) {
- for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
+ for (pi = bgp_node_get_bgp_path_info(rn);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
bgp_path_info_delete(rn, pi);
bgp_path_info_reap(rn, pi);
}
rn = bgp_node_get(es->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
/* Check if route entry is already present. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
&attr_new->mp_nexthop_global)))
SET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED);
+ bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED);
/* Unintern existing, set to new. */
bgp_attr_unintern(&pi->attr);
pi->attr = attr_new;
rn = bgp_node_get(vpn->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
return 0;
/* Find matching route entry. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
return 0;
/* Find matching route entry. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
return 0;
/* Find matching route entry. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
*/
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);
+ table = bgp_node_get_bgp_table_info(rd_rn);
if (!table)
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/*
* Consider "valid" remote routes applicable for
* this ES.
*/
for (rd_rn = bgp_table_top(bgp_def->rib[afi][safi]); rd_rn;
rd_rn = bgp_route_next(rd_rn)) {
- table = (struct bgp_table *)(rd_rn->info);
+ table = bgp_node_get_bgp_table_info(rd_rn);
if (!table)
continue;
|| is_evpn_prefix_ipaddr_v6(evp)))
continue;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VRF.
*/
/* EVPN routes are a 2-level table. */
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);
+ table = bgp_node_get_bgp_table_info(rd_rn);
if (!table)
continue;
if (evp->prefix.route_type != rtype)
continue;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VNI. */
if (!(CHECK_FLAG(pi->flags, BGP_PATH_VALID)
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!rn) /* unexpected */
return 0;
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self &&
pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self
&& pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
/* Only care about "selected" routes - non-imported. */
/* TODO: Support for AddPath for EVPN. */
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& (!pi->extra || !pi->extra->parent)) {
bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p,
* attribute. Also, we only consider "non-imported" routes.
* TODO: Support for AddPath for EVPN.
*/
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& (!pi->extra || !pi->extra->parent)) {
/* EVPN routes are a 2-level table. */
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);
+ table = bgp_node_get_bgp_table_info(rd_rn);
if (!table)
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VNI. */
if (filter)
SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY);
- /* auto derive RD/RT */
+ /* Map auto derive or configured RTs */
if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD))
evpn_auto_rt_import_add_for_vrf(bgp_vrf);
+ else
+ bgp_evpn_map_vrf_to_its_rts(bgp_vrf);
+
if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_EXPORT_RT_CFGD))
evpn_auto_rt_export_add_for_vrf(bgp_vrf);
+
+ /* auto derive RD */
bgp_evpn_derive_auto_rd_for_vrf(bgp_vrf);
/* link all corresponding l2vnis */
/* remove the Rmac from the BGP vrf */
memset(&bgp_vrf->rmac, 0, sizeof(struct ethaddr));
- /* delete RD/RT */
+ /* remove default import RT or Unmap non-default import RT */
if (!list_isempty(bgp_vrf->vrf_import_rtl)) {
bgp_evpn_unmap_vrf_from_its_rts(bgp_vrf);
- list_delete_all_node(bgp_vrf->vrf_import_rtl);
+ if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD))
+ list_delete_all_node(bgp_vrf->vrf_import_rtl);
}
- if (!list_isempty(bgp_vrf->vrf_export_rtl)) {
+
+ /* remove default export RT */
+ if (!list_isempty(bgp_vrf->vrf_export_rtl) &&
+ !CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_EXPORT_RT_CFGD)) {
list_delete_all_node(bgp_vrf->vrf_export_rtl);
}