From 40381db7854c8c9bf7f6e37affc625aaf36131c7 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 2 Oct 2018 20:43:07 -0400 Subject: [PATCH] bgpd: Rename various variable names to something more appropriate ri -> pi bi -> bpi info -> path info -> rmap_path ( for routemap applications ) Signed-off-by: Donald Sharp --- bgpd/bgp_dump.c | 20 +- bgpd/bgp_evpn.c | 759 +++++++++++---------- bgpd/bgp_evpn_vty.c | 58 +- bgpd/bgp_flowspec_vty.c | 8 +- bgpd/bgp_label.c | 18 +- bgpd/bgp_label.h | 8 +- bgpd/bgp_mpath.c | 74 ++- bgpd/bgp_mpath.h | 4 +- bgpd/bgp_mplsvpn.c | 292 ++++---- bgpd/bgp_mplsvpn.h | 8 +- bgpd/bgp_nht.c | 44 +- bgpd/bgp_pbr.c | 8 +- bgpd/bgp_route.c | 1174 +++++++++++++++++---------------- bgpd/bgp_route.h | 12 +- bgpd/bgp_routemap.c | 30 +- bgpd/bgp_updgrp.c | 4 +- bgpd/bgp_updgrp.h | 6 +- bgpd/bgp_updgrp_adv.c | 34 +- bgpd/bgp_zebra.c | 105 ++- bgpd/rfapi/rfapi.c | 104 +-- bgpd/rfapi/rfapi_backend.h | 2 +- bgpd/rfapi/rfapi_import.c | 849 ++++++++++++------------ bgpd/rfapi/rfapi_import.h | 22 +- bgpd/rfapi/rfapi_monitor.c | 12 +- bgpd/rfapi/rfapi_monitor.h | 4 +- bgpd/rfapi/rfapi_rib.c | 62 +- bgpd/rfapi/rfapi_rib.h | 2 +- bgpd/rfapi/rfapi_vty.c | 185 +++--- bgpd/rfapi/vnc_export_bgp.c | 58 +- bgpd/rfapi/vnc_export_bgp_p.h | 4 +- bgpd/rfapi/vnc_import_bgp.c | 437 ++++++------ bgpd/rfapi/vnc_import_bgp.h | 4 +- bgpd/rfapi/vnc_import_bgp_p.h | 8 +- 33 files changed, 2216 insertions(+), 2203 deletions(-) diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 689b174013..3d1880ca48 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -301,7 +301,7 @@ static void bgp_dump_routes_index_table(struct bgp *bgp) static struct bgp_path_info * bgp_dump_route_node_record(int afi, struct bgp_node *rn, - struct bgp_path_info *info, unsigned int seq) + struct bgp_path_info *path, unsigned int seq) { struct stream *obuf; size_t sizep; @@ -349,18 +349,18 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn, stream_putw(obuf, 0); endp = stream_get_endp(obuf); - for (; info; info = info->next) { + for (; path; path = path->next) { size_t cur_endp; /* Peer index */ - stream_putw(obuf, info->peer->table_dump_index); + stream_putw(obuf, path->peer->table_dump_index); /* Originated */ - stream_putl(obuf, time(NULL) - (bgp_clock() - info->uptime)); + stream_putl(obuf, time(NULL) - (bgp_clock() - path->uptime)); /* Dump attribute. */ /* Skip prefix & AFI/SAFI for MP_NLRI */ - bgp_dump_routes_attr(obuf, info->attr, &rn->p); + bgp_dump_routes_attr(obuf, path->attr, &rn->p); cur_endp = stream_get_endp(obuf); if (cur_endp > BGP_MAX_PACKET_SIZE + BGP_DUMP_MSG_HEADER @@ -379,7 +379,7 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn, bgp_dump_set_size(obuf, MSG_TABLE_DUMP_V2); fwrite(STREAM_DATA(obuf), stream_get_endp(obuf), 1, bgp_dump_routes.fp); - return info; + return path; } @@ -387,7 +387,7 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn, static unsigned int bgp_dump_routes_func(int afi, int first_run, unsigned int seq) { - struct bgp_path_info *info; + struct bgp_path_info *path; struct bgp_node *rn; struct bgp *bgp; struct bgp_table *table; @@ -410,9 +410,9 @@ static unsigned int bgp_dump_routes_func(int afi, int first_run, table = bgp->rib[afi][SAFI_UNICAST]; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { - info = rn->info; - while (info) { - info = bgp_dump_route_node_record(afi, rn, info, seq); + path = rn->info; + while (path) { + path = bgp_dump_route_node_record(afi, rn, path, seq); seq++; } } diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 377bf1ad2a..259e6465c4 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -62,7 +62,7 @@ DEFINE_QOBJ_TYPE(evpnes) */ static void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi, struct bgp_node *rn, - struct bgp_path_info **ri); + struct bgp_path_info **pi); static int delete_all_vni_routes(struct bgp *bgp, struct bgpevpn *vpn); /* @@ -916,7 +916,7 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn, struct bgp_path_info *old_local) { struct bgp_node *global_rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; @@ -928,12 +928,12 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn, (struct prefix *)&rn->p, &vpn->prd); if (global_rn) { /* Delete route entry in the global EVPN table. */ - delete_evpn_route_entry(bgp, afi, safi, global_rn, &ri); + delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi); /* Schedule for processing - withdraws to peers happen from * this table. */ - if (ri) + if (pi) bgp_process(bgp, global_rn, afi, safi); bgp_unlock_node(global_rn); } @@ -1216,21 +1216,21 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn, */ static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_node *rn) { - struct bgp_path_info *tmp_ri = NULL; - struct bgp_path_info *local_ri = NULL; + struct bgp_path_info *tmp_pi = NULL; + struct bgp_path_info *local_pi = NULL; - local_ri = NULL; - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { - if (tmp_ri->peer == bgp->peer_self - && tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_STATIC) - local_ri = tmp_ri; + local_pi = NULL; + for (tmp_pi = rn->info; 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) + local_pi = tmp_pi; } - if (!local_ri) + if (!local_pi) return 0; - return local_ri->attr->default_gw; + return local_pi->attr->default_gw; } @@ -1239,21 +1239,21 @@ static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_node *rn) */ static int evpn_route_is_sticky(struct bgp *bgp, struct bgp_node *rn) { - struct bgp_path_info *tmp_ri; - struct bgp_path_info *local_ri; + struct bgp_path_info *tmp_pi; + struct bgp_path_info *local_pi; - local_ri = NULL; - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { - if (tmp_ri->peer == bgp->peer_self - && tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_STATIC) - local_ri = tmp_ri; + local_pi = NULL; + for (tmp_pi = rn->info; 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) + local_pi = tmp_pi; } - if (!local_ri) + if (!local_pi) return 0; - return local_ri->attr->sticky; + return local_pi->attr->sticky; } /* @@ -1269,9 +1269,9 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es, { char buf[ESI_STR_LEN]; char buf1[INET6_ADDRSTRLEN]; - struct bgp_path_info *tmp_ri = NULL; - struct bgp_path_info *local_ri = NULL; /* local route entry if any */ - struct bgp_path_info *remote_ri = NULL; /* remote route entry if any */ + struct bgp_path_info *tmp_pi = NULL; + struct bgp_path_info *local_pi = NULL; /* local route entry if any */ + struct bgp_path_info *remote_pi = NULL; /* remote route entry if any */ struct attr *attr_new = NULL; struct prefix_evpn *evp = NULL; @@ -1280,22 +1280,22 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es, evp = (struct prefix_evpn *)&rn->p; /* locate the local and remote entries if any */ - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { - if (tmp_ri->peer == bgp->peer_self && - tmp_ri->type == ZEBRA_ROUTE_BGP && - tmp_ri->sub_type == BGP_ROUTE_STATIC) - local_ri = tmp_ri; - if (tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_IMPORTED - && CHECK_FLAG(tmp_ri->flags, BGP_PATH_VALID)) - remote_ri = tmp_ri; - } - - /* we don't expect to see a remote_ri at this point. + for (tmp_pi = rn->info; 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) + local_pi = tmp_pi; + if (tmp_pi->type == ZEBRA_ROUTE_BGP + && tmp_pi->sub_type == BGP_ROUTE_IMPORTED + && CHECK_FLAG(tmp_pi->flags, BGP_PATH_VALID)) + remote_pi = tmp_pi; + } + + /* we don't expect to see a remote_pi at this point. * An ES route has esi + vtep_ip as the key, * We shouldn't see the same route from any other vtep. */ - if (remote_ri) { + if (remote_pi) { flog_err( EC_BGP_ES_INVALID, "%u ERROR: local es route for ESI: %s Vtep %s also learnt from remote", @@ -1305,47 +1305,47 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es, return -1; } - if (!local_ri && !add) + if (!local_pi && !add) return 0; /* create or update the entry */ - if (!local_ri) { + if (!local_pi) { /* Add or update attribute to hash */ attr_new = bgp_attr_intern(attr); /* Create new route with its attribute. */ - tmp_ri = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, - 0, bgp->peer_self, attr_new, rn); - SET_FLAG(tmp_ri->flags, BGP_PATH_VALID); + tmp_pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, + bgp->peer_self, attr_new, rn); + SET_FLAG(tmp_pi->flags, BGP_PATH_VALID); /* add the newly created path to the route-node */ - bgp_path_info_add(rn, tmp_ri); + bgp_path_info_add(rn, tmp_pi); } else { - tmp_ri = local_ri; - if (attrhash_cmp(tmp_ri->attr, attr) - && !CHECK_FLAG(tmp_ri->flags, BGP_PATH_REMOVED)) + tmp_pi = local_pi; + if (attrhash_cmp(tmp_pi->attr, attr) + && !CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED)) *route_changed = 0; else { /* The attribute has changed. * Add (or update) attribute to hash. */ attr_new = bgp_attr_intern(attr); - bgp_path_info_set_flag(rn, tmp_ri, + bgp_path_info_set_flag(rn, tmp_pi, BGP_PATH_ATTR_CHANGED); /* Restore route, if needed. */ - if (CHECK_FLAG(tmp_ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, tmp_ri); + if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, tmp_pi); /* Unintern existing, set to new. */ - bgp_attr_unintern(&tmp_ri->attr); - tmp_ri->attr = attr_new; - tmp_ri->uptime = bgp_clock(); + bgp_attr_unintern(&tmp_pi->attr); + tmp_pi->attr = attr_new; + tmp_pi->uptime = bgp_clock(); } } /* Return back the route entry. */ - *ri = tmp_ri; + *ri = tmp_pi; return 0; } @@ -1363,7 +1363,7 @@ static int update_evpn_type4_route(struct bgp *bgp, struct attr attr; struct attr *attr_new = NULL; struct bgp_node *rn = NULL; - struct bgp_path_info *ri = NULL; + struct bgp_path_info *pi = NULL; memset(&attr, 0, sizeof(struct attr)); @@ -1381,9 +1381,8 @@ static int update_evpn_type4_route(struct bgp *bgp, rn = bgp_node_get(es->route_table, (struct prefix *)p); /* Create or update route entry. */ - ret = update_evpn_type4_route_entry(bgp, es, afi, safi, rn, - &attr, 1, &ri, - &route_changed); + ret = update_evpn_type4_route_entry(bgp, es, afi, safi, rn, &attr, 1, + &pi, &route_changed); if (ret != 0) { flog_err(EC_BGP_ES_INVALID, "%u ERROR: Failed to updated ES route ESI: %s VTEP %s", @@ -1392,8 +1391,8 @@ static int update_evpn_type4_route(struct bgp *bgp, ipaddr2str(&es->originator_ip, buf1, sizeof(buf1))); } - assert(ri); - attr_new = ri->attr; + assert(pi); + attr_new = pi->attr; /* Perform route selection; * this is just to set the flags correctly @@ -1408,14 +1407,12 @@ static int update_evpn_type4_route(struct bgp *bgp, * Prefix-level) similar to L3VPN routes. */ if (route_changed) { - struct bgp_path_info *global_ri; + struct bgp_path_info *global_pi; rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, (struct prefix *)p, &es->prd); - update_evpn_type4_route_entry(bgp, es, afi, safi, - rn, attr_new, - 1, &global_ri, - &route_changed); + update_evpn_type4_route_entry(bgp, es, afi, safi, rn, attr_new, + 1, &global_pi, &route_changed); /* Schedule for processing and unlock node. */ bgp_process(bgp, rn, afi, safi); @@ -1433,25 +1430,25 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def, struct attr *attr, int *route_changed) { struct attr *attr_new = NULL; - struct bgp_path_info *ri = NULL; + struct bgp_path_info *pi = NULL; mpls_label_t label = MPLS_INVALID_LABEL; - struct bgp_path_info *local_ri = NULL; - struct bgp_path_info *tmp_ri = NULL; + struct bgp_path_info *local_pi = NULL; + struct bgp_path_info *tmp_pi = NULL; *route_changed = 0; /* locate the local route entry if any */ - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { - if (tmp_ri->peer == bgp_def->peer_self - && tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_STATIC) - local_ri = tmp_ri; + for (tmp_pi = rn->info; 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) + local_pi = tmp_pi; } /* * create a new route entry if one doesnt exist. * Otherwise see if route attr has changed */ - if (!local_ri) { + if (!local_pi) { /* route has changed as this is the first entry */ *route_changed = 1; @@ -1460,22 +1457,22 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def, attr_new = bgp_attr_intern(attr); /* create the route info from attribute */ - ri = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, + pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp_def->peer_self, attr_new, rn); - SET_FLAG(ri->flags, BGP_PATH_VALID); + SET_FLAG(pi->flags, BGP_PATH_VALID); /* Type-5 routes advertise the L3-VNI */ - bgp_path_info_extra_get(ri); + bgp_path_info_extra_get(pi); vni2label(bgp_vrf->l3vni, &label); - memcpy(&ri->extra->label, &label, sizeof(label)); - ri->extra->num_labels = 1; + memcpy(&pi->extra->label, &label, sizeof(label)); + pi->extra->num_labels = 1; /* add the route entry to route node*/ - bgp_path_info_add(rn, ri); + bgp_path_info_add(rn, pi); } else { - tmp_ri = local_ri; - if (!attrhash_cmp(tmp_ri->attr, attr)) { + tmp_pi = local_pi; + if (!attrhash_cmp(tmp_pi->attr, attr)) { /* attribute changed */ *route_changed = 1; @@ -1483,17 +1480,17 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def, /* The attribute has changed. */ /* Add (or update) attribute to hash. */ attr_new = bgp_attr_intern(attr); - bgp_path_info_set_flag(rn, tmp_ri, + bgp_path_info_set_flag(rn, tmp_pi, BGP_PATH_ATTR_CHANGED); /* Restore route, if needed. */ - if (CHECK_FLAG(tmp_ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, tmp_ri); + if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, tmp_pi); /* Unintern existing, set to new. */ - bgp_attr_unintern(&tmp_ri->attr); - tmp_ri->attr = attr_new; - tmp_ri->uptime = bgp_clock(); + bgp_attr_unintern(&tmp_pi->attr); + tmp_pi->attr = attr_new; + tmp_pi->uptime = bgp_clock(); } } return 0; @@ -1560,11 +1557,11 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp, static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, afi_t afi, safi_t safi, struct bgp_node *rn, struct attr *attr, int add, - struct bgp_path_info **ri, uint8_t flags, + struct bgp_path_info **pi, uint8_t flags, uint32_t seq) { - struct bgp_path_info *tmp_ri; - struct bgp_path_info *local_ri; + struct bgp_path_info *tmp_pi; + struct bgp_path_info *local_pi; struct attr *attr_new; mpls_label_t label[BGP_MAX_LABELS]; uint32_t num_labels = 1; @@ -1572,31 +1569,31 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, uint8_t sticky = 0; struct prefix_evpn *evp; - *ri = NULL; + *pi = NULL; evp = (struct prefix_evpn *)&rn->p; memset(&label, 0, sizeof(label)); /* See if this is an update of an existing route, or a new add. */ - local_ri = NULL; - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { - if (tmp_ri->peer == bgp->peer_self - && tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_STATIC) - local_ri = tmp_ri; + local_pi = NULL; + for (tmp_pi = rn->info; 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) + local_pi = tmp_pi; } /* If route doesn't exist already, create a new one, if told to. * Otherwise act based on whether the attributes of the route have * changed or not. */ - if (!local_ri && !add) + if (!local_pi && !add) return 0; /* For non-GW MACs, update MAC mobility seq number, if needed. */ if (seq && !CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW)) add_mac_mobility_to_attr(seq, attr); - if (!local_ri) { + if (!local_pi) { /* Add (or update) attribute to hash. */ attr_new = bgp_attr_intern(attr); @@ -1606,10 +1603,10 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, attr_new->sticky = sticky; /* Create new route with its attribute. */ - tmp_ri = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, + tmp_pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new, rn); - SET_FLAG(tmp_ri->flags, BGP_PATH_VALID); - bgp_path_info_extra_get(tmp_ri); + SET_FLAG(tmp_pi->flags, BGP_PATH_VALID); + bgp_path_info_extra_get(tmp_pi); /* The VNI goes into the 'label' field of the route */ vni2label(vpn->vni, &label[0]); @@ -1629,13 +1626,13 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, } } - memcpy(&tmp_ri->extra->label, label, sizeof(label)); - tmp_ri->extra->num_labels = num_labels; - bgp_path_info_add(rn, tmp_ri); + memcpy(&tmp_pi->extra->label, label, sizeof(label)); + tmp_pi->extra->num_labels = num_labels; + bgp_path_info_add(rn, tmp_pi); } else { - tmp_ri = local_ri; - if (attrhash_cmp(tmp_ri->attr, attr) - && !CHECK_FLAG(tmp_ri->flags, BGP_PATH_REMOVED)) + tmp_pi = local_pi; + if (attrhash_cmp(tmp_pi->attr, attr) + && !CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED)) route_change = 0; else { /* @@ -1654,13 +1651,13 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, num_labels++; } } - memcpy(&tmp_ri->extra->label, label, sizeof(label)); - tmp_ri->extra->num_labels = num_labels; + memcpy(&tmp_pi->extra->label, label, sizeof(label)); + tmp_pi->extra->num_labels = num_labels; /* The attribute has changed. */ /* Add (or update) attribute to hash. */ attr_new = bgp_attr_intern(attr); - bgp_path_info_set_flag(rn, tmp_ri, + bgp_path_info_set_flag(rn, tmp_pi, BGP_PATH_ATTR_CHANGED); /* Extract MAC mobility sequence number, if any. */ @@ -1669,18 +1666,18 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, attr_new->sticky = sticky; /* Restore route, if needed. */ - if (CHECK_FLAG(tmp_ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, tmp_ri); + if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, tmp_pi); /* Unintern existing, set to new. */ - bgp_attr_unintern(&tmp_ri->attr); - tmp_ri->attr = attr_new; - tmp_ri->uptime = bgp_clock(); + bgp_attr_unintern(&tmp_pi->attr); + tmp_pi->attr = attr_new; + tmp_pi->uptime = bgp_clock(); } } /* Return back the route entry. */ - *ri = tmp_ri; + *pi = tmp_pi; return route_change; } @@ -1696,7 +1693,7 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, struct attr attr; struct attr *attr_new; int add_l3_ecomm = 0; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; int route_change; @@ -1742,9 +1739,9 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, /* Create or update route entry. */ route_change = update_evpn_route_entry(bgp, vpn, afi, safi, rn, &attr, - 1, &ri, flags, seq); - assert(ri); - attr_new = ri->attr; + 1, &pi, flags, seq); + assert(pi); + attr_new = pi->attr; /* Perform route selection; this is just to set the flags correctly * as local route in the VNI always wins. @@ -1758,12 +1755,12 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, * Prefix-level) similar to L3VPN routes. */ if (route_change) { - struct bgp_path_info *global_ri; + struct bgp_path_info *global_pi; rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, (struct prefix *)p, &vpn->prd); update_evpn_route_entry(bgp, vpn, afi, safi, rn, attr_new, 1, - &global_ri, flags, seq); + &global_pi, flags, seq); /* Schedule for processing and unlock node. */ bgp_process(bgp, rn, afi, safi); @@ -1782,24 +1779,24 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, */ static void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi, struct bgp_node *rn, - struct bgp_path_info **ri) + struct bgp_path_info **pi) { - struct bgp_path_info *tmp_ri; + struct bgp_path_info *tmp_pi; - *ri = NULL; + *pi = NULL; /* Now, find matching route. */ - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) - if (tmp_ri->peer == bgp->peer_self - && tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_STATIC) + for (tmp_pi = rn->info; 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) break; - *ri = tmp_ri; + *pi = tmp_pi; /* Mark route for delete. */ - if (tmp_ri) - bgp_path_info_delete(rn, tmp_ri); + if (tmp_pi) + bgp_path_info_delete(rn, tmp_pi); } @@ -1811,7 +1808,7 @@ static int delete_evpn_type4_route(struct bgp *bgp, { afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_node *rn = NULL; /* rn in esi table */ struct bgp_node *global_rn = NULL; /* rn in global table */ @@ -1831,13 +1828,12 @@ static int delete_evpn_type4_route(struct bgp *bgp, if (global_rn) { /* Delete route entry in the global EVPN table. */ - delete_evpn_route_entry(bgp, afi, safi, - global_rn, &ri); + delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi); /* Schedule for processing - withdraws to peers happen from * this table. */ - if (ri) + if (pi) bgp_process(bgp, global_rn, afi, safi); bgp_unlock_node(global_rn); } @@ -1846,9 +1842,9 @@ static int delete_evpn_type4_route(struct bgp *bgp, * Delete route entry in the ESI route table. * This can just be removed. */ - delete_evpn_route_entry(bgp, afi, safi, rn, &ri); - if (ri) - bgp_path_info_reap(rn, ri); + delete_evpn_route_entry(bgp, afi, safi, rn, &pi); + if (pi) + bgp_path_info_reap(rn, pi); bgp_unlock_node(rn); return 0; } @@ -1859,7 +1855,7 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp) afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; struct bgp_node *rn = NULL; - struct bgp_path_info *ri = NULL; + struct bgp_path_info *pi = NULL; struct bgp *bgp_def = NULL; /* default bgp instance */ bgp_def = bgp_get_default(); @@ -1872,8 +1868,8 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp) if (!rn) return 0; - delete_evpn_route_entry(bgp_def, afi, safi, rn, &ri); - if (ri) + delete_evpn_route_entry(bgp_def, afi, safi, rn, &pi); + if (pi) bgp_process(bgp_def, rn, afi, safi); bgp_unlock_node(rn); return 0; @@ -1887,7 +1883,7 @@ static int delete_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, struct prefix_evpn *p) { struct bgp_node *rn, *global_rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; @@ -1908,21 +1904,21 @@ static int delete_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, (struct prefix *)p, &vpn->prd); if (global_rn) { /* Delete route entry in the global EVPN table. */ - delete_evpn_route_entry(bgp, afi, safi, global_rn, &ri); + delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi); /* Schedule for processing - withdraws to peers happen from * this table. */ - if (ri) + if (pi) bgp_process(bgp, global_rn, afi, safi); bgp_unlock_node(global_rn); } /* Delete route entry in the VNI route table. This can just be removed. */ - delete_evpn_route_entry(bgp, afi, safi, rn, &ri); - if (ri) - bgp_path_info_reap(rn, ri); + delete_evpn_route_entry(bgp, afi, safi, rn, &pi); + if (pi) + bgp_path_info_reap(rn, pi); bgp_unlock_node(rn); return 0; @@ -1937,7 +1933,7 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) afi_t afi; safi_t safi; struct bgp_node *rn; - struct bgp_path_info *ri, *tmp_ri; + struct bgp_path_info *pi, *tmp_pi; struct attr attr; struct attr *attr_new; uint32_t seq; @@ -1953,20 +1949,20 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) rn = bgp_route_next(rn)) { struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; struct bgp_node *rd_rn; - struct bgp_path_info *global_ri; + struct bgp_path_info *global_pi; if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) continue; /* Identify local route. */ - for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { - if (tmp_ri->peer == bgp->peer_self - && tmp_ri->type == ZEBRA_ROUTE_BGP - && tmp_ri->sub_type == BGP_ROUTE_STATIC) + for (tmp_pi = rn->info; 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) break; } - if (!tmp_ri) + if (!tmp_pi) continue; /* @@ -2001,25 +1997,25 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) /* Set up extended community. */ build_evpn_route_extcomm(vpn, &attr, add_l3_ecomm); - seq = mac_mobility_seqnum(tmp_ri->attr); + seq = mac_mobility_seqnum(tmp_pi->attr); /* Update the route entry. */ - update_evpn_route_entry(bgp, vpn, afi, safi, rn, - &attr, 0, &ri, 0, seq); + update_evpn_route_entry(bgp, vpn, afi, safi, rn, &attr, 0, &pi, + 0, seq); /* Perform route selection; this is just to set the flags * correctly as local route in the VNI always wins. */ evpn_route_select_install(bgp, vpn, rn); - attr_new = ri->attr; + attr_new = pi->attr; /* Update route in global routing table. */ rd_rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, (struct prefix *)evp, &vpn->prd); assert(rd_rn); update_evpn_route_entry(bgp, vpn, afi, safi, rd_rn, attr_new, 0, - &global_ri, 0, + &global_pi, 0, mac_mobility_seqnum(attr_new)); /* Schedule for processing and unlock node. */ @@ -2044,7 +2040,7 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) safi_t safi; struct bgp_node *rdrn, *rn; struct bgp_table *table; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi = AFI_L2VPN; safi = SAFI_EVPN; @@ -2058,8 +2054,8 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) continue; - delete_evpn_route_entry(bgp, afi, safi, rn, &ri); - if (ri) + delete_evpn_route_entry(bgp, afi, safi, rn, &pi); + if (pi) bgp_process(bgp, rn, afi, safi); } } @@ -2080,7 +2076,7 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) afi_t afi; safi_t safi; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi = AFI_L2VPN; safi = SAFI_EVPN; @@ -2099,11 +2095,11 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) continue; - delete_evpn_route_entry(bgp, afi, safi, rn, &ri); + delete_evpn_route_entry(bgp, afi, safi, rn, &pi); /* Route entry in local table gets deleted immediately. */ - if (ri) - bgp_path_info_reap(rn, ri); + if (pi) + bgp_path_info_reap(rn, pi); } return 0; @@ -2115,15 +2111,15 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) static int delete_all_es_routes(struct bgp *bgp, struct evpnes *es) { struct bgp_node *rn; - struct bgp_path_info *ri, *nextri; + struct bgp_path_info *pi, *nextpi; /* 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 (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); - ri = nextri) { - bgp_path_info_delete(rn, ri); - bgp_path_info_reap(rn, ri); + for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1); + pi = nextpi) { + bgp_path_info_delete(rn, pi); + bgp_path_info_reap(rn, pi); } } @@ -2136,15 +2132,15 @@ static int delete_all_es_routes(struct bgp *bgp, struct evpnes *es) static int delete_all_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) { struct bgp_node *rn; - struct bgp_path_info *ri, *nextri; + struct bgp_path_info *pi, *nextpi; /* 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 (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); - ri = nextri) { - bgp_path_info_delete(rn, ri); - bgp_path_info_reap(rn, ri); + for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1); + pi = nextpi) { + bgp_path_info_delete(rn, pi); + bgp_path_info_reap(rn, pi); } } @@ -2261,11 +2257,11 @@ static int handle_tunnel_ip_change(struct bgp *bgp, struct bgpevpn *vpn, /* Install EVPN route entry in ES */ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es, struct prefix_evpn *p, - struct bgp_path_info *parent_ri) + struct bgp_path_info *parent_pi) { int ret = 0; struct bgp_node *rn = NULL; - struct bgp_path_info *ri = NULL; + struct bgp_path_info *pi = NULL; struct attr *attr_new = NULL; /* Create (or fetch) route within the VNI. @@ -2274,44 +2270,44 @@ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es, rn = bgp_node_get(es->route_table, (struct prefix *)p); /* Check if route entry is already present. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->extra - && (struct bgp_path_info *)ri->extra->parent == parent_ri) + for (pi = rn->info; pi; pi = pi->next) + if (pi->extra + && (struct bgp_path_info *)pi->extra->parent == parent_pi) break; - if (!ri) { + if (!pi) { /* Add (or update) attribute to hash. */ - attr_new = bgp_attr_intern(parent_ri->attr); + attr_new = bgp_attr_intern(parent_pi->attr); /* Create new route with its attribute. */ - ri = info_make(parent_ri->type, BGP_ROUTE_IMPORTED, 0, - parent_ri->peer, attr_new, rn); - SET_FLAG(ri->flags, BGP_PATH_VALID); - bgp_path_info_extra_get(ri); - ri->extra->parent = parent_ri; - bgp_path_info_add(rn, ri); + pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0, + parent_pi->peer, attr_new, rn); + SET_FLAG(pi->flags, BGP_PATH_VALID); + bgp_path_info_extra_get(pi); + pi->extra->parent = parent_pi; + bgp_path_info_add(rn, pi); } else { - if (attrhash_cmp(ri->attr, parent_ri->attr) - && !CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) { + if (attrhash_cmp(pi->attr, parent_pi->attr) + && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { bgp_unlock_node(rn); return 0; } /* The attribute has changed. */ /* Add (or update) attribute to hash. */ - attr_new = bgp_attr_intern(parent_ri->attr); + attr_new = bgp_attr_intern(parent_pi->attr); /* Restore route, if needed. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, ri); + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, pi); /* Mark if nexthop has changed. */ - if (!IPV4_ADDR_SAME(&ri->attr->nexthop, &attr_new->nexthop)) - SET_FLAG(ri->flags, BGP_PATH_IGP_CHANGED); + if (!IPV4_ADDR_SAME(&pi->attr->nexthop, &attr_new->nexthop)) + SET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED); /* Unintern existing, set to new. */ - bgp_attr_unintern(&ri->attr); - ri->attr = attr_new; - ri->uptime = bgp_clock(); + bgp_attr_unintern(&pi->attr); + pi->attr = attr_new; + pi->uptime = bgp_clock(); } /* Perform route selection and update zebra, if required. */ @@ -2324,10 +2320,10 @@ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es, */ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, struct prefix_evpn *evp, - struct bgp_path_info *parent_ri) + struct bgp_path_info *parent_pi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct attr attr; struct attr *attr_new; int ret = 0; @@ -2368,38 +2364,38 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, * address for the rest of the code to flow through. In the case of IPv4, * make sure to set the flag for next hop attribute. */ - bgp_attr_dup(&attr, parent_ri->attr); + bgp_attr_dup(&attr, parent_pi->attr); if (afi == AFI_IP6) evpn_convert_nexthop_to_ipv6(&attr); else attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP); /* Check if route entry is already present. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->extra - && (struct bgp_path_info *)ri->extra->parent == parent_ri) + for (pi = rn->info; pi; pi = pi->next) + if (pi->extra + && (struct bgp_path_info *)pi->extra->parent == parent_pi) break; - if (!ri) { + if (!pi) { /* Add (or update) attribute to hash. */ attr_new = bgp_attr_intern(&attr); /* Create new route with its attribute. */ - ri = info_make(parent_ri->type, BGP_ROUTE_IMPORTED, 0, - parent_ri->peer, attr_new, rn); - SET_FLAG(ri->flags, BGP_PATH_VALID); - bgp_path_info_extra_get(ri); - ri->extra->parent = bgp_path_info_lock(parent_ri); - bgp_lock_node((struct bgp_node *)parent_ri->net); - if (parent_ri->extra) { - memcpy(&ri->extra->label, &parent_ri->extra->label, - sizeof(ri->extra->label)); - ri->extra->num_labels = parent_ri->extra->num_labels; + pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0, + parent_pi->peer, attr_new, rn); + SET_FLAG(pi->flags, BGP_PATH_VALID); + bgp_path_info_extra_get(pi); + pi->extra->parent = bgp_path_info_lock(parent_pi); + bgp_lock_node((struct bgp_node *)parent_pi->net); + if (parent_pi->extra) { + memcpy(&pi->extra->label, &parent_pi->extra->label, + sizeof(pi->extra->label)); + pi->extra->num_labels = parent_pi->extra->num_labels; } - bgp_path_info_add(rn, ri); + bgp_path_info_add(rn, pi); } else { - if (attrhash_cmp(ri->attr, &attr) - && !CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) { + if (attrhash_cmp(pi->attr, &attr) + && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { bgp_unlock_node(rn); return 0; } @@ -2408,24 +2404,24 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, attr_new = bgp_attr_intern(&attr); /* Restore route, if needed. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, ri); + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, pi); /* Mark if nexthop has changed. */ - if ((afi == AFI_IP && - !IPV4_ADDR_SAME(&ri->attr->nexthop, &attr_new->nexthop)) || - (afi == AFI_IP6 && - !IPV6_ADDR_SAME(&ri->attr->mp_nexthop_global, - &attr_new->mp_nexthop_global))) - SET_FLAG(ri->flags, BGP_PATH_IGP_CHANGED); + if ((afi == AFI_IP + && !IPV4_ADDR_SAME(&pi->attr->nexthop, &attr_new->nexthop)) + || (afi == AFI_IP6 + && !IPV6_ADDR_SAME(&pi->attr->mp_nexthop_global, + &attr_new->mp_nexthop_global))) + SET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED); /* Unintern existing, set to new. */ - bgp_attr_unintern(&ri->attr); - ri->attr = attr_new; - ri->uptime = bgp_clock(); + bgp_attr_unintern(&pi->attr); + pi->attr = attr_new; + pi->uptime = bgp_clock(); } - bgp_aggregate_increment(bgp_vrf, &rn->p, ri, afi, safi); + bgp_aggregate_increment(bgp_vrf, &rn->p, pi, afi, safi); /* Perform route selection and update zebra, if required. */ bgp_process(bgp_vrf, rn, afi, safi); @@ -2438,10 +2434,10 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, */ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, struct prefix_evpn *p, - struct bgp_path_info *parent_ri) + struct bgp_path_info *parent_pi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct attr *attr_new; int ret; @@ -2450,50 +2446,50 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, rn = bgp_node_get(vpn->route_table, (struct prefix *)p); /* Check if route entry is already present. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->extra - && (struct bgp_path_info *)ri->extra->parent == parent_ri) + for (pi = rn->info; pi; pi = pi->next) + if (pi->extra + && (struct bgp_path_info *)pi->extra->parent == parent_pi) break; - if (!ri) { + if (!pi) { /* Add (or update) attribute to hash. */ - attr_new = bgp_attr_intern(parent_ri->attr); + attr_new = bgp_attr_intern(parent_pi->attr); /* Create new route with its attribute. */ - ri = info_make(parent_ri->type, BGP_ROUTE_IMPORTED, 0, - parent_ri->peer, attr_new, rn); - SET_FLAG(ri->flags, BGP_PATH_VALID); - bgp_path_info_extra_get(ri); - ri->extra->parent = bgp_path_info_lock(parent_ri); - bgp_lock_node((struct bgp_node *)parent_ri->net); - if (parent_ri->extra) { - memcpy(&ri->extra->label, &parent_ri->extra->label, - sizeof(ri->extra->label)); - ri->extra->num_labels = parent_ri->extra->num_labels; + pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0, + parent_pi->peer, attr_new, rn); + SET_FLAG(pi->flags, BGP_PATH_VALID); + bgp_path_info_extra_get(pi); + pi->extra->parent = bgp_path_info_lock(parent_pi); + bgp_lock_node((struct bgp_node *)parent_pi->net); + if (parent_pi->extra) { + memcpy(&pi->extra->label, &parent_pi->extra->label, + sizeof(pi->extra->label)); + pi->extra->num_labels = parent_pi->extra->num_labels; } - bgp_path_info_add(rn, ri); + bgp_path_info_add(rn, pi); } else { - if (attrhash_cmp(ri->attr, parent_ri->attr) - && !CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) { + if (attrhash_cmp(pi->attr, parent_pi->attr) + && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { bgp_unlock_node(rn); return 0; } /* The attribute has changed. */ /* Add (or update) attribute to hash. */ - attr_new = bgp_attr_intern(parent_ri->attr); + attr_new = bgp_attr_intern(parent_pi->attr); /* Restore route, if needed. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, ri); + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, pi); /* Mark if nexthop has changed. */ - if (!IPV4_ADDR_SAME(&ri->attr->nexthop, &attr_new->nexthop)) - SET_FLAG(ri->flags, BGP_PATH_IGP_CHANGED); + if (!IPV4_ADDR_SAME(&pi->attr->nexthop, &attr_new->nexthop)) + SET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED); /* Unintern existing, set to new. */ - bgp_attr_unintern(&ri->attr); - ri->attr = attr_new; - ri->uptime = bgp_clock(); + bgp_attr_unintern(&pi->attr); + pi->attr = attr_new; + pi->uptime = bgp_clock(); } /* Perform route selection and update zebra, if required. */ @@ -2505,11 +2501,11 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, /* Uninstall EVPN route entry from ES route table */ static int uninstall_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es, struct prefix_evpn *p, - struct bgp_path_info *parent_ri) + struct bgp_path_info *parent_pi) { int ret; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; if (!es->route_table) return 0; @@ -2522,16 +2518,16 @@ static int uninstall_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es, return 0; /* Find matching route entry. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->extra - && (struct bgp_path_info *)ri->extra->parent == parent_ri) + for (pi = rn->info; pi; pi = pi->next) + if (pi->extra + && (struct bgp_path_info *)pi->extra->parent == parent_pi) break; - if (!ri) + if (!pi) return 0; /* Mark entry for deletion */ - bgp_path_info_delete(rn, ri); + bgp_path_info_delete(rn, pi); /* Perform route selection and update zebra, if required. */ ret = evpn_es_route_select_install(bgp, es, rn); @@ -2548,10 +2544,10 @@ static int uninstall_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es, */ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, struct prefix_evpn *evp, - struct bgp_path_info *parent_ri) + struct bgp_path_info *parent_pi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; int ret = 0; struct prefix p; struct prefix *pp = &p; @@ -2587,18 +2583,18 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, return 0; /* Find matching route entry. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->extra - && (struct bgp_path_info *)ri->extra->parent == parent_ri) + for (pi = rn->info; pi; pi = pi->next) + if (pi->extra + && (struct bgp_path_info *)pi->extra->parent == parent_pi) break; - if (!ri) + if (!pi) return 0; - bgp_aggregate_decrement(bgp_vrf, &rn->p, ri, afi, safi); + bgp_aggregate_decrement(bgp_vrf, &rn->p, pi, afi, safi); /* Mark entry for deletion */ - bgp_path_info_delete(rn, ri); + bgp_path_info_delete(rn, pi); /* Perform route selection and update zebra, if required. */ bgp_process(bgp_vrf, rn, afi, safi); @@ -2615,10 +2611,10 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, */ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, struct prefix_evpn *p, - struct bgp_path_info *parent_ri) + struct bgp_path_info *parent_pi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; int ret; /* Locate route within the VNI. */ @@ -2628,16 +2624,16 @@ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, return 0; /* Find matching route entry. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->extra - && (struct bgp_path_info *)ri->extra->parent == parent_ri) + for (pi = rn->info; pi; pi = pi->next) + if (pi->extra + && (struct bgp_path_info *)pi->extra->parent == parent_pi) break; - if (!ri) + if (!pi) return 0; /* Mark entry for deletion */ - bgp_path_info_delete(rn, ri); + bgp_path_info_delete(rn, pi); /* Perform route selection and update zebra, if required. */ ret = evpn_route_select_install(bgp, vpn, rn); @@ -2669,9 +2665,9 @@ static int is_prefix_matching_for_es(struct prefix_evpn *p, * imported into the VRF i.e., RTs match. */ static int is_route_matching_for_vrf(struct bgp *bgp_vrf, - struct bgp_path_info *ri) + struct bgp_path_info *pi) { - struct attr *attr = ri->attr; + struct attr *attr = pi->attr; struct ecommunity *ecom; int i; @@ -2736,9 +2732,9 @@ static int is_route_matching_for_vrf(struct bgp *bgp_vrf, * imported into the VNI i.e., RTs match. */ static int is_route_matching_for_vni(struct bgp *bgp, struct bgpevpn *vpn, - struct bgp_path_info *ri) + struct bgp_path_info *pi) { - struct attr *attr = ri->attr; + struct attr *attr = pi->attr; struct ecommunity *ecom; int i; @@ -2809,7 +2805,7 @@ static int install_uninstall_routes_for_es(struct bgp *bgp, char buf1[ESI_STR_LEN]; struct bgp_node *rd_rn, *rn; struct bgp_table *table; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi = AFI_L2VPN; safi = SAFI_EVPN; @@ -2828,14 +2824,14 @@ static int install_uninstall_routes_for_es(struct bgp *bgp, for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { /* * Consider "valid" remote routes applicable for * this ES. */ - if (!(CHECK_FLAG(ri->flags, BGP_PATH_VALID) - && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_NORMAL)) + if (!(CHECK_FLAG(pi->flags, BGP_PATH_VALID) + && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_NORMAL)) continue; if (!is_prefix_matching_for_es(evp, es)) @@ -2843,10 +2839,10 @@ static int install_uninstall_routes_for_es(struct bgp *bgp, if (install) ret = install_evpn_route_entry_in_es( - bgp, es, evp, ri); + bgp, es, evp, pi); else ret = uninstall_evpn_route_entry_in_es( - bgp, es, evp, ri); + bgp, es, evp, pi); if (ret) { flog_err( @@ -2876,7 +2872,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install) safi_t safi; struct bgp_node *rd_rn, *rn; struct bgp_table *table; - struct bgp_path_info *ri; + struct bgp_path_info *pi; int ret; char buf[PREFIX_STRLEN]; struct bgp *bgp_def = NULL; @@ -2911,22 +2907,22 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install) || is_evpn_prefix_ipaddr_v6(evp))) continue; - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { /* Consider "valid" remote routes applicable for * this VRF. */ - if (!(CHECK_FLAG(ri->flags, BGP_PATH_VALID) - && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_NORMAL)) + if (!(CHECK_FLAG(pi->flags, BGP_PATH_VALID) + && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_NORMAL)) continue; - if (is_route_matching_for_vrf(bgp_vrf, ri)) { + if (is_route_matching_for_vrf(bgp_vrf, pi)) { if (install) ret = install_evpn_route_entry_in_vrf( - bgp_vrf, evp, ri); + bgp_vrf, evp, pi); else ret = uninstall_evpn_route_entry_in_vrf( - bgp_vrf, evp, ri); + bgp_vrf, evp, pi); if (ret) { flog_err( @@ -2961,7 +2957,7 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp, safi_t safi; struct bgp_node *rd_rn, *rn; struct bgp_table *table; - struct bgp_path_info *ri; + struct bgp_path_info *pi; int ret; afi = AFI_L2VPN; @@ -2986,21 +2982,21 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp, if (evp->prefix.route_type != rtype) continue; - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { /* Consider "valid" remote routes applicable for * this VNI. */ - if (!(CHECK_FLAG(ri->flags, BGP_PATH_VALID) - && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_NORMAL)) + if (!(CHECK_FLAG(pi->flags, BGP_PATH_VALID) + && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_NORMAL)) continue; - if (is_route_matching_for_vni(bgp, vpn, ri)) { + if (is_route_matching_for_vni(bgp, vpn, pi)) { if (install) ret = install_evpn_route_entry( - bgp, vpn, evp, ri); + bgp, vpn, evp, pi); else ret = uninstall_evpn_route_entry( - bgp, vpn, evp, ri); + bgp, vpn, evp, pi); if (ret) { flog_err( @@ -3094,15 +3090,15 @@ static int uninstall_routes_for_vni(struct bgp *bgp, struct bgpevpn *vpn) static int install_uninstall_route_in_es(struct bgp *bgp, struct evpnes *es, afi_t afi, safi_t safi, struct prefix_evpn *evp, - struct bgp_path_info *ri, int install) + struct bgp_path_info *pi, int install) { int ret = 0; char buf[ESI_STR_LEN]; if (install) - ret = install_evpn_route_entry_in_es(bgp, es, evp, ri); + ret = install_evpn_route_entry_in_es(bgp, es, evp, pi); else - ret = uninstall_evpn_route_entry_in_es(bgp, es, evp, ri); + ret = uninstall_evpn_route_entry_in_es(bgp, es, evp, pi); if (ret) { flog_err( @@ -3120,7 +3116,7 @@ static int install_uninstall_route_in_es(struct bgp *bgp, struct evpnes *es, */ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi, safi_t safi, struct prefix_evpn *evp, - struct bgp_path_info *ri, + struct bgp_path_info *pi, struct list *vrfs, int install) { char buf[PREFIX2STR_BUFFER]; @@ -3142,10 +3138,10 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi, int ret; if (install) - ret = install_evpn_route_entry_in_vrf(bgp_vrf, evp, ri); + ret = install_evpn_route_entry_in_vrf(bgp_vrf, evp, pi); else ret = uninstall_evpn_route_entry_in_vrf(bgp_vrf, evp, - ri); + pi); if (ret) { flog_err(EC_BGP_EVPN_FAIL, @@ -3166,7 +3162,7 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi, */ static int install_uninstall_route_in_vnis(struct bgp *bgp, afi_t afi, safi_t safi, struct prefix_evpn *evp, - struct bgp_path_info *ri, + struct bgp_path_info *pi, struct list *vnis, int install) { struct bgpevpn *vpn; @@ -3179,9 +3175,9 @@ static int install_uninstall_route_in_vnis(struct bgp *bgp, afi_t afi, continue; if (install) - ret = install_evpn_route_entry(bgp, vpn, evp, ri); + ret = install_evpn_route_entry(bgp, vpn, evp, pi); else - ret = uninstall_evpn_route_entry(bgp, vpn, evp, ri); + ret = uninstall_evpn_route_entry(bgp, vpn, evp, pi); if (ret) { flog_err(EC_BGP_EVPN_FAIL, @@ -3203,10 +3199,10 @@ static int install_uninstall_route_in_vnis(struct bgp *bgp, afi_t afi, */ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, struct prefix *p, - struct bgp_path_info *ri, int import) + struct bgp_path_info *pi, int import) { struct prefix_evpn *evp = (struct prefix_evpn *)p; - struct attr *attr = ri->attr; + struct attr *attr = pi->attr; struct ecommunity *ecom; int i; @@ -3258,17 +3254,15 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, irt = lookup_import_rt(bgp, eval); if (irt) - install_uninstall_route_in_vnis(bgp, afi, safi, - evp, ri, - irt->vnis, - import); + install_uninstall_route_in_vnis( + bgp, afi, safi, evp, pi, irt->vnis, + import); vrf_irt = lookup_vrf_import_rt(eval); if (vrf_irt) - install_uninstall_route_in_vrfs(bgp, afi, safi, - evp, ri, - vrf_irt->vrfs, - import); + install_uninstall_route_in_vrfs( + bgp, afi, safi, evp, pi, vrf_irt->vrfs, + import); /* Also check for non-exact match. * In this, we mask out the AS and @@ -3288,15 +3282,13 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, } if (irt) - install_uninstall_route_in_vnis(bgp, afi, safi, - evp, ri, - irt->vnis, - import); + install_uninstall_route_in_vnis( + bgp, afi, safi, evp, pi, irt->vnis, + import); if (vrf_irt) - install_uninstall_route_in_vrfs(bgp, afi, safi, - evp, ri, - vrf_irt->vrfs, - import); + install_uninstall_route_in_vrfs( + bgp, afi, safi, evp, pi, vrf_irt->vrfs, + import); } /* es route is imported into the es table */ @@ -3307,9 +3299,8 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, */ es = bgp_evpn_lookup_es(bgp, &evp->prefix.es_addr.esi); if (es && is_es_local(es)) - install_uninstall_route_in_es(bgp, es, - afi, safi, - evp, ri, import); + install_uninstall_route_in_es( + bgp, es, afi, safi, evp, pi, import); } } @@ -3389,7 +3380,7 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) { struct prefix_evpn p; struct bgp_node *rn, *global_rn; - struct bgp_path_info *ri, *global_ri; + struct bgp_path_info *pi, *global_pi; struct attr *attr; afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; @@ -3402,18 +3393,18 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p); if (!rn) /* unexpected */ return 0; - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) break; - if (!ri) /* unexpected */ + if (!pi) /* unexpected */ return 0; - attr = ri->attr; + attr = pi->attr; global_rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, (struct prefix *)&p, &vpn->prd); - update_evpn_route_entry(bgp, vpn, afi, safi, global_rn, attr, 1, &ri, - 0, mac_mobility_seqnum(attr)); + update_evpn_route_entry(bgp, vpn, afi, safi, global_rn, attr, 1, &pi, 0, + mac_mobility_seqnum(attr)); /* Schedule for processing and unlock node. */ bgp_process(bgp, global_rn, afi, safi); @@ -3430,23 +3421,23 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) continue; - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self - && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self + && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) break; - if (!ri) + if (!pi) continue; /* Create route in global routing table using this route entry's * attribute. */ - attr = ri->attr; + attr = pi->attr; global_rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, (struct prefix *)evp, &vpn->prd); assert(global_rn); update_evpn_route_entry(bgp, vpn, afi, safi, global_rn, attr, 1, - &global_ri, 0, + &global_pi, 0, mac_mobility_seqnum(attr)); /* Schedule for processing and unlock node. */ @@ -3466,7 +3457,7 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) int ret; struct prefix_evpn p; struct bgp_node *global_rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi_t afi = AFI_L2VPN; safi_t safi = SAFI_EVPN; @@ -3483,12 +3474,12 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) (struct prefix *)&p, &vpn->prd); if (global_rn) { /* Delete route entry in the global EVPN table. */ - delete_evpn_route_entry(bgp, afi, safi, global_rn, &ri); + delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi); /* Schedule for processing - withdraws to peers happen from * this table. */ - if (ri) + if (pi) bgp_process(bgp, global_rn, afi, safi); bgp_unlock_node(global_rn); } @@ -4086,15 +4077,15 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi) { struct bgp_table *table = NULL; struct bgp_node *rn = NULL; - struct bgp_path_info *ri; + struct bgp_path_info *pi; table = bgp_vrf->rib[afi][safi]; 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 (ri = rn->info; ri; ri = ri->next) { - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED) - && (!ri->extra || !ri->extra->parent)) { + for (pi = rn->info; 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, afi, safi); break; @@ -4134,7 +4125,7 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi, { struct bgp_table *table = NULL; struct bgp_node *rn = NULL; - struct bgp_path_info *ri; + struct bgp_path_info *pi; table = bgp_vrf->rib[afi][safi]; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { @@ -4142,9 +4133,9 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi, * attribute. Also, we only consider "non-imported" routes. * TODO: Support for AddPath for EVPN. */ - for (ri = rn->info; ri; ri = ri->next) { - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED) - && (!ri->extra || !ri->extra->parent)) { + for (pi = rn->info; pi; pi = pi->next) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) + && (!pi->extra || !pi->extra->parent)) { /* apply the route-map */ if (bgp_vrf->adv_cmd_rmap[afi][safi].map) { @@ -4153,12 +4144,12 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi, ret = route_map_apply( bgp_vrf->adv_cmd_rmap[afi][safi] .map, - &rn->p, RMAP_BGP, ri); + &rn->p, RMAP_BGP, pi); if (ret == RMAP_DENYMATCH) continue; } bgp_evpn_advertise_type5_route( - bgp_vrf, &rn->p, ri->attr, afi, safi); + bgp_vrf, &rn->p, pi->attr, afi, safi); break; } } @@ -5070,18 +5061,18 @@ void bgp_evpn_es_free(struct bgp *bgp, struct evpnes *es) * Import evpn route from global table to VNI/VRF/ESI. */ int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, struct bgp_path_info *ri) + struct prefix *p, struct bgp_path_info *pi) { - return install_uninstall_evpn_route(bgp, afi, safi, p, ri, 1); + return install_uninstall_evpn_route(bgp, afi, safi, p, pi, 1); } /* * Unimport evpn route from VNI/VRF/ESI. */ int bgp_evpn_unimport_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct prefix *p, struct bgp_path_info *ri) + struct prefix *p, struct bgp_path_info *pi) { - return install_uninstall_evpn_route(bgp, afi, safi, p, ri, 0); + return install_uninstall_evpn_route(bgp, afi, safi, p, pi, 0); } /* filter routes which have martian next hops */ @@ -5091,7 +5082,7 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp) safi_t safi; struct bgp_node *rd_rn, *rn; struct bgp_table *table; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi = AFI_L2VPN; safi = SAFI_EVPN; @@ -5110,23 +5101,23 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp) for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { /* Consider "valid" remote routes applicable for * this VNI. */ - if (!(ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_NORMAL)) + if (!(pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_NORMAL)) continue; - if (bgp_nexthop_self(bgp, ri->attr->nexthop)) { + if (bgp_nexthop_self(bgp, pi->attr->nexthop)) { char attr_str[BUFSIZ]; char pbuf[PREFIX_STRLEN]; - bgp_dump_attr(ri->attr, attr_str, + bgp_dump_attr(pi->attr, attr_str, BUFSIZ); - if (bgp_debug_update(ri->peer, &rn->p, + if (bgp_debug_update(pi->peer, &rn->p, NULL, 1)) zlog_debug( "%u: prefix %s with attr %s - DENIED due to martian or self nexthop", @@ -5137,9 +5128,9 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp) attr_str); bgp_evpn_unimport_route(bgp, afi, safi, - &rn->p, ri); + &rn->p, pi); - bgp_rib_remove(rn, ri, ri->peer, afi, + bgp_rib_remove(rn, pi, pi->peer, afi, safi); } } diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 7c6da82b4d..4e38d73146 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -536,7 +536,7 @@ static void show_esi_routes(struct bgp *bgp, { int header = 1; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; uint32_t prefix_cnt, path_cnt; uint64_t tbl_ver; @@ -573,13 +573,13 @@ static void show_esi_routes(struct bgp *bgp, /* 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) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; if (json) json_path = json_object_new_array(); - route_vty_out(vty, &rn->p, ri, 0, SAFI_EVPN, json_path); + route_vty_out(vty, &rn->p, pi, 0, SAFI_EVPN, json_path); if (json) json_object_array_add(json_paths, json_path); @@ -616,7 +616,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, json_object *json) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_table *table; int header = 1; uint64_t tbl_ver; @@ -660,18 +660,18 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, /* 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) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; if (vtep_ip.s_addr && !IPV4_ADDR_SAME(&(vtep_ip), - &(ri->attr->nexthop))) + &(pi->attr->nexthop))) continue; if (json) json_path = json_object_new_array(); - route_vty_out(vty, &rn->p, ri, 0, SAFI_EVPN, json_path); + route_vty_out(vty, &rn->p, pi, 0, SAFI_EVPN, json_path); if (json) json_object_array_add(json_paths, json_path); @@ -990,7 +990,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, struct bgp_table *table; struct bgp_node *rn; struct bgp_node *rm; - struct bgp_path_info *ri; + struct bgp_path_info *pi; int rd_header; int header = 1; @@ -1046,14 +1046,14 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, tbl_ver = table->version; for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) - for (ri = rm->info; ri; ri = ri->next) { + for (pi = rm->info; pi; pi = pi->next) { total_count++; if (type == bgp_show_type_neighbor) { union sockunion *su = output_arg; - if (ri->peer->su_remote == NULL + if (pi->peer->su_remote == NULL || !sockunion_same( - ri->peer->su_remote, su)) + pi->peer->su_remote, su)) continue; } if (header == 0) { @@ -1162,14 +1162,14 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, else json_array = NULL; if (option == SHOW_DISPLAY_TAGS) - route_vty_out_tag(vty, &rm->p, ri, 0, + route_vty_out_tag(vty, &rm->p, pi, 0, SAFI_EVPN, json_array); else if (option == SHOW_DISPLAY_OVERLAY) - route_vty_out_overlay(vty, &rm->p, ri, + route_vty_out_overlay(vty, &rm->p, pi, 0, json_array); else - route_vty_out(vty, &rm->p, ri, 0, + route_vty_out(vty, &rm->p, pi, 0, SAFI_EVPN, json_array); output_count++; } @@ -2017,7 +2017,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp, struct bgpevpn *vpn; struct prefix_evpn p; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; uint32_t path_cnt = 0; afi_t afi; safi_t safi; @@ -2049,13 +2049,13 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp, route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json); /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; if (json) json_path = json_object_new_array(); - route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, + route_vty_out_detail(vty, bgp, &rn->p, pi, afi, safi, json_path); if (json) @@ -2086,7 +2086,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp, struct bgpevpn *vpn; struct prefix_evpn p; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; uint32_t path_cnt = 0; afi_t afi; safi_t safi; @@ -2119,13 +2119,13 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp, route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json); /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; if (json) json_path = json_object_new_array(); - route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, + route_vty_out_detail(vty, bgp, &rn->p, pi, afi, safi, json_path); if (json) @@ -2196,7 +2196,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, { struct prefix_evpn p; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi_t afi; safi_t safi; uint32_t path_cnt = 0; @@ -2226,13 +2226,13 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, json_paths = json_object_new_array(); /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; if (json) json_path = json_object_new_array(); - route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, + route_vty_out_detail(vty, bgp, &rn->p, pi, afi, safi, json_path); if (json) @@ -2262,7 +2262,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, struct bgp_node *rd_rn; struct bgp_table *table; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; int rd_header = 1; afi_t afi; safi_t safi; @@ -2330,13 +2330,13 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, json_paths = json_object_new_array(); /* Display each path for this prefix. */ - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; if (json) json_path = json_object_new_array(); - route_vty_out_detail(vty, bgp, &rn->p, ri, afi, safi, + route_vty_out_detail(vty, bgp, &rn->p, pi, afi, safi, json_path); if (json) @@ -2383,7 +2383,7 @@ 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_path_info *ri; + struct bgp_path_info *pi; int header = 1; int rd_header; afi_t afi; @@ -2467,7 +2467,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, * fit in * with code that already exists). */ - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { json_object *json_path = NULL; path_cnt++; add_prefix_to_json = 1; @@ -2476,7 +2476,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, if (json) json_path = json_object_new_array(); - route_vty_out(vty, &rn->p, ri, 0, SAFI_EVPN, + route_vty_out(vty, &rn->p, pi, 0, SAFI_EVPN, json_path); if (json) diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index 99d4abfff4..4fb055bcc3 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -369,7 +369,7 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi, void *output_arg, bool use_json, int is_last, unsigned long *output_cum, unsigned long *total_cum) { - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_node *rn; unsigned long total_count = 0; json_object *json_paths = NULL; @@ -385,12 +385,10 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi, json_paths = json_object_new_array(); display = NLRI_STRING_FORMAT_JSON; } - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { total_count++; - route_vty_out_flowspec(vty, &rn->p, - ri, display, + route_vty_out_flowspec(vty, &rn->p, pi, display, json_paths); - } if (use_json) { vty_out(vty, "%s\n", diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index 0764280d93..dcaaea6868 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -94,18 +94,18 @@ int bgp_parse_fec_update(void) return 1; } -mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *ri, +mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi, struct peer *to, afi_t afi, safi_t safi) { struct peer *from; mpls_label_t remote_label; int reflect; - if (!rn || !ri || !to) + if (!rn || !pi || !to) return MPLS_INVALID_LABEL; - remote_label = ri->extra ? ri->extra->label[0] : MPLS_INVALID_LABEL; - from = ri->peer; + remote_label = pi->extra ? pi->extra->label[0] : MPLS_INVALID_LABEL; + from = pi->peer; reflect = ((from->sort == BGP_PEER_IBGP) && (to->sort == BGP_PEER_IBGP)); @@ -120,7 +120,7 @@ mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *ri, return rn->local_label; } -void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *ri, +void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *pi, int reg) { struct stream *s; @@ -143,11 +143,11 @@ void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *ri, stream_putw(s, PREFIX_FAMILY(p)); stream_put_prefix(s, p); if (reg) { - assert(ri); - if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID)) { - if (ri->attr->label_index != BGP_INVALID_LABEL_INDEX) { + assert(pi); + if (pi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID)) { + if (pi->attr->label_index != BGP_INVALID_LABEL_INDEX) { flags |= ZEBRA_FEC_REGISTER_LABEL_INDEX; - stream_putl(s, ri->attr->label_index); + stream_putl(s, pi->attr->label_index); } } SET_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL); diff --git a/bgpd/bgp_label.h b/bgpd/bgp_label.h index e910960ed3..b0fc07e547 100644 --- a/bgpd/bgp_label.h +++ b/bgpd/bgp_label.h @@ -31,9 +31,9 @@ struct bgp_path_info; struct peer; extern void bgp_reg_dereg_for_label(struct bgp_node *rn, - struct bgp_path_info *ri, int reg); + struct bgp_path_info *pi, int reg); extern int bgp_parse_fec_update(void); -extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *ri, +extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi, struct peer *to, afi_t afi, safi_t safi); extern int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, @@ -85,9 +85,9 @@ static inline void bgp_unset_valid_label(mpls_label_t *label) } static inline void bgp_register_for_label(struct bgp_node *rn, - struct bgp_path_info *ri) + struct bgp_path_info *pi) { - bgp_reg_dereg_for_label(rn, ri, 1); + bgp_reg_dereg_for_label(rn, pi, 1); } static inline void bgp_unregister_for_label(struct bgp_node *rn) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index dd36c9d1db..b868dba97f 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -116,43 +116,44 @@ static int bgp_interface_same(struct interface *ifp1, struct interface *ifp2) * bgp_path_info_nexthop_cmp * * Compare the nexthops of two paths. Return value is less than, equal to, - * or greater than zero if bi1 is respectively less than, equal to, - * or greater than bi2. + * or greater than zero if bpi1 is respectively less than, equal to, + * or greater than bpi2. */ -int bgp_path_info_nexthop_cmp(struct bgp_path_info *bi1, - struct bgp_path_info *bi2) +int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1, + struct bgp_path_info *bpi2) { int compare; struct in6_addr addr1, addr2; - compare = IPV4_ADDR_CMP(&bi1->attr->nexthop, &bi2->attr->nexthop); + compare = IPV4_ADDR_CMP(&bpi1->attr->nexthop, &bpi2->attr->nexthop); if (!compare) { - if (bi1->attr->mp_nexthop_len == bi2->attr->mp_nexthop_len) { - switch (bi1->attr->mp_nexthop_len) { + if (bpi1->attr->mp_nexthop_len == bpi2->attr->mp_nexthop_len) { + switch (bpi1->attr->mp_nexthop_len) { case BGP_ATTR_NHLEN_IPV4: case BGP_ATTR_NHLEN_VPNV4: compare = IPV4_ADDR_CMP( - &bi1->attr->mp_nexthop_global_in, - &bi2->attr->mp_nexthop_global_in); + &bpi1->attr->mp_nexthop_global_in, + &bpi2->attr->mp_nexthop_global_in); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL: compare = IPV6_ADDR_CMP( - &bi1->attr->mp_nexthop_global, - &bi2->attr->mp_nexthop_global); + &bpi1->attr->mp_nexthop_global, + &bpi2->attr->mp_nexthop_global); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: - addr1 = (bi1->attr->mp_nexthop_prefer_global) - ? bi1->attr->mp_nexthop_global - : bi1->attr->mp_nexthop_local; - addr2 = (bi2->attr->mp_nexthop_prefer_global) - ? bi2->attr->mp_nexthop_global - : bi2->attr->mp_nexthop_local; - - if (!bi1->attr->mp_nexthop_prefer_global - && !bi2->attr->mp_nexthop_prefer_global) + addr1 = (bpi1->attr->mp_nexthop_prefer_global) + ? bpi1->attr->mp_nexthop_global + : bpi1->attr->mp_nexthop_local; + addr2 = (bpi2->attr->mp_nexthop_prefer_global) + ? bpi2->attr->mp_nexthop_global + : bpi2->attr->mp_nexthop_local; + + if (!bpi1->attr->mp_nexthop_prefer_global + && !bpi2->attr->mp_nexthop_prefer_global) compare = !bgp_interface_same( - bi1->peer->ifp, bi2->peer->ifp); + bpi1->peer->ifp, + bpi2->peer->ifp); if (!compare) compare = IPV6_ADDR_CMP(&addr1, &addr2); @@ -164,14 +165,15 @@ int bgp_path_info_nexthop_cmp(struct bgp_path_info *bi1, * link-local * nexthops but another IPv6 peer only sends you global */ - else if (bi1->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL - || bi1->attr->mp_nexthop_len + else if (bpi1->attr->mp_nexthop_len + == BGP_ATTR_NHLEN_IPV6_GLOBAL + || bpi1->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { - compare = IPV6_ADDR_CMP(&bi1->attr->mp_nexthop_global, - &bi2->attr->mp_nexthop_global); + compare = IPV6_ADDR_CMP(&bpi1->attr->mp_nexthop_global, + &bpi2->attr->mp_nexthop_global); if (!compare) { - if (bi1->attr->mp_nexthop_len - < bi2->attr->mp_nexthop_len) + if (bpi1->attr->mp_nexthop_len + < bpi2->attr->mp_nexthop_len) compare = -1; else compare = 1; @@ -196,24 +198,24 @@ int bgp_path_info_nexthop_cmp(struct bgp_path_info *bi1, */ static int bgp_path_info_mpath_cmp(void *val1, void *val2) { - struct bgp_path_info *bi1, *bi2; + struct bgp_path_info *bpi1, *bpi2; int compare; - bi1 = val1; - bi2 = val2; + bpi1 = val1; + bpi2 = val2; - compare = bgp_path_info_nexthop_cmp(bi1, bi2); + compare = bgp_path_info_nexthop_cmp(bpi1, bpi2); if (!compare) { - if (!bi1->peer->su_remote && !bi2->peer->su_remote) + if (!bpi1->peer->su_remote && !bpi2->peer->su_remote) compare = 0; - else if (!bi1->peer->su_remote) + else if (!bpi1->peer->su_remote) compare = 1; - else if (!bi2->peer->su_remote) + else if (!bpi2->peer->su_remote) compare = -1; else - compare = sockunion_cmp(bi1->peer->su_remote, - bi2->peer->su_remote); + compare = sockunion_cmp(bpi1->peer->su_remote, + bpi2->peer->su_remote); } return compare; diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h index 0767d18a61..d15f3c9035 100644 --- a/bgpd/bgp_mpath.h +++ b/bgpd/bgp_mpath.h @@ -50,8 +50,8 @@ extern int bgp_maximum_paths_unset(struct bgp *, afi_t, safi_t, int); /* Functions used by bgp_best_selection to record current * multipath selections */ -extern int bgp_path_info_nexthop_cmp(struct bgp_path_info *bi1, - struct bgp_path_info *bi2); +extern int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1, + struct bgp_path_info *bpi2); extern void bgp_mp_list_init(struct list *); extern void bgp_mp_list_clear(struct list *); extern void bgp_mp_list_add(struct list *mp_list, struct bgp_path_info *mpinfo); diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 3af25ec888..5d42e4d336 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -402,23 +402,23 @@ static int ecom_intersect(struct ecommunity *e1, struct ecommunity *e2) return 0; } -static bool labels_same(struct bgp_path_info *bi, mpls_label_t *label, +static bool labels_same(struct bgp_path_info *bpi, mpls_label_t *label, uint32_t n) { uint32_t i; - if (!bi->extra) { + if (!bpi->extra) { if (!n) return true; else return false; } - if (n != bi->extra->num_labels) + if (n != bpi->extra->num_labels) return false; for (i = 0; i < n; ++i) { - if (label[i] != bi->extra->label[i]) + if (label[i] != bpi->extra->label[i]) return false; } return true; @@ -427,7 +427,7 @@ static bool labels_same(struct bgp_path_info *bi, mpls_label_t *label, /* * make encoded route labels match specified encoded label set */ -static void setlabels(struct bgp_path_info *bi, +static void setlabels(struct bgp_path_info *bpi, mpls_label_t *label, /* array of labels */ uint32_t num_labels) { @@ -436,12 +436,12 @@ static void setlabels(struct bgp_path_info *bi, assert(num_labels <= BGP_MAX_LABELS); if (!num_labels) { - if (bi->extra) - bi->extra->num_labels = 0; + if (bpi->extra) + bpi->extra->num_labels = 0; return; } - struct bgp_path_info_extra *extra = bgp_path_info_extra_get(bi); + struct bgp_path_info_extra *extra = bgp_path_info_extra_get(bpi); uint32_t i; for (i = 0; i < num_labels; ++i) { @@ -459,22 +459,22 @@ static void setlabels(struct bgp_path_info *bi, static struct bgp_path_info * leak_update(struct bgp *bgp, /* destination bgp instance */ struct bgp_node *bn, struct attr *new_attr, /* already interned */ - afi_t afi, safi_t safi, struct bgp_path_info *source_bi, + afi_t afi, safi_t safi, struct bgp_path_info *source_bpi, mpls_label_t *label, uint32_t num_labels, void *parent, struct bgp *bgp_orig, struct prefix *nexthop_orig, int nexthop_self_flag, int debug) { struct prefix *p = &bn->p; - struct bgp_path_info *bi; - struct bgp_path_info *bi_ultimate; + struct bgp_path_info *bpi; + struct bgp_path_info *bpi_ultimate; struct bgp_path_info *new; char buf_prefix[PREFIX_STRLEN]; if (debug) { prefix2str(&bn->p, buf_prefix, sizeof(buf_prefix)); zlog_debug("%s: entry: leak-to=%s, p=%s, type=%d, sub_type=%d", - __func__, bgp->name_pretty, buf_prefix, - source_bi->type, source_bi->sub_type); + __func__, bgp->name_pretty, buf_prefix, + source_bpi->type, source_bpi->sub_type); } /* @@ -486,30 +486,30 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ * should have nexthop tracking, we must find the ultimate * parent so we can check its sub_type. * - * As of now, source_bi may at most be a second-generation route + * As of now, source_bpi may at most be a second-generation route * (only one hop back to ultimate parent for vrf-vpn-vrf scheme). * Using a loop here supports more complex intra-bgp import-export * schemes that could be implemented in the future. * */ - for (bi_ultimate = source_bi; - bi_ultimate->extra && bi_ultimate->extra->parent; - bi_ultimate = bi_ultimate->extra->parent) - ; + for (bpi_ultimate = source_bpi; + bpi_ultimate->extra && bpi_ultimate->extra->parent; + bpi_ultimate = bpi_ultimate->extra->parent) + ; /* * match parent */ - for (bi = bn->info; bi; bi = bi->next) { - if (bi->extra && bi->extra->parent == parent) + for (bpi = bn->info; bpi; bpi = bpi->next) { + if (bpi->extra && bpi->extra->parent == parent) break; } - if (bi) { - bool labelssame = labels_same(bi, label, num_labels); + if (bpi) { + bool labelssame = labels_same(bpi, label, num_labels); - if (attrhash_cmp(bi->attr, new_attr) && labelssame - && !CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (attrhash_cmp(bpi->attr, new_attr) && labelssame + && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { bgp_attr_unintern(&new_attr); if (debug) @@ -521,43 +521,42 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ } /* attr is changed */ - bgp_path_info_set_flag(bn, bi, BGP_PATH_ATTR_CHANGED); + bgp_path_info_set_flag(bn, bpi, BGP_PATH_ATTR_CHANGED); /* Rewrite BGP route information. */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(bn, bi); + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(bn, bpi); else - bgp_aggregate_decrement(bgp, p, bi, afi, safi); - bgp_attr_unintern(&bi->attr); - bi->attr = new_attr; - bi->uptime = bgp_clock(); + bgp_aggregate_decrement(bgp, p, bpi, afi, safi); + bgp_attr_unintern(&bpi->attr); + bpi->attr = new_attr; + bpi->uptime = bgp_clock(); /* * rewrite labels */ if (!labelssame) - setlabels(bi, label, num_labels); + setlabels(bpi, label, num_labels); if (nexthop_self_flag) - bgp_path_info_set_flag(bn, bi, BGP_PATH_ANNC_NH_SELF); + bgp_path_info_set_flag(bn, bpi, BGP_PATH_ANNC_NH_SELF); struct bgp *bgp_nexthop = bgp; int nh_valid; - if (bi->extra && bi->extra->bgp_orig) - bgp_nexthop = bi->extra->bgp_orig; + if (bpi->extra && bpi->extra->bgp_orig) + bgp_nexthop = bpi->extra->bgp_orig; /* No nexthop tracking for redistributed routes */ - if (bi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE) + if (bpi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE) nh_valid = 1; else /* * TBD do we need to do anything about the * 'connected' parameter? */ - nh_valid = bgp_find_or_add_nexthop( - bgp, bgp_nexthop, - afi, bi, NULL, 0); + nh_valid = bgp_find_or_add_nexthop(bgp, bgp_nexthop, + afi, bpi, NULL, 0); if (debug) zlog_debug("%s: nexthop is %svalid (in vrf %s)", @@ -565,10 +564,10 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ bgp_nexthop->name_pretty); if (nh_valid) - bgp_path_info_set_flag(bn, bi, BGP_PATH_VALID); + bgp_path_info_set_flag(bn, bpi, BGP_PATH_VALID); /* Process change. */ - bgp_aggregate_increment(bgp, p, bi, afi, safi); + bgp_aggregate_increment(bgp, p, bpi, afi, safi); bgp_process(bgp, bn, afi, safi); bgp_unlock_node(bn); @@ -576,7 +575,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ zlog_debug("%s: ->%s: %s Found route, changed attr", __func__, bgp->name_pretty, buf_prefix); - return bi; + return bpi; } new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_IMPORTED, 0, @@ -611,7 +610,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ * their originating protocols will do the tracking and * withdraw those routes if the nexthops become unreachable */ - if (bi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE) + if (bpi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE) nh_valid = 1; else /* @@ -644,10 +643,10 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ /* cf vnc_import_bgp_add_route_mode_nvegroup() and add_vnc_route() */ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ struct bgp *bgp_vrf, /* from */ - struct bgp_path_info *info_vrf) /* route */ + struct bgp_path_info *path_vrf) /* route */ { int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); - struct prefix *p = &info_vrf->net->p; + struct prefix *p = &path_vrf->net->p; afi_t afi = family2afi(p->family); struct attr static_attr = {0}; struct attr *new_attr = NULL; @@ -661,12 +660,12 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ if (debug) zlog_debug("%s: from vrf %s", __func__, bgp_vrf->name_pretty); - if (debug && info_vrf->attr->ecommunity) { - char *s = ecommunity_ecom2str(info_vrf->attr->ecommunity, + if (debug && path_vrf->attr->ecommunity) { + char *s = ecommunity_ecom2str(path_vrf->attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - zlog_debug("%s: %s info_vrf->type=%d, EC{%s}", __func__, - bgp_vrf->name, info_vrf->type, s); + zlog_debug("%s: %s path_vrf->type=%d, EC{%s}", __func__, + bgp_vrf->name, path_vrf->type, s); XFREE(MTYPE_ECOMMUNITY_STR, s); } @@ -680,7 +679,7 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ } /* loop check - should not be an imported route. */ - if (info_vrf->extra && info_vrf->extra->bgp_orig) + if (path_vrf->extra && path_vrf->extra->bgp_orig) return; @@ -691,7 +690,7 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ return; } - bgp_attr_dup(&static_attr, info_vrf->attr); /* shallow copy */ + bgp_attr_dup(&static_attr, path_vrf->attr); /* shallow copy */ /* * route map handling @@ -809,8 +808,8 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ * IPv4 nexthops as the attr has been copied * otherwise. */ - if (afi == AFI_IP && - !BGP_ATTR_NEXTHOP_AFI_IP6(info_vrf->attr)) { + if (afi == AFI_IP + && !BGP_ATTR_NEXTHOP_AFI_IP6(path_vrf->attr)) { static_attr.mp_nexthop_global_in.s_addr = static_attr.nexthop.s_addr; static_attr.mp_nexthop_len = 4; @@ -852,8 +851,8 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ struct bgp_path_info *new_info; - new_info = leak_update(bgp_vpn, bn, new_attr, afi, safi, info_vrf, - &label, 1, info_vrf, bgp_vrf, NULL, + new_info = leak_update(bgp_vpn, bn, new_attr, afi, safi, path_vrf, + &label, 1, path_vrf, bgp_vrf, NULL, nexthop_self_flag, debug); /* @@ -871,13 +870,13 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */ struct bgp *bgp_vrf, /* from */ - struct bgp_path_info *info_vrf) /* route */ + struct bgp_path_info *path_vrf) /* route */ { int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); - struct prefix *p = &info_vrf->net->p; + struct prefix *p = &path_vrf->net->p; afi_t afi = family2afi(p->family); safi_t safi = SAFI_MPLS_VPN; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct bgp_node *bn; const char *debugmsg; char buf_prefix[PREFIX_STRLEN]; @@ -887,16 +886,16 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */ zlog_debug( "%s: entry: leak-from=%s, p=%s, type=%d, sub_type=%d", __func__, bgp_vrf->name_pretty, buf_prefix, - info_vrf->type, info_vrf->sub_type); + path_vrf->type, path_vrf->sub_type); } - if (info_vrf->sub_type != BGP_ROUTE_NORMAL - && info_vrf->sub_type != BGP_ROUTE_STATIC - && info_vrf->sub_type != BGP_ROUTE_REDISTRIBUTE) { + if (path_vrf->sub_type != BGP_ROUTE_NORMAL + && path_vrf->sub_type != BGP_ROUTE_STATIC + && path_vrf->sub_type != BGP_ROUTE_REDISTRIBUTE) { if (debug) zlog_debug("%s: wrong sub_type %d", __func__, - info_vrf->sub_type); + path_vrf->sub_type); return; } if (!bgp_vpn) @@ -915,27 +914,27 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */ } if (debug) - zlog_debug("%s: withdrawing (info_vrf=%p)", __func__, info_vrf); + zlog_debug("%s: withdrawing (path_vrf=%p)", __func__, path_vrf); bn = bgp_afi_node_get(bgp_vpn->rib[afi][safi], afi, safi, p, &(bgp_vrf->vpn_policy[afi].tovpn_rd)); /* * vrf -> vpn - * match original bi imported from + * match original bpi imported from */ - for (bi = (bn ? bn->info : NULL); bi; bi = bi->next) { - if (bi->extra && bi->extra->parent == info_vrf) { + for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) { + if (bpi->extra && bpi->extra->parent == path_vrf) { break; } } - if (bi) { + if (bpi) { /* withdraw from looped vrfs as well */ - vpn_leak_to_vrf_withdraw(bgp_vpn, bi); + vpn_leak_to_vrf_withdraw(bgp_vpn, bpi); - bgp_aggregate_decrement(bgp_vpn, p, bi, afi, safi); - bgp_path_info_delete(bn, bi); + bgp_aggregate_decrement(bgp_vpn, p, bpi, afi, safi); + bgp_path_info_delete(bn, bpi); bgp_process(bgp_vpn, bn, afi, safi); } bgp_unlock_node(bn); @@ -950,14 +949,14 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */ safi_t safi = SAFI_MPLS_VPN; /* - * Walk vpn table, delete bi with bgp_orig == bgp_vrf + * Walk vpn table, delete bpi with bgp_orig == bgp_vrf */ for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn; prn = bgp_route_next(prn)) { struct bgp_table *table; struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; /* This is the per-RD table of prefixes */ table = prn->info; @@ -975,24 +974,24 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */ prefix2str(&bn->p, buf, sizeof(buf))); } - for (bi = bn->info; bi; bi = bi->next) { + for (bpi = bn->info; bpi; bpi = bpi->next) { if (debug) zlog_debug("%s: type %d, sub_type %d", - __func__, bi->type, - bi->sub_type); - if (bi->sub_type != BGP_ROUTE_IMPORTED) + __func__, bpi->type, + bpi->sub_type); + if (bpi->sub_type != BGP_ROUTE_IMPORTED) continue; - if (!bi->extra) + if (!bpi->extra) continue; - if ((struct bgp *)bi->extra->bgp_orig + if ((struct bgp *)bpi->extra->bgp_orig == bgp_vrf) { /* delete route */ if (debug) zlog_debug("%s: deleting it\n", __func__); bgp_aggregate_decrement(bgp_vpn, &bn->p, - bi, afi, safi); - bgp_path_info_delete(bn, bi); + bpi, afi, safi); + bgp_path_info_delete(bn, bpi); bgp_process(bgp_vpn, bn, afi, safi); } } @@ -1005,7 +1004,7 @@ void vpn_leak_from_vrf_update_all(struct bgp *bgp_vpn, /* to */ afi_t afi) { struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); if (debug) @@ -1018,12 +1017,12 @@ void vpn_leak_from_vrf_update_all(struct bgp *bgp_vpn, /* to */ if (debug) zlog_debug("%s: node=%p", __func__, bn); - for (bi = bn->info; bi; bi = bi->next) { + for (bpi = bn->info; bpi; bpi = bpi->next) { if (debug) zlog_debug( "%s: calling vpn_leak_from_vrf_update", __func__); - vpn_leak_from_vrf_update(bgp_vpn, bgp_vrf, bi); + vpn_leak_from_vrf_update(bgp_vpn, bgp_vrf, bpi); } } } @@ -1031,9 +1030,9 @@ void vpn_leak_from_vrf_update_all(struct bgp *bgp_vpn, /* to */ static void vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ struct bgp *bgp_vpn, /* from */ - struct bgp_path_info *info_vpn) /* route */ + struct bgp_path_info *path_vpn) /* route */ { - struct prefix *p = &info_vpn->net->p; + struct prefix *p = &path_vpn->net->p; afi_t afi = family2afi(p->family); struct attr static_attr = {0}; @@ -1045,7 +1044,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ mpls_label_t *pLabels = NULL; uint32_t num_labels = 0; int nexthop_self_flag = 1; - struct bgp_path_info *bi_ultimate = NULL; + struct bgp_path_info *bpi_ultimate = NULL; int origin_local = 0; struct bgp *src_vrf; @@ -1060,7 +1059,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ /* Check for intersection of route targets */ if (!ecom_intersect( bgp_vrf->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], - info_vpn->attr->ecommunity)) { + path_vpn->attr->ecommunity)) { return; } @@ -1069,7 +1068,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ zlog_debug("%s: updating to vrf %s", __func__, bgp_vrf->name_pretty); - bgp_attr_dup(&static_attr, info_vpn->attr); /* shallow copy */ + bgp_attr_dup(&static_attr, path_vpn->attr); /* shallow copy */ /* * Nexthop: stash and clear @@ -1078,7 +1077,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ * Stash it for later label resolution by vrf ingress path and then * overwrite with 0, i.e., "me", for the sake of vrf advertisement. */ - uint8_t nhfamily = NEXTHOP_FAMILY(info_vpn->attr->mp_nexthop_len); + uint8_t nhfamily = NEXTHOP_FAMILY(path_vpn->attr->mp_nexthop_len); memset(&nexthop_orig, 0, sizeof(nexthop_orig)); nexthop_orig.family = nhfamily; @@ -1086,7 +1085,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ switch (nhfamily) { case AF_INET: /* save */ - nexthop_orig.u.prefix4 = info_vpn->attr->mp_nexthop_global_in; + nexthop_orig.u.prefix4 = path_vpn->attr->mp_nexthop_global_in; nexthop_orig.prefixlen = 32; if (CHECK_FLAG(bgp_vrf->af_flags[afi][safi], @@ -1095,15 +1094,15 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ nexthop_orig.u.prefix4.s_addr; static_attr.mp_nexthop_global_in = - info_vpn->attr->mp_nexthop_global_in; + path_vpn->attr->mp_nexthop_global_in; static_attr.mp_nexthop_len = - info_vpn->attr->mp_nexthop_len; + path_vpn->attr->mp_nexthop_len; } static_attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP); break; case AF_INET6: /* save */ - nexthop_orig.u.prefix6 = info_vpn->attr->mp_nexthop_global; + nexthop_orig.u.prefix6 = path_vpn->attr->mp_nexthop_global; nexthop_orig.prefixlen = 128; if (CHECK_FLAG(bgp_vrf->af_flags[afi][safi], @@ -1165,30 +1164,30 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ if (!CHECK_FLAG(bgp_vrf->af_flags[afi][safi], BGP_CONFIG_VRF_TO_VRF_IMPORT)) { /* work back to original route */ - for (bi_ultimate = info_vpn; - bi_ultimate->extra && bi_ultimate->extra->parent; - bi_ultimate = bi_ultimate->extra->parent) + for (bpi_ultimate = path_vpn; + bpi_ultimate->extra && bpi_ultimate->extra->parent; + bpi_ultimate = bpi_ultimate->extra->parent) ; /* * if original route was unicast, * then it did not arrive over vpn */ - if (bi_ultimate->net) { + if (bpi_ultimate->net) { struct bgp_table *table; - table = bgp_node_table(bi_ultimate->net); + table = bgp_node_table(bpi_ultimate->net); if (table && (table->safi == SAFI_UNICAST)) origin_local = 1; } /* copy labels */ - if (!origin_local && - info_vpn->extra && info_vpn->extra->num_labels) { - num_labels = info_vpn->extra->num_labels; + if (!origin_local && path_vpn->extra + && path_vpn->extra->num_labels) { + num_labels = path_vpn->extra->num_labels; if (num_labels > BGP_MAX_LABELS) num_labels = BGP_MAX_LABELS; - pLabels = info_vpn->extra->label; + pLabels = path_vpn->extra->label; } } @@ -1203,19 +1202,18 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ * For VRF-2-VRF route-leaking, * the source will be the originating VRF. */ - if (info_vpn->extra && info_vpn->extra->bgp_orig) - src_vrf = info_vpn->extra->bgp_orig; + if (path_vpn->extra && path_vpn->extra->bgp_orig) + src_vrf = path_vpn->extra->bgp_orig; else src_vrf = bgp_vpn; - leak_update(bgp_vrf, bn, new_attr, afi, safi, info_vpn, - pLabels, num_labels, - info_vpn, /* parent */ - src_vrf, &nexthop_orig, nexthop_self_flag, debug); + leak_update(bgp_vrf, bn, new_attr, afi, safi, path_vpn, pLabels, + num_labels, path_vpn, /* parent */ + src_vrf, &nexthop_orig, nexthop_self_flag, debug); } void vpn_leak_to_vrf_update(struct bgp *bgp_vpn, /* from */ - struct bgp_path_info *info_vpn) /* route */ + struct bgp_path_info *path_vpn) /* route */ { struct listnode *mnode, *mnnode; struct bgp *bgp; @@ -1223,20 +1221,20 @@ void vpn_leak_to_vrf_update(struct bgp *bgp_vpn, /* from */ int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); if (debug) - zlog_debug("%s: start (info_vpn=%p)", __func__, info_vpn); + zlog_debug("%s: start (path_vpn=%p)", __func__, path_vpn); /* Loop over VRFs */ for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { - if (!info_vpn->extra - || info_vpn->extra->bgp_orig != bgp) { /* no loop */ - vpn_leak_to_vrf_update_onevrf(bgp, bgp_vpn, info_vpn); + if (!path_vpn->extra + || path_vpn->extra->bgp_orig != bgp) { /* no loop */ + vpn_leak_to_vrf_update_onevrf(bgp, bgp_vpn, path_vpn); } } } void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */ - struct bgp_path_info *info_vpn) /* route */ + struct bgp_path_info *path_vpn) /* route */ { struct prefix *p; afi_t afi; @@ -1244,38 +1242,38 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */ struct bgp *bgp; struct listnode *mnode, *mnnode; struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; const char *debugmsg; char buf_prefix[PREFIX_STRLEN]; int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); if (debug) { - prefix2str(&info_vpn->net->p, buf_prefix, sizeof(buf_prefix)); - zlog_debug("%s: entry: p=%s, type=%d, sub_type=%d", - __func__, buf_prefix, - info_vpn->type, info_vpn->sub_type); + prefix2str(&path_vpn->net->p, buf_prefix, sizeof(buf_prefix)); + zlog_debug("%s: entry: p=%s, type=%d, sub_type=%d", __func__, + buf_prefix, path_vpn->type, path_vpn->sub_type); } if (debug) - zlog_debug("%s: start (info_vpn=%p)", __func__, info_vpn); + zlog_debug("%s: start (path_vpn=%p)", __func__, path_vpn); - if (!info_vpn->net) { + if (!path_vpn->net) { #if ENABLE_BGP_VNC - /* BGP_ROUTE_RFP routes do not have info_vpn->net set (yet) */ - if (info_vpn->type == ZEBRA_ROUTE_BGP && - info_vpn->sub_type == BGP_ROUTE_RFP) { + /* BGP_ROUTE_RFP routes do not have path_vpn->net set (yet) */ + if (path_vpn->type == ZEBRA_ROUTE_BGP + && path_vpn->sub_type == BGP_ROUTE_RFP) { return; } #endif if (debug) - zlog_debug("%s: info_vpn->net unexpectedly NULL, no prefix, bailing", + zlog_debug( + "%s: path_vpn->net unexpectedly NULL, no prefix, bailing", __func__); return; } - p = &info_vpn->net->p; + p = &path_vpn->net->p; afi = family2afi(p->family); /* Loop over VRFs */ @@ -1290,7 +1288,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */ /* Check for intersection of route targets */ if (!ecom_intersect(bgp->vpn_policy[afi] .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], - info_vpn->attr->ecommunity)) { + path_vpn->attr->ecommunity)) { continue; } @@ -1300,19 +1298,20 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */ bgp->name_pretty); bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL); - for (bi = (bn ? bn->info : NULL); bi; bi = bi->next) { - if (bi->extra - && (struct bgp_path_info *)bi->extra->parent - == info_vpn) { + for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) { + if (bpi->extra + && (struct bgp_path_info *)bpi->extra->parent + == path_vpn) { break; } } - if (bi) { + if (bpi) { if (debug) - zlog_debug("%s: deleting bi %p", __func__, bi); - bgp_aggregate_decrement(bgp, p, bi, afi, safi); - bgp_path_info_delete(bn, bi); + zlog_debug("%s: deleting bpi %p", __func__, + bpi); + bgp_aggregate_decrement(bgp, p, bpi, afi, safi); + bgp_path_info_delete(bn, bpi); bgp_process(bgp, bn, afi, safi); } bgp_unlock_node(bn); @@ -1323,25 +1322,25 @@ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */ afi_t afi) { struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; safi_t safi = SAFI_UNICAST; int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); if (debug) zlog_debug("%s: entry", __func__); /* - * Walk vrf table, delete bi with bgp_orig in a different vrf + * Walk vrf table, delete bpi with bgp_orig in a different vrf */ for (bn = bgp_table_top(bgp_vrf->rib[afi][safi]); bn; bn = bgp_route_next(bn)) { - for (bi = bn->info; bi; bi = bi->next) { - if (bi->extra && bi->extra->bgp_orig != bgp_vrf) { + for (bpi = bn->info; bpi; bpi = bpi->next) { + if (bpi->extra && bpi->extra->bgp_orig != bgp_vrf) { /* delete route */ - bgp_aggregate_decrement(bgp_vrf, &bn->p, bi, + bgp_aggregate_decrement(bgp_vrf, &bn->p, bpi, afi, safi); - bgp_path_info_delete(bn, bi); + bgp_path_info_delete(bn, bpi); bgp_process(bgp_vrf, bn, afi, safi); } } @@ -1366,7 +1365,7 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */ struct bgp_table *table; struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; memset(&prd, 0, sizeof(prd)); prd.family = AF_UNSPEC; @@ -1381,13 +1380,14 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */ for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) { - for (bi = bn->info; bi; bi = bi->next) { + for (bpi = bn->info; bpi; bpi = bpi->next) { - if (bi->extra && bi->extra->bgp_orig == bgp_vrf) + if (bpi->extra + && bpi->extra->bgp_orig == bgp_vrf) continue; vpn_leak_to_vrf_update_onevrf(bgp_vrf, bgp_vpn, - bi); + bpi); } } } diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 1ae9169944..5b989e1853 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -53,10 +53,10 @@ extern int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd, int tags, bool use_json); extern void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, struct bgp *bgp_vrf, - struct bgp_path_info *info_vrf); + struct bgp_path_info *path_vrf); extern void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, struct bgp *bgp_vrf, - struct bgp_path_info *info_vrf); + struct bgp_path_info *path_vrf); extern void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, struct bgp *bgp_vrf, afi_t afi); @@ -70,10 +70,10 @@ extern void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, struct bgp *bgp_vpn, afi_t afi); extern void vpn_leak_to_vrf_update(struct bgp *bgp_vpn, - struct bgp_path_info *info_vpn); + struct bgp_path_info *path_vpn); extern void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, - struct bgp_path_info *info_vpn); + struct bgp_path_info *path_vpn); extern void vpn_leak_zebra_vrf_label_update(struct bgp *bgp, afi_t afi); extern void vpn_leak_zebra_vrf_label_withdraw(struct bgp *bgp, afi_t afi); diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index fbf73704b1..5203e6eefd 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -50,7 +50,7 @@ static void register_zebra_rnh(struct bgp_nexthop_cache *bnc, static void unregister_zebra_rnh(struct bgp_nexthop_cache *bnc, int is_bgp_static_route); static void evaluate_paths(struct bgp_nexthop_cache *bnc); -static int make_prefix(int afi, struct bgp_path_info *ri, struct prefix *p); +static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p); static void path_nh_map(struct bgp_path_info *path, struct bgp_nexthop_cache *bnc, int keep); @@ -143,7 +143,7 @@ void bgp_unlink_nexthop_by_peer(struct peer *peer) * we need both the bgp_route and bgp_nexthop pointers. */ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, - afi_t afi, struct bgp_path_info *ri, + afi_t afi, struct bgp_path_info *pi, struct peer *peer, int connected) { struct bgp_node *rn; @@ -151,9 +151,9 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, struct prefix p; int is_bgp_static_route = 0; - if (ri) { - is_bgp_static_route = ((ri->type == ZEBRA_ROUTE_BGP) - && (ri->sub_type == BGP_ROUTE_STATIC)) + if (pi) { + is_bgp_static_route = ((pi->type == ZEBRA_ROUTE_BGP) + && (pi->sub_type == BGP_ROUTE_STATIC)) ? 1 : 0; @@ -161,12 +161,12 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, to derive address-family from the next-hop. */ if (!is_bgp_static_route) - afi = BGP_ATTR_NEXTHOP_AFI_IP6(ri->attr) ? AFI_IP6 + afi = BGP_ATTR_NEXTHOP_AFI_IP6(pi->attr) ? AFI_IP6 : AFI_IP; /* This will return TRUE if the global IPv6 NH is a link local * addr */ - if (make_prefix(afi, ri, &p) < 0) + if (make_prefix(afi, pi, &p) < 0) return 1; } else if (peer) { if (!sockunion2hostprefix(&peer->su, &p)) { @@ -246,19 +246,19 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, bnc->flags |= BGP_NEXTHOP_VALID; } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)) register_zebra_rnh(bnc, is_bgp_static_route); - if (ri && ri->nexthop != bnc) { + if (pi && pi->nexthop != bnc) { /* Unlink from existing nexthop cache, if any. This will also * free * the nexthop cache entry, if appropriate. */ - bgp_unlink_nexthop(ri); + bgp_unlink_nexthop(pi); - path_nh_map(ri, bnc, 1); /* updates NHT ri list reference */ + path_nh_map(pi, bnc, 1); /* updates NHT pi list reference */ if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) && bnc->metric) - (bgp_path_info_extra_get(ri))->igpmetric = bnc->metric; - else if (ri->extra) - ri->extra->igpmetric = 0; + (bgp_path_info_extra_get(pi))->igpmetric = bnc->metric; + else if (pi->extra) + pi->extra->igpmetric = 0; } else if (peer) bnc->nht_info = (void *)peer; /* NHT peer reference */ @@ -527,11 +527,11 @@ void bgp_cleanup_nexthops(struct bgp *bgp) * make_prefix - make a prefix structure from the path (essentially * path's node. */ -static int make_prefix(int afi, struct bgp_path_info *ri, struct prefix *p) +static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p) { - int is_bgp_static = ((ri->type == ZEBRA_ROUTE_BGP) - && (ri->sub_type == BGP_ROUTE_STATIC)) + int is_bgp_static = ((pi->type == ZEBRA_ROUTE_BGP) + && (pi->sub_type == BGP_ROUTE_STATIC)) ? 1 : 0; @@ -540,10 +540,10 @@ static int make_prefix(int afi, struct bgp_path_info *ri, struct prefix *p) case AFI_IP: p->family = AF_INET; if (is_bgp_static) { - p->u.prefix4 = ri->net->p.u.prefix4; - p->prefixlen = ri->net->p.prefixlen; + p->u.prefix4 = pi->net->p.u.prefix4; + p->prefixlen = pi->net->p.prefixlen; } else { - p->u.prefix4 = ri->attr->nexthop; + p->u.prefix4 = pi->attr->nexthop; p->prefixlen = IPV4_MAX_BITLEN; } break; @@ -551,10 +551,10 @@ static int make_prefix(int afi, struct bgp_path_info *ri, struct prefix *p) p->family = AF_INET6; if (is_bgp_static) { - p->u.prefix6 = ri->net->p.u.prefix6; - p->prefixlen = ri->net->p.prefixlen; + p->u.prefix6 = pi->net->p.u.prefix6; + p->prefixlen = pi->net->p.prefixlen; } else { - p->u.prefix6 = ri->attr->mp_nexthop_global; + p->u.prefix6 = pi->attr->mp_nexthop_global; p->prefixlen = IPV6_MAX_BITLEN; } break; diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 60b17a475d..263a3ebf4d 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -627,7 +627,7 @@ static int bgp_pbr_validate_policy_route(struct bgp_pbr_entry_main *api) /* return -1 if build or validation failed */ static int bgp_pbr_build_and_validate_entry(struct prefix *p, - struct bgp_path_info *info, + struct bgp_path_info *path, struct bgp_pbr_entry_main *api) { int ret; @@ -645,8 +645,8 @@ static int bgp_pbr_build_and_validate_entry(struct prefix *p, if (ret < 0) return -1; /* extract actiosn from flowspec ecom list */ - if (info && info->attr && info->attr->ecommunity) { - ecom = info->attr->ecommunity; + if (path && path->attr && path->attr->ecommunity) { + ecom = path->attr->ecommunity; for (i = 0; i < ecom->size; i++) { ecom_eval = (struct ecommunity_val *) (ecom->val + (i * ECOMMUNITY_SIZE)); @@ -690,7 +690,7 @@ static int bgp_pbr_build_and_validate_entry(struct prefix *p, (char)ECOMMUNITY_REDIRECT_IP_NH)) { api_action->action = ACTION_REDIRECT_IP; api_action->u.zr.redirect_ip_v4.s_addr = - info->attr->nexthop.s_addr; + path->attr->nexthop.s_addr; api_action->u.zr.duplicate = ecom_eval->val[7]; } else { if (ecom_eval->val[0] != diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index be2bda95f9..ea107ae135 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -188,25 +188,25 @@ static void bgp_path_info_extra_free(struct bgp_path_info_extra **extra) e->damp_info = NULL; if (e->parent) { - struct bgp_path_info *bi = (struct bgp_path_info *)e->parent; + struct bgp_path_info *bpi = (struct bgp_path_info *)e->parent; - if (bi->net) { + if (bpi->net) { /* FIXME: since multiple e may have the same e->parent * and e->parent->net is holding a refcount for each * of them, we need to do some fudging here. * - * WARNING: if bi->net->lock drops to 0, bi may be - * freed as well (because bi->net was holding the - * last reference to bi) => write after free! + * WARNING: if bpi->net->lock drops to 0, bpi may be + * freed as well (because bpi->net was holding the + * last reference to bpi) => write after free! */ unsigned refcount; - bi = bgp_path_info_lock(bi); - refcount = bi->net->lock - 1; - bgp_unlock_node((struct bgp_node *)bi->net); + bpi = bgp_path_info_lock(bpi); + refcount = bpi->net->lock - 1; + bgp_unlock_node((struct bgp_node *)bpi->net); if (!refcount) - bi->net = NULL; - bgp_path_info_unlock(bi); + bpi->net = NULL; + bgp_path_info_unlock(bpi); } bgp_path_info_unlock(e->parent); e->parent = NULL; @@ -225,11 +225,11 @@ static void bgp_path_info_extra_free(struct bgp_path_info_extra **extra) /* Get bgp_path_info extra information for the given bgp_path_info, lazy * allocated if required. */ -struct bgp_path_info_extra *bgp_path_info_extra_get(struct bgp_path_info *ri) +struct bgp_path_info_extra *bgp_path_info_extra_get(struct bgp_path_info *pi) { - if (!ri->extra) - ri->extra = bgp_path_info_extra_new(); - return ri->extra; + if (!pi->extra) + pi->extra = bgp_path_info_extra_new(); + return pi->extra; } /* Allocate new bgp info structure. */ @@ -284,100 +284,100 @@ struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path) return path; } -void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *ri) +void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *pi) { struct bgp_path_info *top; top = rn->info; - ri->next = rn->info; - ri->prev = NULL; + pi->next = rn->info; + pi->prev = NULL; if (top) - top->prev = ri; - rn->info = ri; + top->prev = pi; + rn->info = pi; - bgp_path_info_lock(ri); + bgp_path_info_lock(pi); bgp_lock_node(rn); - peer_lock(ri->peer); /* bgp_path_info peer reference */ + peer_lock(pi->peer); /* bgp_path_info peer reference */ } /* Do the actual removal of info from RIB, for use by bgp_process completion callback *only* */ -void bgp_path_info_reap(struct bgp_node *rn, struct bgp_path_info *ri) +void bgp_path_info_reap(struct bgp_node *rn, struct bgp_path_info *pi) { - if (ri->next) - ri->next->prev = ri->prev; - if (ri->prev) - ri->prev->next = ri->next; + if (pi->next) + pi->next->prev = pi->prev; + if (pi->prev) + pi->prev->next = pi->next; else - rn->info = ri->next; + rn->info = pi->next; - bgp_path_info_mpath_dequeue(ri); - bgp_path_info_unlock(ri); + bgp_path_info_mpath_dequeue(pi); + bgp_path_info_unlock(pi); bgp_unlock_node(rn); } -void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *ri) +void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *pi) { - bgp_path_info_set_flag(rn, ri, BGP_PATH_REMOVED); + bgp_path_info_set_flag(rn, pi, BGP_PATH_REMOVED); /* set of previous already took care of pcount */ - UNSET_FLAG(ri->flags, BGP_PATH_VALID); + UNSET_FLAG(pi->flags, BGP_PATH_VALID); } /* undo the effects of a previous call to bgp_path_info_delete; typically called when a route is deleted and then quickly re-added before the deletion has been processed */ -void bgp_path_info_restore(struct bgp_node *rn, struct bgp_path_info *ri) +void bgp_path_info_restore(struct bgp_node *rn, struct bgp_path_info *pi) { - bgp_path_info_unset_flag(rn, ri, BGP_PATH_REMOVED); + bgp_path_info_unset_flag(rn, pi, BGP_PATH_REMOVED); /* unset of previous already took care of pcount */ - SET_FLAG(ri->flags, BGP_PATH_VALID); + SET_FLAG(pi->flags, BGP_PATH_VALID); } /* Adjust pcount as required */ -static void bgp_pcount_adjust(struct bgp_node *rn, struct bgp_path_info *ri) +static void bgp_pcount_adjust(struct bgp_node *rn, struct bgp_path_info *pi) { struct bgp_table *table; assert(rn && bgp_node_table(rn)); - assert(ri && ri->peer && ri->peer->bgp); + assert(pi && pi->peer && pi->peer->bgp); table = bgp_node_table(rn); - if (ri->peer == ri->peer->bgp->peer_self) + if (pi->peer == pi->peer->bgp->peer_self) return; - if (!BGP_PATH_COUNTABLE(ri) - && CHECK_FLAG(ri->flags, BGP_PATH_COUNTED)) { + if (!BGP_PATH_COUNTABLE(pi) + && CHECK_FLAG(pi->flags, BGP_PATH_COUNTED)) { - UNSET_FLAG(ri->flags, BGP_PATH_COUNTED); + UNSET_FLAG(pi->flags, BGP_PATH_COUNTED); /* slight hack, but more robust against errors. */ - if (ri->peer->pcount[table->afi][table->safi]) - ri->peer->pcount[table->afi][table->safi]--; + if (pi->peer->pcount[table->afi][table->safi]) + pi->peer->pcount[table->afi][table->safi]--; else flog_err(EC_LIB_DEVELOPMENT, "Asked to decrement 0 prefix count for peer"); - } else if (BGP_PATH_COUNTABLE(ri) - && !CHECK_FLAG(ri->flags, BGP_PATH_COUNTED)) { - SET_FLAG(ri->flags, BGP_PATH_COUNTED); - ri->peer->pcount[table->afi][table->safi]++; + } else if (BGP_PATH_COUNTABLE(pi) + && !CHECK_FLAG(pi->flags, BGP_PATH_COUNTED)) { + SET_FLAG(pi->flags, BGP_PATH_COUNTED); + pi->peer->pcount[table->afi][table->safi]++; } } -static int bgp_label_index_differs(struct bgp_path_info *ri1, - struct bgp_path_info *ri2) +static int bgp_label_index_differs(struct bgp_path_info *pi1, + struct bgp_path_info *pi2) { - return (!(ri1->attr->label_index == ri2->attr->label_index)); + return (!(pi1->attr->label_index == pi2->attr->label_index)); } /* Set/unset bgp_path_info flags, adjusting any other state as needed. * This is here primarily to keep prefix-count in check. */ -void bgp_path_info_set_flag(struct bgp_node *rn, struct bgp_path_info *ri, +void bgp_path_info_set_flag(struct bgp_node *rn, struct bgp_path_info *pi, uint32_t flag) { - SET_FLAG(ri->flags, flag); + SET_FLAG(pi->flags, flag); /* early bath if we know it's not a flag that changes countability state */ @@ -385,13 +385,13 @@ void bgp_path_info_set_flag(struct bgp_node *rn, struct bgp_path_info *ri, BGP_PATH_VALID | BGP_PATH_HISTORY | BGP_PATH_REMOVED)) return; - bgp_pcount_adjust(rn, ri); + bgp_pcount_adjust(rn, pi); } -void bgp_path_info_unset_flag(struct bgp_node *rn, struct bgp_path_info *ri, +void bgp_path_info_unset_flag(struct bgp_node *rn, struct bgp_path_info *pi, uint32_t flag) { - UNSET_FLAG(ri->flags, flag); + UNSET_FLAG(pi->flags, flag); /* early bath if we know it's not a flag that changes countability state */ @@ -399,7 +399,7 @@ void bgp_path_info_unset_flag(struct bgp_node *rn, struct bgp_path_info *ri, BGP_PATH_VALID | BGP_PATH_HISTORY | BGP_PATH_REMOVED)) return; - bgp_pcount_adjust(rn, ri); + bgp_pcount_adjust(rn, pi); } /* Get MED value. If MED value is missing and "bgp bestpath @@ -416,13 +416,13 @@ static uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp) } } -void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *ri, char *buf) +void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi, char *buf) { - if (ri->addpath_rx_id) - sprintf(buf, "path %s (addpath rxid %d)", ri->peer->host, - ri->addpath_rx_id); + if (pi->addpath_rx_id) + sprintf(buf, "path %s (addpath rxid %d)", pi->peer->host, + pi->addpath_rx_id); else - sprintf(buf, "path %s", ri->peer->host); + sprintf(buf, "path %s", pi->peer->host); } /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. @@ -1168,7 +1168,7 @@ static int bgp_input_modifier(struct peer *peer, struct prefix *p, const char *rmap_name) { struct bgp_filter *filter; - struct bgp_path_info info; + struct bgp_path_info rmap_path; route_map_result_t ret; struct route_map *rmap = NULL; @@ -1194,15 +1194,15 @@ static int bgp_input_modifier(struct peer *peer, struct prefix *p, /* Route map apply. */ if (rmap) { - memset(&info, 0, sizeof(struct bgp_path_info)); + memset(&rmap_path, 0, sizeof(struct bgp_path_info)); /* Duplicate current value to new strucutre for modification. */ - info.peer = peer; - info.attr = attr; + rmap_path.peer = peer; + rmap_path.attr = attr; SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN); /* Apply BGP route map to the attribute. */ - ret = route_map_apply(rmap, p, RMAP_BGP, &info); + ret = route_map_apply(rmap, p, RMAP_BGP, &rmap_path); peer->rmap_type = 0; @@ -1216,7 +1216,7 @@ static int bgp_output_modifier(struct peer *peer, struct prefix *p, struct attr *attr, afi_t afi, safi_t safi, const char *rmap_name) { - struct bgp_path_info info; + struct bgp_path_info rmap_path; route_map_result_t ret; struct route_map *rmap = NULL; uint8_t rmap_type; @@ -1243,17 +1243,17 @@ static int bgp_output_modifier(struct peer *peer, struct prefix *p, if (rmap == NULL) return RMAP_DENY; - memset(&info, 0, sizeof(struct bgp_path_info)); + memset(&rmap_path, 0, sizeof(struct bgp_path_info)); /* Route map apply. */ /* Duplicate current value to new strucutre for modification. */ - info.peer = peer; - info.attr = attr; + rmap_path.peer = peer; + rmap_path.attr = attr; rmap_type = peer->rmap_type; SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT); /* Apply BGP route map to the attribute. */ - ret = route_map_apply(rmap, p, RMAP_BGP, &info); + ret = route_map_apply(rmap, p, RMAP_BGP, &rmap_path); peer->rmap_type = rmap_type; @@ -1376,7 +1376,7 @@ static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr) memset(&attr->mp_nexthop_global_in, 0, BGP_ATTR_NHLEN_IPV4); } -int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, +int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi, struct update_subgroup *subgrp, struct prefix *p, struct attr *attr) { @@ -1385,7 +1385,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, struct peer *peer; struct peer *onlypeer; struct bgp *bgp; - struct attr *riattr; + struct attr *piattr; char buf[PREFIX_STRLEN]; int ret; int transparent; @@ -1404,16 +1404,16 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) onlypeer = SUBGRP_PFIRST(subgrp)->peer; - from = ri->peer; + from = pi->peer; filter = &peer->filter[afi][safi]; bgp = SUBGRP_INST(subgrp); - riattr = bgp_path_info_mpath_count(ri) ? bgp_path_info_mpath_attr(ri) - : ri->attr; + piattr = bgp_path_info_mpath_count(pi) ? bgp_path_info_mpath_attr(pi) + : pi->attr; #if ENABLE_BGP_VNC if (((afi == AFI_IP) || (afi == AFI_IP6)) && (safi == SAFI_MPLS_VPN) - && ((ri->type == ZEBRA_ROUTE_BGP_DIRECT) - || (ri->type == ZEBRA_ROUTE_BGP_DIRECT_EXT))) { + && ((pi->type == ZEBRA_ROUTE_BGP_DIRECT) + || (pi->type == ZEBRA_ROUTE_BGP_DIRECT_EXT))) { /* * direct and direct_ext type routes originate internally even @@ -1429,8 +1429,8 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, if (((afi == AFI_IP) || (afi == AFI_IP6)) && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_UNICAST)) - && (ri->type == ZEBRA_ROUTE_BGP) - && (ri->sub_type == BGP_ROUTE_IMPORTED)) { + && (pi->type == ZEBRA_ROUTE_BGP) + && (pi->sub_type == BGP_ROUTE_IMPORTED)) { /* Applies to routes leaked vpn->vrf and vrf->vpn */ @@ -1438,24 +1438,24 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, } /* With addpath we may be asked to TX all kinds of paths so make sure - * ri is valid */ - if (!CHECK_FLAG(ri->flags, BGP_PATH_VALID) - || CHECK_FLAG(ri->flags, BGP_PATH_HISTORY) - || CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) { + * pi is valid */ + if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID) + || CHECK_FLAG(pi->flags, BGP_PATH_HISTORY) + || CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { return 0; } /* If this is not the bestpath then check to see if there is an enabled * addpath * feature that requires us to advertise it */ - if (!CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)) { - if (!bgp_addpath_tx_path(peer, afi, safi, ri)) { + if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { + if (!bgp_addpath_tx_path(peer, afi, safi, pi)) { return 0; } } /* Aggregate-address suppress check. */ - if (ri->extra && ri->extra->suppress) + if (pi->extra && pi->extra->suppress) if (!UNSUPPRESS_MAP_NAME(filter)) { return 0; } @@ -1466,13 +1466,13 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, * off box as that the RT and RD created are localy * significant and globaly useless. */ - if (safi == SAFI_MPLS_VPN && ri->extra && ri->extra->num_labels - && ri->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) + if (safi == SAFI_MPLS_VPN && pi->extra && pi->extra->num_labels + && pi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) return 0; /* If it's labeled safi, make sure the route has a valid label. */ if (safi == SAFI_LABELED_UNICAST) { - mpls_label_t label = bgp_adv_label(rn, ri, peer, afi, safi); + mpls_label_t label = bgp_adv_label(rn, pi, peer, afi, safi); if (!bgp_is_valid_label(&label)) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug("u%" PRIu64 ":s%" PRIu64 @@ -1508,7 +1508,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, transparent = 0; /* If community is not disabled check the no-export and local. */ - if (!transparent && bgp_community_filter(peer, riattr)) { + if (!transparent && bgp_community_filter(peer, piattr)) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug( "subgrpannouncecheck: community filter check fail"); @@ -1517,8 +1517,8 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, /* If the attribute has originator-id and it is same as remote peer's id. */ - if (onlypeer && riattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID) - && (IPV4_ADDR_SAME(&onlypeer->remote_id, &riattr->originator_id))) { + if (onlypeer && piattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID) + && (IPV4_ADDR_SAME(&onlypeer->remote_id, &piattr->originator_id))) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug( "%s [Update:SEND] %s originator-id is same as " @@ -1548,7 +1548,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, } /* Output filter check. */ - if (bgp_output_filter(peer, p, riattr, afi, safi) == FILTER_DENY) { + if (bgp_output_filter(peer, p, piattr, afi, safi) == FILTER_DENY) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug("%s [Update:SEND] %s is filtered", peer->host, prefix2str(p, buf, sizeof(buf))); @@ -1557,7 +1557,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, #ifdef BGP_SEND_ASPATH_CHECK /* AS path loop check. */ - if (onlypeer && aspath_loop_check(riattr->aspath, onlypeer->as)) { + if (onlypeer && aspath_loop_check(piattr->aspath, onlypeer->as)) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug( "%s [Update:SEND] suppress announcement to peer AS %u " @@ -1569,7 +1569,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, /* If we're a CONFED we need to loop check the CONFED ID too */ if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) { - if (aspath_loop_check(riattr->aspath, bgp->confed_id)) { + if (aspath_loop_check(piattr->aspath, bgp->confed_id)) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug( "%s [Update:SEND] suppress announcement to peer AS %u" @@ -1609,7 +1609,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, } /* For modify attribute, copy it to temporary structure. */ - bgp_attr_dup(attr, riattr); + bgp_attr_dup(attr, piattr); /* If local-preference is not set. */ if ((peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED) @@ -1699,19 +1699,19 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, bgp_peer_as_override(bgp, afi, safi, peer, attr); /* Route map & unsuppress-map apply. */ - if (ROUTE_MAP_OUT_NAME(filter) || (ri->extra && ri->extra->suppress)) { - struct bgp_path_info info; - struct bgp_path_info_extra dummy_info_extra; + if (ROUTE_MAP_OUT_NAME(filter) || (pi->extra && pi->extra->suppress)) { + struct bgp_path_info rmap_path; + struct bgp_path_info_extra dummy_rmap_path_extra; struct attr dummy_attr; - memset(&info, 0, sizeof(struct bgp_path_info)); - info.peer = peer; - info.attr = attr; + memset(&rmap_path, 0, sizeof(struct bgp_path_info)); + rmap_path.peer = peer; + rmap_path.attr = attr; - if (ri->extra) { - memcpy(&dummy_info_extra, ri->extra, + if (pi->extra) { + memcpy(&dummy_rmap_path_extra, pi->extra, sizeof(struct bgp_path_info_extra)); - info.extra = &dummy_info_extra; + rmap_path.extra = &dummy_rmap_path_extra; } /* don't confuse inbound and outbound setting */ @@ -1725,17 +1725,17 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, && !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { bgp_attr_dup(&dummy_attr, attr); - info.attr = &dummy_attr; + rmap_path.attr = &dummy_attr; } SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT); - if (ri->extra && ri->extra->suppress) + if (pi->extra && pi->extra->suppress) ret = route_map_apply(UNSUPPRESS_MAP(filter), p, - RMAP_BGP, &info); + RMAP_BGP, &rmap_path); else ret = route_map_apply(ROUTE_MAP_OUT(filter), p, - RMAP_BGP, &info); + RMAP_BGP, &rmap_path); peer->rmap_type = 0; @@ -1774,7 +1774,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, * it is configured as 'peer-address'. */ if (!bgp_rmap_nhop_changed(attr->rmap_change_flags, - riattr->rmap_change_flags) + piattr->rmap_change_flags) && !transparent && !CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) { @@ -1799,14 +1799,14 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *ri, * Note: 3rd party nexthop currently implemented for * IPv4 only. */ - if (!bgp_subgrp_multiaccess_check_v4(riattr->nexthop, + if (!bgp_subgrp_multiaccess_check_v4(piattr->nexthop, subgrp)) subgroup_announce_reset_nhop( (peer_cap_enhe(peer, afi, safi) ? AF_INET6 : p->family), attr); - } else if (CHECK_FLAG(ri->flags, BGP_PATH_ANNC_NH_SELF)) { + } else if (CHECK_FLAG(pi->flags, BGP_PATH_ANNC_NH_SELF)) { /* * This flag is used for leaked vpn-vrf routes */ @@ -1846,10 +1846,10 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, { struct bgp_path_info *new_select; struct bgp_path_info *old_select; - struct bgp_path_info *ri; - struct bgp_path_info *ri1; - struct bgp_path_info *ri2; - struct bgp_path_info *nextri = NULL; + struct bgp_path_info *pi; + struct bgp_path_info *pi1; + struct bgp_path_info *pi2; + struct bgp_path_info *nextpi = NULL; int paths_eq, do_mpath, debug; struct list mp_list; char pfx_buf[PREFIX2STR_BUFFER]; @@ -1869,43 +1869,43 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { /* Clear BGP_PATH_DMED_SELECTED for all paths */ - for (ri1 = rn->info; ri1; ri1 = ri1->next) - bgp_path_info_unset_flag(rn, ri1, + for (pi1 = rn->info; pi1; pi1 = pi1->next) + bgp_path_info_unset_flag(rn, pi1, BGP_PATH_DMED_SELECTED); - for (ri1 = rn->info; ri1; ri1 = ri1->next) { - if (CHECK_FLAG(ri1->flags, BGP_PATH_DMED_CHECK)) + for (pi1 = rn->info; pi1; pi1 = pi1->next) { + if (CHECK_FLAG(pi1->flags, BGP_PATH_DMED_CHECK)) continue; - if (BGP_PATH_HOLDDOWN(ri1)) + if (BGP_PATH_HOLDDOWN(pi1)) continue; - if (ri1->peer && ri1->peer != bgp->peer_self) - if (ri1->peer->status != Established) + if (pi1->peer && pi1->peer != bgp->peer_self) + if (pi1->peer->status != Established) continue; - new_select = ri1; - if (ri1->next) { - for (ri2 = ri1->next; ri2; ri2 = ri2->next) { - if (CHECK_FLAG(ri2->flags, + new_select = pi1; + if (pi1->next) { + for (pi2 = pi1->next; pi2; pi2 = pi2->next) { + if (CHECK_FLAG(pi2->flags, BGP_PATH_DMED_CHECK)) continue; - if (BGP_PATH_HOLDDOWN(ri2)) + if (BGP_PATH_HOLDDOWN(pi2)) continue; - if (ri2->peer - && ri2->peer != bgp->peer_self + if (pi2->peer + && pi2->peer != bgp->peer_self && !CHECK_FLAG( - ri2->peer->sflags, + pi2->peer->sflags, PEER_STATUS_NSF_WAIT)) - if (ri2->peer->status + if (pi2->peer->status != Established) continue; - if (aspath_cmp_left(ri1->attr->aspath, - ri2->attr->aspath) + if (aspath_cmp_left(pi1->attr->aspath, + pi2->attr->aspath) || aspath_cmp_left_confed( - ri1->attr->aspath, - ri2->attr->aspath)) { + pi1->attr->aspath, + pi2->attr->aspath)) { if (bgp_path_info_cmp( - bgp, ri2, + bgp, pi2, new_select, &paths_eq, mpath_cfg, debug, @@ -1914,11 +1914,11 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, bgp_path_info_unset_flag( rn, new_select, BGP_PATH_DMED_SELECTED); - new_select = ri2; + new_select = pi2; } bgp_path_info_set_flag( - rn, ri2, + rn, pi2, BGP_PATH_DMED_CHECK); } } @@ -1942,51 +1942,51 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, /* Check old selected route and new selected route. */ old_select = NULL; new_select = NULL; - for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); - ri = nextri) { - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)) - old_select = ri; + for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1); + pi = nextpi) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) + old_select = pi; - if (BGP_PATH_HOLDDOWN(ri)) { + if (BGP_PATH_HOLDDOWN(pi)) { /* reap REMOVED routes, if needs be * selected route must stay for a while longer though */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED) - && (ri != old_select)) - bgp_path_info_reap(rn, ri); + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) + && (pi != old_select)) + bgp_path_info_reap(rn, pi); if (debug) - zlog_debug("%s: ri %p in holddown", __func__, - ri); + zlog_debug("%s: pi %p in holddown", __func__, + pi); continue; } - if (ri->peer && ri->peer != bgp->peer_self - && !CHECK_FLAG(ri->peer->sflags, PEER_STATUS_NSF_WAIT)) - if (ri->peer->status != Established) { + if (pi->peer && pi->peer != bgp->peer_self + && !CHECK_FLAG(pi->peer->sflags, PEER_STATUS_NSF_WAIT)) + if (pi->peer->status != Established) { if (debug) zlog_debug( - "%s: ri %p non self peer %s not estab state", - __func__, ri, ri->peer->host); + "%s: pi %p non self peer %s not estab state", + __func__, pi, pi->peer->host); continue; } if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) - && (!CHECK_FLAG(ri->flags, BGP_PATH_DMED_SELECTED))) { - bgp_path_info_unset_flag(rn, ri, BGP_PATH_DMED_CHECK); + && (!CHECK_FLAG(pi->flags, BGP_PATH_DMED_SELECTED))) { + bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK); if (debug) - zlog_debug("%s: ri %p dmed", __func__, ri); + zlog_debug("%s: pi %p dmed", __func__, pi); continue; } - bgp_path_info_unset_flag(rn, ri, BGP_PATH_DMED_CHECK); + bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK); - if (bgp_path_info_cmp(bgp, ri, new_select, &paths_eq, mpath_cfg, + if (bgp_path_info_cmp(bgp, pi, new_select, &paths_eq, mpath_cfg, debug, pfx_buf, afi, safi)) { - new_select = ri; + new_select = pi; } } @@ -2007,32 +2007,32 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, } if (do_mpath && new_select) { - for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); - ri = nextri) { + for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1); + pi = nextpi) { if (debug) bgp_path_info_path_with_addpath_rx_str( - ri, path_buf); + pi, path_buf); - if (ri == new_select) { + if (pi == new_select) { if (debug) zlog_debug( "%s: %s is the bestpath, add to the multipath list", pfx_buf, path_buf); - bgp_mp_list_add(&mp_list, ri); + bgp_mp_list_add(&mp_list, pi); continue; } - if (BGP_PATH_HOLDDOWN(ri)) + if (BGP_PATH_HOLDDOWN(pi)) continue; - if (ri->peer && ri->peer != bgp->peer_self - && !CHECK_FLAG(ri->peer->sflags, + if (pi->peer && pi->peer != bgp->peer_self + && !CHECK_FLAG(pi->peer->sflags, PEER_STATUS_NSF_WAIT)) - if (ri->peer->status != Established) + if (pi->peer->status != Established) continue; - if (!bgp_path_info_nexthop_cmp(ri, new_select)) { + if (!bgp_path_info_nexthop_cmp(pi, new_select)) { if (debug) zlog_debug( "%s: %s has the same nexthop as the bestpath, skip it", @@ -2040,7 +2040,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, continue; } - bgp_path_info_cmp(bgp, ri, new_select, &paths_eq, + bgp_path_info_cmp(bgp, pi, new_select, &paths_eq, mpath_cfg, debug, pfx_buf, afi, safi); if (paths_eq) { @@ -2048,7 +2048,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, zlog_debug( "%s: %s is equivalent to the bestpath, add to the multipath list", pfx_buf, path_buf); - bgp_mp_list_add(&mp_list, ri); + bgp_mp_list_add(&mp_list, pi); } } } @@ -2124,13 +2124,13 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp, */ void bgp_zebra_clear_route_change_flags(struct bgp_node *rn) { - struct bgp_path_info *ri; + struct bgp_path_info *pi; - for (ri = rn->info; ri; ri = ri->next) { - if (BGP_PATH_HOLDDOWN(ri)) + for (pi = rn->info; pi; pi = pi->next) { + if (BGP_PATH_HOLDDOWN(pi)) continue; - UNSET_FLAG(ri->flags, BGP_PATH_IGP_CHANGED); - UNSET_FLAG(ri->flags, BGP_PATH_ATTR_CHANGED); + UNSET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED); + UNSET_FLAG(pi->flags, BGP_PATH_ATTR_CHANGED); } } @@ -2682,18 +2682,18 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi, /* Unconditionally remove the route from the RIB, without taking * damping into consideration (eg, because the session went down) */ -void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *ri, +void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *pi, struct peer *peer, afi_t afi, safi_t safi) { - bgp_aggregate_decrement(peer->bgp, &rn->p, ri, afi, safi); + bgp_aggregate_decrement(peer->bgp, &rn->p, pi, afi, safi); - if (!CHECK_FLAG(ri->flags, BGP_PATH_HISTORY)) - bgp_path_info_delete(rn, ri); /* keep historical info */ + if (!CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) + bgp_path_info_delete(rn, pi); /* keep historical info */ bgp_process(peer->bgp, rn, afi, safi); } -static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *ri, +static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *pi, struct peer *peer, afi_t afi, safi_t safi, struct prefix_rd *prd) { @@ -2702,9 +2702,9 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *ri, */ if (CHECK_FLAG(peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) && peer->sort == BGP_PEER_EBGP) - if ((bgp_damp_withdraw(ri, rn, afi, safi, 0)) + if ((bgp_damp_withdraw(pi, rn, afi, safi, 0)) == BGP_DAMP_SUPPRESSED) { - bgp_aggregate_decrement(peer->bgp, &rn->p, ri, afi, + bgp_aggregate_decrement(peer->bgp, &rn->p, pi, afi, safi); return; } @@ -2720,25 +2720,25 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *ri, table = (struct bgp_table *)(prn->info); vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( - peer->bgp, prd, table, &rn->p, ri); + peer->bgp, prd, table, &rn->p, pi); } bgp_unlock_node(prn); } if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { - vnc_import_bgp_del_route(peer->bgp, &rn->p, ri); + vnc_import_bgp_del_route(peer->bgp, &rn->p, pi); vnc_import_bgp_exterior_del_route(peer->bgp, &rn->p, - ri); + pi); } } #endif /* If this is an EVPN route, process for un-import. */ if (safi == SAFI_EVPN) - bgp_evpn_unimport_route(peer->bgp, afi, safi, &rn->p, ri); + bgp_evpn_unimport_route(peer->bgp, afi, safi, &rn->p, pi); - bgp_rib_remove(rn, ri, peer, afi, safi); + bgp_rib_remove(rn, pi, peer, afi, safi); } struct bgp_path_info *info_make(int type, int sub_type, unsigned short instance, @@ -2782,12 +2782,12 @@ static void overlay_index_update(struct attr *attr, } } -static bool overlay_index_equal(afi_t afi, struct bgp_path_info *info, +static bool overlay_index_equal(afi_t afi, struct bgp_path_info *path, struct eth_segment_id *eth_s_id, union gw_addr *gw_ip) { - struct eth_segment_id *info_eth_s_id, *info_eth_s_id_remote; - union gw_addr *info_gw_ip, *info_gw_ip_remote; + struct eth_segment_id *path_eth_s_id, *path_eth_s_id_remote; + union gw_addr *path_gw_ip, *path_gw_ip_remote; union { struct eth_segment_id esi; union gw_addr ip; @@ -2795,34 +2795,34 @@ static bool overlay_index_equal(afi_t afi, struct bgp_path_info *info, if (afi != AFI_L2VPN) return true; - if (!info->attr) { + if (!path->attr) { memset(&temp, 0, sizeof(temp)); - info_eth_s_id = &temp.esi; - info_gw_ip = &temp.ip; + path_eth_s_id = &temp.esi; + path_gw_ip = &temp.ip; if (eth_s_id == NULL && gw_ip == NULL) return true; } else { - info_eth_s_id = &(info->attr->evpn_overlay.eth_s_id); - info_gw_ip = &(info->attr->evpn_overlay.gw_ip); + path_eth_s_id = &(path->attr->evpn_overlay.eth_s_id); + path_gw_ip = &(path->attr->evpn_overlay.gw_ip); } if (gw_ip == NULL) { memset(&temp, 0, sizeof(temp)); - info_gw_ip_remote = &temp.ip; + path_gw_ip_remote = &temp.ip; } else - info_gw_ip_remote = gw_ip; + path_gw_ip_remote = gw_ip; if (eth_s_id == NULL) { memset(&temp, 0, sizeof(temp)); - info_eth_s_id_remote = &temp.esi; + path_eth_s_id_remote = &temp.esi; } else - info_eth_s_id_remote = eth_s_id; + path_eth_s_id_remote = eth_s_id; - if (!memcmp(info_gw_ip, info_gw_ip_remote, sizeof(union gw_addr))) + if (!memcmp(path_gw_ip, path_gw_ip_remote, sizeof(union gw_addr))) return false; - return !memcmp(info_eth_s_id, info_eth_s_id_remote, + return !memcmp(path_eth_s_id, path_eth_s_id_remote, sizeof(struct eth_segment_id)); } @@ -2891,7 +2891,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, struct bgp *bgp; struct attr new_attr; struct attr *attr_new; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_path_info *new; struct bgp_path_info_extra *extra; const char *reason; @@ -2924,10 +2924,10 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, bgp_adj_in_set(rn, peer, attr, addpath_id); /* Check previously received route. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == peer && ri->type == type - && ri->sub_type == sub_type - && ri->addpath_rx_id == addpath_id) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == peer && pi->type == type + && pi->sub_type == sub_type + && pi->addpath_rx_id == addpath_id) break; /* AS path local-as loop check. */ @@ -3027,24 +3027,24 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, attr_new = bgp_attr_intern(&new_attr); /* If the update is implicit withdraw. */ - if (ri) { - ri->uptime = bgp_clock(); - same_attr = attrhash_cmp(ri->attr, attr_new); + if (pi) { + pi->uptime = bgp_clock(); + same_attr = attrhash_cmp(pi->attr, attr_new); /* Same attribute comes in. */ - if (!CHECK_FLAG(ri->flags, BGP_PATH_REMOVED) - && attrhash_cmp(ri->attr, attr_new) + if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) + && attrhash_cmp(pi->attr, attr_new) && (!has_valid_label - || memcmp(&(bgp_path_info_extra_get(ri))->label, label, + || memcmp(&(bgp_path_info_extra_get(pi))->label, label, num_labels * sizeof(mpls_label_t)) == 0) && (overlay_index_equal( - afi, ri, evpn == NULL ? NULL : &evpn->eth_s_id, + afi, pi, evpn == NULL ? NULL : &evpn->eth_s_id, evpn == NULL ? NULL : &evpn->gw_ip))) { if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) && peer->sort == BGP_PEER_EBGP - && CHECK_FLAG(ri->flags, BGP_PATH_HISTORY)) { + && CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) { if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str( afi, safi, prd, p, label, @@ -3055,9 +3055,9 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, pfx_buf); } - if (bgp_damp_update(ri, rn, afi, safi) + if (bgp_damp_update(pi, rn, afi, safi) != BGP_DAMP_SUPPRESSED) { - bgp_aggregate_increment(bgp, p, ri, afi, + bgp_aggregate_increment(bgp, p, pi, afi, safi); bgp_process(bgp, rn, afi, safi); } @@ -3083,9 +3083,9 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, } /* graceful restart STALE flag unset. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_STALE)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_STALE)) { bgp_path_info_unset_flag( - rn, ri, BGP_PATH_STALE); + rn, pi, BGP_PATH_STALE); bgp_process(bgp, rn, afi, safi); } } @@ -3097,7 +3097,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, } /* Withdraw/Announce before we fully processed the withdraw */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str( afi, safi, prd, p, label, num_labels, @@ -3108,7 +3108,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, peer->host, pfx_buf); } - bgp_path_info_restore(rn, ri); + bgp_path_info_restore(rn, pi); } /* Received Logging. */ @@ -3121,16 +3121,16 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, } /* graceful restart STALE flag unset. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_STALE)) - bgp_path_info_unset_flag(rn, ri, BGP_PATH_STALE); + if (CHECK_FLAG(pi->flags, BGP_PATH_STALE)) + bgp_path_info_unset_flag(rn, pi, BGP_PATH_STALE); /* The attribute is changed. */ - bgp_path_info_set_flag(rn, ri, BGP_PATH_ATTR_CHANGED); + bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED); /* implicit withdraw, decrement aggregate and pcount here. * only if update is accepted, they'll increment below. */ - bgp_aggregate_decrement(bgp, p, ri, afi, safi); + bgp_aggregate_decrement(bgp, p, pi, afi, safi); /* Update bgp route dampening information. */ if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) @@ -3138,8 +3138,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, /* This is implicit withdraw so we should update dampening information. */ - if (!CHECK_FLAG(ri->flags, BGP_PATH_HISTORY)) - bgp_damp_withdraw(ri, rn, afi, safi, 1); + if (!CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) + bgp_damp_withdraw(pi, rn, afi, safi, 1); } #if ENABLE_BGP_VNC if (safi == SAFI_MPLS_VPN) { @@ -3152,19 +3152,19 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, table = (struct bgp_table *)(prn->info); vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( - bgp, prd, table, p, ri); + bgp, prd, table, p, pi); } bgp_unlock_node(prn); } if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { /* * Implicit withdraw case. */ ++vnc_implicit_withdraw; - vnc_import_bgp_del_route(bgp, p, ri); - vnc_import_bgp_exterior_del_route(bgp, p, ri); + vnc_import_bgp_del_route(bgp, p, pi); + vnc_import_bgp_exterior_del_route(bgp, p, pi); } } #endif @@ -3177,35 +3177,35 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, * community. */ if (safi == SAFI_EVPN && !same_attr) { - if ((ri->attr->flag + if ((pi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) && (attr_new->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) { int cmp; - cmp = ecommunity_cmp(ri->attr->ecommunity, + cmp = ecommunity_cmp(pi->attr->ecommunity, attr_new->ecommunity); if (!cmp) { if (bgp_debug_update(peer, p, NULL, 1)) zlog_debug( "Change in EXT-COMM, existing %s new %s", ecommunity_str( - ri->attr->ecommunity), + pi->attr->ecommunity), ecommunity_str( attr_new->ecommunity)); bgp_evpn_unimport_route(bgp, afi, safi, - p, ri); + p, pi); } } } /* Update to new attribute. */ - bgp_attr_unintern(&ri->attr); - ri->attr = attr_new; + bgp_attr_unintern(&pi->attr); + pi->attr = attr_new; /* Update MPLS label */ if (has_valid_label) { - extra = bgp_path_info_extra_get(ri); + extra = bgp_path_info_extra_get(pi); memcpy(&extra->label, label, num_labels * sizeof(mpls_label_t)); extra->num_labels = num_labels; @@ -3230,15 +3230,15 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, * changes) which * trigger re-importation of the entire RIB. */ - vnc_import_bgp_add_route(bgp, p, ri); - vnc_import_bgp_exterior_add_route(bgp, p, ri); + vnc_import_bgp_add_route(bgp, p, pi); + vnc_import_bgp_exterior_add_route(bgp, p, pi); } } #endif /* Update Overlay Index */ if (afi == AFI_L2VPN) { overlay_index_update( - ri->attr, evpn == NULL ? NULL : &evpn->eth_s_id, + pi->attr, evpn == NULL ? NULL : &evpn->eth_s_id, evpn == NULL ? NULL : &evpn->gw_ip); } @@ -3246,7 +3246,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) && peer->sort == BGP_PEER_EBGP) { /* Now we do normal update dampening. */ - ret = bgp_damp_update(ri, rn, afi, safi); + ret = bgp_damp_update(pi, rn, afi, safi); if (ret == BGP_DAMP_SUPPRESSED) { bgp_unlock_node(rn); return 0; @@ -3268,13 +3268,13 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, struct bgp *bgp_nexthop = bgp; - if (ri->extra && ri->extra->bgp_orig) - bgp_nexthop = ri->extra->bgp_orig; + if (pi->extra && pi->extra->bgp_orig) + bgp_nexthop = pi->extra->bgp_orig; - if (bgp_find_or_add_nexthop(bgp, bgp_nexthop, afi, - ri, NULL, connected) + if (bgp_find_or_add_nexthop(bgp, bgp_nexthop, afi, pi, + NULL, connected) || CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)) - bgp_path_info_set_flag(rn, ri, BGP_PATH_VALID); + bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID); else { if (BGP_DEBUG(nht, NHT)) { char buf1[INET6_ADDRSTRLEN]; @@ -3285,11 +3285,11 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); } - bgp_path_info_unset_flag(rn, ri, + bgp_path_info_unset_flag(rn, pi, BGP_PATH_VALID); } } else - bgp_path_info_set_flag(rn, ri, BGP_PATH_VALID); + bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID); #if ENABLE_BGP_VNC if (safi == SAFI_MPLS_VPN) { @@ -3302,7 +3302,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, table = (struct bgp_table *)(prn->info); vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( - bgp, prd, table, p, ri); + bgp, prd, table, p, pi); } bgp_unlock_node(prn); } @@ -3321,10 +3321,10 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, * the attributes for the route in the VNI(s). */ if (safi == SAFI_EVPN && !same_attr) - bgp_evpn_import_route(bgp, afi, safi, p, ri); + bgp_evpn_import_route(bgp, afi, safi, p, pi); /* Process change. */ - bgp_aggregate_increment(bgp, p, ri, afi, safi); + bgp_aggregate_increment(bgp, p, pi, afi, safi); bgp_process(bgp, rn, afi, safi); bgp_unlock_node(rn); @@ -3333,12 +3333,12 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_from_vrf_update(bgp_get_default(), bgp, ri); + vpn_leak_from_vrf_update(bgp_get_default(), bgp, pi); } if ((SAFI_MPLS_VPN == safi) && (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_to_vrf_update(bgp, ri); + vpn_leak_to_vrf_update(bgp, pi); } #if ENABLE_BGP_VNC @@ -3499,25 +3499,25 @@ filtered: peer->host, pfx_buf, reason); } - if (ri) { + if (pi) { /* If this is an EVPN route, un-import it as it is now filtered. */ if (safi == SAFI_EVPN) - bgp_evpn_unimport_route(bgp, afi, safi, p, ri); + bgp_evpn_unimport_route(bgp, afi, safi, p, pi); if (SAFI_UNICAST == safi && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, ri); + vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, pi); } if ((SAFI_MPLS_VPN == safi) && (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_to_vrf_withdraw(bgp, ri); + vpn_leak_to_vrf_withdraw(bgp, pi); } - bgp_rib_remove(rn, ri, peer, afi, safi); + bgp_rib_remove(rn, pi, peer, afi, safi); } bgp_unlock_node(rn); @@ -3545,7 +3545,7 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, uint32_t addpath_id, struct bgp *bgp; char pfx_buf[BGP_PRD_PATH_STRLEN]; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; #if ENABLE_BGP_VNC if ((SAFI_MPLS_VPN == safi) || (SAFI_ENCAP == safi)) { @@ -3587,10 +3587,10 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, uint32_t addpath_id, } /* Lookup withdrawn route. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == peer && ri->type == type - && ri->sub_type == sub_type - && ri->addpath_rx_id == addpath_id) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == peer && pi->type == type + && pi->sub_type == sub_type + && pi->addpath_rx_id == addpath_id) break; /* Logging. */ @@ -3603,17 +3603,17 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, uint32_t addpath_id, } /* Withdraw specified route from routing table. */ - if (ri && !CHECK_FLAG(ri->flags, BGP_PATH_HISTORY)) { - bgp_rib_withdraw(rn, ri, peer, afi, safi, prd); + if (pi && !CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) { + bgp_rib_withdraw(rn, pi, peer, afi, safi, prd); if (SAFI_UNICAST == safi && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, ri); + vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, pi); } if ((SAFI_MPLS_VPN == safi) && (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_to_vrf_withdraw(bgp, ri); + vpn_leak_to_vrf_withdraw(bgp, pi); } } else if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, num_labels, @@ -3741,14 +3741,14 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi, if (ain->peer != peer) continue; - struct bgp_path_info *ri = rn->info; + struct bgp_path_info *pi = rn->info; uint32_t num_labels = 0; mpls_label_t *label_pnt = NULL; - if (ri && ri->extra) - num_labels = ri->extra->num_labels; + if (pi && pi->extra) + num_labels = pi->extra->num_labels; if (num_labels) - label_pnt = &ri->extra->label[0]; + label_pnt = &pi->extra->label[0]; ret = bgp_update(peer, &rn->p, ain->addpath_rx_id, ain->attr, afi, safi, ZEBRA_ROUTE_BGP, @@ -3797,7 +3797,7 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data) struct bgp_clear_node_queue *cnq = data; struct bgp_node *rn = cnq->rn; struct peer *peer = wq->spec.data; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp *bgp; afi_t afi = bgp_node_table(rn)->afi; safi_t safi = bgp_node_table(rn)->safi; @@ -3808,35 +3808,35 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data) /* It is possible that we have multiple paths for a prefix from a peer * if that peer is using AddPath. */ - for (ri = rn->info; ri; ri = ri->next) { - if (ri->peer != peer) + for (pi = rn->info; pi; pi = pi->next) { + if (pi->peer != peer) continue; /* graceful restart STALE flag set. */ if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT) && peer->nsf[afi][safi] - && !CHECK_FLAG(ri->flags, BGP_PATH_STALE) - && !CHECK_FLAG(ri->flags, BGP_PATH_UNUSEABLE)) - bgp_path_info_set_flag(rn, ri, BGP_PATH_STALE); + && !CHECK_FLAG(pi->flags, BGP_PATH_STALE) + && !CHECK_FLAG(pi->flags, BGP_PATH_UNUSEABLE)) + bgp_path_info_set_flag(rn, pi, BGP_PATH_STALE); else { /* If this is an EVPN route, process for * un-import. */ if (safi == SAFI_EVPN) - bgp_evpn_unimport_route(bgp, afi, safi, - &rn->p, ri); + bgp_evpn_unimport_route(bgp, afi, safi, &rn->p, + pi); /* Handle withdraw for VRF route-leaking and L3VPN */ if (SAFI_UNICAST == safi && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { vpn_leak_from_vrf_withdraw(bgp_get_default(), - bgp, ri); + bgp, pi); } if (SAFI_MPLS_VPN == safi && bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { - vpn_leak_to_vrf_withdraw(bgp, ri); + vpn_leak_to_vrf_withdraw(bgp, pi); } - bgp_rib_remove(rn, ri, peer, afi, safi); + bgp_rib_remove(rn, pi, peer, afi, safi); } } return WQ_SUCCESS; @@ -3896,7 +3896,7 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi, return; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *ri, *next; + struct bgp_path_info *pi, *next; struct bgp_adj_in *ain; struct bgp_adj_in *ain_next; @@ -3947,13 +3947,13 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi, ain = ain_next; } - for (ri = rn->info; ri; ri = next) { - next = ri->next; - if (ri->peer != peer) + for (pi = rn->info; pi; pi = next) { + next = pi->next; + if (pi->peer != peer) continue; if (force) - bgp_path_info_reap(rn, ri); + bgp_path_info_reap(rn, pi); else { struct bgp_clear_node_queue *cnq; @@ -4057,7 +4057,7 @@ void bgp_clear_adj_in(struct peer *peer, afi_t afi, safi_t safi) void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_table *table; if (safi == SAFI_MPLS_VPN) { @@ -4071,26 +4071,26 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi) for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) - for (ri = rm->info; ri; ri = ri->next) { - if (ri->peer != peer) + for (pi = rm->info; pi; pi = pi->next) { + if (pi->peer != peer) continue; - if (!CHECK_FLAG(ri->flags, + if (!CHECK_FLAG(pi->flags, BGP_PATH_STALE)) break; - bgp_rib_remove(rm, ri, peer, afi, safi); + bgp_rib_remove(rm, pi, peer, afi, safi); break; } } } else { for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) - for (ri = rn->info; ri; ri = ri->next) { - if (ri->peer != peer) + for (pi = rn->info; pi; pi = pi->next) { + if (pi->peer != peer) continue; - if (!CHECK_FLAG(ri->flags, BGP_PATH_STALE)) + if (!CHECK_FLAG(pi->flags, BGP_PATH_STALE)) break; - bgp_rib_remove(rn, ri, peer, afi, safi); + bgp_rib_remove(rn, pi, peer, afi, safi); break; } } @@ -4100,22 +4100,22 @@ static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table, safi_t safi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_path_info *next; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) - for (ri = rn->info; ri; ri = next) { - next = ri->next; - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED) - && ri->type == ZEBRA_ROUTE_BGP - && (ri->sub_type == BGP_ROUTE_NORMAL - || ri->sub_type == BGP_ROUTE_AGGREGATE - || ri->sub_type == BGP_ROUTE_IMPORTED)) { + for (pi = rn->info; pi; pi = next) { + next = pi->next; + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) + && pi->type == ZEBRA_ROUTE_BGP + && (pi->sub_type == BGP_ROUTE_NORMAL + || pi->sub_type == BGP_ROUTE_AGGREGATE + || pi->sub_type == BGP_ROUTE_IMPORTED)) { if (bgp_fibupd_safi(safi)) - bgp_zebra_withdraw(&rn->p, ri, - bgp, safi); - bgp_path_info_reap(rn, ri); + bgp_zebra_withdraw(&rn->p, pi, bgp, + safi); + bgp_path_info_reap(rn, pi); } } } @@ -4366,9 +4366,9 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, struct bgp_static *bgp_static, afi_t afi, safi_t safi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_path_info *new; - struct bgp_path_info info; + struct bgp_path_info rmap_path; struct attr attr; struct attr *attr_new; int ret; @@ -4401,13 +4401,14 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, if (bgp_static->rmap.name) { struct attr attr_tmp = attr; - memset(&info, 0, sizeof(struct bgp_path_info)); - info.peer = bgp->peer_self; - info.attr = &attr_tmp; + memset(&rmap_path, 0, sizeof(struct bgp_path_info)); + rmap_path.peer = bgp->peer_self; + rmap_path.attr = &attr_tmp; SET_FLAG(bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); - ret = route_map_apply(bgp_static->rmap.map, p, RMAP_BGP, &info); + ret = route_map_apply(bgp_static->rmap.map, p, RMAP_BGP, + &rmap_path); bgp->peer_self->rmap_type = 0; @@ -4433,14 +4434,14 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, attr_new = bgp_attr_intern(&attr); } - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) break; - if (ri) { - if (attrhash_cmp(ri->attr, attr_new) - && !CHECK_FLAG(ri->flags, BGP_PATH_REMOVED) + if (pi) { + if (attrhash_cmp(pi->attr, attr_new) + && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) && !bgp_flag_check(bgp, BGP_FLAG_FORCE_STATIC_PROCESS)) { bgp_unlock_node(rn); bgp_attr_unintern(&attr_new); @@ -4448,39 +4449,39 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, return; } else { /* The attribute is changed. */ - bgp_path_info_set_flag(rn, ri, BGP_PATH_ATTR_CHANGED); + bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED); /* Rewrite BGP route information. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, ri); + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, pi); else - bgp_aggregate_decrement(bgp, p, ri, afi, safi); + bgp_aggregate_decrement(bgp, p, pi, afi, safi); #if ENABLE_BGP_VNC if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { /* * Implicit withdraw case. - * We have to do this before ri is + * We have to do this before pi is * changed */ ++vnc_implicit_withdraw; - vnc_import_bgp_del_route(bgp, p, ri); + vnc_import_bgp_del_route(bgp, p, pi); vnc_import_bgp_exterior_del_route( - bgp, p, ri); + bgp, p, pi); } } #endif - bgp_attr_unintern(&ri->attr); - ri->attr = attr_new; - ri->uptime = bgp_clock(); + bgp_attr_unintern(&pi->attr); + pi->attr = attr_new; + pi->uptime = bgp_clock(); #if ENABLE_BGP_VNC if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { if (vnc_implicit_withdraw) { - vnc_import_bgp_add_route(bgp, p, ri); + vnc_import_bgp_add_route(bgp, p, pi); vnc_import_bgp_exterior_add_route( - bgp, p, ri); + bgp, p, pi); } } #endif @@ -4492,12 +4493,12 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, struct bgp *bgp_nexthop = bgp; - if (ri->extra && ri->extra->bgp_orig) - bgp_nexthop = ri->extra->bgp_orig; + if (pi->extra && pi->extra->bgp_orig) + bgp_nexthop = pi->extra->bgp_orig; if (bgp_find_or_add_nexthop(bgp, bgp_nexthop, - afi, ri, NULL, 0)) - bgp_path_info_set_flag(rn, ri, + afi, pi, NULL, 0)) + bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID); else { if (BGP_DEBUG(nht, NHT)) { @@ -4510,7 +4511,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, __FUNCTION__, buf1); } bgp_path_info_unset_flag( - rn, ri, BGP_PATH_VALID); + rn, pi, BGP_PATH_VALID); } } else { /* Delete the NHT structure if any, if we're @@ -4520,11 +4521,11 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, * from NHT to avoid overloading NHT and the * process interaction */ - bgp_unlink_nexthop(ri); - bgp_path_info_set_flag(rn, ri, BGP_PATH_VALID); + bgp_unlink_nexthop(pi); + bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID); } /* Process change. */ - bgp_aggregate_increment(bgp, p, ri, afi, safi); + bgp_aggregate_increment(bgp, p, pi, afi, safi); bgp_process(bgp, rn, afi, safi); if (SAFI_UNICAST == safi @@ -4532,7 +4533,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p, || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { vpn_leak_from_vrf_update(bgp_get_default(), bgp, - ri); + pi); } bgp_unlock_node(rn); @@ -4596,26 +4597,26 @@ void bgp_static_withdraw(struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL); /* Check selected route and self inserted route. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) break; /* Withdraw static BGP route from routing table. */ - if (ri) { + if (pi) { if (SAFI_UNICAST == safi && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, ri); + vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, pi); } - bgp_aggregate_decrement(bgp, p, ri, afi, safi); - bgp_unlink_nexthop(ri); - bgp_path_info_delete(rn, ri); + bgp_aggregate_decrement(bgp, p, pi, afi, safi); + bgp_unlink_nexthop(pi); + bgp_path_info_delete(rn, pi); bgp_process(bgp, rn, afi, safi); } @@ -4631,29 +4632,29 @@ static void bgp_static_withdraw_safi(struct bgp *bgp, struct prefix *p, struct prefix_rd *prd) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd); /* Check selected route and self inserted route. */ - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) break; /* Withdraw static BGP route from routing table. */ - if (ri) { + if (pi) { #if ENABLE_BGP_VNC rfapiProcessWithdraw( - ri->peer, NULL, p, prd, ri->attr, afi, safi, ri->type, + pi->peer, NULL, p, prd, pi->attr, afi, safi, pi->type, 1); /* Kill, since it is an administrative change */ #endif if (SAFI_MPLS_VPN == safi && bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { - vpn_leak_to_vrf_withdraw(bgp, ri); + vpn_leak_to_vrf_withdraw(bgp, pi); } - bgp_aggregate_decrement(bgp, p, ri, afi, safi); - bgp_path_info_delete(rn, ri); + bgp_aggregate_decrement(bgp, p, pi, afi, safi); + bgp_path_info_delete(rn, pi); bgp_process(bgp, rn, afi, safi); } @@ -4669,7 +4670,7 @@ static void bgp_static_update_safi(struct bgp *bgp, struct prefix *p, struct bgp_path_info *new; struct attr *attr_new; struct attr attr = {0}; - struct bgp_path_info *ri; + struct bgp_path_info *pi; #if ENABLE_BGP_VNC mpls_label_t label = 0; #endif @@ -4717,15 +4718,16 @@ static void bgp_static_update_safi(struct bgp *bgp, struct prefix *p, /* Apply route-map. */ if (bgp_static->rmap.name) { struct attr attr_tmp = attr; - struct bgp_path_info info; + struct bgp_path_info rmap_path; int ret; - info.peer = bgp->peer_self; - info.attr = &attr_tmp; + rmap_path.peer = bgp->peer_self; + rmap_path.attr = &attr_tmp; SET_FLAG(bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); - ret = route_map_apply(bgp_static->rmap.map, p, RMAP_BGP, &info); + ret = route_map_apply(bgp_static->rmap.map, p, RMAP_BGP, + &rmap_path); bgp->peer_self->rmap_type = 0; @@ -4745,49 +4747,49 @@ static void bgp_static_update_safi(struct bgp *bgp, struct prefix *p, attr_new = bgp_attr_intern(&attr); } - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) break; - if (ri) { + if (pi) { memset(&add, 0, sizeof(union gw_addr)); - if (attrhash_cmp(ri->attr, attr_new) - && overlay_index_equal(afi, ri, bgp_static->eth_s_id, &add) - && !CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) { + if (attrhash_cmp(pi->attr, attr_new) + && overlay_index_equal(afi, pi, bgp_static->eth_s_id, &add) + && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { bgp_unlock_node(rn); bgp_attr_unintern(&attr_new); aspath_unintern(&attr.aspath); return; } else { /* The attribute is changed. */ - bgp_path_info_set_flag(rn, ri, BGP_PATH_ATTR_CHANGED); + bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED); /* Rewrite BGP route information. */ - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(rn, ri); + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(rn, pi); else - bgp_aggregate_decrement(bgp, p, ri, afi, safi); - bgp_attr_unintern(&ri->attr); - ri->attr = attr_new; - ri->uptime = bgp_clock(); + bgp_aggregate_decrement(bgp, p, pi, afi, safi); + bgp_attr_unintern(&pi->attr); + pi->attr = attr_new; + pi->uptime = bgp_clock(); #if ENABLE_BGP_VNC - if (ri->extra) - label = decode_label(&ri->extra->label[0]); + if (pi->extra) + label = decode_label(&pi->extra->label[0]); #endif /* Process change. */ - bgp_aggregate_increment(bgp, p, ri, afi, safi); + bgp_aggregate_increment(bgp, p, pi, afi, safi); bgp_process(bgp, rn, afi, safi); if (SAFI_MPLS_VPN == safi && bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { - vpn_leak_to_vrf_update(bgp, ri); + vpn_leak_to_vrf_update(bgp, pi); } #if ENABLE_BGP_VNC - rfapiProcessUpdate(ri->peer, NULL, p, &bgp_static->prd, - ri->attr, afi, safi, ri->type, - ri->sub_type, &label); + rfapiProcessUpdate(pi->peer, NULL, p, &bgp_static->prd, + pi->attr, afi, safi, pi->type, + pi->sub_type, &label); #endif bgp_unlock_node(rn); aspath_unintern(&attr.aspath); @@ -5085,21 +5087,21 @@ static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi, { struct bgp_table *table; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; table = bgp->rib[afi][safi]; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { - for (ri = rn->info; ri; ri = ri->next) { - if (ri->peer == bgp->peer_self - && ((ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_STATIC) - || (ri->type != ZEBRA_ROUTE_BGP - && ri->sub_type + for (pi = rn->info; pi; pi = pi->next) { + if (pi->peer == bgp->peer_self + && ((pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_STATIC) + || (pi->type != ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_REDISTRIBUTE))) { - bgp_aggregate_decrement(bgp, &rn->p, ri, afi, + bgp_aggregate_decrement(bgp, &rn->p, pi, afi, safi); - bgp_unlink_nexthop(ri); - bgp_path_info_delete(rn, ri); + bgp_unlink_nexthop(pi); + bgp_path_info_delete(rn, pi); bgp_process(bgp, rn, afi, safi); } } @@ -5481,7 +5483,7 @@ static void bgp_aggregate_free(struct bgp_aggregate *aggregate) XFREE(MTYPE_BGP_AGGREGATE, aggregate); } -static int bgp_aggregate_info_same(struct bgp_path_info *ri, uint8_t origin, +static int bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin, struct aspath *aspath, struct community *comm) { @@ -5490,19 +5492,19 @@ static int bgp_aggregate_info_same(struct bgp_path_info *ri, uint8_t origin, if (!ae) ae = aspath_empty(); - if (!ri) + if (!pi) return 0; - if (origin != ri->attr->origin) + if (origin != pi->attr->origin) return 0; - if (!aspath_cmp(ri->attr->aspath, (aspath) ? aspath : ae)) + if (!aspath_cmp(pi->attr->aspath, (aspath) ? aspath : ae)) return 0; - if (!community_cmp(ri->attr->community, comm)) + if (!community_cmp(pi->attr->community, comm)) return 0; - if (!CHECK_FLAG(ri->flags, BGP_PATH_VALID)) + if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID)) return 0; return 1; @@ -5517,15 +5519,15 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi, { struct bgp_node *rn; struct bgp_table *table; - struct bgp_path_info *ri, *new; + struct bgp_path_info *pi, *new; table = bgp->rib[afi][safi]; rn = bgp_node_get(table, p); - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_AGGREGATE) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_AGGREGATE) break; if (aggregate->count > 0) { @@ -5548,8 +5550,8 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi, /* * Mark the old as unusable */ - if (ri) - bgp_path_info_delete(rn, ri); + if (pi) + bgp_path_info_delete(rn, pi); new = info_make( ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, @@ -5562,15 +5564,15 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi, bgp_path_info_add(rn, new); bgp_process(bgp, rn, afi, safi); } else { - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self - && ri->type == ZEBRA_ROUTE_BGP - && ri->sub_type == BGP_ROUTE_AGGREGATE) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self + && pi->type == ZEBRA_ROUTE_BGP + && pi->sub_type == BGP_ROUTE_AGGREGATE) break; /* Withdraw static BGP route from routing table. */ - if (ri) { - bgp_path_info_delete(rn, ri); + if (pi) { + bgp_path_info_delete(rn, pi); bgp_process(bgp, rn, afi, safi); } } @@ -5580,7 +5582,7 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi, /* Update an aggregate as routes are added/removed from the BGP table */ static void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, - struct bgp_path_info *rinew, afi_t afi, + struct bgp_path_info *pinew, afi_t afi, safi_t safi, struct bgp_path_info *del, struct bgp_aggregate *aggregate) { @@ -5592,7 +5594,7 @@ static void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, struct aspath *asmerge = NULL; struct community *community = NULL; struct community *commerge = NULL; - struct bgp_path_info *ri; + struct bgp_path_info *pi; unsigned long match = 0; uint8_t atomic_aggregate = 0; @@ -5616,18 +5618,18 @@ static void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, match = 0; - for (ri = rn->info; ri; ri = ri->next) { - if (BGP_PATH_HOLDDOWN(ri)) + for (pi = rn->info; pi; pi = pi->next) { + if (BGP_PATH_HOLDDOWN(pi)) continue; - if (del && ri == del) + if (del && pi == del) continue; - if (ri->attr->flag + if (pi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) atomic_aggregate = 1; - if (ri->sub_type == BGP_ROUTE_AGGREGATE) + if (pi->sub_type == BGP_ROUTE_AGGREGATE) continue; /* @@ -5635,8 +5637,8 @@ static void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, * aggregated route announcements. */ if (aggregate->summary_only) { - (bgp_path_info_extra_get(ri))->suppress++; - bgp_path_info_set_flag(rn, ri, + (bgp_path_info_extra_get(pi))->suppress++; + bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED); match++; } @@ -5653,8 +5655,8 @@ static void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, * route MUST have the ORIGIN attribute with the value * EGP. */ - if (origin < ri->attr->origin) - origin = ri->attr->origin; + if (origin < pi->attr->origin) + origin = pi->attr->origin; if (!aggregate->as_set) continue; @@ -5665,57 +5667,57 @@ static void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, */ if (aspath) { asmerge = aspath_aggregate(aspath, - ri->attr->aspath); + pi->attr->aspath); aspath_free(aspath); aspath = asmerge; } else - aspath = aspath_dup(ri->attr->aspath); + aspath = aspath_dup(pi->attr->aspath); - if (!ri->attr->community) + if (!pi->attr->community) continue; if (community) { commerge = community_merge(community, - ri->attr->community); + pi->attr->community); community = community_uniq_sort(commerge); community_free(commerge); } else - community = community_dup(ri->attr->community); + community = community_dup(pi->attr->community); } if (match) bgp_process(bgp, rn, afi, safi); } bgp_unlock_node(top); - if (rinew) { + if (pinew) { aggregate->count++; if (aggregate->summary_only) - (bgp_path_info_extra_get(rinew))->suppress++; + (bgp_path_info_extra_get(pinew))->suppress++; - if (origin < rinew->attr->origin) - origin = rinew->attr->origin; + if (origin < pinew->attr->origin) + origin = pinew->attr->origin; if (aggregate->as_set) { if (aspath) { asmerge = aspath_aggregate(aspath, - rinew->attr->aspath); + pinew->attr->aspath); aspath_free(aspath); aspath = asmerge; } else - aspath = aspath_dup(rinew->attr->aspath); + aspath = aspath_dup(pinew->attr->aspath); - if (rinew->attr->community) { + if (pinew->attr->community) { if (community) { commerge = community_merge( community, - rinew->attr->community); + pinew->attr->community); community = community_uniq_sort(commerge); community_free(commerge); } else community = community_dup( - rinew->attr->community); + pinew->attr->community); } } } @@ -5737,7 +5739,7 @@ static void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi, struct bgp_table *table; struct bgp_node *top; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; unsigned long match; table = bgp->rib[afi][safi]; @@ -5750,19 +5752,19 @@ static void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi, continue; match = 0; - for (ri = rn->info; ri; ri = ri->next) { - if (BGP_PATH_HOLDDOWN(ri)) + for (pi = rn->info; pi; pi = pi->next) { + if (BGP_PATH_HOLDDOWN(pi)) continue; - if (ri->sub_type == BGP_ROUTE_AGGREGATE) + if (pi->sub_type == BGP_ROUTE_AGGREGATE) continue; - if (aggregate->summary_only && ri->extra) { - ri->extra->suppress--; + if (aggregate->summary_only && pi->extra) { + pi->extra->suppress--; - if (ri->extra->suppress == 0) { + if (pi->extra->suppress == 0) { bgp_path_info_set_flag( - rn, ri, BGP_PATH_ATTR_CHANGED); + rn, pi, BGP_PATH_ATTR_CHANGED); match++; } } @@ -5777,7 +5779,7 @@ static void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi, } void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, - struct bgp_path_info *ri, afi_t afi, safi_t safi) + struct bgp_path_info *pi, afi_t afi, safi_t safi) { struct bgp_node *child; struct bgp_node *rn; @@ -5793,7 +5795,7 @@ void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, if (p->prefixlen == 0) return; - if (BGP_PATH_HOLDDOWN(ri)) + if (BGP_PATH_HOLDDOWN(pi)) return; child = bgp_node_get(table, p); @@ -5803,7 +5805,7 @@ void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, aggregate = bgp_aggregate_get_node_info(rn); if (aggregate != NULL && rn->p.prefixlen < p->prefixlen) { bgp_aggregate_delete(bgp, &rn->p, afi, safi, aggregate); - bgp_aggregate_route(bgp, &rn->p, ri, afi, safi, NULL, + bgp_aggregate_route(bgp, &rn->p, pi, afi, safi, NULL, aggregate); } } @@ -6076,8 +6078,8 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, route_tag_t tag) { struct bgp_path_info *new; - struct bgp_path_info *bi; - struct bgp_path_info info; + struct bgp_path_info *bpi; + struct bgp_path_info rmap_path; struct bgp_node *bn; struct attr attr; struct attr *new_attr; @@ -6133,15 +6135,15 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, /* Apply route-map. */ if (red->rmap.name) { - memset(&info, 0, sizeof(struct bgp_path_info)); - info.peer = bgp->peer_self; - info.attr = &attr_new; + memset(&rmap_path, 0, sizeof(struct bgp_path_info)); + rmap_path.peer = bgp->peer_self; + rmap_path.attr = &attr_new; SET_FLAG(bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); ret = route_map_apply(red->rmap.map, p, RMAP_BGP, - &info); + &rmap_path); bgp->peer_self->rmap_type = 0; @@ -6164,37 +6166,37 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, new_attr = bgp_attr_intern(&attr_new); - for (bi = bn->info; bi; bi = bi->next) - if (bi->peer == bgp->peer_self - && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) + for (bpi = bn->info; bpi; bpi = bpi->next) + if (bpi->peer == bgp->peer_self + && bpi->sub_type == BGP_ROUTE_REDISTRIBUTE) break; - if (bi) { + if (bpi) { /* Ensure the (source route) type is updated. */ - bi->type = type; - if (attrhash_cmp(bi->attr, new_attr) - && !CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + bpi->type = type; + if (attrhash_cmp(bpi->attr, new_attr) + && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { bgp_attr_unintern(&new_attr); aspath_unintern(&attr.aspath); bgp_unlock_node(bn); return; } else { /* The attribute is changed. */ - bgp_path_info_set_flag(bn, bi, + bgp_path_info_set_flag(bn, bpi, BGP_PATH_ATTR_CHANGED); /* Rewrite BGP route information. */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(bn, bi); + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(bn, bpi); else - bgp_aggregate_decrement(bgp, p, bi, afi, - SAFI_UNICAST); - bgp_attr_unintern(&bi->attr); - bi->attr = new_attr; - bi->uptime = bgp_clock(); + bgp_aggregate_decrement( + bgp, p, bpi, afi, SAFI_UNICAST); + bgp_attr_unintern(&bpi->attr); + bpi->attr = new_attr; + bpi->uptime = bgp_clock(); /* Process change. */ - bgp_aggregate_increment(bgp, p, bi, afi, + bgp_aggregate_increment(bgp, p, bpi, afi, SAFI_UNICAST); bgp_process(bgp, bn, afi, SAFI_UNICAST); bgp_unlock_node(bn); @@ -6205,7 +6207,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, == BGP_INSTANCE_TYPE_DEFAULT)) { vpn_leak_from_vrf_update( - bgp_get_default(), bgp, bi); + bgp_get_default(), bgp, bpi); } return; } @@ -6236,7 +6238,7 @@ void bgp_redistribute_delete(struct bgp *bgp, struct prefix *p, uint8_t type, { afi_t afi; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_redist *red; afi = family2afi(p->family); @@ -6246,19 +6248,19 @@ void bgp_redistribute_delete(struct bgp *bgp, struct prefix *p, uint8_t type, rn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == type) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == type) break; - if (ri) { + if (pi) { if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF) || (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { vpn_leak_from_vrf_withdraw(bgp_get_default(), - bgp, ri); + bgp, pi); } - bgp_aggregate_decrement(bgp, p, ri, afi, SAFI_UNICAST); - bgp_path_info_delete(rn, ri); + bgp_aggregate_decrement(bgp, p, pi, afi, SAFI_UNICAST); + bgp_path_info_delete(rn, pi); bgp_process(bgp, rn, afi, SAFI_UNICAST); } bgp_unlock_node(rn); @@ -6270,27 +6272,27 @@ void bgp_redistribute_withdraw(struct bgp *bgp, afi_t afi, int type, unsigned short instance) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_table *table; table = bgp->rib[afi][SAFI_UNICAST]; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self && ri->type == type - && ri->instance == instance) + for (pi = rn->info; pi; pi = pi->next) + if (pi->peer == bgp->peer_self && pi->type == type + && pi->instance == instance) break; - if (ri) { + if (pi) { if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF) || (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { vpn_leak_from_vrf_withdraw(bgp_get_default(), - bgp, ri); + bgp, pi); } - bgp_aggregate_decrement(bgp, &rn->p, ri, afi, + bgp_aggregate_decrement(bgp, &rn->p, pi, afi, SAFI_UNICAST); - bgp_path_info_delete(rn, ri); + bgp_path_info_delete(rn, pi); bgp_process(bgp, rn, afi, SAFI_UNICAST); } } @@ -8204,7 +8206,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, unsigned long *total_cum, unsigned long *json_header_depth) { - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_node *rn; int header = 1; int display; @@ -8249,19 +8251,19 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, else json_paths = NULL; - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { total_count++; if (type == bgp_show_type_flap_statistics || type == bgp_show_type_flap_neighbor || type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) { - if (!(ri->extra && ri->extra->damp_info)) + if (!(pi->extra && pi->extra->damp_info)) continue; } if (type == bgp_show_type_regexp) { regex_t *regex = output_arg; - if (bgp_regexec(regex, ri->attr->aspath) + if (bgp_regexec(regex, pi->attr->aspath) == REG_NOMATCH) continue; } @@ -8275,7 +8277,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (type == bgp_show_type_filter_list) { struct as_list *as_list = output_arg; - if (as_list_apply(as_list, ri->attr->aspath) + if (as_list_apply(as_list, pi->attr->aspath) != AS_FILTER_PERMIT) continue; } @@ -8285,9 +8287,9 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct attr dummy_attr; int ret; - bgp_attr_dup(&dummy_attr, ri->attr); + bgp_attr_dup(&dummy_attr, pi->attr); - path.peer = ri->peer; + path.peer = pi->peer; path.attr = &dummy_attr; ret = route_map_apply(rmap, &rn->p, RMAP_BGP, @@ -8300,9 +8302,9 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, || type == bgp_show_type_damp_neighbor) { union sockunion *su = output_arg; - if (ri->peer == NULL - || ri->peer->su_remote == NULL - || !sockunion_same(ri->peer->su_remote, su)) + if (pi->peer == NULL + || pi->peer->su_remote == NULL + || !sockunion_same(pi->peer->su_remote, su)) continue; } if (type == bgp_show_type_cidr_only) { @@ -8325,28 +8327,28 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, continue; } if (type == bgp_show_type_community_all) { - if (!ri->attr->community) + if (!pi->attr->community) continue; } if (type == bgp_show_type_community) { struct community *com = output_arg; - if (!ri->attr->community - || !community_match(ri->attr->community, + if (!pi->attr->community + || !community_match(pi->attr->community, com)) continue; } if (type == bgp_show_type_community_exact) { struct community *com = output_arg; - if (!ri->attr->community - || !community_cmp(ri->attr->community, com)) + if (!pi->attr->community + || !community_cmp(pi->attr->community, com)) continue; } if (type == bgp_show_type_community_list) { struct community_list *list = output_arg; - if (!community_list_match(ri->attr->community, + if (!community_list_match(pi->attr->community, list)) continue; } @@ -8354,32 +8356,32 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct community_list *list = output_arg; if (!community_list_exact_match( - ri->attr->community, list)) + pi->attr->community, list)) continue; } if (type == bgp_show_type_lcommunity) { struct lcommunity *lcom = output_arg; - if (!ri->attr->lcommunity - || !lcommunity_match(ri->attr->lcommunity, + if (!pi->attr->lcommunity + || !lcommunity_match(pi->attr->lcommunity, lcom)) continue; } if (type == bgp_show_type_lcommunity_list) { struct community_list *list = output_arg; - if (!lcommunity_list_match(ri->attr->lcommunity, + if (!lcommunity_list_match(pi->attr->lcommunity, list)) continue; } if (type == bgp_show_type_lcommunity_all) { - if (!ri->attr->lcommunity) + if (!pi->attr->lcommunity) continue; } if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) { - if (!CHECK_FLAG(ri->flags, BGP_PATH_DAMPED) - || CHECK_FLAG(ri->flags, BGP_PATH_HISTORY)) + if (!CHECK_FLAG(pi->flags, BGP_PATH_DAMPED) + || CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) continue; } @@ -8414,14 +8416,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, } if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) - damp_route_vty_out(vty, &rn->p, ri, display, + damp_route_vty_out(vty, &rn->p, pi, display, safi, use_json, json_paths); else if (type == bgp_show_type_flap_statistics || type == bgp_show_type_flap_neighbor) - flap_route_vty_out(vty, &rn->p, ri, display, + flap_route_vty_out(vty, &rn->p, pi, display, safi, use_json, json_paths); else - route_vty_out(vty, &rn->p, ri, display, safi, + route_vty_out(vty, &rn->p, pi, display, safi, json_paths); display++; } @@ -8606,7 +8608,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, struct bgp_node *rn, struct prefix_rd *prd, afi_t afi, safi_t safi, json_object *json) { - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct prefix *p; struct peer *peer; struct listnode *node, *nnode; @@ -8673,44 +8675,44 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, vty_out(vty, "not allocated\n"); } - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { count++; - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { best = count; - if (ri->extra && ri->extra->suppress) + if (pi->extra && pi->extra->suppress) suppress = 1; - if (ri->attr->community == NULL) + if (pi->attr->community == NULL) continue; no_advertise += community_include( - ri->attr->community, COMMUNITY_NO_ADVERTISE); - no_export += community_include(ri->attr->community, + pi->attr->community, COMMUNITY_NO_ADVERTISE); + no_export += community_include(pi->attr->community, COMMUNITY_NO_EXPORT); - local_as += community_include(ri->attr->community, + local_as += community_include(pi->attr->community, COMMUNITY_LOCAL_AS); - accept_own += community_include(ri->attr->community, + accept_own += community_include(pi->attr->community, COMMUNITY_ACCEPT_OWN); route_filter_translated_v4 += community_include( - ri->attr->community, + pi->attr->community, COMMUNITY_ROUTE_FILTER_TRANSLATED_v4); route_filter_translated_v6 += community_include( - ri->attr->community, + pi->attr->community, COMMUNITY_ROUTE_FILTER_TRANSLATED_v6); route_filter_v4 += community_include( - ri->attr->community, COMMUNITY_ROUTE_FILTER_v4); + pi->attr->community, COMMUNITY_ROUTE_FILTER_v4); route_filter_v6 += community_include( - ri->attr->community, COMMUNITY_ROUTE_FILTER_v6); - llgr_stale += community_include(ri->attr->community, + pi->attr->community, COMMUNITY_ROUTE_FILTER_v6); + llgr_stale += community_include(pi->attr->community, COMMUNITY_LLGR_STALE); - no_llgr += community_include(ri->attr->community, + no_llgr += community_include(pi->attr->community, COMMUNITY_NO_LLGR); accept_own_nexthop += - community_include(ri->attr->community, + community_include(pi->attr->community, COMMUNITY_ACCEPT_OWN_NEXTHOP); - blackhole += community_include(ri->attr->community, + blackhole += community_include(pi->attr->community, COMMUNITY_BLACKHOLE); - no_peer += community_include(ri->attr->community, + no_peer += community_include(pi->attr->community, COMMUNITY_NO_PEER); } } @@ -8814,7 +8816,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, struct prefix match; struct bgp_node *rn; struct bgp_node *rm; - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_table *table; json_object *json = NULL; json_object *json_paths = NULL; @@ -8852,7 +8854,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, continue; } - for (ri = rm->info; ri; ri = ri->next) { + for (pi = rm->info; pi; pi = pi->next) { if (header) { route_vty_out_detail_header( vty, bgp, rm, @@ -8864,15 +8866,15 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, if (pathtype == BGP_PATH_SHOW_ALL || (pathtype == BGP_PATH_SHOW_BESTPATH - && CHECK_FLAG(ri->flags, + && CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) || (pathtype == BGP_PATH_SHOW_MULTIPATH - && (CHECK_FLAG(ri->flags, + && (CHECK_FLAG(pi->flags, BGP_PATH_MULTIPATH) - || CHECK_FLAG(ri->flags, + || CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)))) route_vty_out_detail(vty, bgp, &rm->p, - ri, AFI_IP, safi, + pi, AFI_IP, safi, json_paths); } @@ -8890,7 +8892,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, if ((rn = bgp_node_match(rib, &match)) != NULL) { if (!prefix_check || rn->p.prefixlen == match.prefixlen) { - for (ri = rn->info; ri; ri = ri->next) { + for (pi = rn->info; pi; pi = pi->next) { if (header) { route_vty_out_detail_header( vty, bgp, rn, NULL, afi, @@ -8903,18 +8905,18 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, || (pathtype == BGP_PATH_SHOW_BESTPATH && CHECK_FLAG( - ri->flags, + pi->flags, BGP_PATH_SELECTED)) || (pathtype == BGP_PATH_SHOW_MULTIPATH && (CHECK_FLAG( - ri->flags, + pi->flags, BGP_PATH_MULTIPATH) || CHECK_FLAG( - ri->flags, + pi->flags, BGP_PATH_SELECTED)))) route_vty_out_detail( - vty, bgp, &rn->p, ri, + vty, bgp, &rn->p, pi, afi, safi, json_paths); } } @@ -9692,9 +9694,9 @@ static int bgp_table_stats_walker(struct thread *t) ts->counts[BGP_STATS_MAXBITLEN] = space; for (rn = top; rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *ri; + struct bgp_path_info *pi; struct bgp_node *prn = bgp_node_parent_nolock(rn); - unsigned int rinum = 0; + unsigned int pinum = 0; if (rn == top) continue; @@ -9725,23 +9727,23 @@ static int bgp_table_stats_walker(struct thread *t) } else if (prn->info) ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; - for (ri = rn->info; ri; ri = ri->next) { - rinum++; + for (pi = rn->info; pi; pi = pi->next) { + pinum++; ts->counts[BGP_STATS_RIB]++; - if (ri->attr - && (CHECK_FLAG(ri->attr->flag, + if (pi->attr + && (CHECK_FLAG(pi->attr->flag, ATTR_FLAG_BIT( BGP_ATTR_ATOMIC_AGGREGATE)))) ts->counts[BGP_STATS_AGGREGATES]++; /* as-path stats */ - if (ri->attr && ri->attr->aspath) { + if (pi->attr && pi->attr->aspath) { unsigned int hops = - aspath_count_hops(ri->attr->aspath); + aspath_count_hops(pi->attr->aspath); unsigned int size = - aspath_size(ri->attr->aspath); - as_t highest = aspath_highest(ri->attr->aspath); + aspath_size(pi->attr->aspath); + as_t highest = aspath_highest(pi->attr->aspath); ts->counts[BGP_STATS_ASPATH_COUNT]++; @@ -9902,39 +9904,39 @@ static int bgp_peer_count_walker(struct thread *t) for (rn = bgp_table_top(pc->table); rn; rn = bgp_route_next(rn)) { struct bgp_adj_in *ain; - struct bgp_path_info *ri; + struct bgp_path_info *pi; for (ain = rn->adj_in; ain; ain = ain->next) if (ain->peer == peer) pc->count[PCOUNT_ADJ_IN]++; - for (ri = rn->info; ri; ri = ri->next) { - if (ri->peer != peer) + for (pi = rn->info; pi; pi = pi->next) { + if (pi->peer != peer) continue; pc->count[PCOUNT_ALL]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_DAMPED)) + if (CHECK_FLAG(pi->flags, BGP_PATH_DAMPED)) pc->count[PCOUNT_DAMPED]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_HISTORY)) + if (CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) pc->count[PCOUNT_HISTORY]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) pc->count[PCOUNT_REMOVED]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_STALE)) + if (CHECK_FLAG(pi->flags, BGP_PATH_STALE)) pc->count[PCOUNT_STALE]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_VALID)) + if (CHECK_FLAG(pi->flags, BGP_PATH_VALID)) pc->count[PCOUNT_VALID]++; - if (!CHECK_FLAG(ri->flags, BGP_PATH_UNUSEABLE)) + if (!CHECK_FLAG(pi->flags, BGP_PATH_UNUSEABLE)) pc->count[PCOUNT_PFCNT]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_COUNTED)) { + if (CHECK_FLAG(pi->flags, BGP_PATH_COUNTED)) { pc->count[PCOUNT_COUNTED]++; - if (CHECK_FLAG(ri->flags, BGP_PATH_UNUSEABLE)) + if (CHECK_FLAG(pi->flags, BGP_PATH_UNUSEABLE)) flog_err( EC_LIB_DEVELOPMENT, "Attempting to count but flags say it is unusable"); } else { - if (!CHECK_FLAG(ri->flags, BGP_PATH_UNUSEABLE)) + if (!CHECK_FLAG(pi->flags, BGP_PATH_UNUSEABLE)) flog_err( EC_LIB_DEVELOPMENT, "Not counted but flags say we should"); @@ -10879,7 +10881,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str, } /* Apply BGP information to distance method. */ -uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *rinfo, +uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *pinfo, afi_t afi, safi_t safi, struct bgp *bgp) { struct bgp_node *rn; @@ -10892,7 +10894,7 @@ uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *rinfo, if (!bgp) return 0; - peer = rinfo->peer; + peer = pinfo->peer; /* Check source address. */ sockunion2hostprefix(&peer->su, &q); @@ -11158,8 +11160,8 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name, struct prefix match; struct bgp_node *rn; struct bgp_node *rm; - struct bgp_path_info *ri; - struct bgp_path_info *ri_temp; + struct bgp_path_info *pi; + struct bgp_path_info *pi_temp; struct bgp *bgp; struct bgp_table *table; @@ -11201,16 +11203,16 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name, if (!prefix_check || rm->p.prefixlen == match.prefixlen) { - ri = rm->info; - while (ri) { - if (ri->extra && ri->extra->damp_info) { - ri_temp = ri->next; + pi = rm->info; + while (pi) { + if (pi->extra && pi->extra->damp_info) { + pi_temp = pi->next; bgp_damp_info_free( - ri->extra->damp_info, + pi->extra->damp_info, 1); - ri = ri_temp; + pi = pi_temp; } else - ri = ri->next; + pi = pi->next; } } @@ -11221,16 +11223,16 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name, != NULL) { if (!prefix_check || rn->p.prefixlen == match.prefixlen) { - ri = rn->info; - while (ri) { - if (ri->extra && ri->extra->damp_info) { - ri_temp = ri->next; + pi = rn->info; + while (pi) { + if (pi->extra && pi->extra->damp_info) { + pi_temp = pi->next; bgp_damp_info_free( - ri->extra->damp_info, + pi->extra->damp_info, 1); - ri = ri_temp; + pi = pi_temp; } else - ri = ri->next; + pi = pi->next; } } diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 2bced5d5bd..f0edc8d49a 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -339,7 +339,7 @@ static inline int bgp_fibupd_safi(safi_t safi) } /* Prototypes. */ -extern void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *ri, +extern void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *pi, struct peer *peer, afi_t afi, safi_t safi); extern void bgp_process_queue_init(void); extern void bgp_route_init(void); @@ -360,16 +360,16 @@ extern struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, struct prefix_rd *prd); extern struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path); extern struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path); -extern void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *ri); -extern void bgp_path_info_reap(struct bgp_node *rn, struct bgp_path_info *ri); -extern void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *ri); +extern void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *pi); +extern void bgp_path_info_reap(struct bgp_node *rn, struct bgp_path_info *pi); +extern void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *pi); extern struct bgp_path_info_extra * bgp_path_info_extra_get(struct bgp_path_info *path); extern void bgp_path_info_set_flag(struct bgp_node *rn, struct bgp_path_info *path, uint32_t flag); extern void bgp_path_info_unset_flag(struct bgp_node *rn, struct bgp_path_info *path, uint32_t flag); -extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *ri, +extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi, char *buf); extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *); @@ -461,7 +461,7 @@ extern int subgroup_process_announce_selected(struct update_subgroup *subgrp, uint32_t addpath_tx_id); extern int subgroup_announce_check(struct bgp_node *rn, - struct bgp_path_info *ri, + struct bgp_path_info *pi, struct update_subgroup *subgrp, struct prefix *p, struct attr *attr); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index eee519134e..d468d48d86 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -341,7 +341,7 @@ static route_map_result_t route_match_command(void *rule, u_int32_t locpref = 0; u_int32_t newlocpref = 0; enum lua_rm_status lrm_status; - struct bgp_path_info *info = (struct bgp_path_info *)object; + struct bgp_path_info *path = (struct bgp_path_info *)object; lua_State *L = lua_initialize("/etc/frr/lua.scr"); if (L == NULL) @@ -357,15 +357,15 @@ static route_map_result_t route_match_command(void *rule, * Setup the bgp_path_info information */ lua_newtable(L); - lua_pushinteger(L, info->attr->med); + lua_pushinteger(L, path->attr->med); lua_setfield(L, -2, "metric"); - lua_pushinteger(L, info->attr->nh_ifindex); + lua_pushinteger(L, path->attr->nh_ifindex); lua_setfield(L, -2, "ifindex"); - lua_pushstring(L, info->attr->aspath->str); + lua_pushstring(L, path->attr->aspath->str); lua_setfield(L, -2, "aspath"); - lua_pushinteger(L, info->attr->local_pref); + lua_pushinteger(L, path->attr->local_pref); lua_setfield(L, -2, "localpref"); - zlog_debug("%s %d", info->attr->aspath->str, info->attr->nh_ifindex); + zlog_debug("%s %d", path->attr->aspath->str, path->attr->nh_ifindex); lua_setglobal(L, "nexthop"); zlog_debug("Set up nexthop information"); @@ -383,16 +383,16 @@ static route_map_result_t route_match_command(void *rule, case LUA_RM_MATCH_AND_CHANGE: zlog_debug("MATCH AND CHANGE"); lua_getglobal(L, "nexthop"); - info->attr->med = get_integer(L, "metric"); + path->attr->med = get_integer(L, "metric"); /* * This needs to be abstraced with the set function */ - if (info->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) - locpref = info->attr->local_pref; + if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) + locpref = path->attr->local_pref; newlocpref = get_integer(L, "localpref"); if (newlocpref != locpref) { - info->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); - info->attr->local_pref = newlocpref; + path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); + path->attr->local_pref = newlocpref; } status = RMAP_MATCH; break; @@ -1321,17 +1321,17 @@ static route_map_result_t route_match_interface(void *rule, void *object) { struct interface *ifp; - struct bgp_path_info *info; + struct bgp_path_info *path; if (type == RMAP_BGP) { - info = object; + path = object; - if (!info || !info->attr) + if (!path || !path->attr) return RMAP_NOMATCH; ifp = if_lookup_by_name_all_vrf((char *)rule); - if (ifp == NULL || ifp->ifindex != info->attr->nh_ifindex) + if (ifp == NULL || ifp->ifindex != path->attr->nh_ifindex) return RMAP_NOMATCH; return RMAP_MATCH; diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 1b116c1ba4..c944c7c6e1 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -1904,7 +1904,7 @@ int bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi) * configured addpath-tx knob */ int bgp_addpath_tx_path(struct peer *peer, afi_t afi, safi_t safi, - struct bgp_path_info *ri) + struct bgp_path_info *pi) { if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) @@ -1912,7 +1912,7 @@ int bgp_addpath_tx_path(struct peer *peer, afi_t afi, safi_t safi, if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS) - && CHECK_FLAG(ri->flags, BGP_PATH_DMED_SELECTED)) + && CHECK_FLAG(pi->flags, BGP_PATH_DMED_SELECTED)) return 1; return 0; diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index fcb8406c8e..b1d852d384 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -293,7 +293,7 @@ typedef int (*updgrp_walkcb)(struct update_group *updgrp, void *ctx); struct updwalk_context { struct vty *vty; struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; uint64_t updgrp_id; uint64_t subgrp_id; bgp_policy_type_e policy_type; @@ -442,7 +442,7 @@ extern void subgroup_announce_all(struct update_subgroup *subgrp); extern void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw); extern void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct bgp_node *rn, struct bgp_path_info *ri); + struct bgp_node *rn, struct bgp_path_info *pi); extern void subgroup_clear_table(struct update_subgroup *subgrp); extern void update_group_announce(struct bgp *bgp); extern void update_group_announce_rrclients(struct bgp *bgp); @@ -470,7 +470,7 @@ extern int update_group_clear_update_dbg(struct update_group *updgrp, extern void update_bgp_group_free(struct bgp *bgp); extern int bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi); extern int bgp_addpath_tx_path(struct peer *peer, afi_t afi, safi_t safi, - struct bgp_path_info *ri); + struct bgp_path_info *pi); /* * Inline functions diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 5934256887..1f81dad649 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -101,7 +101,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg) { struct updwalk_context *ctx = arg; struct update_subgroup *subgrp; - struct bgp_path_info *ri; + struct bgp_path_info *pi; afi_t afi; safi_t safi; struct peer *peer; @@ -140,15 +140,15 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg) adj_next = adj->next; if (adj->subgroup == subgrp) { - for (ri = ctx->rn->info; ri; - ri = ri->next) { - if (ri->addpath_tx_id + for (pi = ctx->rn->info; pi; + pi = pi->next) { + if (pi->addpath_tx_id == adj->addpath_tx_id) { break; } } - if (!ri) { + if (!pi) { subgroup_process_announce_selected( subgrp, NULL, ctx->rn, @@ -157,32 +157,32 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg) } } - for (ri = ctx->rn->info; ri; ri = ri->next) { + for (pi = ctx->rn->info; pi; pi = pi->next) { /* Skip the bestpath for now */ - if (ri == ctx->ri) + if (pi == ctx->pi) continue; subgroup_process_announce_selected( - subgrp, ri, ctx->rn, - ri->addpath_tx_id); + subgrp, pi, ctx->rn, + pi->addpath_tx_id); } /* Process the bestpath last so the "show [ip] * bgp neighbor x.x.x.x advertised" * output shows the attributes from the bestpath */ - if (ctx->ri) + if (ctx->pi) subgroup_process_announce_selected( - subgrp, ctx->ri, ctx->rn, - ctx->ri->addpath_tx_id); + subgrp, ctx->pi, ctx->rn, + ctx->pi->addpath_tx_id); } /* An update-group that does not use addpath */ else { - if (ctx->ri) { + if (ctx->pi) { subgroup_process_announce_selected( - subgrp, ctx->ri, ctx->rn, - ctx->ri->addpath_tx_id); + subgrp, ctx->pi, ctx->rn, + ctx->pi->addpath_tx_id); } else { /* Find the addpath_tx_id of the path we * had advertised and @@ -831,10 +831,10 @@ void subgroup_announce_all(struct update_subgroup *subgrp) * input route. */ void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi, - struct bgp_node *rn, struct bgp_path_info *ri) + struct bgp_node *rn, struct bgp_path_info *pi) { struct updwalk_context ctx; - ctx.ri = ri; + ctx.pi = pi; ctx.rn = rn; update_group_af_walk(bgp, afi, safi, group_announce_route_walkcb, &ctx); } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 1c0553344b..e2bdf38350 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -926,40 +926,39 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, } static struct in6_addr * -bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *info, ifindex_t *ifindex) +bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex) { struct in6_addr *nexthop = NULL; /* Only global address nexthop exists. */ - if (info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) { - nexthop = &info->attr->mp_nexthop_global; + if (path->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) { + nexthop = &path->attr->mp_nexthop_global; if (IN6_IS_ADDR_LINKLOCAL(nexthop)) - *ifindex = info->attr->nh_ifindex; - + *ifindex = path->attr->nh_ifindex; } /* If both global and link-local address present. */ - if (info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { + if (path->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { /* Check if route-map is set to prefer global over link-local */ - if (info->attr->mp_nexthop_prefer_global) { - nexthop = &info->attr->mp_nexthop_global; + if (path->attr->mp_nexthop_prefer_global) { + nexthop = &path->attr->mp_nexthop_global; if (IN6_IS_ADDR_LINKLOCAL(nexthop)) - *ifindex = info->attr->nh_ifindex; + *ifindex = path->attr->nh_ifindex; } else { /* Workaround for Cisco's nexthop bug. */ if (IN6_IS_ADDR_UNSPECIFIED( - &info->attr->mp_nexthop_global) - && info->peer->su_remote->sa.sa_family + &path->attr->mp_nexthop_global) + && path->peer->su_remote->sa.sa_family == AF_INET6) { nexthop = - &info->peer->su_remote->sin6.sin6_addr; + &path->peer->su_remote->sin6.sin6_addr; if (IN6_IS_ADDR_LINKLOCAL(nexthop)) - *ifindex = info->peer->nexthop.ifp + *ifindex = path->peer->nexthop.ifp ->ifindex; } else { - nexthop = &info->attr->mp_nexthop_local; + nexthop = &path->attr->mp_nexthop_local; if (IN6_IS_ADDR_LINKLOCAL(nexthop)) - *ifindex = info->attr->nh_lla_ifindex; + *ifindex = path->attr->nh_lla_ifindex; } } } @@ -968,12 +967,12 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *info, ifindex_t *ifindex) } static int bgp_table_map_apply(struct route_map *map, struct prefix *p, - struct bgp_path_info *info) + struct bgp_path_info *path) { route_map_result_t ret; - ret = route_map_apply(map, p, RMAP_BGP, info); - bgp_attr_flush(info->attr); + ret = route_map_apply(map, p, RMAP_BGP, path); + bgp_attr_flush(path->attr); if (ret != RMAP_DENYMATCH) return 1; @@ -986,7 +985,7 @@ static int bgp_table_map_apply(struct route_map *map, struct prefix *p, inet_ntop(AF_INET, &p->u.prefix4, buf[0], sizeof(buf[0])), p->prefixlen, - inet_ntop(AF_INET, &info->attr->nexthop, buf[1], + inet_ntop(AF_INET, &path->attr->nexthop, buf[1], sizeof(buf[1]))); } if (p->family == AF_INET6) { @@ -994,7 +993,7 @@ static int bgp_table_map_apply(struct route_map *map, struct prefix *p, ifindex_t ifindex; struct in6_addr *nexthop; - nexthop = bgp_path_info_to_ipv6_nexthop(info, &ifindex); + nexthop = bgp_path_info_to_ipv6_nexthop(path, &ifindex); zlog_debug( "Zebra rmap deny: IPv6 route %s/%d nexthop %s", inet_ntop(AF_INET6, &p->u.prefix6, buf[0], @@ -1123,13 +1122,13 @@ static int update_ipv4nh_for_route_install(int nh_othervrf, static int update_ipv6nh_for_route_install(int nh_othervrf, struct in6_addr *nexthop, - ifindex_t ifindex, struct bgp_path_info *ri, - struct bgp_path_info *best_ri, bool is_evpn, + ifindex_t ifindex, struct bgp_path_info *pi, + struct bgp_path_info *best_pi, bool is_evpn, struct zapi_nexthop *api_nh) { struct attr *attr; - attr = ri->attr; + attr = pi->attr; if (is_evpn) api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; @@ -1148,22 +1147,22 @@ update_ipv6nh_for_route_install(int nh_othervrf, struct in6_addr *nexthop, } } else { if (IN6_IS_ADDR_LINKLOCAL(nexthop)) { - if (ri == best_ri && - attr->mp_nexthop_len - == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - if (ri->peer->nexthop.ifp) - ifindex = ri->peer->nexthop.ifp - ->ifindex; + if (pi == best_pi + && attr->mp_nexthop_len + == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + if (pi->peer->nexthop.ifp) + ifindex = + pi->peer->nexthop.ifp->ifindex; if (!ifindex) { - if (ri->peer->conf_if) - ifindex = ri->peer->ifp->ifindex; - else if (ri->peer->ifname) + if (pi->peer->conf_if) + ifindex = pi->peer->ifp->ifindex; + else if (pi->peer->ifname) ifindex = ifname2ifindex( - ri->peer->ifname, - ri->peer->bgp->vrf_id); - else if (ri->peer->nexthop.ifp) - ifindex = ri->peer->nexthop.ifp - ->ifindex; + pi->peer->ifname, + pi->peer->bgp->vrf_id); + else if (pi->peer->nexthop.ifp) + ifindex = + pi->peer->nexthop.ifp->ifindex; } if (ifindex == 0) @@ -1465,7 +1464,7 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi) { struct bgp_node *rn; struct bgp_table *table; - struct bgp_path_info *ri; + struct bgp_path_info *pi; /* Don't try to install if we're not connected to Zebra or Zebra doesn't * know of this instance. @@ -1478,14 +1477,14 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi) return; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) - for (ri = rn->info; ri; ri = ri->next) - if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED) && + for (pi = rn->info; pi; pi = pi->next) + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) && - (ri->type == ZEBRA_ROUTE_BGP - && (ri->sub_type == BGP_ROUTE_NORMAL - || ri->sub_type == BGP_ROUTE_IMPORTED))) + (pi->type == ZEBRA_ROUTE_BGP + && (pi->sub_type == BGP_ROUTE_NORMAL + || pi->sub_type == BGP_ROUTE_IMPORTED))) - bgp_zebra_announce(rn, &rn->p, ri, bgp, afi, + bgp_zebra_announce(rn, &rn->p, pi, bgp, afi, safi); } @@ -1679,7 +1678,7 @@ int bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red, afi_t afi, int type, uint32_t metric) { struct bgp_node *rn; - struct bgp_path_info *ri; + struct bgp_path_info *pi; if (red->redist_metric_flag && red->redist_metric == metric) return 0; @@ -1689,20 +1688,20 @@ int bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red, for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; rn = bgp_route_next(rn)) { - for (ri = rn->info; ri; ri = ri->next) { - if (ri->sub_type == BGP_ROUTE_REDISTRIBUTE - && ri->type == type - && ri->instance == red->instance) { + for (pi = rn->info; pi; pi = pi->next) { + if (pi->sub_type == BGP_ROUTE_REDISTRIBUTE + && pi->type == type + && pi->instance == red->instance) { struct attr *old_attr; struct attr new_attr; - bgp_attr_dup(&new_attr, ri->attr); + bgp_attr_dup(&new_attr, pi->attr); new_attr.med = red->redist_metric; - old_attr = ri->attr; - ri->attr = bgp_attr_intern(&new_attr); + old_attr = pi->attr; + pi->attr = bgp_attr_intern(&new_attr); bgp_attr_unintern(&old_attr); - bgp_path_info_set_flag(rn, ri, + bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED); bgp_process(bgp, rn, afi, SAFI_UNICAST); } diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index ab29cb0ac1..0595700bbc 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -361,7 +361,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd, { afi_t afi; /* of the VN address */ struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; char buf[PREFIX_STRLEN]; char buf2[RD_ADDRSTRLEN]; struct prefix_rd prd0; @@ -384,21 +384,22 @@ void del_vnc_route(struct rfapi_descriptor *rfd, __func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)), afi, safi, bn, (bn ? bn->info : NULL)); - for (bi = (bn ? bn->info : NULL); bi; bi = bi->next) { + for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) { vnc_zlog_debug_verbose( - "%s: trying bi=%p, bi->peer=%p, bi->type=%d, bi->sub_type=%d, bi->extra->vnc.export.rfapi_handle=%p, local_pref=%u", - __func__, bi, bi->peer, bi->type, bi->sub_type, - (bi->extra ? bi->extra->vnc.export.rfapi_handle : NULL), - ((bi->attr - && CHECK_FLAG(bi->attr->flag, + "%s: trying bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p, local_pref=%u", + __func__, bpi, bpi->peer, bpi->type, bpi->sub_type, + (bpi->extra ? bpi->extra->vnc.export.rfapi_handle + : NULL), + ((bpi->attr + && CHECK_FLAG(bpi->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) - ? bi->attr->local_pref + ? bpi->attr->local_pref : 0)); - if (bi->peer == peer && bi->type == type - && bi->sub_type == sub_type && bi->extra - && bi->extra->vnc.export.rfapi_handle == (void *)rfd) { + if (bpi->peer == peer && bpi->type == type + && bpi->sub_type == sub_type && bpi->extra + && bpi->extra->vnc.export.rfapi_handle == (void *)rfd) { vnc_zlog_debug_verbose("%s: matched it", __func__); @@ -412,8 +413,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd, * route. Leave the route itself in place. * TBD add return code reporting of success/failure */ - if (!bi || !bi->extra - || !bi->extra->vnc.export.local_nexthops) { + if (!bpi || !bpi->extra + || !bpi->extra->vnc.export.local_nexthops) { /* * no local nexthops */ @@ -429,7 +430,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd, struct listnode *node; struct rfapi_nexthop *pLnh = NULL; - for (ALL_LIST_ELEMENTS_RO(bi->extra->vnc.export.local_nexthops, + for (ALL_LIST_ELEMENTS_RO(bpi->extra->vnc.export.local_nexthops, node, pLnh)) { if (prefix_same(&pLnh->addr, &lnh->addr)) { @@ -438,7 +439,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd, } if (pLnh) { - listnode_delete(bi->extra->vnc.export.local_nexthops, + listnode_delete(bpi->extra->vnc.export.local_nexthops, pLnh); /* silly rabbit, listnode_delete doesn't invoke @@ -458,7 +459,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd, */ rfapiProcessWithdraw(peer, rfd, p, prd, NULL, afi, safi, type, kill); - if (bi) { + if (bpi) { prefix2str(p, buf, sizeof(buf)); vnc_zlog_debug_verbose( "%s: Found route (safi=%d) to delete at prefix %s", @@ -474,7 +475,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd, table = (struct bgp_table *)(prn->info); vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( - bgp, prd, table, p, bi); + bgp, prd, table, p, bpi); } bgp_unlock_node(prn); } @@ -482,13 +483,12 @@ void del_vnc_route(struct rfapi_descriptor *rfd, /* * Delete local_nexthops list */ - if (bi->extra && bi->extra->vnc.export.local_nexthops) { - list_delete( - &bi->extra->vnc.export.local_nexthops); + if (bpi->extra && bpi->extra->vnc.export.local_nexthops) { + list_delete(&bpi->extra->vnc.export.local_nexthops); } - bgp_aggregate_decrement(bgp, p, bi, afi, safi); - bgp_path_info_delete(bn, bi); + bgp_aggregate_decrement(bgp, p, bpi, afi, safi); + bgp_path_info_delete(bn, bpi); bgp_process(bgp, bn, afi, safi); } else { vnc_zlog_debug_verbose( @@ -576,7 +576,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ { afi_t afi; /* of the VN address */ struct bgp_path_info *new; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct bgp_node *bn; struct attr attr = {0}; @@ -946,29 +946,29 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ * ecommunity: POINTS TO interned/refcounted dynamic 2-part AS attr * aspath: POINTS TO interned/refcounted hashed block */ - for (bi = bn->info; bi; bi = bi->next) { + for (bpi = bn->info; bpi; bpi = bpi->next) { /* probably only need to check - * bi->extra->vnc.export.rfapi_handle */ - if (bi->peer == rfd->peer && bi->type == type - && bi->sub_type == sub_type && bi->extra - && bi->extra->vnc.export.rfapi_handle == (void *)rfd) { + * bpi->extra->vnc.export.rfapi_handle */ + if (bpi->peer == rfd->peer && bpi->type == type + && bpi->sub_type == sub_type && bpi->extra + && bpi->extra->vnc.export.rfapi_handle == (void *)rfd) { break; } } - if (bi) { + if (bpi) { /* * Adding new local_nexthop, which does not by itself change * what is advertised via BGP */ if (lnh) { - if (!bi->extra->vnc.export.local_nexthops) { + if (!bpi->extra->vnc.export.local_nexthops) { /* TBD make arrangements to free when needed */ - bi->extra->vnc.export.local_nexthops = + bpi->extra->vnc.export.local_nexthops = list_new(); - bi->extra->vnc.export.local_nexthops->del = + bpi->extra->vnc.export.local_nexthops->del = rfapi_nexthop_free; } @@ -979,8 +979,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ struct rfapi_nexthop *pLnh = NULL; for (ALL_LIST_ELEMENTS_RO( - bi->extra->vnc.export.local_nexthops, node, - pLnh)) { + bpi->extra->vnc.export.local_nexthops, + node, pLnh)) { if (prefix_same(&pLnh->addr, &lnh->addr)) { break; @@ -993,13 +993,13 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ if (!pLnh) { pLnh = rfapi_nexthop_new(lnh); listnode_add( - bi->extra->vnc.export.local_nexthops, + bpi->extra->vnc.export.local_nexthops, pLnh); } } - if (attrhash_cmp(bi->attr, new_attr) - && !CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (attrhash_cmp(bpi->attr, new_attr) + && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { bgp_attr_unintern(&new_attr); bgp_unlock_node(bn); @@ -1010,7 +1010,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ goto done; } else { /* The attribute is changed. */ - bgp_path_info_set_flag(bn, bi, BGP_PATH_ATTR_CHANGED); + bgp_path_info_set_flag(bn, bpi, BGP_PATH_ATTR_CHANGED); if (safi == SAFI_MPLS_VPN) { struct bgp_node *prn = NULL; @@ -1022,19 +1022,19 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ table = (struct bgp_table *)(prn->info); vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( - bgp, prd, table, p, bi); + bgp, prd, table, p, bpi); } bgp_unlock_node(prn); } /* Rewrite BGP route information. */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) - bgp_path_info_restore(bn, bi); + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) + bgp_path_info_restore(bn, bpi); else - bgp_aggregate_decrement(bgp, p, bi, afi, safi); - bgp_attr_unintern(&bi->attr); - bi->attr = new_attr; - bi->uptime = bgp_clock(); + bgp_aggregate_decrement(bgp, p, bpi, afi, safi); + bgp_attr_unintern(&bpi->attr); + bpi->attr = new_attr; + bpi->uptime = bgp_clock(); if (safi == SAFI_MPLS_VPN) { @@ -1047,13 +1047,13 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ table = (struct bgp_table *)(prn->info); vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( - bgp, prd, table, p, bi); + bgp, prd, table, p, bpi); } bgp_unlock_node(prn); } /* Process change. */ - bgp_aggregate_increment(bgp, p, bi, afi, safi); + bgp_aggregate_increment(bgp, p, bpi, afi, safi); bgp_process(bgp, bn, afi, safi); bgp_unlock_node(bn); @@ -3690,7 +3690,7 @@ static void rfapi_print_exported(struct bgp *bgp) { struct bgp_node *rdn; struct bgp_node *rn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; if (!bgp) return; @@ -3705,8 +3705,8 @@ static void rfapi_print_exported(struct bgp *bgp) if (!rn->info) continue; fprintf(stderr, "%s: rn=%p\n", __func__, rn); - for (bi = rn->info; bi; bi = bi->next) { - rfapiPrintBi((void *)2, bi); /* 2 => stderr */ + for (bpi = rn->info; bpi; bpi = bpi->next) { + rfapiPrintBi((void *)2, bpi); /* 2 => stderr */ } } } @@ -3720,8 +3720,8 @@ static void rfapi_print_exported(struct bgp *bgp) if (!rn->info) continue; fprintf(stderr, "%s: rn=%p\n", __func__, rn); - for (bi = rn->info; bi; bi = bi->next) { - rfapiPrintBi((void *)2, bi); /* 2 => stderr */ + for (bpi = rn->info; bpi; bpi = bpi->next) { + rfapiPrintBi((void *)2, bpi); /* 2 => stderr */ } } } diff --git a/bgpd/rfapi/rfapi_backend.h b/bgpd/rfapi/rfapi_backend.h index 0e4fc8208b..96e464d2ae 100644 --- a/bgpd/rfapi/rfapi_backend.h +++ b/bgpd/rfapi/rfapi_backend.h @@ -57,7 +57,7 @@ extern void vnc_zebra_withdraw(struct prefix *p, extern void rfapi_vty_out_vncinfo(struct vty *vty, struct prefix *p, - struct bgp_path_info *bi, safi_t safi); + struct bgp_path_info *bpi, safi_t safi); extern void vnc_direct_bgp_vpn_enable(struct bgp *bgp, afi_t afi); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 36269b9c3f..7b304c7fbc 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -150,22 +150,22 @@ void rfapiCheckRouteCount() for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct bgp_path_info *next; - for (bi = rn->info; bi; bi = next) { - next = bi->next; + for (bpi = rn->info; bpi; bpi = next) { + next = bpi->next; - if (CHECK_FLAG(bi->flags, + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { ++holddown_count; } else { - if (RFAPI_LOCAL_BI(bi)) { + if (RFAPI_LOCAL_BI(bpi)) { ++local_count; } else { if (RFAPI_DIRECT_IMPORT_BI( - bi)) { + bpi)) { ++imported_count; } else { ++remote_count; @@ -216,14 +216,14 @@ void rfapiCheckRouteCount() */ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset) { - unsigned int count_bi = 0; + unsigned int count_bpi = 0; unsigned int count_monitor = 0; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct rfapi_monitor_encap *hme; struct rfapi_monitor_vpn *hmv; - for (bi = rn->info; bi; bi = bi->next) - ++count_bi; + for (bpi = rn->info; bpi; bpi = bpi->next) + ++count_bpi; if (rn->aggregate) { @@ -265,10 +265,10 @@ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset) } } - if (count_bi + count_monitor + lockoffset != rn->lock) { + if (count_bpi + count_monitor + lockoffset != rn->lock) { vnc_zlog_debug_verbose( - "%s: count_bi=%d, count_monitor=%d, lockoffset=%d, rn->lock=%d", - __func__, count_bi, count_monitor, lockoffset, + "%s: count_bpi=%d, count_monitor=%d, lockoffset=%d, rn->lock=%d", + __func__, count_bpi, count_monitor, lockoffset, rn->lock); assert(0); } @@ -457,28 +457,28 @@ int rfapiGetVncTunnelUnAddr(struct attr *attr, struct prefix *p) /* * Get UN address wherever it might be */ -int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bi, struct prefix *p) +int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bpi, struct prefix *p) { /* If it's in this route's VNC attribute, we're done */ - if (!rfapiGetVncTunnelUnAddr(bi->attr, p)) + if (!rfapiGetVncTunnelUnAddr(bpi->attr, p)) return 0; /* * Otherwise, see if it's cached from a corresponding ENCAP SAFI * advertisement */ - if (bi->extra) { - switch (bi->extra->vnc.import.un_family) { + if (bpi->extra) { + switch (bpi->extra->vnc.import.un_family) { case AF_INET: if (p) { - p->family = bi->extra->vnc.import.un_family; - p->u.prefix4 = bi->extra->vnc.import.un.addr4; + p->family = bpi->extra->vnc.import.un_family; + p->u.prefix4 = bpi->extra->vnc.import.un.addr4; p->prefixlen = 32; } return 0; case AF_INET6: if (p) { - p->family = bi->extra->vnc.import.un_family; - p->u.prefix6 = bi->extra->vnc.import.un.addr6; + p->family = bpi->extra->vnc.import.un_family; + p->u.prefix6 = bpi->extra->vnc.import.un.addr6; p->prefixlen = 128; } return 0; @@ -487,7 +487,7 @@ int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bi, struct prefix *p) p->family = 0; #if DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose( - "%s: bi->extra->vnc.import.un_family is 0, no UN addr", + "%s: bpi->extra->vnc.import.un_family is 0, no UN addr", __func__); #endif break; @@ -635,7 +635,7 @@ struct rfapi_import_table *rfapiMacImportTableGet(struct bgp *bgp, uint32_t lni) static struct rfapi_monitor_vpn * rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct agg_node *par; struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *mlast; @@ -656,14 +656,14 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) #endif /* - * 1. If there is at least one bi (either regular route or + * 1. If there is at least one bpi (either regular route or * route marked as withdrawn, with a pending timer) at * original_node with a valid UN address, we're done. Return. */ - for (bi = original_vpn_node->info; bi; bi = bi->next) { + for (bpi = original_vpn_node->info; bpi; bpi = bpi->next) { struct prefix pfx; - if (!rfapiGetUnAddrOfVpnBi(bi, &pfx)) { + if (!rfapiGetUnAddrOfVpnBi(bpi, &pfx)) { #if DEBUG_MONITOR_MOVE_SHORTER vnc_zlog_debug_verbose( "%s: have valid UN at original node, no change", @@ -681,13 +681,13 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) */ for (par = agg_node_parent(original_vpn_node); par; par = agg_node_parent(par)) { - for (bi = par->info; bi; bi = bi->next) { + for (bpi = par->info; bpi; bpi = bpi->next) { struct prefix pfx; - if (!rfapiGetUnAddrOfVpnBi(bi, &pfx)) { + if (!rfapiGetUnAddrOfVpnBi(bpi, &pfx)) { break; } } - if (bi) + if (bpi) break; } @@ -802,7 +802,7 @@ static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node) { struct rfapi_monitor_vpn *monitor; struct rfapi_monitor_vpn *mlast; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct agg_node *par; RFAPI_CHECK_REFCOUNT(new_vpn_node, SAFI_MPLS_VPN, 0); @@ -810,13 +810,13 @@ static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node) /* * Make sure we have at least one valid route at the new node */ - for (bi = new_vpn_node->info; bi; bi = bi->next) { + for (bpi = new_vpn_node->info; bpi; bpi = bpi->next) { struct prefix pfx; - if (!rfapiGetUnAddrOfVpnBi(bi, &pfx)) + if (!rfapiGetUnAddrOfVpnBi(bpi, &pfx)) break; } - if (!bi) { + if (!bpi) { vnc_zlog_debug_verbose( "%s: no valid routes at node %p, so not attempting moves", __func__, new_vpn_node); @@ -882,31 +882,31 @@ static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node) } -static void rfapiBgpInfoChainFree(struct bgp_path_info *bi) +static void rfapiBgpInfoChainFree(struct bgp_path_info *bpi) { struct bgp_path_info *next; - while (bi) { + while (bpi) { /* - * If there is a timer waiting to delete this bi, cancel + * If there is a timer waiting to delete this bpi, cancel * the timer and delete immediately */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) - && bi->extra->vnc.import.timer) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) + && bpi->extra->vnc.import.timer) { struct thread *t = - (struct thread *)bi->extra->vnc.import.timer; + (struct thread *)bpi->extra->vnc.import.timer; struct rfapi_withdraw *wcb = t->arg; XFREE(MTYPE_RFAPI_WITHDRAW, wcb); thread_cancel(t); } - next = bi->next; - bi->next = NULL; - rfapiBgpInfoFree(bi); - bi = next; + next = bpi->next; + bpi->next = NULL; + rfapiBgpInfoFree(bpi); + bpi = next; } } @@ -1101,28 +1101,28 @@ int rfapiEcommunityGetEthernetTag(struct ecommunity *ecom, uint16_t *tag_id) return ENOENT; } -static int rfapiVpnBiNhEqualsPt(struct bgp_path_info *bi, +static int rfapiVpnBiNhEqualsPt(struct bgp_path_info *bpi, struct rfapi_ip_addr *hpt) { uint8_t family; - if (!hpt || !bi) + if (!hpt || !bpi) return 0; - family = BGP_MP_NEXTHOP_FAMILY(bi->attr->mp_nexthop_len); + family = BGP_MP_NEXTHOP_FAMILY(bpi->attr->mp_nexthop_len); if (hpt->addr_family != family) return 0; switch (family) { case AF_INET: - if (bi->attr->mp_nexthop_global_in.s_addr + if (bpi->attr->mp_nexthop_global_in.s_addr != hpt->addr.v4.s_addr) return 0; break; case AF_INET6: - if (IPV6_ADDR_CMP(&bi->attr->mp_nexthop_global, &hpt->addr.v6)) + if (IPV6_ADDR_CMP(&bpi->attr->mp_nexthop_global, &hpt->addr.v6)) return 0; break; @@ -1138,37 +1138,37 @@ static int rfapiVpnBiNhEqualsPt(struct bgp_path_info *bi, /* * Compare 2 VPN BIs. Return true if they have the same VN and UN addresses */ -static int rfapiVpnBiSamePtUn(struct bgp_path_info *bi1, - struct bgp_path_info *bi2) +static int rfapiVpnBiSamePtUn(struct bgp_path_info *bpi1, + struct bgp_path_info *bpi2) { struct prefix pfx_un1; struct prefix pfx_un2; - if (!bi1 || !bi2) + if (!bpi1 || !bpi2) return 0; - if (!bi1->attr || !bi2->attr) + if (!bpi1->attr || !bpi2->attr) return 0; /* * VN address comparisons */ - if (BGP_MP_NEXTHOP_FAMILY(bi1->attr->mp_nexthop_len) - != BGP_MP_NEXTHOP_FAMILY(bi2->attr->mp_nexthop_len)) { + if (BGP_MP_NEXTHOP_FAMILY(bpi1->attr->mp_nexthop_len) + != BGP_MP_NEXTHOP_FAMILY(bpi2->attr->mp_nexthop_len)) { return 0; } - switch (BGP_MP_NEXTHOP_FAMILY(bi1->attr->mp_nexthop_len)) { + switch (BGP_MP_NEXTHOP_FAMILY(bpi1->attr->mp_nexthop_len)) { case AF_INET: - if (bi1->attr->mp_nexthop_global_in.s_addr - != bi2->attr->mp_nexthop_global_in.s_addr) + if (bpi1->attr->mp_nexthop_global_in.s_addr + != bpi2->attr->mp_nexthop_global_in.s_addr) return 0; break; case AF_INET6: - if (IPV6_ADDR_CMP(&bi1->attr->mp_nexthop_global, - &bi2->attr->mp_nexthop_global)) + if (IPV6_ADDR_CMP(&bpi1->attr->mp_nexthop_global, + &bpi2->attr->mp_nexthop_global)) return 0; break; @@ -1180,17 +1180,17 @@ static int rfapiVpnBiSamePtUn(struct bgp_path_info *bi1, /* * UN address comparisons */ - if (rfapiGetVncTunnelUnAddr(bi1->attr, &pfx_un1)) { - if (bi1->extra) { - pfx_un1.family = bi1->extra->vnc.import.un_family; - switch (bi1->extra->vnc.import.un_family) { + if (rfapiGetVncTunnelUnAddr(bpi1->attr, &pfx_un1)) { + if (bpi1->extra) { + pfx_un1.family = bpi1->extra->vnc.import.un_family; + switch (bpi1->extra->vnc.import.un_family) { case AF_INET: pfx_un1.u.prefix4 = - bi1->extra->vnc.import.un.addr4; + bpi1->extra->vnc.import.un.addr4; break; case AF_INET6: pfx_un1.u.prefix6 = - bi1->extra->vnc.import.un.addr6; + bpi1->extra->vnc.import.un.addr6; break; default: pfx_un1.family = 0; @@ -1199,17 +1199,17 @@ static int rfapiVpnBiSamePtUn(struct bgp_path_info *bi1, } } - if (rfapiGetVncTunnelUnAddr(bi2->attr, &pfx_un2)) { - if (bi2->extra) { - pfx_un2.family = bi2->extra->vnc.import.un_family; - switch (bi2->extra->vnc.import.un_family) { + if (rfapiGetVncTunnelUnAddr(bpi2->attr, &pfx_un2)) { + if (bpi2->extra) { + pfx_un2.family = bpi2->extra->vnc.import.un_family; + switch (bpi2->extra->vnc.import.un_family) { case AF_INET: pfx_un2.u.prefix4 = - bi2->extra->vnc.import.un.addr4; + bpi2->extra->vnc.import.un.addr4; break; case AF_INET6: pfx_un2.u.prefix6 = - bi2->extra->vnc.import.un.addr6; + bpi2->extra->vnc.import.un.addr6; break; default: pfx_un2.family = 0; @@ -1298,15 +1298,15 @@ int rfapi_extract_l2o( static struct rfapi_next_hop_entry * rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, - struct bgp_path_info *bi, /* route to encode */ - uint32_t lifetime, /* use this in nhe */ - struct agg_node *rn) /* req for L2 eth addr */ + struct bgp_path_info *bpi, /* route to encode */ + uint32_t lifetime, /* use this in nhe */ + struct agg_node *rn) /* req for L2 eth addr */ { struct rfapi_next_hop_entry *new; int have_vnc_tunnel_un = 0; #if DEBUG_ENCAP_MONITOR - vnc_zlog_debug_verbose("%s: entry, bi %p, rn %p", __func__, bi, rn); + vnc_zlog_debug_verbose("%s: entry, bpi %p, rn %p", __func__, bpi, rn); #endif new = XCALLOC(MTYPE_RFAPI_NEXTHOP, sizeof(struct rfapi_next_hop_entry)); @@ -1314,8 +1314,8 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, new->prefix = *rprefix; - if (bi->extra - && decode_rd_type(bi->extra->vnc.import.rd.val) + if (bpi->extra + && decode_rd_type(bpi->extra->vnc.import.rd.val) == RD_TYPE_VNC_ETH) { /* ethernet */ @@ -1330,19 +1330,19 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, memcpy(&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet, ETH_ALEN); /* only low 3 bytes of this are significant */ - if (bi->attr) { + if (bpi->attr) { (void)rfapiEcommunityGetLNI( - bi->attr->ecommunity, + bpi->attr->ecommunity, &vo->v.l2addr.logical_net_id); (void)rfapiEcommunityGetEthernetTag( - bi->attr->ecommunity, &vo->v.l2addr.tag_id); + bpi->attr->ecommunity, &vo->v.l2addr.tag_id); } /* local_nve_id comes from lower byte of RD type */ - vo->v.l2addr.local_nve_id = bi->extra->vnc.import.rd.val[1]; + vo->v.l2addr.local_nve_id = bpi->extra->vnc.import.rd.val[1]; /* label comes from MP_REACH_NLRI label */ - vo->v.l2addr.label = decode_label(&bi->extra->label[0]); + vo->v.l2addr.label = decode_label(&bpi->extra->label[0]); new->vn_options = vo; @@ -1350,38 +1350,38 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, * If there is an auxiliary prefix (i.e., host IP address), * use it as the nexthop prefix instead of the query prefix */ - if (bi->extra->vnc.import.aux_prefix.family) { - rfapiQprefix2Rprefix(&bi->extra->vnc.import.aux_prefix, + if (bpi->extra->vnc.import.aux_prefix.family) { + rfapiQprefix2Rprefix(&bpi->extra->vnc.import.aux_prefix, &new->prefix); } } - if (bi->attr) { + if (bpi->attr) { bgp_encap_types tun_type; - new->prefix.cost = rfapiRfpCost(bi->attr); + new->prefix.cost = rfapiRfpCost(bpi->attr); struct bgp_attr_encap_subtlv *pEncap; - switch (BGP_MP_NEXTHOP_FAMILY(bi->attr->mp_nexthop_len)) { + switch (BGP_MP_NEXTHOP_FAMILY(bpi->attr->mp_nexthop_len)) { case AF_INET: new->vn_address.addr_family = AF_INET; new->vn_address.addr.v4 = - bi->attr->mp_nexthop_global_in; + bpi->attr->mp_nexthop_global_in; break; case AF_INET6: new->vn_address.addr_family = AF_INET6; - new->vn_address.addr.v6 = bi->attr->mp_nexthop_global; + new->vn_address.addr.v6 = bpi->attr->mp_nexthop_global; break; default: zlog_warn("%s: invalid vpn nexthop length: %d", - __func__, bi->attr->mp_nexthop_len); + __func__, bpi->attr->mp_nexthop_len); rfapi_free_next_hop_list(new); return NULL; } - for (pEncap = bi->attr->vnc_subtlvs; pEncap; + for (pEncap = bpi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { switch (pEncap->type) { case BGP_VNC_SUBTLV_TYPE_LIFETIME: @@ -1397,18 +1397,18 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, } } - rfapiGetTunnelType(bi->attr, &tun_type); + rfapiGetTunnelType(bpi->attr, &tun_type); if (tun_type == BGP_ENCAP_TYPE_MPLS) { struct prefix p; /* MPLS carries UN address in next hop */ - rfapiNexthop2Prefix(bi->attr, &p); + rfapiNexthop2Prefix(bpi->attr, &p); if (p.family != 0) { rfapiQprefix2Raddr(&p, &new->un_address); have_vnc_tunnel_un = 1; } } - for (pEncap = bi->attr->encap_subtlvs; pEncap; + for (pEncap = bpi->attr->encap_subtlvs; pEncap; pEncap = pEncap->next) { switch (pEncap->type) { case BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT: @@ -1433,8 +1433,8 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, default: zlog_warn( - "%s: invalid tunnel subtlv UN addr length (%d) for bi %p", - __func__, pEncap->length, bi); + "%s: invalid tunnel subtlv UN addr length (%d) for bpi %p", + __func__, pEncap->length, bpi); } break; @@ -1448,33 +1448,33 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, } } - new->un_options = rfapi_encap_tlv_to_un_option(bi->attr); + new->un_options = rfapi_encap_tlv_to_un_option(bpi->attr); #if DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: line %d: have_vnc_tunnel_un=%d", __func__, __LINE__, have_vnc_tunnel_un); #endif - if (!have_vnc_tunnel_un && bi->extra) { + if (!have_vnc_tunnel_un && bpi->extra) { /* * use cached UN address from ENCAP route */ new->un_address.addr_family = - bi->extra->vnc.import.un_family; + bpi->extra->vnc.import.un_family; switch (new->un_address.addr_family) { case AF_INET: new->un_address.addr.v4 = - bi->extra->vnc.import.un.addr4; + bpi->extra->vnc.import.un.addr4; break; case AF_INET6: new->un_address.addr.v6 = - bi->extra->vnc.import.un.addr6; + bpi->extra->vnc.import.un.addr6; break; default: zlog_warn( - "%s: invalid UN addr family (%d) for bi %p", + "%s: invalid UN addr family (%d) for bpi %p", __func__, new->un_address.addr_family, - bi); + bpi); rfapi_free_next_hop_list(new); return NULL; break; @@ -1488,13 +1488,13 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, int rfapiHasNonRemovedRoutes(struct agg_node *rn) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { struct prefix pfx; - if (!CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) - && (bi->extra && !rfapiGetUnAddrOfVpnBi(bi, &pfx))) { + if (!CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) + && (bpi->extra && !rfapiGetUnAddrOfVpnBi(bpi, &pfx))) { return 1; } @@ -1508,16 +1508,16 @@ int rfapiHasNonRemovedRoutes(struct agg_node *rn) */ void rfapiDumpNode(struct agg_node *rn) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; vnc_zlog_debug_verbose("%s: rn=%p", __func__, rn); - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { struct prefix pfx; - int ctrc = rfapiGetUnAddrOfVpnBi(bi, &pfx); + int ctrc = rfapiGetUnAddrOfVpnBi(bpi, &pfx); int nr; - if (!CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) - && (bi->extra && !ctrc)) { + if (!CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) + && (bpi->extra && !ctrc)) { nr = 1; } else { @@ -1525,8 +1525,8 @@ void rfapiDumpNode(struct agg_node *rn) } vnc_zlog_debug_verbose( - " bi=%p, nr=%d, flags=0x%x, extra=%p, ctrc=%d", bi, nr, - bi->flags, bi->extra, ctrc); + " bpi=%p, nr=%d, flags=0x%x, extra=%p, ctrc=%d", bpi, + nr, bpi->flags, bpi->extra, ctrc); } } #endif @@ -1542,7 +1542,7 @@ static int rfapiNhlAddNodeRoutes( struct agg_node *rfd_rib_node, /* preload this NVE rib node */ struct prefix *pfx_target_original) /* query target */ { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct rfapi_next_hop_entry *new; struct prefix pfx_un; struct skiplist *seen_nexthops; @@ -1565,12 +1565,12 @@ static int rfapiNhlAddNodeRoutes( seen_nexthops = skiplist_new(0, vnc_prefix_cmp, (void (*)(void *))prefix_free); - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { struct prefix pfx_vn; struct prefix *newpfx; - if (removed && !CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (removed && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { #if DEBUG_RETURNED_NHL vnc_zlog_debug_verbose( "%s: want holddown, this route not holddown, skip", @@ -1578,18 +1578,18 @@ static int rfapiNhlAddNodeRoutes( #endif continue; } - if (!removed && CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (!removed && CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { continue; } - if (!bi->extra) { + if (!bpi->extra) { continue; } /* * Check for excluded VN address */ - if (rfapiVpnBiNhEqualsPt(bi, exclude_vnaddr)) + if (rfapiVpnBiNhEqualsPt(bpi, exclude_vnaddr)) continue; /* @@ -1598,9 +1598,9 @@ static int rfapiNhlAddNodeRoutes( if (is_l2) { /* L2 routes: semantic nexthop in aux_prefix; VN addr * ain't it */ - pfx_vn = bi->extra->vnc.import.aux_prefix; + pfx_vn = bpi->extra->vnc.import.aux_prefix; } else { - rfapiNexthop2Prefix(bi->attr, &pfx_vn); + rfapiNexthop2Prefix(bpi->attr, &pfx_vn); } if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) { #if DEBUG_RETURNED_NHL @@ -1614,10 +1614,10 @@ static int rfapiNhlAddNodeRoutes( continue; } - if (rfapiGetUnAddrOfVpnBi(bi, &pfx_un)) { + if (rfapiGetUnAddrOfVpnBi(bpi, &pfx_un)) { #if DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose( - "%s: failed to get UN address of this VPN bi", + "%s: failed to get UN address of this VPN bpi", __func__); #endif continue; @@ -1627,10 +1627,10 @@ static int rfapiNhlAddNodeRoutes( *newpfx = pfx_vn; skiplist_insert(seen_nexthops, newpfx, newpfx); - new = rfapiRouteInfo2NextHopEntry(rprefix, bi, lifetime, rn); + new = rfapiRouteInfo2NextHopEntry(rprefix, bpi, lifetime, rn); if (new) { if (rfapiRibPreloadBi(rfd_rib_node, &pfx_vn, &pfx_un, - lifetime, bi)) { + lifetime, bpi)) { /* duplicate filtered by RIB */ rfapi_free_next_hop_list(new); new = NULL; @@ -1994,8 +1994,8 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList( } /* - * Insert a new bi to the imported route table node, - * keeping the list of BIs sorted best route first + * Insert a new bpi to the imported route table node, + * keeping the list of BPIs sorted best route first */ static void rfapiBgpInfoAttachSorted(struct agg_node *rn, struct bgp_path_info *info_new, afi_t afi, @@ -2040,18 +2040,18 @@ static void rfapiBgpInfoAttachSorted(struct agg_node *rn, bgp_attr_intern(info_new->attr); } -static void rfapiBgpInfoDetach(struct agg_node *rn, struct bgp_path_info *bi) +static void rfapiBgpInfoDetach(struct agg_node *rn, struct bgp_path_info *bpi) { /* * Remove the route (doubly-linked) */ - // bgp_attr_unintern (&bi->attr); - if (bi->next) - bi->next->prev = bi->prev; - if (bi->prev) - bi->prev->next = bi->next; + // bgp_attr_unintern (&bpi->attr); + if (bpi->next) + bpi->next->prev = bpi->prev; + if (bpi->prev) + bpi->prev->next = bpi->next; else - rn->info = bi->next; + rn->info = bpi->next; } /* @@ -2059,48 +2059,48 @@ static void rfapiBgpInfoDetach(struct agg_node *rn, struct bgp_path_info *bi) */ static int rfapi_bi_peer_rd_cmp(void *b1, void *b2) { - struct bgp_path_info *bi1 = b1; - struct bgp_path_info *bi2 = b2; + struct bgp_path_info *bpi1 = b1; + struct bgp_path_info *bpi2 = b2; /* * Compare peers */ - if (bi1->peer < bi2->peer) + if (bpi1->peer < bpi2->peer) return -1; - if (bi1->peer > bi2->peer) + if (bpi1->peer > bpi2->peer) return 1; /* * compare RDs */ - return vnc_prefix_cmp((struct prefix *)&bi1->extra->vnc.import.rd, - (struct prefix *)&bi2->extra->vnc.import.rd); + return vnc_prefix_cmp((struct prefix *)&bpi1->extra->vnc.import.rd, + (struct prefix *)&bpi2->extra->vnc.import.rd); } /* * For L2-indexed import tables - * The BIs in these tables should ALWAYS have an aux_prefix set because + * The BPIs in these tables should ALWAYS have an aux_prefix set because * they arrive via IPv4 or IPv6 advertisements. */ static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2) { - struct bgp_path_info *bi1 = b1; - struct bgp_path_info *bi2 = b2; + struct bgp_path_info *bpi1 = b1; + struct bgp_path_info *bpi2 = b2; int rc; /* * Compare peers */ - if (bi1->peer < bi2->peer) + if (bpi1->peer < bpi2->peer) return -1; - if (bi1->peer > bi2->peer) + if (bpi1->peer > bpi2->peer) return 1; /* * compare RDs */ - rc = vnc_prefix_cmp((struct prefix *)&bi1->extra->vnc.import.rd, - (struct prefix *)&bi2->extra->vnc.import.rd); + rc = vnc_prefix_cmp((struct prefix *)&bpi1->extra->vnc.import.rd, + (struct prefix *)&bpi2->extra->vnc.import.rd); if (rc) { return rc; } @@ -2111,16 +2111,16 @@ static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2) * * Use presence of aux_prefix with AF=ethernet and prefixlen=1 * as magic value to signify explicit wildcarding of the aux_prefix. - * This magic value will not appear in bona fide bi entries in - * the import table, but is allowed in the "fake" bi used to + * This magic value will not appear in bona fide bpi entries in + * the import table, but is allowed in the "fake" bpi used to * probe the table when searching. (We have to test both b1 and b2 * because there is no guarantee of the order the test key and * the real key will be passed) */ - if ((bi1->extra->vnc.import.aux_prefix.family == AF_ETHERNET - && (bi1->extra->vnc.import.aux_prefix.prefixlen == 1)) - || (bi2->extra->vnc.import.aux_prefix.family == AF_ETHERNET - && (bi2->extra->vnc.import.aux_prefix.prefixlen == 1))) { + if ((bpi1->extra->vnc.import.aux_prefix.family == AF_ETHERNET + && (bpi1->extra->vnc.import.aux_prefix.prefixlen == 1)) + || (bpi2->extra->vnc.import.aux_prefix.family == AF_ETHERNET + && (bpi2->extra->vnc.import.aux_prefix.prefixlen == 1))) { /* * wildcard aux address specified @@ -2128,8 +2128,8 @@ static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2) return 0; } - return vnc_prefix_cmp(&bi1->extra->vnc.import.aux_prefix, - &bi2->extra->vnc.import.aux_prefix); + return vnc_prefix_cmp(&bpi1->extra->vnc.import.aux_prefix, + &bpi2->extra->vnc.import.aux_prefix); } @@ -2137,20 +2137,20 @@ static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2) * Index on RD and Peer */ static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */ - struct bgp_path_info *bi) /* new BI */ + struct bgp_path_info *bpi) /* new BPI */ { struct skiplist *sl; assert(rn); - assert(bi); - assert(bi->extra); + assert(bpi); + assert(bpi->extra); { char buf[RD_ADDRSTRLEN]; - vnc_zlog_debug_verbose("%s: bi %p, peer %p, rd %s", __func__, - bi, bi->peer, - prefix_rd2str(&bi->extra->vnc.import.rd, + vnc_zlog_debug_verbose("%s: bpi %p, peer %p, rd %s", __func__, + bpi, bpi->peer, + prefix_rd2str(&bpi->extra->vnc.import.rd, buf, sizeof(buf))); } @@ -2164,10 +2164,10 @@ static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */ RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd = sl; agg_lock_node(rn); /* for skiplist */ } - assert(!skiplist_insert(sl, (void *)bi, (void *)bi)); + assert(!skiplist_insert(sl, (void *)bpi, (void *)bpi)); agg_lock_node(rn); /* for skiplist entry */ - /* NB: BIs in import tables are not refcounted */ + /* NB: BPIs in import tables are not refcounted */ } static void rfapiItBiIndexDump(struct agg_node *rn) @@ -2195,7 +2195,7 @@ static void rfapiItBiIndexDump(struct agg_node *rn) } else strncpy(buf_aux_pfx, "(none)", PREFIX_STRLEN); - vnc_zlog_debug_verbose("bi %p, peer %p, rd %s, aux_prefix %s", + vnc_zlog_debug_verbose("bpi %p, peer %p, rd %s, aux_prefix %s", k, k->peer, buf, buf_aux_pfx); } } @@ -2207,9 +2207,9 @@ static struct bgp_path_info *rfapiItBiIndexSearch( { struct skiplist *sl; int rc; - struct bgp_path_info bi_fake; - struct bgp_path_info_extra bi_extra; - struct bgp_path_info *bi_result; + struct bgp_path_info bpi_fake; + struct bgp_path_info_extra bpi_extra; + struct bgp_path_info *bpi_result; sl = RFAPI_RDINDEX(rn); if (!sl) @@ -2240,22 +2240,22 @@ static struct bgp_path_info *rfapiItBiIndexSearch( vnc_zlog_debug_verbose("%s: short list algorithm", __func__); #endif /* if short list, linear search might be faster */ - for (bi_result = rn->info; bi_result; - bi_result = bi_result->next) { + for (bpi_result = rn->info; bpi_result; + bpi_result = bpi_result->next) { #if DEBUG_BI_SEARCH { char buf[RD_ADDRSTRLEN]; vnc_zlog_debug_verbose( - "%s: bi has prd=%s, peer=%p", __func__, - prefix_rd2str(&bi_result->extra->vnc + "%s: bpi has prd=%s, peer=%p", __func__, + prefix_rd2str(&bpi_result->extra->vnc .import.rd, buf, sizeof(buf)), - bi_result->peer); + bpi_result->peer); } #endif - if (peer == bi_result->peer - && !prefix_cmp((struct prefix *)&bi_result->extra + if (peer == bpi_result->peer + && !prefix_cmp((struct prefix *)&bpi_result->extra ->vnc.import.rd, (struct prefix *)prd)) { @@ -2265,9 +2265,10 @@ static struct bgp_path_info *rfapiItBiIndexSearch( __func__); #endif if (!aux_prefix - || !prefix_cmp(aux_prefix, - &bi_result->extra->vnc.import - .aux_prefix)) { + || !prefix_cmp( + aux_prefix, + &bpi_result->extra->vnc.import + .aux_prefix)) { #if DEBUG_BI_SEARCH vnc_zlog_debug_verbose("%s: match", @@ -2277,21 +2278,21 @@ static struct bgp_path_info *rfapiItBiIndexSearch( } } } - return bi_result; + return bpi_result; } - bi_fake.peer = peer; - bi_fake.extra = &bi_extra; - bi_fake.extra->vnc.import.rd = *(struct prefix_rd *)prd; + bpi_fake.peer = peer; + bpi_fake.extra = &bpi_extra; + bpi_fake.extra->vnc.import.rd = *(struct prefix_rd *)prd; if (aux_prefix) { - bi_fake.extra->vnc.import.aux_prefix = *aux_prefix; + bpi_fake.extra->vnc.import.aux_prefix = *aux_prefix; } else { /* wildcard */ - bi_fake.extra->vnc.import.aux_prefix.family = AF_ETHERNET; - bi_fake.extra->vnc.import.aux_prefix.prefixlen = 1; + bpi_fake.extra->vnc.import.aux_prefix.family = AF_ETHERNET; + bpi_fake.extra->vnc.import.aux_prefix.prefixlen = 1; } - rc = skiplist_search(sl, (void *)&bi_fake, (void *)&bi_result); + rc = skiplist_search(sl, (void *)&bpi_fake, (void *)&bpi_result); if (rc) { #if DEBUG_BI_SEARCH @@ -2301,14 +2302,14 @@ static struct bgp_path_info *rfapiItBiIndexSearch( } #if DEBUG_BI_SEARCH - vnc_zlog_debug_verbose("%s: matched bi=%p", __func__, bi_result); + vnc_zlog_debug_verbose("%s: matched bpi=%p", __func__, bpi_result); #endif - return bi_result; + return bpi_result; } static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */ - struct bgp_path_info *bi) /* old BI */ + struct bgp_path_info *bpi) /* old BPI */ { struct skiplist *sl; int rc; @@ -2316,16 +2317,16 @@ static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */ { char buf[RD_ADDRSTRLEN]; - vnc_zlog_debug_verbose("%s: bi %p, peer %p, rd %s", __func__, - bi, bi->peer, - prefix_rd2str(&bi->extra->vnc.import.rd, + vnc_zlog_debug_verbose("%s: bpi %p, peer %p, rd %s", __func__, + bpi, bpi->peer, + prefix_rd2str(&bpi->extra->vnc.import.rd, buf, sizeof(buf))); } sl = RFAPI_RDINDEX(rn); assert(sl); - rc = skiplist_delete(sl, (void *)(bi), (void *)bi); + rc = skiplist_delete(sl, (void *)(bpi), (void *)bpi); if (rc) { rfapiItBiIndexDump(rn); } @@ -2333,7 +2334,7 @@ static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */ agg_unlock_node(rn); /* for skiplist entry */ - /* NB: BIs in import tables are not refcounted */ + /* NB: BPIs in import tables are not refcounted */ } /* @@ -2342,9 +2343,9 @@ static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */ */ static void rfapiMonitorEncapAdd(struct rfapi_import_table *import_table, - struct prefix *p, /* VN address */ - struct agg_node *vpn_rn, /* VPN node */ - struct bgp_path_info *vpn_bi) /* VPN bi/route */ + struct prefix *p, /* VN address */ + struct agg_node *vpn_rn, /* VPN node */ + struct bgp_path_info *vpn_bpi) /* VPN bpi/route */ { afi_t afi = family2afi(p->family); struct agg_node *rn; @@ -2359,7 +2360,7 @@ rfapiMonitorEncapAdd(struct rfapi_import_table *import_table, assert(m); m->node = vpn_rn; - m->bi = vpn_bi; + m->bpi = vpn_bpi; m->rn = rn; /* insert to encap node's list */ @@ -2369,24 +2370,25 @@ rfapiMonitorEncapAdd(struct rfapi_import_table *import_table, RFAPI_MONITOR_ENCAP_W_ALLOC(rn) = m; /* for easy lookup when deleting vpn route */ - vpn_bi->extra->vnc.import.hme = m; + vpn_bpi->extra->vnc.import.hme = m; vnc_zlog_debug_verbose( - "%s: it=%p, vpn_bi=%p, afi=%d, encap rn=%p, setting vpn_bi->extra->vnc.import.hme=%p", - __func__, import_table, vpn_bi, afi, rn, m); + "%s: it=%p, vpn_bpi=%p, afi=%d, encap rn=%p, setting vpn_bpi->extra->vnc.import.hme=%p", + __func__, import_table, vpn_bpi, afi, rn, m); RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 0); - bgp_attr_intern(vpn_bi->attr); + bgp_attr_intern(vpn_bpi->attr); } -static void rfapiMonitorEncapDelete(struct bgp_path_info *vpn_bi) +static void rfapiMonitorEncapDelete(struct bgp_path_info *vpn_bpi) { /* * Remove encap monitor */ - vnc_zlog_debug_verbose("%s: vpn_bi=%p", __func__, vpn_bi); - if (vpn_bi->extra) { - struct rfapi_monitor_encap *hme = vpn_bi->extra->vnc.import.hme; + vnc_zlog_debug_verbose("%s: vpn_bpi=%p", __func__, vpn_bpi); + if (vpn_bpi->extra) { + struct rfapi_monitor_encap *hme = + vpn_bpi->extra->vnc.import.hme; if (hme) { @@ -2410,7 +2412,7 @@ static void rfapiMonitorEncapDelete(struct bgp_path_info *vpn_bi) agg_unlock_node(hme->rn); /* decr ref count */ XFREE(MTYPE_RFAPI_MONITOR_ENCAP, hme); - vpn_bi->extra->vnc.import.hme = NULL; + vpn_bpi->extra->vnc.import.hme = NULL; } } } @@ -2422,16 +2424,16 @@ static void rfapiMonitorEncapDelete(struct bgp_path_info *vpn_bi) static int rfapiWithdrawTimerVPN(struct thread *t) { struct rfapi_withdraw *wcb = t->arg; - struct bgp_path_info *bi = wcb->info; + struct bgp_path_info *bpi = wcb->info; struct bgp *bgp = bgp_get_default(); struct rfapi_monitor_vpn *moved; afi_t afi; assert(wcb->node); - assert(bi); + assert(bpi); assert(wcb->import_table); - assert(bi->extra); + assert(bpi->extra); RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_MPLS_VPN, wcb->lockoffset); @@ -2439,7 +2441,7 @@ static int rfapiWithdrawTimerVPN(struct thread *t) char buf[BUFSIZ]; vnc_zlog_debug_verbose( - "%s: removing bi %p at prefix %s/%d", __func__, bi, + "%s: removing bpi %p at prefix %s/%d", __func__, bpi, rfapi_ntop(wcb->node->p.family, &wcb->node->p.u.prefix, buf, BUFSIZ), wcb->node->p.prefixlen); @@ -2448,17 +2450,17 @@ static int rfapiWithdrawTimerVPN(struct thread *t) /* * Remove the route (doubly-linked) */ - if (CHECK_FLAG(bi->flags, BGP_PATH_VALID) - && VALID_INTERIOR_TYPE(bi->type)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_VALID) + && VALID_INTERIOR_TYPE(bpi->type)) RFAPI_MONITOR_EXTERIOR(wcb->node)->valid_interior_count--; afi = family2afi(wcb->node->p.family); wcb->import_table->holddown_count[afi] -= 1; /* keep count consistent */ - rfapiItBiIndexDel(wcb->node, bi); - rfapiBgpInfoDetach(wcb->node, bi); /* with removed bi */ + rfapiItBiIndexDel(wcb->node, bpi); + rfapiBgpInfoDetach(wcb->node, bpi); /* with removed bpi */ vnc_import_bgp_exterior_del_route_interior(bgp, wcb->import_table, - wcb->node, bi); + wcb->node, bpi); /* @@ -2470,7 +2472,7 @@ static int rfapiWithdrawTimerVPN(struct thread *t) & BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE)) { int has_valid_duplicate = 0; - struct bgp_path_info *bii; + struct bgp_path_info *bpii; /* * First check if there are any OTHER routes at this node @@ -2478,8 +2480,8 @@ static int rfapiWithdrawTimerVPN(struct thread *t) * there are (e.g., from other peers), then the route isn't * really gone, so skip sending a response removal message. */ - for (bii = wcb->node->info; bii; bii = bii->next) { - if (rfapiVpnBiSamePtUn(bi, bii)) { + for (bpii = wcb->node->info; bpii; bpii = bpii->next) { + if (rfapiVpnBiSamePtUn(bpi, bpii)) { has_valid_duplicate = 1; break; } @@ -2494,7 +2496,7 @@ static int rfapiWithdrawTimerVPN(struct thread *t) } } - rfapiMonitorEncapDelete(bi); + rfapiMonitorEncapDelete(bpi); /* * If there are no VPN monitors at this VPN Node A, @@ -2519,9 +2521,9 @@ static int rfapiWithdrawTimerVPN(struct thread *t) done: /* - * Free VPN bi + * Free VPN bpi */ - rfapiBgpInfoFree(bi); + rfapiBgpInfoFree(bpi); wcb->info = NULL; /* @@ -2618,48 +2620,48 @@ static int rfapiAttrNexthopAddrDifferent(struct prefix *p1, struct prefix *p2) return 1; } -static void rfapiCopyUnEncap2VPN(struct bgp_path_info *encap_bi, - struct bgp_path_info *vpn_bi) +static void rfapiCopyUnEncap2VPN(struct bgp_path_info *encap_bpi, + struct bgp_path_info *vpn_bpi) { - if (!encap_bi->attr) { - zlog_warn("%s: no encap bi attr/extra, can't copy UN address", + if (!encap_bpi->attr) { + zlog_warn("%s: no encap bpi attr/extra, can't copy UN address", __func__); return; } - if (!vpn_bi || !vpn_bi->extra) { - zlog_warn("%s: no vpn bi attr/extra, can't copy UN address", + if (!vpn_bpi || !vpn_bpi->extra) { + zlog_warn("%s: no vpn bpi attr/extra, can't copy UN address", __func__); return; } - switch (BGP_MP_NEXTHOP_FAMILY(encap_bi->attr->mp_nexthop_len)) { + switch (BGP_MP_NEXTHOP_FAMILY(encap_bpi->attr->mp_nexthop_len)) { case AF_INET: /* * instrumentation to debug segfault of 091127 */ - vnc_zlog_debug_verbose("%s: vpn_bi=%p", __func__, vpn_bi); - if (vpn_bi) { - vnc_zlog_debug_verbose("%s: vpn_bi->extra=%p", __func__, - vpn_bi->extra); + vnc_zlog_debug_verbose("%s: vpn_bpi=%p", __func__, vpn_bpi); + if (vpn_bpi) { + vnc_zlog_debug_verbose("%s: vpn_bpi->extra=%p", + __func__, vpn_bpi->extra); } - vpn_bi->extra->vnc.import.un_family = AF_INET; - vpn_bi->extra->vnc.import.un.addr4 = - encap_bi->attr->mp_nexthop_global_in; + vpn_bpi->extra->vnc.import.un_family = AF_INET; + vpn_bpi->extra->vnc.import.un.addr4 = + encap_bpi->attr->mp_nexthop_global_in; break; case AF_INET6: - vpn_bi->extra->vnc.import.un_family = AF_INET6; - vpn_bi->extra->vnc.import.un.addr6 = - encap_bi->attr->mp_nexthop_global; + vpn_bpi->extra->vnc.import.un_family = AF_INET6; + vpn_bpi->extra->vnc.import.un.addr6 = + encap_bpi->attr->mp_nexthop_global; break; default: zlog_warn("%s: invalid encap nexthop length: %d", __func__, - encap_bi->attr->mp_nexthop_len); - vpn_bi->extra->vnc.import.un_family = 0; + encap_bpi->attr->mp_nexthop_len); + vpn_bpi->extra->vnc.import.un_family = 0; break; } } @@ -2667,55 +2669,57 @@ static void rfapiCopyUnEncap2VPN(struct bgp_path_info *encap_bi, /* * returns 0 on success, nonzero on error */ -static int rfapiWithdrawEncapUpdateCachedUn( - struct rfapi_import_table *import_table, struct bgp_path_info *encap_bi, - struct agg_node *vpn_rn, struct bgp_path_info *vpn_bi) +static int +rfapiWithdrawEncapUpdateCachedUn(struct rfapi_import_table *import_table, + struct bgp_path_info *encap_bpi, + struct agg_node *vpn_rn, + struct bgp_path_info *vpn_bpi) { - if (!encap_bi) { + if (!encap_bpi) { /* * clear cached UN address */ - if (!vpn_bi || !vpn_bi->extra) { + if (!vpn_bpi || !vpn_bpi->extra) { zlog_warn( - "%s: missing VPN bi/extra, can't clear UN addr", + "%s: missing VPN bpi/extra, can't clear UN addr", __func__); return 1; } - vpn_bi->extra->vnc.import.un_family = 0; - memset(&vpn_bi->extra->vnc.import.un, 0, - sizeof(vpn_bi->extra->vnc.import.un)); - if (CHECK_FLAG(vpn_bi->flags, BGP_PATH_VALID)) { - if (rfapiGetVncTunnelUnAddr(vpn_bi->attr, NULL)) { - UNSET_FLAG(vpn_bi->flags, BGP_PATH_VALID); - if (VALID_INTERIOR_TYPE(vpn_bi->type)) + vpn_bpi->extra->vnc.import.un_family = 0; + memset(&vpn_bpi->extra->vnc.import.un, 0, + sizeof(vpn_bpi->extra->vnc.import.un)); + if (CHECK_FLAG(vpn_bpi->flags, BGP_PATH_VALID)) { + if (rfapiGetVncTunnelUnAddr(vpn_bpi->attr, NULL)) { + UNSET_FLAG(vpn_bpi->flags, BGP_PATH_VALID); + if (VALID_INTERIOR_TYPE(vpn_bpi->type)) RFAPI_MONITOR_EXTERIOR(vpn_rn) ->valid_interior_count--; /* signal interior route withdrawal to * import-exterior */ vnc_import_bgp_exterior_del_route_interior( bgp_get_default(), import_table, vpn_rn, - vpn_bi); + vpn_bpi); } } } else { - if (!vpn_bi) { - zlog_warn("%s: missing VPN bi, can't clear UN addr", + if (!vpn_bpi) { + zlog_warn("%s: missing VPN bpi, can't clear UN addr", __func__); return 1; } - rfapiCopyUnEncap2VPN(encap_bi, vpn_bi); - if (!CHECK_FLAG(vpn_bi->flags, BGP_PATH_VALID)) { - SET_FLAG(vpn_bi->flags, BGP_PATH_VALID); - if (VALID_INTERIOR_TYPE(vpn_bi->type)) + rfapiCopyUnEncap2VPN(encap_bpi, vpn_bpi); + if (!CHECK_FLAG(vpn_bpi->flags, BGP_PATH_VALID)) { + SET_FLAG(vpn_bpi->flags, BGP_PATH_VALID); + if (VALID_INTERIOR_TYPE(vpn_bpi->type)) RFAPI_MONITOR_EXTERIOR(vpn_rn) ->valid_interior_count++; /* signal interior route withdrawal to import-exterior */ vnc_import_bgp_exterior_add_route_interior( bgp_get_default(), import_table, vpn_rn, - vpn_bi); + vpn_bpi); } } return 0; @@ -2724,25 +2728,25 @@ static int rfapiWithdrawEncapUpdateCachedUn( static int rfapiWithdrawTimerEncap(struct thread *t) { struct rfapi_withdraw *wcb = t->arg; - struct bgp_path_info *bi = wcb->info; + struct bgp_path_info *bpi = wcb->info; int was_first_route = 0; struct rfapi_monitor_encap *em; struct skiplist *vpn_node_sl = skiplist_new(0, NULL, NULL); assert(wcb->node); - assert(bi); + assert(bpi); assert(wcb->import_table); RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_ENCAP, 0); - if (wcb->node->info == bi) + if (wcb->node->info == bpi) was_first_route = 1; /* - * Remove the route/bi and free it + * Remove the route/bpi and free it */ - rfapiBgpInfoDetach(wcb->node, bi); - rfapiBgpInfoFree(bi); + rfapiBgpInfoDetach(wcb->node, bpi); + rfapiBgpInfoFree(bpi); if (!was_first_route) goto done; @@ -2750,13 +2754,13 @@ static int rfapiWithdrawTimerEncap(struct thread *t) for (em = RFAPI_MONITOR_ENCAP(wcb->node); em; em = em->next) { /* - * Update monitoring VPN BIs with new encap info at the - * head of the encap bi chain (which could be NULL after - * removing the expiring bi above) + * Update monitoring VPN BPIs with new encap info at the + * head of the encap bpi chain (which could be NULL after + * removing the expiring bpi above) */ if (rfapiWithdrawEncapUpdateCachedUn(wcb->import_table, wcb->node->info, em->node, - em->bi)) + em->bpi)) continue; /* @@ -2805,14 +2809,14 @@ done: */ static void rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, - struct agg_node *rn, struct bgp_path_info *bi, + struct agg_node *rn, struct bgp_path_info *bpi, afi_t afi, safi_t safi, int (*timer_service_func)(struct thread *)) { uint32_t lifetime; struct rfapi_withdraw *wcb; - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { /* * Already on the path to being withdrawn, * should already have a timer set up to @@ -2823,13 +2827,13 @@ rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, return; } - rfapiGetVncLifetime(bi->attr, &lifetime); + rfapiGetVncLifetime(bpi->attr, &lifetime); vnc_zlog_debug_verbose("%s: VNC lifetime is %u", __func__, lifetime); /* * withdrawn routes get to hang around for a while */ - SET_FLAG(bi->flags, BGP_PATH_REMOVED); + SET_FLAG(bpi->flags, BGP_PATH_REMOVED); /* set timer to remove the route later */ lifetime = rfapiGetHolddownFromLifetime(lifetime); @@ -2842,24 +2846,24 @@ rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, wcb = XCALLOC(MTYPE_RFAPI_WITHDRAW, sizeof(struct rfapi_withdraw)); assert(wcb); wcb->node = rn; - wcb->info = bi; + wcb->info = bpi; wcb->import_table = import_table; - bgp_attr_intern(bi->attr); + bgp_attr_intern(bpi->attr); if (VNC_DEBUG(VERBOSE)) { vnc_zlog_debug_verbose( - "%s: wcb values: node=%p, info=%p, import_table=%p (bi follows)", + "%s: wcb values: node=%p, info=%p, import_table=%p (bpi follows)", __func__, wcb->node, wcb->info, wcb->import_table); - rfapiPrintBi(NULL, bi); + rfapiPrintBi(NULL, bpi); } - assert(bi->extra); + assert(bpi->extra); if (lifetime > UINT32_MAX / 1001) { /* sub-optimal case, but will probably never happen */ - bi->extra->vnc.import.timer = NULL; + bpi->extra->vnc.import.timer = NULL; thread_add_timer(bm->master, timer_service_func, wcb, lifetime, - &bi->extra->vnc.import.timer); + &bpi->extra->vnc.import.timer); } else { static uint32_t jitter; uint32_t lifetime_msec; @@ -2873,16 +2877,16 @@ rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, lifetime_msec = (lifetime * 1000) + jitter; - bi->extra->vnc.import.timer = NULL; + bpi->extra->vnc.import.timer = NULL; thread_add_timer_msec(bm->master, timer_service_func, wcb, lifetime_msec, - &bi->extra->vnc.import.timer); + &bpi->extra->vnc.import.timer); } /* re-sort route list (BGP_PATH_REMOVED routes are last) */ if (((struct bgp_path_info *)rn->info)->next) { - rfapiBgpInfoDetach(rn, bi); - rfapiBgpInfoAttachSorted(rn, bi, afi, safi); + rfapiBgpInfoDetach(rn, bpi); + rfapiBgpInfoAttachSorted(rn, bpi, afi, safi); } } @@ -2895,7 +2899,7 @@ typedef void(rfapi_bi_filtered_import_f)(struct rfapi_import_table *, int, static void rfapiExpireEncapNow(struct rfapi_import_table *it, - struct agg_node *rn, struct bgp_path_info *bi) + struct agg_node *rn, struct bgp_path_info *bpi) { struct rfapi_withdraw *wcb; struct thread t; @@ -2904,7 +2908,7 @@ static void rfapiExpireEncapNow(struct rfapi_import_table *it, * pretend we're an expiring timer */ wcb = XCALLOC(MTYPE_RFAPI_WITHDRAW, sizeof(struct rfapi_withdraw)); - wcb->info = bi; + wcb->info = bpi; wcb->node = rn; wcb->import_table = it; memset(&t, 0, sizeof(t)); @@ -2951,12 +2955,12 @@ static void rfapiBgpInfoFilteredImportEncap( struct agg_table *rt = NULL; struct agg_node *rn; struct bgp_path_info *info_new; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct bgp_path_info *next; char buf[BUFSIZ]; - struct prefix p_firstbi_old; - struct prefix p_firstbi_new; + struct prefix p_firstbpi_old; + struct prefix p_firstbpi_new; int replacing = 0; const char *action_str = NULL; struct prefix un_prefix; @@ -2983,8 +2987,8 @@ static void rfapiBgpInfoFilteredImportEncap( "%s: entry: %s: prefix %s/%d", __func__, action_str, inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); - memset(&p_firstbi_old, 0, sizeof(p_firstbi_old)); - memset(&p_firstbi_new, 0, sizeof(p_firstbi_new)); + memset(&p_firstbpi_old, 0, sizeof(p_firstbpi_old)); + memset(&p_firstbpi_new, 0, sizeof(p_firstbpi_new)); if (action == FIF_ACTION_UPDATE) { /* @@ -3060,37 +3064,37 @@ static void rfapiBgpInfoFilteredImportEncap( /* - * capture nexthop of first bi + * capture nexthop of first bpi */ if (rn->info) { rfapiNexthop2Prefix( ((struct bgp_path_info *)(rn->info))->attr, - &p_firstbi_old); + &p_firstbpi_old); } - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { /* * Does this bgp_path_info refer to the same route * as we are trying to add? */ - vnc_zlog_debug_verbose("%s: comparing BI %p", __func__, - bi); + vnc_zlog_debug_verbose("%s: comparing BPI %p", __func__, + bpi); /* * Compare RDs * - * RD of import table bi is in bi->extra->vnc.import.rd - * RD of info_orig is in prd + * RD of import table bpi is in + * bpi->extra->vnc.import.rd RD of info_orig is in prd */ - if (!bi->extra) { - vnc_zlog_debug_verbose("%s: no bi->extra", + if (!bpi->extra) { + vnc_zlog_debug_verbose("%s: no bpi->extra", __func__); continue; } if (prefix_cmp( - (struct prefix *)&bi->extra->vnc.import.rd, + (struct prefix *)&bpi->extra->vnc.import.rd, (struct prefix *)prd)) { vnc_zlog_debug_verbose("%s: prd does not match", @@ -3101,16 +3105,16 @@ static void rfapiBgpInfoFilteredImportEncap( /* * Compare peers */ - if (bi->peer != peer) { + if (bpi->peer != peer) { vnc_zlog_debug_verbose( "%s: peer does not match", __func__); continue; } - vnc_zlog_debug_verbose("%s: found matching bi", + vnc_zlog_debug_verbose("%s: found matching bpi", __func__); - /* Same route. Delete this bi, replace with new one */ + /* Same route. Delete this bpi, replace with new one */ if (action == FIF_ACTION_WITHDRAW) { @@ -3122,7 +3126,7 @@ static void rfapiBgpInfoFilteredImportEncap( rn->p.prefixlen); rfapiBiStartWithdrawTimer( - import_table, rn, bi, afi, SAFI_ENCAP, + import_table, rn, bpi, afi, SAFI_ENCAP, rfapiWithdrawTimerEncap); } else { @@ -3141,11 +3145,11 @@ static void rfapiBgpInfoFilteredImportEncap( * a previous withdraw, we must cancel its * timer. */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) - && bi->extra->vnc.import.timer) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) + && bpi->extra->vnc.import.timer) { struct thread *t = - (struct thread *)bi->extra->vnc + (struct thread *)bpi->extra->vnc .import.timer; struct rfapi_withdraw *wcb = t->arg; @@ -3154,13 +3158,13 @@ static void rfapiBgpInfoFilteredImportEncap( } if (action == FIF_ACTION_UPDATE) { - rfapiBgpInfoDetach(rn, bi); - rfapiBgpInfoFree(bi); + rfapiBgpInfoDetach(rn, bpi); + rfapiBgpInfoFree(bpi); replacing = 1; } else { /* * Kill: do export stuff when removing - * bi + * bpi */ struct rfapi_withdraw *wcb; struct thread t; @@ -3171,7 +3175,7 @@ static void rfapiBgpInfoFilteredImportEncap( wcb = XCALLOC( MTYPE_RFAPI_WITHDRAW, sizeof(struct rfapi_withdraw)); - wcb->info = bi; + wcb->info = bpi; wcb->node = rn; wcb->import_table = import_table; memset(&t, 0, sizeof(t)); @@ -3196,7 +3200,7 @@ static void rfapiBgpInfoFilteredImportEncap( if (rn) { if (!replacing) - agg_lock_node(rn); /* incr ref count for new BI */ + agg_lock_node(rn); /* incr ref count for new BPI */ } else { rn = agg_node_get(rt, p); } @@ -3212,13 +3216,13 @@ static void rfapiBgpInfoFilteredImportEncap( * Delete holddown routes from same NVE. See details in * rfapiBgpInfoFilteredImportVPN() */ - for (bi = info_new->next; bi; bi = next) { + for (bpi = info_new->next; bpi; bpi = next) { struct prefix pfx_un; int un_match = 0; - next = bi->next; - if (!CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + next = bpi->next; + if (!CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; /* @@ -3226,7 +3230,7 @@ static void rfapiBgpInfoFilteredImportEncap( * of the route node) */ - if (!rfapiGetNexthop(bi->attr, &pfx_un) + if (!rfapiGetNexthop(bpi->attr, &pfx_un) && prefix_same(&pfx_un, &un_prefix)) { un_match = 1; @@ -3236,21 +3240,21 @@ static void rfapiBgpInfoFilteredImportEncap( continue; vnc_zlog_debug_verbose( - "%s: removing holddown bi matching NVE of new route", + "%s: removing holddown bpi matching NVE of new route", __func__); - if (bi->extra->vnc.import.timer) { + if (bpi->extra->vnc.import.timer) { struct thread *t = - (struct thread *)bi->extra->vnc.import.timer; + (struct thread *)bpi->extra->vnc.import.timer; struct rfapi_withdraw *wcb = t->arg; XFREE(MTYPE_RFAPI_WITHDRAW, wcb); thread_cancel(t); } - rfapiExpireEncapNow(import_table, rn, bi); + rfapiExpireEncapNow(import_table, rn, bpi); } rfapiNexthop2Prefix(((struct bgp_path_info *)(rn->info))->attr, - &p_firstbi_new); + &p_firstbpi_new); /* * If the nexthop address of the selected Encap route (i.e., @@ -3258,7 +3262,7 @@ static void rfapiBgpInfoFilteredImportEncap( * routes that refer to this Encap route and possibly force * rfapi callbacks. */ - if (rfapiAttrNexthopAddrDifferent(&p_firstbi_old, &p_firstbi_new)) { + if (rfapiAttrNexthopAddrDifferent(&p_firstbpi_old, &p_firstbpi_new)) { struct rfapi_monitor_encap *m; struct rfapi_monitor_encap *mnext; @@ -3289,19 +3293,19 @@ static void rfapiBgpInfoFilteredImportEncap( for (m = RFAPI_MONITOR_ENCAP(rn); m; m = m->next) { /* - * For each referenced bi/route, copy the ENCAP route's + * For each referenced bpi/route, copy the ENCAP route's * nexthop to the VPN route's cached UN address field * and set * the address family of the cached UN address field. */ - rfapiCopyUnEncap2VPN(info_new, m->bi); - if (!CHECK_FLAG(m->bi->flags, BGP_PATH_VALID)) { - SET_FLAG(m->bi->flags, BGP_PATH_VALID); - if (VALID_INTERIOR_TYPE(m->bi->type)) + rfapiCopyUnEncap2VPN(info_new, m->bpi); + if (!CHECK_FLAG(m->bpi->flags, BGP_PATH_VALID)) { + SET_FLAG(m->bpi->flags, BGP_PATH_VALID); + if (VALID_INTERIOR_TYPE(m->bpi->type)) RFAPI_MONITOR_EXTERIOR(m->node) ->valid_interior_count++; vnc_import_bgp_exterior_add_route_interior( - bgp, import_table, m->node, m->bi); + bgp, import_table, m->node, m->bpi); } /* @@ -3374,7 +3378,7 @@ static void rfapiBgpInfoFilteredImportEncap( } static void rfapiExpireVpnNow(struct rfapi_import_table *it, - struct agg_node *rn, struct bgp_path_info *bi, + struct agg_node *rn, struct bgp_path_info *bpi, int lockoffset) { struct rfapi_withdraw *wcb; @@ -3384,7 +3388,7 @@ static void rfapiExpireVpnNow(struct rfapi_import_table *it, * pretend we're an expiring timer */ wcb = XCALLOC(MTYPE_RFAPI_WITHDRAW, sizeof(struct rfapi_withdraw)); - wcb->info = bi; + wcb->info = bpi; wcb->node = rn; wcb->import_table = it; wcb->lockoffset = lockoffset; @@ -3413,7 +3417,7 @@ void rfapiBgpInfoFilteredImportVPN( struct agg_node *rn; struct agg_node *n; struct bgp_path_info *info_new; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct bgp_path_info *next; char buf[BUFSIZ]; struct prefix vn_prefix; @@ -3529,25 +3533,25 @@ void rfapiBgpInfoFilteredImportVPN( /* * Look for same route (will have same RD and peer) */ - bi = rfapiItBiIndexSearch(rn, prd, peer, aux_prefix); + bpi = rfapiItBiIndexSearch(rn, prd, peer, aux_prefix); - if (bi) { + if (bpi) { /* * This was an old test when we iterated over the - * BIs linearly. Since we're now looking up with + * BPIs linearly. Since we're now looking up with * RD and peer, comparing types should not be * needed. Changed to assertion. * * Compare types. Doing so prevents a RFP-originated * route from matching an imported route, for example. */ - if (VNC_DEBUG(VERBOSE) && bi->type != type) + if (VNC_DEBUG(VERBOSE) && bpi->type != type) /* should be handled by RDs, but warn for now */ - zlog_warn("%s: type mismatch! (bi=%d, arg=%d)", - __func__, bi->type, type); + zlog_warn("%s: type mismatch! (bpi=%d, arg=%d)", + __func__, bpi->type, type); - vnc_zlog_debug_verbose("%s: found matching bi", + vnc_zlog_debug_verbose("%s: found matching bpi", __func__); /* @@ -3555,15 +3559,15 @@ void rfapiBgpInfoFilteredImportVPN( * holddown */ if (import_table == bgp->rfapi->it_ce) { - vnc_direct_bgp_del_route_ce(bgp, rn, bi); + vnc_direct_bgp_del_route_ce(bgp, rn, bpi); if (action == FIF_ACTION_WITHDRAW) action = FIF_ACTION_KILL; } if (action == FIF_ACTION_WITHDRAW) { - int washolddown = - CHECK_FLAG(bi->flags, BGP_PATH_REMOVED); + int washolddown = CHECK_FLAG(bpi->flags, + BGP_PATH_REMOVED); vnc_zlog_debug_verbose( "%s: withdrawing at prefix %s/%d%s", @@ -3578,12 +3582,12 @@ void rfapiBgpInfoFilteredImportVPN( VNC_ITRCCK; if (!washolddown) { rfapiBiStartWithdrawTimer( - import_table, rn, bi, afi, + import_table, rn, bpi, afi, SAFI_MPLS_VPN, rfapiWithdrawTimerVPN); RFAPI_UPDATE_ITABLE_COUNT( - bi, import_table, afi, -1); + bpi, import_table, afi, -1); import_table->holddown_count[afi] += 1; } VNC_ITRCCK; @@ -3604,11 +3608,11 @@ void rfapiBgpInfoFilteredImportVPN( * a previous withdraw, we must cancel its * timer. */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) - && bi->extra->vnc.import.timer) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) + && bpi->extra->vnc.import.timer) { struct thread *t = - (struct thread *)bi->extra->vnc + (struct thread *)bpi->extra->vnc .import.timer; struct rfapi_withdraw *wcb = t->arg; @@ -3617,15 +3621,15 @@ void rfapiBgpInfoFilteredImportVPN( import_table->holddown_count[afi] -= 1; RFAPI_UPDATE_ITABLE_COUNT( - bi, import_table, afi, 1); + bpi, import_table, afi, 1); } /* * decrement remote count (if route is remote) * because * we are going to remove it below */ - RFAPI_UPDATE_ITABLE_COUNT(bi, import_table, afi, - -1); + RFAPI_UPDATE_ITABLE_COUNT(bpi, import_table, + afi, -1); if (action == FIF_ACTION_UPDATE) { replacing = 1; @@ -3633,31 +3637,31 @@ void rfapiBgpInfoFilteredImportVPN( * make copy of original nexthop so we * can see if it changed */ - rfapiGetNexthop(bi->attr, + rfapiGetNexthop(bpi->attr, &original_nexthop); /* - * remove bi without doing any export + * remove bpi without doing any export * processing */ - if (CHECK_FLAG(bi->flags, + if (CHECK_FLAG(bpi->flags, BGP_PATH_VALID) - && VALID_INTERIOR_TYPE(bi->type)) + && VALID_INTERIOR_TYPE(bpi->type)) RFAPI_MONITOR_EXTERIOR(rn) ->valid_interior_count--; - rfapiItBiIndexDel(rn, bi); - rfapiBgpInfoDetach(rn, bi); - rfapiMonitorEncapDelete(bi); + rfapiItBiIndexDel(rn, bpi); + rfapiBgpInfoDetach(rn, bpi); + rfapiMonitorEncapDelete(bpi); vnc_import_bgp_exterior_del_route_interior( - bgp, import_table, rn, bi); - rfapiBgpInfoFree(bi); + bgp, import_table, rn, bpi); + rfapiBgpInfoFree(bpi); } else { /* Kill */ /* - * remove bi and do export processing + * remove bpi and do export processing */ import_table->holddown_count[afi] += 1; - rfapiExpireVpnNow(import_table, rn, bi, + rfapiExpireVpnNow(import_table, rn, bpi, 0); } } @@ -3705,16 +3709,17 @@ void rfapiBgpInfoFilteredImportVPN( /* * For ethernet routes, if there is an accompanying IP address, - * save it in the bi + * save it in the bpi */ if ((AFI_L2VPN == afi) && aux_prefix) { - vnc_zlog_debug_verbose("%s: setting BI's aux_prefix", __func__); + vnc_zlog_debug_verbose("%s: setting BPI's aux_prefix", + __func__); info_new->extra->vnc.import.aux_prefix = *aux_prefix; } vnc_zlog_debug_verbose( - "%s: inserting bi %p at prefix %s/%d #%d", __func__, info_new, + "%s: inserting bpi %p at prefix %s/%d #%d", __func__, info_new, rfapi_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ), rn->p.prefixlen, rn->lock); @@ -3784,40 +3789,40 @@ void rfapiBgpInfoFilteredImportVPN( * by the fresh route). */ /* - * We know that the new bi will have been inserted before any routes + * We know that the new bpi will have been inserted before any routes * in holddown, so we can skip any that came before it */ - for (bi = info_new->next; bi; bi = next) { + for (bpi = info_new->next; bpi; bpi = next) { struct prefix pfx_vn; struct prefix pfx_un; int un_match = 0; int remote_peer_match = 0; - next = bi->next; + next = bpi->next; /* * Must be holddown */ - if (!CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (!CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; /* * Must match VN address (nexthop of VPN route) */ - if (rfapiGetNexthop(bi->attr, &pfx_vn)) + if (rfapiGetNexthop(bpi->attr, &pfx_vn)) continue; if (!prefix_same(&pfx_vn, &vn_prefix)) continue; if (un_prefix_valid && /* new route UN addr */ - !rfapiGetUnAddrOfVpnBi(bi, &pfx_un) + !rfapiGetUnAddrOfVpnBi(bpi, &pfx_un) && /* old route UN addr */ prefix_same(&pfx_un, &un_prefix)) { /* compare */ un_match = 1; } - if (!RFAPI_LOCAL_BI(bi) && !RFAPI_LOCAL_BI(info_new) - && sockunion_same(&bi->peer->su, &info_new->peer->su)) { + if (!RFAPI_LOCAL_BI(bpi) && !RFAPI_LOCAL_BI(info_new) + && sockunion_same(&bpi->peer->su, &info_new->peer->su)) { /* old & new are both remote, same peer */ remote_peer_match = 1; } @@ -3826,17 +3831,17 @@ void rfapiBgpInfoFilteredImportVPN( continue; vnc_zlog_debug_verbose( - "%s: removing holddown bi matching NVE of new route", + "%s: removing holddown bpi matching NVE of new route", __func__); - if (bi->extra->vnc.import.timer) { + if (bpi->extra->vnc.import.timer) { struct thread *t = - (struct thread *)bi->extra->vnc.import.timer; + (struct thread *)bpi->extra->vnc.import.timer; struct rfapi_withdraw *wcb = t->arg; XFREE(MTYPE_RFAPI_WITHDRAW, wcb); thread_cancel(t); } - rfapiExpireVpnNow(import_table, rn, bi, 0); + rfapiExpireVpnNow(import_table, rn, bpi, 0); } if (!original_had_routes) { @@ -4093,22 +4098,22 @@ void rfapiProcessWithdraw(struct peer *peer, void *rfd, struct prefix *p, * routes expiring at the same time due to peer drop. */ /* - * 1. Visit all BIs in all ENCAP import tables. + * 1. Visit all BPIs in all ENCAP import tables. * - * a. If a bi's peer is the failed peer, remove the bi. - * b. If the removed ENCAP bi was first in the list of - * BIs at this ENCAP node, loop over all monitors + * a. If a bpi's peer is the failed peer, remove the bpi. + * b. If the removed ENCAP bpi was first in the list of + * BPIs at this ENCAP node, loop over all monitors * at this node: * * (1) for each ENCAP monitor, loop over all its * VPN node monitors and set their RFAPI_MON_FLAG_NEEDCALLBACK * flags. * - * 2. Visit all BIs in all VPN import tables. - * a. If a bi's peer is the failed peer, remove the bi. + * 2. Visit all BPIs in all VPN import tables. + * a. If a bpi's peer is the failed peer, remove the bpi. * b. loop over all the VPN node monitors and set their * RFAPI_MON_FLAG_NEEDCALLBACK flags - * c. If there are no BIs left at this VPN node, + * c. If there are no BPIs left at this VPN node, * */ @@ -4119,7 +4124,7 @@ static void rfapiProcessPeerDownRt(struct peer *peer, afi_t afi, safi_t safi) { struct agg_node *rn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct agg_table *rt; int (*timer_service_func)(struct thread *); @@ -4142,20 +4147,20 @@ static void rfapiProcessPeerDownRt(struct peer *peer, for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { - for (bi = rn->info; bi; bi = bi->next) { - if (bi->peer == peer) { + for (bpi = rn->info; bpi; bpi = bpi->next) { + if (bpi->peer == peer) { - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { /* already in holddown, skip */ continue; } if (safi == SAFI_MPLS_VPN) { RFAPI_UPDATE_ITABLE_COUNT( - bi, import_table, afi, -1); + bpi, import_table, afi, -1); import_table->holddown_count[afi] += 1; } - rfapiBiStartWithdrawTimer(import_table, rn, bi, + rfapiBiStartWithdrawTimer(import_table, rn, bpi, afi, safi, timer_service_func); } @@ -4187,11 +4192,11 @@ void rfapiProcessPeerDown(struct peer *peer) return; /* - * 1. Visit all BIs in all ENCAP import tables. - * Start withdraw timer on the BIs that match peer. + * 1. Visit all BPIs in all ENCAP import tables. + * Start withdraw timer on the BPIs that match peer. * - * 2. Visit All BIs in all VPN import tables. - * Start withdraw timer on the BIs that match peer. + * 2. Visit All BPIs in all VPN import tables. + * Start withdraw timer on the BPIs that match peer. */ bgp = bgp_get_default(); /* assume 1 instance for now */ @@ -4243,27 +4248,27 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp, for (rn2 = bgp_table_top(rn1->info); rn2; rn2 = bgp_route_next(rn2)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; - for (bi = rn2->info; bi; bi = bi->next) { + for (bpi = rn2->info; bpi; bpi = bpi->next) { uint32_t label = 0; - if (CHECK_FLAG(bi->flags, + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; - if (bi->extra) + if (bpi->extra) label = decode_label( - &bi->extra->label[0]); + &bpi->extra->label[0]); (*rfapiBgpInfoFilteredImportFunction( safi))( it, /* which import table */ - FIF_ACTION_UPDATE, bi->peer, + FIF_ACTION_UPDATE, bpi->peer, NULL, &rn2->p, /* prefix */ NULL, afi, (struct prefix_rd *)&rn1->p, - bi->attr, bi->type, - bi->sub_type, &label); + bpi->attr, bpi->type, + bpi->sub_type, &label); } } } @@ -4477,7 +4482,7 @@ static void rfapiDeleteRemotePrefixesIt( afi); for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct bgp_path_info *next; if (VNC_DEBUG(IMPORT_DEL_REMOTE)) { @@ -4504,8 +4509,8 @@ static void rfapiDeleteRemotePrefixesIt( /* TBD is this valid for afi == AFI_L2VPN? */ RFAPI_CHECK_REFCOUNT(rn, SAFI_MPLS_VPN, 1); - for (bi = rn->info; bi; bi = next) { - next = bi->next; + for (bpi = rn->info; bpi; bpi = next) { + next = bpi->next; struct prefix qpt; struct prefix qct; @@ -4513,11 +4518,11 @@ static void rfapiDeleteRemotePrefixesIt( int qct_valid = 0; int is_active = 0; - vnc_zlog_debug_verbose("%s: examining bi %p", - __func__, bi); + vnc_zlog_debug_verbose("%s: examining bpi %p", + __func__, bpi); - if (bi->attr) { - if (!rfapiGetNexthop(bi->attr, &qpt)) + if (bpi->attr) { + if (!rfapiGetNexthop(bpi->attr, &qpt)) qpt_valid = 1; } if (vn) { @@ -4532,7 +4537,7 @@ static void rfapiDeleteRemotePrefixesIt( } } - if (!rfapiGetUnAddrOfVpnBi(bi, &qct)) + if (!rfapiGetUnAddrOfVpnBi(bpi, &qct)) qct_valid = 1; if (un) { @@ -4549,7 +4554,7 @@ static void rfapiDeleteRemotePrefixesIt( /* - * Blow bi away + * Blow bpi away */ /* * If this route is waiting to be deleted @@ -4557,13 +4562,13 @@ static void rfapiDeleteRemotePrefixesIt( * a previous withdraw, we must cancel its * timer. */ - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { if (!delete_holddown) continue; - if (bi->extra->vnc.import.timer) { + if (bpi->extra->vnc.import.timer) { struct thread *t = - (struct thread *)bi + (struct thread *)bpi ->extra->vnc .import.timer; struct rfapi_withdraw *wcb = @@ -4573,7 +4578,7 @@ static void rfapiDeleteRemotePrefixesIt( ->holddown_count[afi] -= 1; RFAPI_UPDATE_ITABLE_COUNT( - bi, wcb->import_table, + bpi, wcb->import_table, afi, 1); XFREE(MTYPE_RFAPI_WITHDRAW, wcb); @@ -4586,8 +4591,8 @@ static void rfapiDeleteRemotePrefixesIt( } vnc_zlog_debug_verbose( - "%s: deleting bi %p (qct_valid=%d, qpt_valid=%d, delete_holddown=%d, delete_active=%d)", - __func__, bi, qct_valid, qpt_valid, + "%s: deleting bpi %p (qct_valid=%d, qpt_valid=%d, delete_holddown=%d, delete_active=%d)", + __func__, bpi, qct_valid, qpt_valid, delete_holddown, delete_active); @@ -4633,11 +4638,11 @@ static void rfapiDeleteRemotePrefixesIt( } vnc_direct_bgp_rh_del_route(bgp, afi, &rn->p, - bi->peer); + bpi->peer); - RFAPI_UPDATE_ITABLE_COUNT(bi, it, afi, -1); + RFAPI_UPDATE_ITABLE_COUNT(bpi, it, afi, -1); it->holddown_count[afi] += 1; - rfapiExpireVpnNow(it, rn, bi, 1); + rfapiExpireVpnNow(it, rn, bpi, 1); vnc_zlog_debug_verbose( "%s: incrementing count (is_active=%d)", diff --git a/bgpd/rfapi/rfapi_import.h b/bgpd/rfapi/rfapi_import.h index 69e623e30e..1ab9cc5193 100644 --- a/bgpd/rfapi/rfapi_import.h +++ b/bgpd/rfapi/rfapi_import.h @@ -51,18 +51,18 @@ struct rfapi_import_table { int imported_count[AFI_MAX]; }; -#define RFAPI_LOCAL_BI(bi) \ - (((bi)->type == ZEBRA_ROUTE_BGP) && ((bi)->sub_type == BGP_ROUTE_RFP)) +#define RFAPI_LOCAL_BI(bpi) \ + (((bpi)->type == ZEBRA_ROUTE_BGP) && ((bpi)->sub_type == BGP_ROUTE_RFP)) -#define RFAPI_DIRECT_IMPORT_BI(bi) \ - (((bi)->type == ZEBRA_ROUTE_BGP_DIRECT) \ - || ((bi)->type == ZEBRA_ROUTE_BGP_DIRECT_EXT)) +#define RFAPI_DIRECT_IMPORT_BI(bpi) \ + (((bpi)->type == ZEBRA_ROUTE_BGP_DIRECT) \ + || ((bpi)->type == ZEBRA_ROUTE_BGP_DIRECT_EXT)) -#define RFAPI_UPDATE_ITABLE_COUNT(bi, itable, afi, cnt) \ - if (RFAPI_LOCAL_BI(bi)) { \ +#define RFAPI_UPDATE_ITABLE_COUNT(bpi, itable, afi, cnt) \ + if (RFAPI_LOCAL_BI(bpi)) { \ (itable)->local_count[(afi)] += (cnt); \ } else { \ - if (RFAPI_DIRECT_IMPORT_BI(bi)) \ + if (RFAPI_DIRECT_IMPORT_BI(bpi)) \ (itable)->imported_count[(afi)] += (cnt); \ else \ (itable)->remote_count[(afi)] += (cnt); \ @@ -75,9 +75,9 @@ extern void rfapiDebugBacktrace(void); extern void rfapiCheckRouteCount(void); /* - * Print BI in an Import Table + * Print BPI in an Import Table */ -extern void rfapiPrintBi(void *stream, struct bgp_path_info *bi); +extern void rfapiPrintBi(void *stream, struct bgp_path_info *bpi); extern void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt, int isvpn); @@ -128,7 +128,7 @@ extern int rfapiHasNonRemovedRoutes(struct agg_node *rn); extern int rfapiProcessDeferredClose(struct thread *t); -extern int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bi, struct prefix *p); +extern int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bpi, struct prefix *p); extern void rfapiNexthop2Prefix(struct attr *attr, struct prefix *p); diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index 846a63f4fa..dc1f7e0fbb 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -226,7 +226,7 @@ void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn) agg_unlock_node(rn); } if (hie->u.vpn.idx_rd) { - /* looping through bi->extra->vnc.import.rd is tbd */ + /* looping through bpi->extra->vnc.import.rd is tbd */ while (!skiplist_delete_first(hie->u.vpn.idx_rd)) { agg_unlock_node(rn); } @@ -346,16 +346,16 @@ struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, for (rn = agg_node_match(rfd->import_table->imported_vpn[afi], p); rn;) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct prefix pfx_dummy; /* TBD update this code to use new valid_interior_count */ - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { /* * If there is a cached ENCAP UN address, it's a usable * VPN route */ - if (bi->extra && bi->extra->vnc.import.un_family) { + if (bpi->extra && bpi->extra->vnc.import.un_family) { break; } @@ -364,11 +364,11 @@ struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, * address, * it's a usable VPN route. */ - if (!rfapiGetVncTunnelUnAddr(bi->attr, &pfx_dummy)) { + if (!rfapiGetVncTunnelUnAddr(bpi->attr, &pfx_dummy)) { break; } } - if (bi) + if (bpi) break; agg_unlock_node(rn); diff --git a/bgpd/rfapi/rfapi_monitor.h b/bgpd/rfapi/rfapi_monitor.h index 117bed347b..b8eec56475 100644 --- a/bgpd/rfapi/rfapi_monitor.h +++ b/bgpd/rfapi/rfapi_monitor.h @@ -45,7 +45,7 @@ struct rfapi_monitor_encap { struct rfapi_monitor_encap *next; struct rfapi_monitor_encap *prev; struct agg_node *node; /* VPN node */ - struct bgp_path_info *bi; /* VPN bi */ + struct bgp_path_info *bpi; /* VPN bpi */ struct agg_node *rn; /* parent node */ }; @@ -83,7 +83,7 @@ struct rfapi_it_extra { * Encap TLV */ int valid_interior_count; - /* unicast exterior routes, key=bi, + /* unicast exterior routes, key=bpi, * val=allocated prefix */ struct skiplist *source; } e; diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index b0f71fde5c..520cc141c0 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -618,16 +618,16 @@ void rfapiRibFree(struct rfapi_descriptor *rfd) /* * Copies struct bgp_path_info to struct rfapi_info, except for rk fields and un */ -static void rfapiRibBi2Ri(struct bgp_path_info *bi, struct rfapi_info *ri, +static void rfapiRibBi2Ri(struct bgp_path_info *bpi, struct rfapi_info *ri, uint32_t lifetime) { struct bgp_attr_encap_subtlv *pEncap; - ri->cost = rfapiRfpCost(bi->attr); + ri->cost = rfapiRfpCost(bpi->attr); ri->lifetime = lifetime; /* This loop based on rfapiRouteInfo2NextHopEntry() */ - for (pEncap = bi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { + for (pEncap = bpi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { struct bgp_tea_options *hop; switch (pEncap->type) { @@ -665,13 +665,13 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bi, struct rfapi_info *ri, } rfapi_un_options_free(ri->un_options); /* maybe free old version */ - ri->un_options = rfapi_encap_tlv_to_un_option(bi->attr); + ri->un_options = rfapi_encap_tlv_to_un_option(bpi->attr); /* * VN options */ - if (bi->extra - && decode_rd_type(bi->extra->vnc.import.rd.val) + if (bpi->extra + && decode_rd_type(bpi->extra->vnc.import.rd.val) == RD_TYPE_VNC_ETH) { /* ethernet route */ @@ -683,21 +683,21 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bi, struct rfapi_info *ri, vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR; - /* copy from RD already stored in bi, so we don't need it_node + /* copy from RD already stored in bpi, so we don't need it_node */ - memcpy(&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val + 2, + memcpy(&vo->v.l2addr.macaddr, bpi->extra->vnc.import.rd.val + 2, ETH_ALEN); - (void)rfapiEcommunityGetLNI(bi->attr->ecommunity, + (void)rfapiEcommunityGetLNI(bpi->attr->ecommunity, &vo->v.l2addr.logical_net_id); - (void)rfapiEcommunityGetEthernetTag(bi->attr->ecommunity, + (void)rfapiEcommunityGetEthernetTag(bpi->attr->ecommunity, &vo->v.l2addr.tag_id); /* local_nve_id comes from RD */ - vo->v.l2addr.local_nve_id = bi->extra->vnc.import.rd.val[1]; + vo->v.l2addr.local_nve_id = bpi->extra->vnc.import.rd.val[1]; /* label comes from MP_REACH_NLRI label */ - vo->v.l2addr.label = decode_label(&bi->extra->label[0]); + vo->v.l2addr.label = decode_label(&bpi->extra->label[0]); rfapi_vn_options_free( ri->vn_options); /* maybe free old version */ @@ -707,8 +707,8 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bi, struct rfapi_info *ri, /* * If there is an auxiliary IP address (L2 can have it), copy it */ - if (bi->extra && bi->extra->vnc.import.aux_prefix.family) { - ri->rk.aux_prefix = bi->extra->vnc.import.aux_prefix; + if (bpi->extra && bpi->extra->vnc.import.aux_prefix.family) { + ri->rk.aux_prefix = bpi->extra->vnc.import.aux_prefix; } } @@ -733,7 +733,7 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bi, struct rfapi_info *ri, int rfapiRibPreloadBi( struct agg_node *rfd_rib_node, /* NULL = don't preload or filter */ struct prefix *pfx_vn, struct prefix *pfx_un, uint32_t lifetime, - struct bgp_path_info *bi) + struct bgp_path_info *bpi) { struct rfapi_descriptor *rfd; struct skiplist *slRibPt = NULL; @@ -751,13 +751,13 @@ int rfapiRibPreloadBi( memset((void *)&rk, 0, sizeof(rk)); rk.vn = *pfx_vn; - rk.rd = bi->extra->vnc.import.rd; + rk.rd = bpi->extra->vnc.import.rd; /* * If there is an auxiliary IP address (L2 can have it), copy it */ - if (bi->extra->vnc.import.aux_prefix.family) { - rk.aux_prefix = bi->extra->vnc.import.aux_prefix; + if (bpi->extra->vnc.import.aux_prefix.family) { + rk.aux_prefix = bpi->extra->vnc.import.aux_prefix; } /* @@ -774,13 +774,13 @@ int rfapiRibPreloadBi( /* found: update contents of existing route in RIB */ ori->un = *pfx_un; - rfapiRibBi2Ri(bi, ori, lifetime); + rfapiRibBi2Ri(bpi, ori, lifetime); } else { /* not found: add new route to RIB */ ori = rfapi_info_new(); ori->rk = rk; ori->un = *pfx_un; - rfapiRibBi2Ri(bi, ori, lifetime); + rfapiRibBi2Ri(bpi, ori, lifetime); if (!slRibPt) { slRibPt = skiplist_new(0, rfapi_rib_key_cmp, NULL); @@ -1590,7 +1590,7 @@ void rfapiRibUpdatePendingNode( struct agg_node *it_node, uint32_t lifetime) { struct prefix *prefix; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct agg_node *pn; afi_t afi; uint32_t queued_flag; @@ -1640,25 +1640,25 @@ void rfapiRibUpdatePendingNode( } /* - * The BIs in the import table are already sorted by cost + * The BPIs in the import table are already sorted by cost */ - for (bi = it_node->info; bi; bi = bi->next) { + for (bpi = it_node->info; bpi; bpi = bpi->next) { struct rfapi_info *ri; struct prefix pfx_nh; - if (!bi->attr) { + if (!bpi->attr) { /* shouldn't happen */ /* TBD increment error stats counter */ continue; } - if (!bi->extra) { + if (!bpi->extra) { /* shouldn't happen */ /* TBD increment error stats counter */ continue; } - rfapiNexthop2Prefix(bi->attr, &pfx_nh); + rfapiNexthop2Prefix(bpi->attr, &pfx_nh); /* * Omit route if nexthop is self @@ -1675,15 +1675,15 @@ void rfapiRibUpdatePendingNode( ri = rfapi_info_new(); ri->rk.vn = pfx_nh; - ri->rk.rd = bi->extra->vnc.import.rd; + ri->rk.rd = bpi->extra->vnc.import.rd; /* * If there is an auxiliary IP address (L2 can have it), copy it */ - if (bi->extra->vnc.import.aux_prefix.family) { - ri->rk.aux_prefix = bi->extra->vnc.import.aux_prefix; + if (bpi->extra->vnc.import.aux_prefix.family) { + ri->rk.aux_prefix = bpi->extra->vnc.import.aux_prefix; } - if (rfapiGetUnAddrOfVpnBi(bi, &ri->un)) { + if (rfapiGetUnAddrOfVpnBi(bpi, &ri->un)) { rfapi_info_free(ri); continue; } @@ -1711,7 +1711,7 @@ void rfapiRibUpdatePendingNode( continue; } - rfapiRibBi2Ri(bi, ri, lifetime); + rfapiRibBi2Ri(bpi, ri, lifetime); if (!pn->info) { pn->info = list_new(); diff --git a/bgpd/rfapi/rfapi_rib.h b/bgpd/rfapi/rfapi_rib.h index 3ee9d447e6..38a6df9fbf 100644 --- a/bgpd/rfapi/rfapi_rib.h +++ b/bgpd/rfapi/rfapi_rib.h @@ -105,7 +105,7 @@ extern void rfapiRibUpdatePendingNodeSubtree(struct bgp *bgp, extern int rfapiRibPreloadBi(struct agg_node *rfd_rib_node, struct prefix *pfx_vn, struct prefix *pfx_un, - uint32_t lifetime, struct bgp_path_info *bi); + uint32_t lifetime, struct bgp_path_info *bpi); extern struct rfapi_next_hop_entry * rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 62ca4cd29b..cdf281f240 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -394,7 +394,7 @@ int rfapiStream2Vty(void *stream, /* input */ /* called from bgpd/bgp_vty.c'route_vty_out() */ void rfapi_vty_out_vncinfo(struct vty *vty, struct prefix *p, - struct bgp_path_info *bi, safi_t safi) + struct bgp_path_info *bpi, safi_t safi) { char *s; uint32_t lifetime; @@ -410,7 +410,7 @@ void rfapi_vty_out_vncinfo(struct vty *vty, struct prefix *p, if (safi == SAFI_MPLS_VPN) { struct prefix pfx_un; - if (!rfapiGetVncTunnelUnAddr(bi->attr, &pfx_un)) { + if (!rfapiGetVncTunnelUnAddr(bpi->attr, &pfx_un)) { char buf[BUFSIZ]; vty_out(vty, "UN=%s", inet_ntop(pfx_un.family, pfx_un.u.val, buf, @@ -418,27 +418,27 @@ void rfapi_vty_out_vncinfo(struct vty *vty, struct prefix *p, } } - if (bi->attr && bi->attr->ecommunity) { - s = ecommunity_ecom2str(bi->attr->ecommunity, + if (bpi->attr && bpi->attr->ecommunity) { + s = ecommunity_ecom2str(bpi->attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); vty_out(vty, " EC{%s}", s); XFREE(MTYPE_ECOMMUNITY_STR, s); } - if (bi->extra != NULL) { - if (bi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) + if (bpi->extra != NULL) { + if (bpi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) vty_out(vty, " label=VRF2VRF"); else vty_out(vty, " label=%u", - decode_label(&bi->extra->label[0])); + decode_label(&bpi->extra->label[0])); } - if (!rfapiGetVncLifetime(bi->attr, &lifetime)) { + if (!rfapiGetVncLifetime(bpi->attr, &lifetime)) { vty_out(vty, " life=%d", lifetime); } - vty_out(vty, " type=%s, subtype=%d", zebra_route_string(bi->type), - bi->sub_type); + vty_out(vty, " type=%s, subtype=%d", zebra_route_string(bpi->type), + bpi->sub_type); vty_out(vty, "%s", HVTYNL); } @@ -477,9 +477,9 @@ void rfapiPrintAttrPtrs(void *stream, struct attr *attr) } /* - * Print BI in an Import Table + * Print BPI in an Import Table */ -void rfapiPrintBi(void *stream, struct bgp_path_info *bi) +void rfapiPrintBi(void *stream, struct bgp_path_info *bpi) { char buf[BUFSIZ]; char *s; @@ -503,12 +503,13 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0) return; - if (!bi) + if (!bpi) return; - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) && bi->extra - && bi->extra->vnc.import.timer) { - struct thread *t = (struct thread *)bi->extra->vnc.import.timer; + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) && bpi->extra + && bpi->extra->vnc.import.timer) { + struct thread *t = + (struct thread *)bpi->extra->vnc.import.timer; r = snprintf(p, REMAIN, " [%4lu] ", thread_timer_remain_second(t)); INCP; @@ -518,14 +519,14 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) INCP; } - if (bi->extra) { + if (bpi->extra) { /* TBD This valid only for SAFI_MPLS_VPN, but not for encap */ - if (decode_rd_type(bi->extra->vnc.import.rd.val) + if (decode_rd_type(bpi->extra->vnc.import.rd.val) == RD_TYPE_VNC_ETH) { has_macaddr = 1; - memcpy(macaddr.octet, bi->extra->vnc.import.rd.val + 2, + memcpy(macaddr.octet, bpi->extra->vnc.import.rd.val + 2, 6); - l2hid = bi->extra->vnc.import.rd.val[1]; + l2hid = bpi->extra->vnc.import.rd.val[1]; } } @@ -537,24 +538,24 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) * RFP option sizes (they are opaque values) * extended communities (RTs) */ - if (bi->attr) { + if (bpi->attr) { uint32_t lifetime; int printed_1st_gol = 0; struct bgp_attr_encap_subtlv *pEncap; struct prefix pfx_un; - int af = BGP_MP_NEXTHOP_FAMILY(bi->attr->mp_nexthop_len); + int af = BGP_MP_NEXTHOP_FAMILY(bpi->attr->mp_nexthop_len); /* Nexthop */ if (af == AF_INET) { r = snprintf(p, REMAIN, "%s", inet_ntop(AF_INET, - &bi->attr->mp_nexthop_global_in, + &bpi->attr->mp_nexthop_global_in, buf, BUFSIZ)); INCP; } else if (af == AF_INET6) { r = snprintf(p, REMAIN, "%s", inet_ntop(AF_INET6, - &bi->attr->mp_nexthop_global, + &bpi->attr->mp_nexthop_global, buf, BUFSIZ)); INCP; } else { @@ -565,7 +566,7 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) /* * VNC tunnel subtlv, if present, contains UN address */ - if (!rfapiGetVncTunnelUnAddr(bi->attr, &pfx_un)) { + if (!rfapiGetVncTunnelUnAddr(bpi->attr, &pfx_un)) { r = snprintf(p, REMAIN, " un=%s", inet_ntop(pfx_un.family, pfx_un.u.val, buf, BUFSIZ)); @@ -573,7 +574,7 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) } /* Lifetime */ - if (rfapiGetVncLifetime(bi->attr, &lifetime)) { + if (rfapiGetVncLifetime(bpi->attr, &lifetime)) { r = snprintf(p, REMAIN, " nolife"); INCP; } else { @@ -585,7 +586,7 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) } /* RFP option lengths */ - for (pEncap = bi->attr->vnc_subtlvs; pEncap; + for (pEncap = bpi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { if (pEncap->type == BGP_VNC_SUBTLV_TYPE_RFPOPTION) { @@ -604,8 +605,8 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) } /* RT list */ - if (bi->attr->ecommunity) { - s = ecommunity_ecom2str(bi->attr->ecommunity, + if (bpi->attr->ecommunity) { + s = ecommunity_ecom2str(bpi->attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); r = snprintf(p, REMAIN, " %s", s); INCP; @@ -613,13 +614,13 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) } } - r = snprintf(p, REMAIN, " bi@%p", bi); + r = snprintf(p, REMAIN, " bpi@%p", bpi); INCP; - r = snprintf(p, REMAIN, " p@%p", bi->peer); + r = snprintf(p, REMAIN, " p@%p", bpi->peer); INCP; - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { r = snprintf(p, REMAIN, " HD=yes"); INCP; } else { @@ -627,15 +628,16 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) INCP; } - if (bi->attr) { + if (bpi->attr) { - if (bi->attr->weight) { - r = snprintf(p, REMAIN, " W=%d", bi->attr->weight); + if (bpi->attr->weight) { + r = snprintf(p, REMAIN, " W=%d", bpi->attr->weight); INCP; } - if (bi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) { - r = snprintf(p, REMAIN, " LP=%d", bi->attr->local_pref); + if (bpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) { + r = snprintf(p, REMAIN, " LP=%d", + bpi->attr->local_pref); INCP; } else { r = snprintf(p, REMAIN, " LP=unset"); @@ -643,8 +645,8 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) } } - r = snprintf(p, REMAIN, " %c:%u", zebra_route_char(bi->type), - bi->sub_type); + r = snprintf(p, REMAIN, " %c:%u", zebra_route_char(bpi->type), + bpi->sub_type); INCP; fp(out, "%s%s", line, HVTYNL); @@ -656,7 +658,7 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) HVTYNL); } - if (!rfapiGetL2o(bi->attr, &l2o_buf)) { + if (!rfapiGetL2o(bpi->attr, &l2o_buf)) { fp(out, " L2O ETH=%02x:%02x:%02x:%02x:%02x:%02x LBL=%d LNI=%d LHI=%hhu%s", l2o_buf.macaddr.octet[0], l2o_buf.macaddr.octet[1], @@ -665,12 +667,12 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) l2o_buf.label, l2o_buf.logical_net_id, l2o_buf.local_nve_id, HVTYNL); } - if (bi->extra && bi->extra->vnc.import.aux_prefix.family) { + if (bpi->extra && bpi->extra->vnc.import.aux_prefix.family) { const char *sp; - sp = rfapi_ntop(bi->extra->vnc.import.aux_prefix.family, - &bi->extra->vnc.import.aux_prefix.u.prefix, buf, - BUFSIZ); + sp = rfapi_ntop(bpi->extra->vnc.import.aux_prefix.family, + &bpi->extra->vnc.import.aux_prefix.u.prefix, + buf, BUFSIZ); buf[BUFSIZ - 1] = 0; if (sp) { fp(out, " IP: %s%s", sp, HVTYNL); @@ -678,7 +680,7 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bi) } { struct rfapi_un_option *uo = - rfapi_encap_tlv_to_un_option(bi->attr); + rfapi_encap_tlv_to_un_option(bpi->attr); if (uo) { rfapi_print_tunneltype_option(stream, 8, &uo->v.tunnel); rfapi_un_options_free(uo); @@ -734,13 +736,13 @@ static void rfapiDebugPrintMonitorEncap(void *stream, if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0) return; - fp(out, " Mon m=%p, next=%p, node=%p, bi=%p%s", m, m->next, m->node, - m->bi, HVTYNL); + fp(out, " Mon m=%p, next=%p, node=%p, bpi=%p%s", m, m->next, m->node, + m->bpi, HVTYNL); } void rfapiShowItNode(void *stream, struct agg_node *rn) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; char buf[BUFSIZ]; int (*fp)(void *, const char *, ...); @@ -755,8 +757,8 @@ void rfapiShowItNode(void *stream, struct agg_node *rn) rfapi_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ), rn->p.prefixlen, rn, rn->lock, HVTYNL); - for (bi = rn->info; bi; bi = bi->next) { - rfapiPrintBi(stream, bi); + for (bpi = rn->info; bpi; bpi = bpi->next) { + rfapiPrintBi(stream, bpi); } /* doesn't show montors */ @@ -779,7 +781,7 @@ void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt, fp(out, "Import Table [%s]%s", label, HVTYNL); for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; if (rn->p.family == AF_ETHERNET) { rfapiEthAddr2Str(&rn->p.u.prefix_eth, buf, BUFSIZ); @@ -791,8 +793,8 @@ void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt, rn->lock - 1, /* account for loop iterator locking */ HVTYNL); - for (bi = rn->info; bi; bi = bi->next) { - rfapiPrintBi(stream, bi); + for (bpi = rn->info; bpi; bpi = bpi->next) { + rfapiPrintBi(stream, bpi); } if (isvpn) { @@ -1008,7 +1010,7 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) } static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, - struct agg_node *rn, struct bgp_path_info *bi) + struct agg_node *rn, struct bgp_path_info *bpi) { int (*fp)(void *, const char *, ...); struct vty *vty; @@ -1047,26 +1049,26 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, * UN addr */ buf_un[0] = 0; - if (!rfapiGetUnAddrOfVpnBi(bi, &pfx_un)) { + if (!rfapiGetUnAddrOfVpnBi(bpi, &pfx_un)) { snprintf(buf_un, BUFSIZ, "%s", inet_ntop(pfx_un.family, &pfx_un.u.prefix, buf_ntop, BUFSIZ)); } - rfapiGetTunnelType(bi->attr, &tun_type); + rfapiGetTunnelType(bpi->attr, &tun_type); /* * VN addr */ buf_vn[0] = 0; - rfapiNexthop2Prefix(bi->attr, &pfx_vn); + rfapiNexthop2Prefix(bpi->attr, &pfx_vn); if (tun_type == BGP_ENCAP_TYPE_MPLS) { /* MPLS carries un in nrli next hop (same as vn for IP tunnels) */ snprintf(buf_un, BUFSIZ, "%s", inet_ntop(pfx_vn.family, &pfx_vn.u.prefix, buf_ntop, BUFSIZ)); - if (bi->extra) { - uint32_t l = decode_label(&bi->extra->label[0]); + if (bpi->extra) { + uint32_t l = decode_label(&bpi->extra->label[0]); snprintf(buf_vn, BUFSIZ, "Label: %d", l); } else /* should never happen */ { @@ -1085,10 +1087,10 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, * See rfapi_import.c'rfapiRouteInfo2NextHopEntry() for conversion * back to cost. */ - if (bi->attr) { + if (bpi->attr) { uint32_t local_pref; - if (bi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) - local_pref = bi->attr->local_pref; + if (bpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) + local_pref = bpi->attr->local_pref; else local_pref = 0; cost = (local_pref > 255) ? 0 : 255 - local_pref; @@ -1103,7 +1105,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, /* Lifetime */ /* NB rfapiGetVncLifetime sets infinite value when returning !0 */ - if (rfapiGetVncLifetime(bi->attr, &lifetime) + if (rfapiGetVncLifetime(bpi->attr, &lifetime) || (lifetime == RFAPI_INFINITE_LIFETIME)) { fp(out, "%-10s ", "infinite"); @@ -1113,14 +1115,15 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, fp(out, "%-10s ", buf_lifetime); } - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED) && bi->extra - && bi->extra->vnc.import.timer) { + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) && bpi->extra + && bpi->extra->vnc.import.timer) { uint32_t remaining; time_t age; char buf_age[BUFSIZ]; - struct thread *t = (struct thread *)bi->extra->vnc.import.timer; + struct thread *t = + (struct thread *)bpi->extra->vnc.import.timer; remaining = thread_timer_remain_second(t); #if RFAPI_REGISTRATIONS_REPORT_AGE @@ -1140,12 +1143,12 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, fp(out, "%-10s ", buf_age); - } else if (RFAPI_LOCAL_BI(bi)) { + } else if (RFAPI_LOCAL_BI(bpi)) { char buf_age[BUFSIZ]; - if (bi->extra && bi->extra->vnc.import.create_time) { - rfapiFormatAge(bi->extra->vnc.import.create_time, + if (bpi->extra && bpi->extra->vnc.import.create_time) { + rfapiFormatAge(bpi->extra->vnc.import.create_time, buf_age, BUFSIZ); } else { buf_age[0] = '?'; @@ -1161,12 +1164,12 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, * print that on the next line */ - if (bi->extra && bi->extra->vnc.import.aux_prefix.family) { + if (bpi->extra && bpi->extra->vnc.import.aux_prefix.family) { const char *sp; sp = rfapi_ntop( - bi->extra->vnc.import.aux_prefix.family, - &bi->extra->vnc.import.aux_prefix.u.prefix, + bpi->extra->vnc.import.aux_prefix.family, + &bpi->extra->vnc.import.aux_prefix.u.prefix, buf_ntop, BUFSIZ); buf_ntop[BUFSIZ - 1] = 0; @@ -1177,8 +1180,8 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, } } } - if (tun_type != BGP_ENCAP_TYPE_MPLS && bi->extra) { - uint32_t l = decode_label(&bi->extra->label[0]); + if (tun_type != BGP_ENCAP_TYPE_MPLS && bpi->extra) { + uint32_t l = decode_label(&bpi->extra->label[0]); if (!MPLS_LABEL_IS_NULL(l)) { fp(out, " Label: %d", l); if (nlines == 1) @@ -1222,7 +1225,7 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, for (rn = agg_route_top(it->imported_vpn[afi]); rn; rn = agg_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; int count_only; /* allow for wider or more narrow mask from user */ @@ -1232,30 +1235,32 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, else count_only = 0; - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { - if (!show_local && RFAPI_LOCAL_BI(bi)) { + if (!show_local && RFAPI_LOCAL_BI(bpi)) { /* local route from RFP */ continue; } - if (!show_remote && !RFAPI_LOCAL_BI(bi)) { + if (!show_remote && !RFAPI_LOCAL_BI(bpi)) { /* remote route */ continue; } if (show_expiring - && !CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + && !CHECK_FLAG(bpi->flags, + BGP_PATH_REMOVED)) continue; if (!show_expiring - && CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + && CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; - if (bi->type == ZEBRA_ROUTE_BGP_DIRECT - || bi->type == ZEBRA_ROUTE_BGP_DIRECT_EXT) { + if (bpi->type == ZEBRA_ROUTE_BGP_DIRECT + || bpi->type + == ZEBRA_ROUTE_BGP_DIRECT_EXT) { if (!show_imported) continue; } else { @@ -1277,7 +1282,7 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, type = "Holddown"; } else { if (RFAPI_LOCAL_BI( - bi)) { + bpi)) { type = "Local"; } else { type = "Remote"; @@ -1327,7 +1332,7 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, "Lifetime", agetype, HVTYNL); } printed += rfapiPrintRemoteRegBi(bgp, stream, - rn, bi); + rn, bpi); } } } @@ -1535,7 +1540,7 @@ void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd, { afi_t afi; /* of the VN address */ struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; uint8_t type = ZEBRA_ROUTE_BGP; struct bgp *bgp; int printed = 0; @@ -1565,12 +1570,12 @@ void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd, vty_out(vty, " bn=%p%s", bn, HVTYNL); - for (bi = bn->info; bi; bi = bi->next) { - if (bi->peer == rfd->peer && bi->type == type - && bi->sub_type == BGP_ROUTE_RFP && bi->extra - && bi->extra->vnc.export.rfapi_handle == (void *)rfd) { + for (bpi = bn->info; bpi; bpi = bpi->next) { + if (bpi->peer == rfd->peer && bpi->type == type + && bpi->sub_type == BGP_ROUTE_RFP && bpi->extra + && bpi->extra->vnc.export.rfapi_handle == (void *)rfd) { - rfapiPrintBi(vty, bi); + rfapiPrintBi(vty, bpi); printed = 1; } } diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index 0c46419f3f..3d010e25f8 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -173,14 +173,14 @@ static int getce(struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce) void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, - struct bgp_path_info *bi) + struct bgp_path_info *bpi) { - struct attr *attr = bi->attr; - struct peer *peer = bi->peer; + struct attr *attr = bpi->attr; + struct peer *peer = bpi->peer; struct prefix *prefix = &rn->p; afi_t afi = family2afi(prefix->family); struct bgp_node *urn; - struct bgp_path_info *ubi; + struct bgp_path_info *ubpi; struct attr hattr; struct attr *iattr; struct prefix ce_nexthop; @@ -193,10 +193,10 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, return; } - if ((bi->type != ZEBRA_ROUTE_BGP) - || (bi->sub_type != BGP_ROUTE_NORMAL - && bi->sub_type != BGP_ROUTE_RFP - && bi->sub_type != BGP_ROUTE_STATIC)) { + if ((bpi->type != ZEBRA_ROUTE_BGP) + || (bpi->sub_type != BGP_ROUTE_NORMAL + && bpi->sub_type != BGP_ROUTE_RFP + && bpi->sub_type != BGP_ROUTE_STATIC)) { vnc_zlog_debug_verbose( "%s: wrong route type/sub_type for export, skipping", @@ -256,17 +256,17 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, */ urn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, prefix, NULL); - for (ubi = urn->info; ubi; ubi = ubi->next) { + for (ubpi = urn->info; ubpi; ubpi = ubpi->next) { struct prefix unicast_nexthop; - if (CHECK_FLAG(ubi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(ubpi->flags, BGP_PATH_REMOVED)) continue; - rfapiUnicastNexthop2Prefix(afi, ubi->attr, &unicast_nexthop); + rfapiUnicastNexthop2Prefix(afi, ubpi->attr, &unicast_nexthop); - if (ubi->type == ZEBRA_ROUTE_VNC_DIRECT - && ubi->sub_type == BGP_ROUTE_REDISTRIBUTE - && ubi->peer == peer + if (ubpi->type == ZEBRA_ROUTE_VNC_DIRECT + && ubpi->sub_type == BGP_ROUTE_REDISTRIBUTE + && ubpi->peer == peer && prefix_same(&unicast_nexthop, &ce_nexthop)) { vnc_zlog_debug_verbose( @@ -328,10 +328,10 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, * "Withdrawing a Route" export process */ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, - struct bgp_path_info *bi) + struct bgp_path_info *bpi) { afi_t afi = family2afi(rn->p.family); - struct bgp_path_info *vbi; + struct bgp_path_info *vbpi; struct prefix ce_nexthop; if (!afi) { @@ -364,7 +364,7 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, * This works only for IPv4 because IPv6 addresses are too big * to fit in an extended community */ - if (getce(bgp, bi->attr, &ce_nexthop)) { + if (getce(bgp, bpi->attr, &ce_nexthop)) { vnc_zlog_debug_verbose("%s: EC has no encoded CE, skipping", __func__); return; @@ -376,13 +376,13 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, * route from the unicast RIB */ - for (vbi = rn->info; vbi; vbi = vbi->next) { + for (vbpi = rn->info; vbpi; vbpi = vbpi->next) { struct prefix ce; - if (bi == vbi) + if (bpi == vbpi) continue; - if (bi->peer != vbi->peer) + if (bpi->peer != vbpi->peer) continue; - if (getce(bgp, vbi->attr, &ce)) + if (getce(bgp, vbpi->attr, &ce)) continue; if (prefix_same(&ce, &ce_nexthop)) { vnc_zlog_debug_verbose( @@ -395,8 +395,8 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, /* * withdraw the route */ - bgp_withdraw(bi->peer, &rn->p, 0, /* addpath_id */ - NULL, /* attr, ignored */ + bgp_withdraw(bpi->peer, &rn->p, 0, /* addpath_id */ + NULL, /* attr, ignored */ afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ NULL, 0, NULL); /* tag not used for unicast */ @@ -516,24 +516,24 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi) static struct ecommunity *vnc_route_origin_ecom(struct agg_node *rn) { struct ecommunity *new; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; if (!rn->info) return NULL; new = ecommunity_new(); - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { struct ecommunity_val roec; - switch (BGP_MP_NEXTHOP_FAMILY(bi->attr->mp_nexthop_len)) { + switch (BGP_MP_NEXTHOP_FAMILY(bpi->attr->mp_nexthop_len)) { case AF_INET: memset(&roec, 0, sizeof(roec)); roec.val[0] = 0x01; roec.val[1] = 0x03; memcpy(roec.val + 2, - &bi->attr->mp_nexthop_global_in.s_addr, 4); + &bpi->attr->mp_nexthop_global_in.s_addr, 4); roec.val[6] = 0; roec.val[7] = 0; ecommunity_add_val(new, &roec); @@ -1629,7 +1629,7 @@ void vnc_direct_bgp_vpn_disable(struct bgp *bgp, afi_t afi) /* * "Adding a Route" export process - * TBD do we need to check bi->type and bi->sub_type here, or does + * TBD do we need to check bpi->type and bpi->sub_type here, or does * caller do it? */ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi, @@ -1753,7 +1753,7 @@ static int vncExportWithdrawTimer(struct thread *t) /* * "Withdrawing a Route" export process - * TBD do we need to check bi->type and bi->sub_type here, or does + * TBD do we need to check bpi->type and bpi->sub_type here, or does * caller do it? */ void vnc_direct_bgp_rh_del_route(struct bgp *bgp, afi_t afi, diff --git a/bgpd/rfapi/vnc_export_bgp_p.h b/bgpd/rfapi/vnc_export_bgp_p.h index 3d66f93c9b..a1cb972740 100644 --- a/bgpd/rfapi/vnc_export_bgp_p.h +++ b/bgpd/rfapi/vnc_export_bgp_p.h @@ -30,10 +30,10 @@ #include "rfapi_private.h" extern void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, - struct bgp_path_info *bi); + struct bgp_path_info *bpi); extern void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, - struct bgp_path_info *bi); + struct bgp_path_info *bpi); extern void vnc_direct_bgp_add_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index a8de537fea..2f634f6f40 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -122,7 +122,7 @@ static int is_host_prefix(struct prefix *p) struct prefix_bag { struct prefix hpfx; /* ce address = unicast nexthop */ struct prefix upfx; /* unicast prefix */ - struct bgp_path_info *ubi; /* unicast route */ + struct bgp_path_info *ubpi; /* unicast route */ }; static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, @@ -217,8 +217,8 @@ static void print_rhn_list(const char *tag1, const char *tag2) prefix2str(&pb->upfx, ubuf, sizeof(ubuf)); vnc_zlog_debug_verbose( - "RHN Entry %d (q=%p): kpfx=%s, upfx=%s, hpfx=%s, ubi=%p", - ++count, p, kbuf, ubuf, hbuf, pb->ubi); + "RHN Entry %d (q=%p): kpfx=%s, upfx=%s, hpfx=%s, ubpi=%p", + ++count, p, kbuf, ubuf, hbuf, pb->ubpi); } } #endif @@ -253,10 +253,10 @@ static void vnc_rhnck(char *tag) afi = family2afi(pb->upfx.family); - rfapiUnicastNexthop2Prefix(afi, pb->ubi->attr, + rfapiUnicastNexthop2Prefix(afi, pb->ubpi->attr, &pfx_orig_nexthop); - /* pb->hpfx, pb->ubi nexthop, pkey should all reflect the same + /* pb->hpfx, pb->ubpi nexthop, pkey should all reflect the same * pfx */ assert(!vnc_prefix_cmp(&pb->hpfx, pkey)); if (vnc_prefix_cmp(&pb->hpfx, &pfx_orig_nexthop)) { @@ -267,7 +267,7 @@ static void vnc_rhnck(char *tag) prefix2str(&pb->hpfx, str_nve_pfx, sizeof(str_nve_pfx)); vnc_zlog_debug_verbose( - "%s: %s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s", + "%s: %s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s", __func__, tag, str_onh, str_nve_pfx); assert(0); } @@ -422,8 +422,8 @@ static int process_unicast_route(struct bgp *bgp, /* in */ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( - struct bgp *bgp, afi_t afi, struct bgp_path_info *bi, /* VPN bi */ - struct prefix_rd *prd, /* RD */ + struct bgp *bgp, afi_t afi, struct bgp_path_info *bpi, /* VPN bpi */ + struct prefix_rd *prd, /* RD */ struct prefix *prefix, /* unicast route prefix */ uint32_t *local_pref, /* NULL = no local_pref */ uint32_t *med, /* NULL = no med */ @@ -443,20 +443,22 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( vnc_zlog_debug_verbose("%s: entry", __func__); - if (bi->type != ZEBRA_ROUTE_BGP && bi->type != ZEBRA_ROUTE_BGP_DIRECT) { + if (bpi->type != ZEBRA_ROUTE_BGP + && bpi->type != ZEBRA_ROUTE_BGP_DIRECT) { return; } - if (bi->sub_type != BGP_ROUTE_NORMAL && bi->sub_type != BGP_ROUTE_STATIC - && bi->sub_type != BGP_ROUTE_RFP) { + if (bpi->sub_type != BGP_ROUTE_NORMAL + && bpi->sub_type != BGP_ROUTE_STATIC + && bpi->sub_type != BGP_ROUTE_RFP) { return; } - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) return; - vncHDResolveNve.peer = bi->peer; - if (!rfapiGetVncTunnelUnAddr(bi->attr, &un)) { + vncHDResolveNve.peer = bpi->peer; + if (!rfapiGetVncTunnelUnAddr(bpi->attr, &un)) { if (rfapiQprefix2Raddr(&un, &vncHDResolveNve.un_addr)) return; } else { @@ -465,26 +467,26 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( } /* Use nexthop of VPN route as nexthop of constructed route */ - rfapiNexthop2Prefix(bi->attr, &nexthop); + rfapiNexthop2Prefix(bpi->attr, &nexthop); rfapiQprefix2Raddr(&nexthop, &nexthop_h); - if (rfapiGetVncLifetime(bi->attr, &lifetime)) { + if (rfapiGetVncLifetime(bpi->attr, &lifetime)) { plifetime = NULL; } else { plifetime = &lifetime; } - if (bi->attr) { - encaptlvs = bi->attr->vnc_subtlvs; - if (bi->attr->encap_tunneltype != BGP_ENCAP_TYPE_RESERVED - && bi->attr->encap_tunneltype != BGP_ENCAP_TYPE_MPLS) { + if (bpi->attr) { + encaptlvs = bpi->attr->vnc_subtlvs; + if (bpi->attr->encap_tunneltype != BGP_ENCAP_TYPE_RESERVED + && bpi->attr->encap_tunneltype != BGP_ENCAP_TYPE_MPLS) { if (opt != NULL) opt->next = &optary[cur_opt]; opt = &optary[cur_opt++]; memset(opt, 0, sizeof(struct rfapi_un_option)); opt->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE; - opt->v.tunnel.type = bi->attr->encap_tunneltype; - /* TBD parse bi->attr->extra->encap_subtlvs */ + opt->v.tunnel.type = bpi->attr->encap_tunneltype; + /* TBD parse bpi->attr->extra->encap_subtlvs */ } } else { encaptlvs = NULL; @@ -492,11 +494,11 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( struct ecommunity *new_ecom = ecommunity_dup(ecom); - if (bi->attr && bi->attr->ecommunity) - ecommunity_merge(new_ecom, bi->attr->ecommunity); + if (bpi->attr && bpi->attr->ecommunity) + ecommunity_merge(new_ecom, bpi->attr->ecommunity); - if (bi->extra) - label = decode_label(&bi->extra->label[0]); + if (bpi->extra) + label = decode_label(&bpi->extra->label[0]); add_vnc_route(&vncHDResolveNve, bgp, SAFI_MPLS_VPN, prefix, /* unicast route prefix */ @@ -516,12 +518,12 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd( struct bgp_table *table_rd, /* per-rd VPN route table */ afi_t afi, struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ struct ecommunity *ecom, /* generated ecoms */ - uint32_t *local_pref, /* NULL = no local_pref */ - uint32_t *med, /* NULL = no med */ - struct prefix *ubi_nexthop) /* unicast nexthop */ + uint32_t *local_pref, /* NULL = no local_pref */ + uint32_t *med, /* NULL = no med */ + struct prefix *ubpi_nexthop) /* unicast nexthop */ { struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; if (!table_rd) return; @@ -529,24 +531,25 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd( { char str_nh[PREFIX_STRLEN]; - prefix2str(ubi_nexthop, str_nh, sizeof(str_nh)); + prefix2str(ubpi_nexthop, str_nh, sizeof(str_nh)); - vnc_zlog_debug_verbose("%s: ubi_nexthop=%s", __func__, str_nh); + vnc_zlog_debug_verbose("%s: ubpi_nexthop=%s", __func__, str_nh); } /* exact match */ - bn = bgp_node_lookup(table_rd, ubi_nexthop); + bn = bgp_node_lookup(table_rd, ubpi_nexthop); if (!bn) { vnc_zlog_debug_verbose( - "%s: no match in RD's table for ubi_nexthop", __func__); + "%s: no match in RD's table for ubpi_nexthop", + __func__); return; } /* Iterate over bgp_path_info items at this node */ - for (bi = bn->info; bi; bi = bi->next) { + for (bpi = bn->info; bpi; bpi = bpi->next) { vnc_import_bgp_add_route_mode_resolve_nve_one_bi( - bgp, afi, bi, /* VPN bi */ + bgp, afi, bpi, /* VPN bpi */ prd, prefix, local_pref, med, ecom); } @@ -657,7 +660,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve( pb = XCALLOC(MTYPE_RFAPI_PREFIX_BAG, sizeof(struct prefix_bag)); pb->hpfx = pfx_unicast_nexthop; - pb->ubi = info; + pb->ubpi = info; pb->upfx = *prefix; bgp_path_info_lock(info); /* skiplist refers to it */ @@ -1238,26 +1241,28 @@ static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp, } static void vnc_import_bgp_del_route_mode_resolve_nve_one_bi( - struct bgp *bgp, afi_t afi, struct bgp_path_info *bi, /* VPN bi */ - struct prefix_rd *prd, /* RD */ + struct bgp *bgp, afi_t afi, struct bgp_path_info *bpi, /* VPN bpi */ + struct prefix_rd *prd, /* RD */ struct prefix *prefix) /* unicast route prefix */ { struct prefix un; - if (bi->type != ZEBRA_ROUTE_BGP && bi->type != ZEBRA_ROUTE_BGP_DIRECT) { + if (bpi->type != ZEBRA_ROUTE_BGP + && bpi->type != ZEBRA_ROUTE_BGP_DIRECT) { return; } - if (bi->sub_type != BGP_ROUTE_NORMAL && bi->sub_type != BGP_ROUTE_STATIC - && bi->sub_type != BGP_ROUTE_RFP) { + if (bpi->sub_type != BGP_ROUTE_NORMAL + && bpi->sub_type != BGP_ROUTE_STATIC + && bpi->sub_type != BGP_ROUTE_RFP) { return; } - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) return; - vncHDResolveNve.peer = bi->peer; - if (!rfapiGetVncTunnelUnAddr(bi->attr, &un)) { + vncHDResolveNve.peer = bpi->peer; + if (!rfapiGetVncTunnelUnAddr(bpi->attr, &un)) { if (rfapiQprefix2Raddr(&un, &vncHDResolveNve.un_addr)) return; } else { @@ -1275,10 +1280,10 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd( struct prefix_rd *prd, struct bgp_table *table_rd, /* per-rd VPN route table */ afi_t afi, struct bgp *bgp, struct prefix *prefix, /* unicast prefix */ - struct prefix *ubi_nexthop) /* unicast bi's nexthop */ + struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */ { struct bgp_node *bn; - struct bgp_path_info *bi; + struct bgp_path_info *bpi; if (!table_rd) return; @@ -1286,26 +1291,27 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd( { char str_nh[PREFIX_STRLEN]; - prefix2str(ubi_nexthop, str_nh, sizeof(str_nh)); - vnc_zlog_debug_verbose("%s: ubi_nexthop=%s", __func__, str_nh); + prefix2str(ubpi_nexthop, str_nh, sizeof(str_nh)); + vnc_zlog_debug_verbose("%s: ubpi_nexthop=%s", __func__, str_nh); } /* exact match */ - bn = bgp_node_lookup(table_rd, ubi_nexthop); + bn = bgp_node_lookup(table_rd, ubpi_nexthop); if (!bn) { vnc_zlog_debug_verbose( - "%s: no match in RD's table for ubi_nexthop", __func__); + "%s: no match in RD's table for ubpi_nexthop", + __func__); return; } /* Iterate over bgp_path_info items at this node */ - for (bi = bn->info; bi; bi = bi->next) { + for (bpi = bn->info; bpi; bpi = bpi->next) { vnc_import_bgp_del_route_mode_resolve_nve_one_bi( - bgp, afi, bi, /* VPN bi */ - prd, /* VPN RD */ - prefix); /* unicast route prefix */ + bgp, afi, bpi, /* VPN bpi */ + prd, /* VPN RD */ + prefix); /* unicast route prefix */ } bgp_unlock_node(bn); @@ -1352,7 +1358,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi, rc = skiplist_first_value(sl, &pfx_unicast_nexthop, (void *)&pb, &cursor); while (!rc) { - if (pb->ubi == info) { + if (pb->ubpi == info) { skiplist_delete(sl, &pfx_unicast_nexthop, pb); bgp_path_info_unlock(info); break; @@ -1391,14 +1397,14 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi, ***********************************************************************/ /* - * Should be called whan a bi is added to VPN RIB. This function + * Should be called whan a bpi is added to VPN RIB. This function * will check if it is a host route and return immediately if not. */ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ struct prefix *prefix, /* VPN prefix */ - struct bgp_path_info *bi) /* new VPN host route */ + struct bgp_path_info *bpi) /* new VPN host route */ { afi_t afi = family2afi(prefix->family); struct skiplist *sl = NULL; @@ -1469,11 +1475,11 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( prefix2str(&pb->upfx, ubuf, sizeof(ubuf)); vnc_zlog_debug_any( - "%s: examining RHN Entry (q=%p): upfx=%s, hpfx=%s, ubi=%p", - __func__, cursor, ubuf, hbuf, pb->ubi); + "%s: examining RHN Entry (q=%p): upfx=%s, hpfx=%s, ubpi=%p", + __func__, cursor, ubuf, hbuf, pb->ubpi); } - if (process_unicast_route(bgp, afi, &pb->upfx, pb->ubi, &ecom, + if (process_unicast_route(bgp, afi, &pb->upfx, pb->ubpi, &ecom, &pfx_unicast_nexthop)) { vnc_zlog_debug_verbose( @@ -1481,13 +1487,13 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( __func__); continue; } - local_pref = calc_local_pref(pb->ubi->attr, pb->ubi->peer); + local_pref = calc_local_pref(pb->ubpi->attr, pb->ubpi->peer); - if (pb->ubi->attr - && (pb->ubi->attr->flag + if (pb->ubpi->attr + && (pb->ubpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))) { - med = &pb->ubi->attr->med; + med = &pb->ubpi->attr->med; } /* @@ -1502,13 +1508,13 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx)); vnc_zlog_debug_verbose( - "%s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s", + "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s", __func__, str_unh, str_nve_pfx); assert(0); } vnc_import_bgp_add_route_mode_resolve_nve_one_bi( - bgp, afi, bi, /* VPN bi */ + bgp, afi, bpi, /* VPN bpi */ prd, &pb->upfx, /* unicast prefix */ &local_pref, med, ecom); @@ -1538,7 +1544,7 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ struct prefix *prefix, /* VPN prefix */ - struct bgp_path_info *bi) /* old VPN host route */ + struct bgp_path_info *bpi) /* old VPN host route */ { afi_t afi = family2afi(prefix->family); struct skiplist *sl = NULL; @@ -1605,7 +1611,7 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( memset(&pfx_unicast_nexthop, 0, sizeof(struct prefix)); /* keep valgrind happy */ - if (process_unicast_route(bgp, afi, &pb->upfx, pb->ubi, &ecom, + if (process_unicast_route(bgp, afi, &pb->upfx, pb->ubpi, &ecom, &pfx_unicast_nexthop)) { vnc_zlog_debug_verbose( @@ -1626,13 +1632,13 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx)); vnc_zlog_debug_verbose( - "%s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s", + "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s", __func__, str_unh, str_nve_pfx); assert(0); } vnc_import_bgp_del_route_mode_resolve_nve_one_bi( - bgp, afi, bi, prd, &pb->upfx); + bgp, afi, bpi, prd, &pb->upfx); if (ecom) ecommunity_free(&ecom); @@ -1648,17 +1654,17 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( #define DEBUG_IS_USABLE_INTERIOR 1 -static int is_usable_interior_route(struct bgp_path_info *bi_interior) +static int is_usable_interior_route(struct bgp_path_info *bpi_interior) { - if (!VALID_INTERIOR_TYPE(bi_interior->type)) { + if (!VALID_INTERIOR_TYPE(bpi_interior->type)) { #if DEBUG_IS_USABLE_INTERIOR vnc_zlog_debug_verbose( "%s: NO: type %d is not valid interior type", __func__, - bi_interior->type); + bpi_interior->type); #endif return 0; } - if (!CHECK_FLAG(bi_interior->flags, BGP_PATH_VALID)) { + if (!CHECK_FLAG(bpi_interior->flags, BGP_PATH_VALID)) { #if DEBUG_IS_USABLE_INTERIOR vnc_zlog_debug_verbose("%s: NO: BGP_PATH_VALID not set", __func__); @@ -1740,7 +1746,7 @@ static void vnc_import_bgp_exterior_add_route_it( struct agg_table *table; struct agg_node *rn; struct agg_node *par; - struct bgp_path_info *bi_interior; + struct bgp_path_info *bpi_interior; int have_usable_route; vnc_zlog_debug_verbose("%s: doing it %p", __func__, it); @@ -1760,18 +1766,18 @@ static void vnc_import_bgp_exterior_add_route_it( vnc_zlog_debug_verbose("%s: it %p trying rn %p", __func__, it, rn); - for (bi_interior = rn->info; bi_interior; - bi_interior = bi_interior->next) { + for (bpi_interior = rn->info; bpi_interior; + bpi_interior = bpi_interior->next) { struct prefix_rd *prd; struct attr new_attr; uint32_t label = 0; - if (!is_usable_interior_route(bi_interior)) + if (!is_usable_interior_route(bpi_interior)) continue; vnc_zlog_debug_verbose( - "%s: usable: bi_interior %p", __func__, - bi_interior); + "%s: usable: bpi_interior %p", __func__, + bpi_interior); /* * have a legitimate route to exterior's nexthop @@ -1781,17 +1787,17 @@ static void vnc_import_bgp_exterior_add_route_it( */ have_usable_route = 1; - if (bi_interior->extra) { - prd = &bi_interior->extra->vnc.import + if (bpi_interior->extra) { + prd = &bpi_interior->extra->vnc.import .rd; label = decode_label( - &bi_interior->extra->label[0]); + &bpi_interior->extra->label[0]); } else prd = NULL; /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); - bgp_attr_dup(&new_attr, bi_interior->attr); + bgp_attr_dup(&new_attr, bpi_interior->attr); if (info->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) { new_attr.local_pref = @@ -1802,7 +1808,7 @@ static void vnc_import_bgp_exterior_add_route_it( rfapiBgpInfoFilteredImportVPN( it, FIF_ACTION_UPDATE, - bi_interior->peer, NULL, /* rfd */ + bpi_interior->peer, NULL, /* rfd */ prefix, NULL, afi, prd, &new_attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); @@ -1931,7 +1937,7 @@ void vnc_import_bgp_exterior_del_route( struct agg_table *table; struct agg_node *rn; struct agg_node *par; - struct bgp_path_info *bi_interior; + struct bgp_path_info *bpi_interior; int have_usable_route; table = it->imported_vpn[afi]; @@ -1940,12 +1946,12 @@ void vnc_import_bgp_exterior_del_route( have_usable_route = 0; (!have_usable_route) && rn;) { - for (bi_interior = rn->info; bi_interior; - bi_interior = bi_interior->next) { + for (bpi_interior = rn->info; bpi_interior; + bpi_interior = bpi_interior->next) { struct prefix_rd *prd; uint32_t label = 0; - if (!is_usable_interior_route(bi_interior)) + if (!is_usable_interior_route(bpi_interior)) continue; /* @@ -1956,19 +1962,19 @@ void vnc_import_bgp_exterior_del_route( */ have_usable_route = 1; - if (bi_interior->extra) { - prd = &bi_interior->extra->vnc.import + if (bpi_interior->extra) { + prd = &bpi_interior->extra->vnc.import .rd; label = decode_label( - &bi_interior->extra->label[0]); + &bpi_interior->extra->label[0]); } else prd = NULL; rfapiBgpInfoFilteredImportVPN( - it, FIF_ACTION_KILL, bi_interior->peer, + it, FIF_ACTION_KILL, bpi_interior->peer, NULL, /* rfd */ prefix, NULL, afi, prd, - bi_interior->attr, + bpi_interior->attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); @@ -2039,12 +2045,12 @@ void vnc_import_bgp_exterior_del_route( */ void vnc_import_bgp_exterior_add_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct agg_node *rn_interior, /* VPN IT node */ - struct bgp_path_info *bi_interior) /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_path_info *bpi_interior) /* VPN IT route */ { afi_t afi = family2afi(rn_interior->p.family); struct agg_node *par; - struct bgp_path_info *bi_exterior; + struct bgp_path_info *bpi_exterior; struct prefix *pfx_exterior; /* exterior pfx */ void *cursor; int rc; @@ -2052,7 +2058,7 @@ void vnc_import_bgp_exterior_add_route_interior( vnc_zlog_debug_verbose("%s: entry", __func__); - if (!is_usable_interior_route(bi_interior)) { + if (!is_usable_interior_route(bpi_interior)) { vnc_zlog_debug_verbose( "%s: not usable interior route, skipping", __func__); return; @@ -2076,8 +2082,8 @@ void vnc_import_bgp_exterior_add_route_interior( char str_pfx[PREFIX_STRLEN]; prefix2str(&rn_interior->p, str_pfx, sizeof(str_pfx)); - vnc_zlog_debug_verbose("%s: interior prefix=%s, bi type=%d", - __func__, str_pfx, bi_interior->type); + vnc_zlog_debug_verbose("%s: interior prefix=%s, bpi type=%d", + __func__, str_pfx, bpi_interior->type); } if (RFAPI_HAS_MONITOR_EXTERIOR(rn_interior)) { @@ -2096,12 +2102,12 @@ void vnc_import_bgp_exterior_add_route_interior( cursor = NULL; for (rc = skiplist_next( RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, (void **)&pfx_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor); !rc; rc = skiplist_next( RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, (void **)&pfx_exterior, - &cursor)) { + (void **)&bpi_exterior, + (void **)&pfx_exterior, &cursor)) { struct prefix_rd *prd; struct attr new_attr; @@ -2110,30 +2116,30 @@ void vnc_import_bgp_exterior_add_route_interior( ++count; /* debugging */ - assert(bi_exterior); + assert(bpi_exterior); assert(pfx_exterior); - if (bi_interior->extra) { - prd = &bi_interior->extra->vnc.import.rd; + if (bpi_interior->extra) { + prd = &bpi_interior->extra->vnc.import.rd; label = decode_label( - &bi_interior->extra->label[0]); + &bpi_interior->extra->label[0]); } else prd = NULL; /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); - bgp_attr_dup(&new_attr, bi_interior->attr); - if (bi_exterior - && (bi_exterior->attr->flag + bgp_attr_dup(&new_attr, bpi_interior->attr); + if (bpi_exterior + && (bpi_exterior->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) { new_attr.local_pref = - bi_exterior->attr->local_pref; + bpi_exterior->attr->local_pref; new_attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); } rfapiBgpInfoFilteredImportVPN( - it, FIF_ACTION_UPDATE, bi_interior->peer, + it, FIF_ACTION_UPDATE, bpi_interior->peer, NULL, /* rfd */ pfx_exterior, NULL, afi, prd, &new_attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, @@ -2177,11 +2183,11 @@ void vnc_import_bgp_exterior_add_route_interior( /* check monitors at par for possible pulldown */ cursor = NULL; for (rc = skiplist_next(RFAPI_MONITOR_EXTERIOR(par)->source, - (void **)&bi_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor); !rc; rc = skiplist_next(RFAPI_MONITOR_EXTERIOR(par)->source, - (void **)&bi_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor)) { struct prefix pfx_nexthop; @@ -2190,12 +2196,12 @@ void vnc_import_bgp_exterior_add_route_interior( sizeof(struct prefix)); /* keep valgrind happy */ /* check original nexthop for prefix match */ - rfapiUnicastNexthop2Prefix(afi, bi_exterior->attr, + rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr, &pfx_nexthop); if (prefix_match(&rn_interior->p, &pfx_nexthop)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; struct prefix_rd *prd; struct attr new_attr; uint32_t label = 0; @@ -2218,27 +2224,28 @@ void vnc_import_bgp_exterior_add_route_interior( skiplist_insert( RFAPI_MONITOR_EXTERIOR(rn_interior) ->source, - bi_exterior, pfx_mon); + bpi_exterior, pfx_mon); agg_lock_node(rn_interior); /* * Delete constructed exterior routes based on * parent routes. */ - for (bi = par->info; bi; bi = bi->next) { + for (bpi = par->info; bpi; bpi = bpi->next) { - if (bi->extra) { - prd = &bi->extra->vnc.import.rd; + if (bpi->extra) { + prd = &bpi->extra->vnc.import + .rd; label = decode_label( - &bi->extra->label[0]); + &bpi->extra->label[0]); } else prd = NULL; rfapiBgpInfoFilteredImportVPN( - it, FIF_ACTION_KILL, bi->peer, + it, FIF_ACTION_KILL, bpi->peer, NULL, /* rfd */ pfx_exterior, NULL, afi, prd, - bi->attr, + bpi->attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); } @@ -2248,29 +2255,29 @@ void vnc_import_bgp_exterior_add_route_interior( * Add constructed exterior routes based on * the new interior route at longer prefix. */ - if (bi_interior->extra) { - prd = &bi_interior->extra->vnc.import + if (bpi_interior->extra) { + prd = &bpi_interior->extra->vnc.import .rd; label = decode_label( - &bi_interior->extra->label[0]); + &bpi_interior->extra->label[0]); } else prd = NULL; /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); - bgp_attr_dup(&new_attr, bi_interior->attr); - if (bi_exterior - && (bi_exterior->attr->flag + bgp_attr_dup(&new_attr, bpi_interior->attr); + if (bpi_exterior + && (bpi_exterior->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) { new_attr.local_pref = - bi_exterior->attr->local_pref; + bpi_exterior->attr->local_pref; new_attr.flag |= ATTR_FLAG_BIT( BGP_ATTR_LOCAL_PREF); } rfapiBgpInfoFilteredImportVPN( it, FIF_ACTION_UPDATE, - bi_interior->peer, NULL, /* rfd */ + bpi_interior->peer, NULL, /* rfd */ pfx_exterior, NULL, afi, prd, &new_attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); @@ -2285,14 +2292,14 @@ void vnc_import_bgp_exterior_add_route_interior( cursor = NULL; for (rc = skiplist_next( RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, NULL, &cursor); + (void **)&bpi_exterior, NULL, &cursor); !rc; rc = skiplist_next( RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, NULL, &cursor)) { + (void **)&bpi_exterior, NULL, &cursor)) { skiplist_delete(RFAPI_MONITOR_EXTERIOR(par)->source, - bi_exterior, NULL); + bpi_exterior, NULL); agg_unlock_node(par); /* sl entry */ } if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(par)->source)) { @@ -2310,10 +2317,10 @@ void vnc_import_bgp_exterior_add_route_interior( cursor = NULL; list_adopted = NULL; for (rc = skiplist_next(it->monitor_exterior_orphans, - (void **)&bi_exterior, (void **)&pfx_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor); !rc; rc = skiplist_next(it->monitor_exterior_orphans, - (void **)&bi_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor)) { struct prefix pfx_nexthop; @@ -2333,7 +2340,7 @@ void vnc_import_bgp_exterior_add_route_interior( } /* check original nexthop for prefix match */ - rfapiUnicastNexthop2Prefix(afi, bi_exterior->attr, + rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr, &pfx_nexthop); if (prefix_match(&rn_interior->p, &pfx_nexthop)) { @@ -2359,38 +2366,38 @@ void vnc_import_bgp_exterior_add_route_interior( } skiplist_insert( RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - bi_exterior, pfx_mon); + bpi_exterior, pfx_mon); agg_lock_node(rn_interior); /* sl entry */ if (!list_adopted) { list_adopted = list_new(); } - listnode_add(list_adopted, bi_exterior); + listnode_add(list_adopted, bpi_exterior); /* * Add constructed exterior routes based on the * new interior route at the longer prefix. */ - if (bi_interior->extra) { - prd = &bi_interior->extra->vnc.import.rd; + if (bpi_interior->extra) { + prd = &bpi_interior->extra->vnc.import.rd; label = decode_label( - &bi_interior->extra->label[0]); + &bpi_interior->extra->label[0]); } else prd = NULL; /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); - bgp_attr_dup(&new_attr, bi_interior->attr); - if (bi_exterior - && (bi_exterior->attr->flag + bgp_attr_dup(&new_attr, bpi_interior->attr); + if (bpi_exterior + && (bpi_exterior->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) { new_attr.local_pref = - bi_exterior->attr->local_pref; + bpi_exterior->attr->local_pref; new_attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); } rfapiBgpInfoFilteredImportVPN( - it, FIF_ACTION_UPDATE, bi_interior->peer, + it, FIF_ACTION_UPDATE, bpi_interior->peer, NULL, /* rfd */ pfx_exterior, NULL, afi, prd, &new_attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, @@ -2399,11 +2406,12 @@ void vnc_import_bgp_exterior_add_route_interior( } if (list_adopted) { struct listnode *node; - struct agg_node *an_bi_exterior; + struct agg_node *an_bpi_exterior; - for (ALL_LIST_ELEMENTS_RO(list_adopted, node, an_bi_exterior)) { + for (ALL_LIST_ELEMENTS_RO(list_adopted, node, + an_bpi_exterior)) { skiplist_delete(it->monitor_exterior_orphans, - an_bi_exterior, NULL); + an_bpi_exterior, NULL); } list_delete(&list_adopted); } @@ -2412,7 +2420,7 @@ void vnc_import_bgp_exterior_add_route_interior( /* * This function should be called after an interior VPN route * has been deleted from an import_table. - * bi_interior must still be valid, but it must already be detached + * bpi_interior must still be valid, but it must already be detached * from its route node and the route node's valid_interior_count * must already be decremented. * @@ -2421,20 +2429,20 @@ void vnc_import_bgp_exterior_add_route_interior( */ void vnc_import_bgp_exterior_del_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct agg_node *rn_interior, /* VPN IT node */ - struct bgp_path_info *bi_interior) /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_path_info *bpi_interior) /* VPN IT route */ { afi_t afi = family2afi(rn_interior->p.family); struct agg_node *par; - struct bgp_path_info *bi_exterior; + struct bgp_path_info *bpi_exterior; struct prefix *pfx_exterior; /* exterior pfx */ void *cursor; int rc; - if (!VALID_INTERIOR_TYPE(bi_interior->type)) { + if (!VALID_INTERIOR_TYPE(bpi_interior->type)) { vnc_zlog_debug_verbose( "%s: type %d not valid interior type, skipping", - __func__, bi_interior->type); + __func__, bpi_interior->type); return; } @@ -2463,8 +2471,8 @@ void vnc_import_bgp_exterior_del_route_interior( prefix2str(&rn_interior->p, str_pfx, sizeof(str_pfx)); - vnc_zlog_debug_verbose("%s: interior prefix=%s, bi type=%d", - __func__, str_pfx, bi_interior->type); + vnc_zlog_debug_verbose("%s: interior prefix=%s, bpi type=%d", + __func__, str_pfx, bpi_interior->type); } /* @@ -2472,25 +2480,25 @@ void vnc_import_bgp_exterior_del_route_interior( */ cursor = NULL; for (rc = skiplist_next(RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, (void **)&pfx_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor); !rc; rc = skiplist_next(RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, (void **)&pfx_exterior, + (void **)&bpi_exterior, (void **)&pfx_exterior, &cursor)) { struct prefix_rd *prd; uint32_t label = 0; - if (bi_interior->extra) { - prd = &bi_interior->extra->vnc.import.rd; - label = decode_label(&bi_interior->extra->label[0]); + if (bpi_interior->extra) { + prd = &bpi_interior->extra->vnc.import.rd; + label = decode_label(&bpi_interior->extra->label[0]); } else prd = NULL; rfapiBgpInfoFilteredImportVPN( - it, FIF_ACTION_KILL, bi_interior->peer, NULL, /* rfd */ - pfx_exterior, NULL, afi, prd, bi_interior->attr, + it, FIF_ACTION_KILL, bpi_interior->peer, NULL, /* rfd */ + pfx_exterior, NULL, afi, prd, bpi_interior->attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); } @@ -2525,7 +2533,8 @@ void vnc_import_bgp_exterior_del_route_interior( * We will use and delete every element of the source skiplist */ while (!skiplist_first(RFAPI_MONITOR_EXTERIOR(rn_interior)->source, - (void **)&bi_exterior, (void **)&pfx_exterior)) { + (void **)&bpi_exterior, + (void **)&pfx_exterior)) { struct prefix *pfx_mon = prefix_new(); @@ -2533,7 +2542,7 @@ void vnc_import_bgp_exterior_del_route_interior( if (par) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; /* * Add monitor to parent node @@ -2546,40 +2555,40 @@ void vnc_import_bgp_exterior_del_route_interior( agg_lock_node(par); /* sl */ } skiplist_insert(RFAPI_MONITOR_EXTERIOR(par)->source, - bi_exterior, pfx_mon); + bpi_exterior, pfx_mon); agg_lock_node(par); /* sl entry */ /* Add constructed exterior routes based on parent */ - for (bi = par->info; bi; bi = bi->next) { + for (bpi = par->info; bpi; bpi = bpi->next) { struct prefix_rd *prd; struct attr new_attr; uint32_t label = 0; - if (bi->type == ZEBRA_ROUTE_BGP_DIRECT_EXT) + if (bpi->type == ZEBRA_ROUTE_BGP_DIRECT_EXT) continue; - if (bi->extra) { - prd = &bi->extra->vnc.import.rd; + if (bpi->extra) { + prd = &bpi->extra->vnc.import.rd; label = decode_label( - &bi->extra->label[0]); + &bpi->extra->label[0]); } else prd = NULL; /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); - bgp_attr_dup(&new_attr, bi->attr); - if (bi_exterior - && (bi_exterior->attr->flag + bgp_attr_dup(&new_attr, bpi->attr); + if (bpi_exterior + && (bpi_exterior->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) { new_attr.local_pref = - bi_exterior->attr->local_pref; + bpi_exterior->attr->local_pref; new_attr.flag |= ATTR_FLAG_BIT( BGP_ATTR_LOCAL_PREF); } rfapiBgpInfoFilteredImportVPN( - it, FIF_ACTION_UPDATE, bi->peer, + it, FIF_ACTION_UPDATE, bpi->peer, NULL, /* rfd */ pfx_exterior, NULL, afi, prd, &new_attr, ZEBRA_ROUTE_BGP_DIRECT_EXT, @@ -2594,7 +2603,7 @@ void vnc_import_bgp_exterior_del_route_interior( * in orphan list to await future route. */ skiplist_insert(it->monitor_exterior_orphans, - bi_exterior, pfx_mon); + bpi_exterior, pfx_mon); } skiplist_delete_first( @@ -2769,14 +2778,14 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi) for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; - vnc_import_bgp_add_route(bgp, &rn->p, bi); + vnc_import_bgp_add_route(bgp, &rn->p, bpi); } } vnc_zlog_debug_verbose( @@ -2809,15 +2818,15 @@ void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi) for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; vnc_import_bgp_exterior_add_route(bgp_exterior, &rn->p, - bi); + bpi); } } vnc_zlog_debug_verbose( @@ -2854,15 +2863,15 @@ void vnc_import_bgp_exterior_redist_enable_it( for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; vnc_import_bgp_exterior_add_route_it( - bgp_exterior, &rn->p, bi, it_only); + bgp_exterior, &rn->p, bpi, it_only); } } } @@ -2897,30 +2906,31 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi) for (rn2 = bgp_table_top(rn1->info); rn2; rn2 = bgp_route_next(rn2)) { - struct bgp_path_info *bi; - struct bgp_path_info *nextbi; + struct bgp_path_info *bpi; + struct bgp_path_info *nextbpi; - for (bi = rn2->info; bi; bi = nextbi) { + for (bpi = rn2->info; bpi; bpi = nextbpi) { - nextbi = bi->next; + nextbpi = bpi->next; - if (bi->type + if (bpi->type == ZEBRA_ROUTE_BGP_DIRECT) { struct rfapi_descriptor *rfd; - vncHDBgpDirect.peer = bi->peer; + vncHDBgpDirect.peer = bpi->peer; - assert(bi->extra); + assert(bpi->extra); - rfd = bi->extra->vnc.export + rfd = bpi->extra->vnc.export .rfapi_handle; vnc_zlog_debug_verbose( - "%s: deleting bi=%p, bi->peer=%p, bi->type=%d, bi->sub_type=%d, bi->extra->vnc.export.rfapi_handle=%p [passing rfd=%p]", - __func__, bi, bi->peer, - bi->type, bi->sub_type, - (bi->extra - ? bi->extra + "%s: deleting bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p [passing rfd=%p]", + __func__, bpi, + bpi->peer, bpi->type, + bpi->sub_type, + (bpi->extra + ? bpi->extra ->vnc .export .rfapi_handle @@ -2929,12 +2939,13 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi) del_vnc_route( - rfd, bi->peer, bgp, + rfd, bpi->peer, bgp, SAFI_MPLS_VPN, &rn2->p, (struct prefix_rd *)&rn1 ->p, - bi->type, bi->sub_type, - NULL, 1); /* kill */ + bpi->type, + bpi->sub_type, NULL, + 1); /* kill */ vncHDBgpDirect.peer = NULL; } @@ -2948,7 +2959,7 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi) struct bgp_path_info *info; while (!skiplist_first(bgp->rfapi->resolve_nve_nexthop, NULL, (void *)&pb)) { - info = pb->ubi; + info = pb->ubpi; skiplist_delete_first(bgp->rfapi->resolve_nve_nexthop); bgp_path_info_unlock(info); } @@ -2986,15 +2997,15 @@ void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi) for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *bi; + struct bgp_path_info *bpi; - for (bi = rn->info; bi; bi = bi->next) { + for (bpi = rn->info; bpi; bpi = bpi->next) { - if (CHECK_FLAG(bi->flags, BGP_PATH_REMOVED)) + if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; vnc_import_bgp_exterior_del_route(bgp_exterior, - &rn->p, bi); + &rn->p, bpi); } } #if DEBUG_RHN_LIST diff --git a/bgpd/rfapi/vnc_import_bgp.h b/bgpd/rfapi/vnc_import_bgp.h index 294740c864..3db6f4010a 100644 --- a/bgpd/rfapi/vnc_import_bgp.h +++ b/bgpd/rfapi/vnc_import_bgp.h @@ -62,12 +62,12 @@ extern void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ struct prefix *prefix, /* VPN prefix */ - struct bgp_path_info *bi); /* new VPN host route */ + struct bgp_path_info *bpi); /* new VPN host route */ extern void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( struct bgp *bgp, struct prefix_rd *prd, /* RD */ struct bgp_table *table_rd, /* per-rd VPN route table */ struct prefix *prefix, /* VPN prefix */ - struct bgp_path_info *bi); /* old VPN host route */ + struct bgp_path_info *bpi); /* old VPN host route */ #endif /* _QUAGGA_RFAPI_VNC_IMPORT_BGP_H_ */ diff --git a/bgpd/rfapi/vnc_import_bgp_p.h b/bgpd/rfapi/vnc_import_bgp_p.h index 1d2b51713b..c6627dfba4 100644 --- a/bgpd/rfapi/vnc_import_bgp_p.h +++ b/bgpd/rfapi/vnc_import_bgp_p.h @@ -29,13 +29,13 @@ extern void vnc_import_bgp_exterior_add_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct agg_node *rn_interior, /* VPN IT node */ - struct bgp_path_info *bi_interior); /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_path_info *bpi_interior); /* VPN IT route */ extern void vnc_import_bgp_exterior_del_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct agg_node *rn_interior, /* VPN IT node */ - struct bgp_path_info *bi_interior); /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_path_info *bpi_interior); /* VPN IT route */ extern void vnc_import_bgp_exterior_redist_enable_it(struct bgp *bgp, afi_t afi, -- 2.39.5