]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_route.c
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / bgpd / bgp_route.c
index be2bda95f9ef74d3d42a25cb4f1ce356e51a75dd..2c361bef4d5b2693f85bd1289914d44da0a86176 100644 (file)
@@ -65,6 +65,7 @@
 #include "bgpd/bgp_nht.h"
 #include "bgpd/bgp_updgrp.h"
 #include "bgpd/bgp_label.h"
+#include "bgpd/bgp_addpath.h"
 
 #if ENABLE_BGP_VNC
 #include "bgpd/rfapi/rfapi_backend.h"
@@ -119,11 +120,12 @@ struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
            || (safi == SAFI_EVPN)) {
                prn = bgp_node_get(table, (struct prefix *)prd);
 
-               if (prn->info == NULL)
-                       prn->info = bgp_table_init(table->bgp, afi, safi);
+               if (!bgp_node_has_bgp_path_info_data(prn))
+                       bgp_node_set_bgp_table_info(
+                               prn, bgp_table_init(table->bgp, afi, safi));
                else
                        bgp_unlock_node(prn);
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
        }
 
        rn = bgp_node_get(table, p);
@@ -151,12 +153,12 @@ struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
                if (!prn)
                        return NULL;
 
-               if (prn->info == NULL) {
+               if (!bgp_node_has_bgp_path_info_data(prn)) {
                        bgp_unlock_node(prn);
                        return NULL;
                }
 
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
        }
 
        rn = bgp_node_lookup(table, p);
@@ -175,7 +177,7 @@ static struct bgp_path_info_extra *bgp_path_info_extra_new(void)
        return new;
 }
 
-static void bgp_path_info_extra_free(struct bgp_path_info_extra **extra)
+void bgp_path_info_extra_free(struct bgp_path_info_extra **extra)
 {
        struct bgp_path_info_extra *e;
 
@@ -188,25 +190,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 +227,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. */
@@ -247,6 +249,8 @@ static void bgp_path_info_free(struct bgp_path_info *path)
        bgp_unlink_nexthop(path);
        bgp_path_info_extra_free(&path->extra);
        bgp_path_info_mpath_free(&path->mpath);
+       bgp_addpath_free_info_data(&path->tx_addpath,
+                                path->net ? &path->net->tx_addpath : NULL);
 
        peer_unlock(path->peer); /* bgp_path_info peer reference */
 
@@ -284,100 +288,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;
+       top = bgp_node_get_bgp_path_info(rn);
 
-       ri->next = rn->info;
-       ri->prev = NULL;
+       pi->next = top;
+       pi->prev = NULL;
        if (top)
-               top->prev = ri;
-       rn->info = ri;
+               top->prev = pi;
+       bgp_node_set_bgp_path_info(rn, 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;
+               bgp_node_set_bgp_path_info(rn, 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 +389,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 +403,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 +420,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.
@@ -453,6 +457,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
        char exist_buf[PATH_ADDPATH_STR_BUFFER];
        uint32_t new_mm_seq;
        uint32_t exist_mm_seq;
+       int nh_cmp;
 
        *paths_eq = 0;
 
@@ -545,6 +550,28 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
                                        exist_mm_seq);
                        return 0;
                }
+
+               /*
+                * if sequence numbers are the same path with the lowest IP
+                * wins
+                */
+               nh_cmp = bgp_path_info_nexthop_cmp(new, exist);
+               if (nh_cmp < 0) {
+                       if (debug)
+                               zlog_debug(
+                                       "%s: %s wins over %s due to same MM seq %u and lower IP %s",
+                                       pfx_buf, new_buf, exist_buf, new_mm_seq,
+                                       inet_ntoa(new->attr->nexthop));
+                       return 1;
+               }
+               if (nh_cmp > 0) {
+                       if (debug)
+                               zlog_debug(
+                                       "%s: %s loses to %s due to same MM seq %u and higher IP %s",
+                                       pfx_buf, new_buf, exist_buf, new_mm_seq,
+                                       inet_ntoa(new->attr->nexthop));
+                       return 0;
+               }
        }
 
        /* 1. Weight check. */
@@ -1168,7 +1195,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 +1221,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 +1243,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 +1270,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;
 
@@ -1345,15 +1372,15 @@ void bgp_attr_add_gshut_community(struct attr *attr)
                merge = community_merge(community_dup(old), gshut);
 
                if (old->refcnt == 0)
-                       community_free(old);
+                       community_free(&old);
 
                new = community_uniq_sort(merge);
-               community_free(merge);
+               community_free(&merge);
        } else {
                new = community_dup(gshut);
        }
 
-       community_free(gshut);
+       community_free(&gshut);
        attr->community = new;
        attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
 
@@ -1376,7 +1403,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 +1412,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 +1431,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 +1456,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 +1465,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->addpath_type[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 +1493,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 +1535,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 +1544,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 +1575,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 +1584,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 +1596,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 +1636,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 +1726,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 +1752,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 +1801,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 +1826,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 +1873,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,58 +1896,57 @@ 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 = bgp_node_get_bgp_path_info(rn); 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 = bgp_node_get_bgp_path_info(rn); 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)
-                                           || aspath_cmp_left_confed(
-                                                      ri1->attr->aspath,
-                                                      ri2->attr->aspath)) {
-                                               if (bgp_path_info_cmp(
-                                                           bgp, ri2,
-                                                           new_select,
-                                                           &paths_eq,
-                                                           mpath_cfg, debug,
-                                                           pfx_buf, afi,
-                                                           safi)) {
-                                                       bgp_path_info_unset_flag(
-                                                               rn, new_select,
-                                                               BGP_PATH_DMED_SELECTED);
-                                                       new_select = ri2;
-                                               }
+                                       if (!aspath_cmp_left(pi1->attr->aspath,
+                                                            pi2->attr->aspath)
+                                           && !aspath_cmp_left_confed(
+                                                      pi1->attr->aspath,
+                                                      pi2->attr->aspath))
+                                               continue;
 
-                                               bgp_path_info_set_flag(
-                                                       rn, ri2,
-                                                       BGP_PATH_DMED_CHECK);
+                                       if (bgp_path_info_cmp(
+                                                   bgp, pi2, new_select,
+                                                   &paths_eq, mpath_cfg, debug,
+                                                   pfx_buf, afi, safi)) {
+                                               bgp_path_info_unset_flag(
+                                                       rn, new_select,
+                                                       BGP_PATH_DMED_SELECTED);
+                                               new_select = pi2;
                                        }
+
+                                       bgp_path_info_set_flag(
+                                               rn, pi2, BGP_PATH_DMED_CHECK);
                                }
                        }
                        bgp_path_info_set_flag(rn, new_select,
@@ -1942,51 +1968,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 = bgp_node_get_bgp_path_info(rn);
+            (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 +2033,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 = bgp_node_get_bgp_path_info(rn);
+                    (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 +2066,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 +2074,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);
                        }
                }
        }
@@ -2058,6 +2084,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
        bgp_path_info_mpath_aggregate_update(new_select, old_select);
        bgp_mp_list_clear(&mp_list);
 
+       bgp_addpath_update_ids(bgp, rn, afi, safi);
+
        result->old = old_select;
        result->new = new_select;
 
@@ -2107,7 +2135,7 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,
                        bgp_adj_out_set_subgroup(rn, subgrp, &attr, selected);
                else
                        bgp_adj_out_unset_subgroup(rn, subgrp, 1,
-                                                  selected->addpath_tx_id);
+                                                  addpath_tx_id);
        }
 
        /* If selected is NULL we must withdraw the path using addpath_tx_id */
@@ -2124,13 +2152,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 = bgp_node_get_bgp_path_info(rn); 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);
        }
 }
 
@@ -2237,20 +2265,26 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
 
        /* Do we need to allocate or free labels?
         * Right now, since we only deal with per-prefix labels, it is not
-        * necessary to do this upon changes to best path except if the label
-        * index changes
+        * necessary to do this upon changes to best path. Exceptions:
+        * - label index has changed -> recalculate resulting label
+        * - path_info sub_type changed -> switch to/from implicit-null
+        * - no valid label (due to removed static label binding) -> get new one
         */
        if (bgp->allocate_mpls_labels[afi][safi]) {
                if (new_select) {
                        if (!old_select
                            || bgp_label_index_differs(new_select, old_select)
-                           || new_select->sub_type != old_select->sub_type) {
+                           || new_select->sub_type != old_select->sub_type
+                           || !bgp_is_valid_label(&rn->local_label)) {
+                               /* Enforced penultimate hop popping:
+                                * implicit-null for local routes, aggregate
+                                * and redistributed routes
+                                */
                                if (new_select->sub_type == BGP_ROUTE_STATIC
-                                   && new_select->attr->flag
-                                              & ATTR_FLAG_BIT(
-                                                        BGP_ATTR_PREFIX_SID)
-                                   && new_select->attr->label_index
-                                              != BGP_INVALID_LABEL_INDEX) {
+                                   || new_select->sub_type
+                                               == BGP_ROUTE_AGGREGATE
+                                   || new_select->sub_type
+                                               == BGP_ROUTE_REDISTRIBUTE) {
                                        if (CHECK_FLAG(
                                                    rn->flags,
                                                    BGP_NODE_REGISTERED_FOR_LABEL))
@@ -2283,7 +2317,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
        if (old_select && old_select == new_select
            && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
            && !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
-           && !bgp->addpath_tx_used[afi][safi]) {
+           && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
                if (bgp_zebra_has_route_changed(rn, old_select)) {
 #if ENABLE_BGP_VNC
                        vnc_import_bgp_add_route(bgp, p, old_select);
@@ -2682,18 +2716,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 +2736,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;
                }
@@ -2716,29 +2750,29 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *ri,
 
                prn = bgp_node_get(peer->bgp->rib[afi][safi],
                                   (struct prefix *)prd);
-               if (prn->info) {
-                       table = (struct bgp_table *)(prn->info);
+               if (bgp_node_has_bgp_path_info_data(prn)) {
+                       table = bgp_node_get_bgp_table_info(prn);
 
                        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,
@@ -2756,7 +2790,6 @@ struct bgp_path_info *info_make(int type, int sub_type, unsigned short instance,
        new->attr = attr;
        new->uptime = bgp_clock();
        new->net = rn;
-       new->addpath_tx_id = ++peer->bgp->addpath_tx_id;
        return new;
 }
 
@@ -2782,12 +2815,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 +2828,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 +2924,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 +2957,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 = bgp_node_get_bgp_path_info(rn); 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 +3060,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 +3088,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 +3116,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 +3130,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 +3141,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 +3154,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 +3171,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) {
@@ -3148,23 +3181,23 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
 
                        prn = bgp_node_get(bgp->rib[afi][safi],
                                           (struct prefix *)prd);
-                       if (prn->info) {
-                               table = (struct bgp_table *)(prn->info);
+                       if (bgp_node_has_bgp_path_info_data(prn)) {
+                               table = bgp_node_get_bgp_table_info(prn);
 
                                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 +3210,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 +3263,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 +3279,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 +3301,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 +3318,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) {
@@ -3298,11 +3331,11 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
 
                        prn = bgp_node_get(bgp->rib[afi][safi],
                                           (struct prefix *)prd);
-                       if (prn->info) {
-                               table = (struct bgp_table *)(prn->info);
+                       if (bgp_node_has_bgp_path_info_data(prn)) {
+                               table = bgp_node_get_bgp_table_info(prn);
 
                                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 +3354,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 +3366,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
@@ -3435,8 +3468,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
                struct bgp_table *table = NULL;
 
                prn = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
-               if (prn->info) {
-                       table = (struct bgp_table *)(prn->info);
+               if (bgp_node_has_bgp_path_info_data(prn)) {
+                       table = bgp_node_get_bgp_table_info(prn);
 
                        vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
                                bgp, prd, table, p, new);
@@ -3499,25 +3532,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 +3578,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 +3620,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 = bgp_node_get_bgp_path_info(rn); 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 +3636,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 +3774,15 @@ 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 =
+                               bgp_node_get_bgp_path_info(rn);
                        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,
@@ -3775,9 +3809,11 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
                bgp_soft_reconfig_table(peer, afi, safi, NULL, NULL);
        else
                for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
-                    rn = bgp_route_next(rn))
-                       if ((table = rn->info) != NULL) {
+                    rn = bgp_route_next(rn)) {
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (table != NULL) {
                                struct prefix_rd prd;
+
                                prd.family = AF_UNSPEC;
                                prd.prefixlen = 64;
                                memcpy(&prd.val, rn->p.u.val, 8);
@@ -3785,6 +3821,7 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
                                bgp_soft_reconfig_table(peer, afi, safi, table,
                                                        &prd);
                        }
+               }
 }
 
 
@@ -3797,7 +3834,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 +3845,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 = bgp_node_get_bgp_path_info(rn); 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 +3933,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 +3984,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 = bgp_node_get_bgp_path_info(rn); 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;
 
@@ -4004,9 +4041,13 @@ void bgp_clear_route(struct peer *peer, afi_t afi, safi_t safi)
                bgp_clear_route_table(peer, afi, safi, NULL);
        else
                for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
-                    rn = bgp_route_next(rn))
-                       if ((table = rn->info) != NULL)
-                               bgp_clear_route_table(peer, afi, safi, table);
+                    rn = bgp_route_next(rn)) {
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (!table)
+                               continue;
+
+                       bgp_clear_route_table(peer, afi, safi, table);
+               }
 
        /* unlock if no nodes got added to the clear-node-queue. */
        if (!peer->clear_node_queue->thread)
@@ -4057,7 +4098,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) {
@@ -4066,31 +4107,34 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
                        struct bgp_node *rm;
 
                        /* look for neighbor in tables */
-                       if ((table = rn->info) == NULL)
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (!table)
                                continue;
 
                        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 = bgp_node_get_bgp_path_info(rm); 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 = bgp_node_get_bgp_path_info(rn); 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 +4144,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 = bgp_node_get_bgp_path_info(rn); 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);
                        }
                }
 }
@@ -4125,6 +4169,7 @@ void bgp_cleanup_routes(struct bgp *bgp)
 {
        afi_t afi;
        struct bgp_node *rn;
+       struct bgp_table *table;
 
        for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
                if (afi == AFI_L2VPN)
@@ -4139,26 +4184,22 @@ void bgp_cleanup_routes(struct bgp *bgp)
                        safi = SAFI_MPLS_VPN;
                        for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
                             rn = bgp_route_next(rn)) {
-                               if (rn->info) {
-                                       bgp_cleanup_table(bgp,
-                                               (struct bgp_table *)(rn->info),
-                                               safi);
-                                       bgp_table_finish((struct bgp_table **)&(
-                                               rn->info));
-                                       rn->info = NULL;
+                               table = bgp_node_get_bgp_table_info(rn);
+                               if (table != NULL) {
+                                       bgp_cleanup_table(bgp, table, safi);
+                                       bgp_table_finish(&table);
+                                       bgp_node_set_bgp_table_info(rn, NULL);
                                        bgp_unlock_node(rn);
                                }
                        }
                        safi = SAFI_ENCAP;
                        for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
                             rn = bgp_route_next(rn)) {
-                               if (rn->info) {
-                                       bgp_cleanup_table(bgp,
-                                               (struct bgp_table *)(rn->info),
-                                               safi);
-                                       bgp_table_finish((struct bgp_table **)&(
-                                               rn->info));
-                                       rn->info = NULL;
+                               table = bgp_node_get_bgp_table_info(rn);
+                               if (table != NULL) {
+                                       bgp_cleanup_table(bgp, table, safi);
+                                       bgp_table_finish(&table);
+                                       bgp_node_set_bgp_table_info(rn, NULL);
                                        bgp_unlock_node(rn);
                                }
                        }
@@ -4166,12 +4207,11 @@ void bgp_cleanup_routes(struct bgp *bgp)
        }
        for (rn = bgp_table_top(bgp->rib[AFI_L2VPN][SAFI_EVPN]); rn;
             rn = bgp_route_next(rn)) {
-               if (rn->info) {
-                       bgp_cleanup_table(bgp,
-                                         (struct bgp_table *)(rn->info),
-                                         SAFI_EVPN);
-                       bgp_table_finish((struct bgp_table **)&(rn->info));
-                       rn->info = NULL;
+               table = bgp_node_get_bgp_table_info(rn);
+               if (table != NULL) {
+                       bgp_cleanup_table(bgp, table, SAFI_EVPN);
+                       bgp_table_finish(&table);
+                       bgp_node_set_bgp_table_info(rn, NULL);
                        bgp_unlock_node(rn);
                }
        }
@@ -4366,9 +4406,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 +4441,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 +4474,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 = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+               if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
+                   && pi->sub_type == BGP_ROUTE_STATIC)
                        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 +4489,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 +4533,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 +4551,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 +4561,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 +4573,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 +4637,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 = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+               if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
+                   && pi->sub_type == BGP_ROUTE_STATIC)
                        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 +4672,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 = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+               if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
+                   && pi->sub_type == BGP_ROUTE_STATIC)
                        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 +4710,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 +4758,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 +4787,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 = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+               if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
+                   && pi->sub_type == BGP_ROUTE_STATIC)
                        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);
@@ -4869,7 +4911,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
                        return CMD_WARNING_CONFIG_FAILED;
                }
 
-               bgp_static = bgp_static_get_node_info(rn);
+               bgp_static = bgp_node_get_bgp_static_info(rn);
 
                if ((label_index != BGP_INVALID_LABEL_INDEX)
                    && (label_index != bgp_static->label_index)) {
@@ -4891,7 +4933,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
 
                /* Clear configuration. */
                bgp_static_free(bgp_static);
-               bgp_static_set_node_info(rn, NULL);
+               bgp_node_set_bgp_static_info(rn, NULL);
                bgp_unlock_node(rn);
                bgp_unlock_node(rn);
        } else {
@@ -4899,7 +4941,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
                /* Set BGP static route configuration. */
                rn = bgp_node_get(bgp->route[afi][safi], &p);
 
-               bgp_static = bgp_static_get_node_info(rn);
+               bgp_static = bgp_node_get_bgp_static_info(rn);
                if (bgp_static) {
                        /* Configuration change. */
                        /* Label index cannot be changed. */
@@ -4950,7 +4992,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
                                bgp_static->rmap.map =
                                        route_map_lookup_by_name(rmap);
                        }
-                       bgp_static_set_node_info(rn, bgp_static);
+                       bgp_node_set_bgp_static_info(rn, bgp_static);
                }
 
                bgp_static->valid = 1;
@@ -4976,25 +5018,27 @@ void bgp_static_add(struct bgp *bgp)
        FOREACH_AFI_SAFI (afi, safi)
                for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
                     rn = bgp_route_next(rn)) {
-                       if (rn->info == NULL)
+                       if (!bgp_node_has_bgp_path_info_data(rn))
                                continue;
 
                        if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
                            || (safi == SAFI_EVPN)) {
-                               table = rn->info;
+                               table = bgp_node_get_bgp_table_info(rn);
 
                                for (rm = bgp_table_top(table); rm;
                                     rm = bgp_route_next(rm)) {
                                        bgp_static =
-                                               bgp_static_get_node_info(rm);
+                                               bgp_node_get_bgp_static_info(
+                                                       rm);
                                        bgp_static_update_safi(bgp, &rm->p,
                                                               bgp_static, afi,
                                                               safi);
                                }
                        } else {
-                               bgp_static_update(bgp, &rn->p,
-                                                 bgp_static_get_node_info(rn),
-                                                 afi, safi);
+                               bgp_static_update(
+                                       bgp, &rn->p,
+                                       bgp_node_get_bgp_static_info(rn), afi,
+                                       safi);
                        }
                }
 }
@@ -5013,29 +5057,30 @@ void bgp_static_delete(struct bgp *bgp)
        FOREACH_AFI_SAFI (afi, safi)
                for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
                     rn = bgp_route_next(rn)) {
-                       if (rn->info == NULL)
+                       if (!bgp_node_has_bgp_path_info_data(rn))
                                continue;
 
                        if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
                            || (safi == SAFI_EVPN)) {
-                               table = rn->info;
+                               table = bgp_node_get_bgp_table_info(rn);
 
                                for (rm = bgp_table_top(table); rm;
                                     rm = bgp_route_next(rm)) {
                                        bgp_static =
-                                               bgp_static_get_node_info(rm);
+                                               bgp_node_get_bgp_static_info(
+                                                       rm);
                                        bgp_static_withdraw_safi(
                                                bgp, &rm->p, AFI_IP, safi,
                                                (struct prefix_rd *)&rn->p);
                                        bgp_static_free(bgp_static);
-                                       bgp_static_set_node_info(rn, NULL);
+                                       bgp_node_set_bgp_static_info(rn, NULL);
                                        bgp_unlock_node(rn);
                                }
                        } else {
-                               bgp_static = bgp_static_get_node_info(rn);
+                               bgp_static = bgp_node_get_bgp_static_info(rn);
                                bgp_static_withdraw(bgp, &rn->p, afi, safi);
                                bgp_static_free(bgp_static);
-                               bgp_static_set_node_info(rn, NULL);
+                               bgp_node_set_bgp_static_info(rn, NULL);
                                bgp_unlock_node(rn);
                        }
                }
@@ -5055,23 +5100,24 @@ void bgp_static_redo_import_check(struct bgp *bgp)
        FOREACH_AFI_SAFI (afi, safi) {
                for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
                     rn = bgp_route_next(rn)) {
-                       if (rn->info == NULL)
+                       if (!bgp_node_has_bgp_path_info_data(rn))
                                continue;
 
                        if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
                            || (safi == SAFI_EVPN)) {
-                               table = rn->info;
+                               table = bgp_node_get_bgp_table_info(rn);
 
                                for (rm = bgp_table_top(table); rm;
                                     rm = bgp_route_next(rm)) {
                                        bgp_static =
-                                               bgp_static_get_node_info(rm);
+                                               bgp_node_get_bgp_static_info(
+                                                       rm);
                                        bgp_static_update_safi(bgp, &rm->p,
                                                               bgp_static, afi,
                                                               safi);
                                }
                        } else {
-                               bgp_static = bgp_static_get_node_info(rn);
+                               bgp_static = bgp_node_get_bgp_static_info(rn);
                                bgp_static_update(bgp, &rn->p, bgp_static, afi,
                                                  safi);
                        }
@@ -5085,21 +5131,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 = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+                       if (pi->peer == bgp->peer_self
+                           && ((pi->type == ZEBRA_ROUTE_BGP
+                                && pi->sub_type == BGP_ROUTE_STATIC)
+                               || (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);
                        }
                }
@@ -5196,15 +5242,16 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
                }
        }
        prn = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
-       if (prn->info == NULL)
-               prn->info = bgp_table_init(bgp, afi, safi);
+       if (!bgp_node_has_bgp_path_info_data(prn))
+               bgp_node_set_bgp_table_info(prn,
+                                           bgp_table_init(bgp, afi, safi));
        else
                bgp_unlock_node(prn);
-       table = prn->info;
+       table = bgp_node_get_bgp_table_info(prn);
 
        rn = bgp_node_get(table, &p);
 
-       if (rn->info) {
+       if (bgp_node_has_bgp_path_info_data(rn)) {
                vty_out(vty, "%% Same network configuration exists\n");
                bgp_unlock_node(rn);
        } else {
@@ -5243,7 +5290,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
                        if (gwip)
                                prefix_copy(&bgp_static->gatewayIp, &gw_ip);
                }
-               bgp_static_set_node_info(rn, bgp_static);
+               bgp_node_set_bgp_static_info(rn, bgp_static);
 
                bgp_static->valid = 1;
                bgp_static_update_safi(bgp, &p, bgp_static, afi, safi);
@@ -5294,20 +5341,21 @@ int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty,
        }
 
        prn = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
-       if (prn->info == NULL)
-               prn->info = bgp_table_init(bgp, afi, safi);
+       if (!bgp_node_has_bgp_path_info_data(prn))
+               bgp_node_set_bgp_table_info(prn,
+                                           bgp_table_init(bgp, afi, safi));
        else
                bgp_unlock_node(prn);
-       table = prn->info;
+       table = bgp_node_get_bgp_table_info(prn);
 
        rn = bgp_node_lookup(table, &p);
 
        if (rn) {
                bgp_static_withdraw_safi(bgp, &p, afi, safi, &prd);
 
-               bgp_static = bgp_static_get_node_info(rn);
+               bgp_static = bgp_node_get_bgp_static_info(rn);
                bgp_static_free(bgp_static);
-               bgp_static_set_node_info(rn, NULL);
+               bgp_node_set_bgp_static_info(rn, NULL);
                bgp_unlock_node(rn);
                bgp_unlock_node(rn);
        } else
@@ -5481,28 +5529,36 @@ 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)
+                                  struct community *comm,
+                                  struct ecommunity *ecomm,
+                                  struct lcommunity *lcomm)
 {
        static struct aspath *ae = NULL;
 
        if (!ae)
                ae = aspath_empty();
 
-       if (!ri)
+       if (!pi)
+               return 0;
+
+       if (origin != pi->attr->origin)
                return 0;
 
-       if (origin != ri->attr->origin)
+       if (!aspath_cmp(pi->attr->aspath, (aspath) ? aspath : ae))
                return 0;
 
-       if (!aspath_cmp(ri->attr->aspath, (aspath) ? aspath : ae))
+       if (!community_cmp(pi->attr->community, comm))
                return 0;
 
-       if (!community_cmp(ri->attr->community, comm))
+       if (!ecommunity_cmp(pi->attr->ecommunity, ecomm))
                return 0;
 
-       if (!CHECK_FLAG(ri->flags, BGP_PATH_VALID))
+       if (!lcommunity_cmp(pi->attr->lcommunity, lcomm))
+               return 0;
+
+       if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID))
                return 0;
 
        return 1;
@@ -5512,20 +5568,22 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi,
                                  struct prefix *p, uint8_t origin,
                                  struct aspath *aspath,
                                  struct community *community,
+                                 struct ecommunity *ecommunity,
+                                 struct lcommunity *lcommunity,
                                  uint8_t atomic_aggregate,
                                  struct bgp_aggregate *aggregate)
 {
        struct bgp_node *rn;
        struct bgp_table *table;
-       struct bgp_path_info *ri, *new;
+       struct bgp_path_info *pi, *orig, *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 (orig = pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+               if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
+                   && pi->sub_type == BGP_ROUTE_AGGREGATE)
                        break;
 
        if (aggregate->count > 0) {
@@ -5533,14 +5591,18 @@ static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi,
                 * If the aggregate information has not changed
                 * no need to re-install it again.
                 */
-               if (bgp_aggregate_info_same(rn->info, origin, aspath,
-                                           community)) {
+               if (bgp_aggregate_info_same(orig, origin, aspath, community,
+                                           ecommunity, lcommunity)) {
                        bgp_unlock_node(rn);
 
                        if (aspath)
                                aspath_free(aspath);
                        if (community)
-                               community_free(community);
+                               community_free(&community);
+                       if (ecommunity)
+                               ecommunity_free(&ecommunity);
+                       if (lcommunity)
+                               lcommunity_free(&lcommunity);
 
                        return;
                }
@@ -5548,29 +5610,31 @@ 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);
-
-               new = info_make(
-                       ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self,
-                       bgp_attr_aggregate_intern(bgp, origin, aspath,
-                                                 community, aggregate->as_set,
-                                                 atomic_aggregate),
-                       rn);
+               if (pi)
+                       bgp_path_info_delete(rn, pi);
+
+               new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0,
+                               bgp->peer_self,
+                               bgp_attr_aggregate_intern(bgp, origin, aspath,
+                                                         community, ecommunity,
+                                                         lcommunity,
+                                                         aggregate->as_set,
+                                                         atomic_aggregate),
+                               rn);
                SET_FLAG(new->flags, BGP_PATH_VALID);
 
                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 = orig; 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 +5644,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 +5656,11 @@ 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 ecommunity *ecommunity = NULL;
+       struct ecommunity *ecommerge = NULL;
+       struct lcommunity *lcommunity = NULL;
+       struct lcommunity *lcommerge = NULL;
+       struct bgp_path_info *pi;
        unsigned long match = 0;
        uint8_t atomic_aggregate = 0;
 
@@ -5616,18 +5684,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 = bgp_node_get_bgp_path_info(rn); 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 +5703,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 +5721,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,69 +5733,127 @@ 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)
-                               continue;
+                       if (pi->attr->community) {
+                               if (community) {
+                                       commerge = community_merge(
+                                               community, pi->attr->community);
+                                       community =
+                                               community_uniq_sort(commerge);
+                                       community_free(&commerge);
+                               } else
+                                       community = community_dup(
+                                               pi->attr->community);
+                       }
 
-                       if (community) {
-                               commerge = community_merge(community,
-                                                          ri->attr->community);
-                               community = community_uniq_sort(commerge);
-                               community_free(commerge);
-                       } else
-                               community = community_dup(ri->attr->community);
+                       if (pi->attr->ecommunity) {
+                               if (ecommunity) {
+                                       ecommerge = ecommunity_merge(
+                                               ecommunity,
+                                               pi->attr->ecommunity);
+                                       ecommunity =
+                                               ecommunity_uniq_sort(ecommerge);
+                                       ecommunity_free(&ecommerge);
+                               } else
+                                       ecommunity = ecommunity_dup(
+                                               pi->attr->ecommunity);
+                       }
+
+                       if (pi->attr->lcommunity) {
+                               if (lcommunity) {
+                                       lcommerge = lcommunity_merge(
+                                               lcommunity,
+                                               pi->attr->lcommunity);
+                                       lcommunity =
+                                               lcommunity_uniq_sort(lcommerge);
+                                       lcommunity_free(&lcommerge);
+                               } else
+                                       lcommunity = lcommunity_dup(
+                                               pi->attr->lcommunity);
+                       }
                }
                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);
+                                       community_free(&commerge);
                                } else
                                        community = community_dup(
-                                               rinew->attr->community);
+                                               pinew->attr->community);
+                       }
+
+                       if (pinew->attr->ecommunity) {
+                               if (ecommunity) {
+                                       ecommerge = ecommunity_merge(
+                                               ecommunity,
+                                               pinew->attr->ecommunity);
+                                       ecommunity =
+                                               ecommunity_uniq_sort(ecommerge);
+                                       ecommunity_free(&ecommerge);
+                               } else
+                                       ecommunity = ecommunity_dup(
+                                               pinew->attr->ecommunity);
+                       }
+
+                       if (pinew->attr->lcommunity) {
+                               if (lcommunity) {
+                                       lcommerge = lcommunity_merge(
+                                               lcommunity,
+                                               pinew->attr->lcommunity);
+                                       lcommunity =
+                                               lcommunity_uniq_sort(lcommerge);
+                                       lcommunity_free(&lcommerge);
+                               } else
+                                       lcommunity = lcommunity_dup(
+                                               pinew->attr->lcommunity);
                        }
                }
        }
 
        bgp_aggregate_install(bgp, afi, safi, p, origin, aspath, community,
-                             atomic_aggregate, aggregate);
+                             ecommunity, lcommunity, atomic_aggregate,
+                             aggregate);
 
        if (aggregate->count == 0) {
                if (aspath)
                        aspath_free(aspath);
                if (community)
-                       community_free(community);
+                       community_free(&community);
+               if (ecommunity)
+                       ecommunity_free(&ecommunity);
+               if (lcommunity)
+                       lcommunity_free(&lcommunity);
        }
 }
 
@@ -5737,7 +5863,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 +5876,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 = bgp_node_get_bgp_path_info(rn); 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 +5903,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,17 +5919,17 @@ 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);
 
        /* Aggregate address configuration check. */
        for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
-               aggregate = bgp_aggregate_get_node_info(rn);
+               aggregate = bgp_node_get_bgp_aggregate_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);
                }
        }
@@ -5831,7 +5957,7 @@ void bgp_aggregate_decrement(struct bgp *bgp, struct prefix *p,
 
        /* Aggregate address configuration check. */
        for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
-               aggregate = bgp_aggregate_get_node_info(rn);
+               aggregate = bgp_node_get_bgp_aggregate_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, NULL, afi, safi, del,
@@ -5870,12 +5996,13 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       aggregate = bgp_aggregate_get_node_info(rn);
+       aggregate = bgp_node_get_bgp_aggregate_info(rn);
        bgp_aggregate_delete(bgp, &p, afi, safi, aggregate);
-       bgp_aggregate_install(bgp, afi, safi, &p, 0, NULL, NULL, 0, aggregate);
+       bgp_aggregate_install(bgp, afi, safi, &p, 0, NULL, NULL,
+                             NULL, NULL,  0, aggregate);
 
        /* Unlock aggregate address configuration. */
-       bgp_aggregate_set_node_info(rn, NULL);
+       bgp_node_set_bgp_aggregate_info(rn, NULL);
        bgp_aggregate_free(aggregate);
        bgp_unlock_node(rn);
        bgp_unlock_node(rn);
@@ -5910,7 +6037,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
        /* Old configuration check. */
        rn = bgp_node_get(bgp->aggregate[afi][safi], &p);
 
-       if (rn->info) {
+       if (bgp_node_has_bgp_path_info_data(rn)) {
                vty_out(vty, "There is already same aggregate network.\n");
                /* try to remove the old entry */
                ret = bgp_aggregate_unset(vty, prefix_str, afi, safi);
@@ -5926,7 +6053,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
        aggregate->summary_only = summary_only;
        aggregate->as_set = as_set;
        aggregate->safi = safi;
-       bgp_aggregate_set_node_info(rn, aggregate);
+       bgp_node_set_bgp_aggregate_info(rn, aggregate);
 
        /* Aggregate address insert into BGP routing table. */
        bgp_aggregate_route(bgp, &p, NULL, afi, safi, NULL, aggregate);
@@ -6076,8 +6203,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 +6260,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 +6291,38 @@ 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 = bgp_node_get_bgp_path_info(bn); 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 +6333,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 +6364,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 +6374,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 = bgp_node_get_bgp_path_info(rn); 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 +6398,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 = bgp_node_get_bgp_path_info(rn); 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);
                }
        }
@@ -6302,6 +6430,7 @@ static void route_vty_out_route(struct prefix *p, struct vty *vty,
 {
        int len = 0;
        char buf[BUFSIZ];
+       char buf2[BUFSIZ];
 
        if (p->family == AF_INET) {
                if (!json) {
@@ -6315,6 +6444,8 @@ static void route_vty_out_route(struct prefix *p, struct vty *vty,
                                                         &p->u.prefix, buf,
                                                         BUFSIZ));
                        json_object_int_add(json, "prefixLen", p->prefixlen);
+                       prefix2str(p, buf2, PREFIX_STRLEN);
+                       json_object_string_add(json, "network", buf2);
                }
        } else if (p->family == AF_ETHERNET) {
                prefix2str(p, buf, PREFIX_STRLEN);
@@ -6338,6 +6469,15 @@ static void route_vty_out_route(struct prefix *p, struct vty *vty,
                                vty, "%s/%d",
                                inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
                                p->prefixlen);
+               else {
+                       json_object_string_add(json, "prefix",
+                                               inet_ntop(p->family,
+                                                       &p->u.prefix, buf,
+                                                       BUFSIZ));
+                       json_object_int_add(json, "prefixLen", p->prefixlen);
+                       prefix2str(p, buf2, PREFIX_STRLEN);
+                       json_object_string_add(json, "network", buf2);
+               }
        }
 
        if (!json) {
@@ -6447,7 +6587,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
                CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
        bool nexthop_othervrf = false;
        vrf_id_t nexthop_vrfid = VRF_DEFAULT;
-       const char *nexthop_vrfname = "Default";
+       const char *nexthop_vrfname = VRF_DEFAULT_NAME;
 
        if (json_paths)
                json_path = json_object_new_object();
@@ -6574,7 +6714,8 @@ void route_vty_out(struct vty *vty, struct prefix *p,
                                               inet_ntoa(attr->nexthop));
                                json_object_string_add(json_nexthop_global,
                                                       "afi", "ipv4");
-                               json_object_boolean_true_add(json_nexthop_global,
+                               json_object_boolean_true_add(
+                                                       json_nexthop_global,
                                                             "used");
                        } else {
                                vty_out(vty, "%-16s", inet_ntoa(attr->nexthop));
@@ -6701,19 +6842,32 @@ void route_vty_out(struct vty *vty, struct prefix *p,
 
        /* MED/Metric */
        if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
-               if (json_paths)
+               if (json_paths) {
+
+                       /*
+                        * Adding "metric" field to match with corresponding
+                        * CLI. "med" will be deprecated in future.
+                        */
                        json_object_int_add(json_path, "med", attr->med);
-               else
+                       json_object_int_add(json_path, "metric", attr->med);
+               } else
                        vty_out(vty, "%10u", attr->med);
        else if (!json_paths)
                vty_out(vty, "          ");
 
        /* Local Pref */
        if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
-               if (json_paths)
+               if (json_paths) {
+
+                       /*
+                        * Adding "locPrf" field to match with corresponding
+                        * CLI. "localPref" will be deprecated in future.
+                        */
                        json_object_int_add(json_path, "localpref",
                                            attr->local_pref);
-               else
+                       json_object_int_add(json_path, "locPrf",
+                                               attr->local_pref);
+               } else
                        vty_out(vty, "%7u", attr->local_pref);
        else if (!json_paths)
                vty_out(vty, "       ");
@@ -6732,10 +6886,17 @@ void route_vty_out(struct vty *vty, struct prefix *p,
 
        /* Print aspath */
        if (attr->aspath) {
-               if (json_paths)
+               if (json_paths) {
+
+                       /*
+                        * Adding "path" field to match with corresponding
+                        * CLI. "aspath" will be deprecated in future.
+                        */
                        json_object_string_add(json_path, "aspath",
                                               attr->aspath->str);
-               else
+                       json_object_string_add(json_path, "path",
+                                               attr->aspath->str);
+               } else
                        aspath_print_vty(vty, "%s", attr->aspath, " ");
        }
 
@@ -6796,6 +6957,7 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
        json_object *json_status = NULL;
        json_object *json_net = NULL;
        char buff[BUFSIZ];
+       char buf2[BUFSIZ];
        /* Route status display. */
        if (use_json) {
                json_status = json_object_new_object();
@@ -6807,11 +6969,14 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
        }
 
        /* print prefix and mask */
-       if (use_json)
+       if (use_json) {
                json_object_string_add(
                        json_net, "addrPrefix",
                        inet_ntop(p->family, &p->u.prefix, buff, BUFSIZ));
-       else
+               json_object_int_add(json_net, "prefixLen", p->prefixlen);
+               prefix2str(p, buf2, PREFIX_STRLEN);
+               json_object_string_add(json_net, "network", buf2);
+       } else
                route_vty_out_route(p, vty, NULL);
 
        /* Print attribute */
@@ -6836,7 +7001,7 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
                                char buf[BUFSIZ];
 
                                json_object_string_add(
-                                       json_net, "netHopGloabal",
+                                       json_net, "nextHopGlobal",
                                        inet_ntop(AF_INET6,
                                                  &attr->mp_nexthop_global, buf,
                                                  BUFSIZ));
@@ -6847,16 +7012,34 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
                                json_object_int_add(json_net, "metric",
                                                    attr->med);
 
-                       if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
+                       if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
+
+                               /*
+                                * Adding "locPrf" field to match with
+                                * corresponding CLI. "localPref" will be
+                                * deprecated in future.
+                                */
                                json_object_int_add(json_net, "localPref",
                                                    attr->local_pref);
+                               json_object_int_add(json_net, "locPrf",
+                                                       attr->local_pref);
+                       }
 
                        json_object_int_add(json_net, "weight", attr->weight);
 
                        /* Print aspath */
-                       if (attr->aspath)
+                       if (attr->aspath) {
+
+                               /*
+                                * Adding "path" field to match with
+                                * corresponding CLI. "localPref" will be
+                                * deprecated in future.
+                                */
                                json_object_string_add(json_net, "asPath",
                                                       attr->aspath->str);
+                               json_object_string_add(json_net, "path",
+                                                       attr->aspath->str);
+                       }
 
                        /* Print origin */
                        json_object_string_add(json_net, "bgpOriginCode",
@@ -7330,6 +7513,18 @@ static void route_vty_out_advertised_to(struct vty *vty, struct peer *peer,
        }
 }
 
+static void route_vty_out_tx_ids(struct vty *vty,
+                                struct bgp_addpath_info_data *d)
+{
+       int i;
+
+       for (i = 0; i < BGP_ADDPATH_MAX; i++) {
+               vty_out(vty, "TX-%s %u%s", bgp_addpath_names(i)->human_name,
+                       d->addpath_tx_id[i],
+                       i < BGP_ADDPATH_MAX - 1 ? " " : "\n");
+       }
+}
+
 void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
                          struct bgp_path_info *path, afi_t afi, safi_t safi,
                          json_object *json_paths)
@@ -7361,6 +7556,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
        unsigned int first_as;
        bool nexthop_self =
                CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
+       int i;
 
        if (json_paths) {
                json_path = json_object_new_object();
@@ -7673,7 +7869,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
                                if (path->extra->bgp_orig->inst_type
                                    == BGP_INSTANCE_TYPE_DEFAULT)
 
-                                       vn = "Default";
+                                       vn = VRF_DEFAULT_NAME;
                                else
                                        vn = path->extra->bgp_orig->name;
 
@@ -7759,10 +7955,18 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
                                bgp_origin_long_str[attr->origin]);
 
                if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) {
-                       if (json_paths)
+                       if (json_paths) {
+
+                               /*
+                                * Adding "metric" field to match with
+                                * corresponding CLI. "med" will be
+                                * deprecated in future.
+                                */
                                json_object_int_add(json_path, "med",
                                                    attr->med);
-                       else
+                               json_object_int_add(json_path, "metric",
+                                                       attr->med);
+                       } else
                                vty_out(vty, ", metric %u", attr->med);
                }
 
@@ -8045,6 +8249,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
                if (path->extra && bgp_is_valid_label(&path->extra->label[0])
                    && safi != SAFI_EVPN) {
                        mpls_label_t label = label_pton(&path->extra->label[0]);
+
                        if (json_paths)
                                json_object_int_add(json_path, "remoteLabel",
                                                    label);
@@ -8063,29 +8268,53 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
                }
 
                /* Line 8 display Addpath IDs */
-               if (path->addpath_rx_id || path->addpath_tx_id) {
+               if (path->addpath_rx_id
+                   || bgp_addpath_info_has_ids(&path->tx_addpath)) {
                        if (json_paths) {
                                json_object_int_add(json_path, "addpathRxId",
                                                    path->addpath_rx_id);
-                               json_object_int_add(json_path, "addpathTxId",
-                                                   path->addpath_tx_id);
+
+                               /* Keep backwards compatibility with the old API
+                                * by putting TX All's ID in the old field
+                                */
+                               json_object_int_add(
+                                       json_path, "addpathTxId",
+                                       path->tx_addpath.addpath_tx_id
+                                               [BGP_ADDPATH_ALL]);
+
+                               /* ... but create a specific field for each
+                                * strategy
+                                */
+                               for (i = 0; i < BGP_ADDPATH_MAX; i++) {
+                                       json_object_int_add(
+                                               json_path,
+                                               bgp_addpath_names(i)
+                                                       ->id_json_name,
+                                               path->tx_addpath
+                                                       .addpath_tx_id[i]);
+                               }
                        } else {
-                               vty_out(vty, "      AddPath ID: RX %u, TX %u\n",
-                                       path->addpath_rx_id,
-                                       path->addpath_tx_id);
+                               vty_out(vty, "      AddPath ID: RX %u, ",
+                                       path->addpath_rx_id);
+
+                               route_vty_out_tx_ids(vty, &path->tx_addpath);
                        }
                }
 
                /* If we used addpath to TX a non-bestpath we need to display
-                * "Advertised to" on a path-by-path basis */
-               if (bgp->addpath_tx_used[afi][safi]) {
+                * "Advertised to" on a path-by-path basis
+                */
+               if (bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
                        first = 1;
 
                        for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
                                addpath_capable =
                                        bgp_addpath_encode_tx(peer, afi, safi);
                                has_adj = bgp_adj_out_lookup(
-                                       peer, path->net, path->addpath_tx_id);
+                                       peer, path->net,
+                                       bgp_addpath_id_for_peer(
+                                               peer, afi, safi,
+                                               &path->tx_addpath));
 
                                if ((addpath_capable && has_adj)
                                    || (!addpath_capable && has_adj
@@ -8204,14 +8433,13 @@ 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;
        unsigned long output_count = 0;
        unsigned long total_count = 0;
        struct prefix *p;
-       char buf[BUFSIZ];
        char buf2[BUFSIZ];
        json_object *json_paths = NULL;
        int first = 1;
@@ -8222,11 +8450,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
        if (use_json && !*json_header_depth) {
                vty_out(vty,
                        "{\n \"vrfId\": %d,\n \"vrfName\": \"%s\",\n \"tableVersion\": %" PRId64
-                       ",\n \"routerId\": \"%s\",\n \"routes\": { ",
+                       ",\n \"routerId\": \"%s\",\n \"defaultLocPrf\": %u,\n"
+                       " \"localAS\": %u,\n \"routes\": { ",
                        bgp->vrf_id == VRF_UNKNOWN ? -1 : (int)bgp->vrf_id,
-                       bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? "Default"
-                                                                   : bgp->name,
-                       table->version, inet_ntoa(bgp->router_id));
+                       bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT
+                                               ? VRF_DEFAULT_NAME
+                                               : bgp->name,
+                       table->version, inet_ntoa(bgp->router_id),
+                       bgp->default_local_pref, bgp->as);
                *json_header_depth = 2;
                if (rd) {
                        vty_out(vty, " \"routeDistinguishers\" : {");
@@ -8240,7 +8471,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
 
        /* Start processing of routes. */
        for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
-               if (rn->info == NULL)
+               pi = bgp_node_get_bgp_path_info(rn);
+               if (pi == NULL)
                        continue;
 
                display = 0;
@@ -8249,19 +8481,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; 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 +8507,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 +8517,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 +8532,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 +8557,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 +8586,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;
                        }
 
@@ -8393,6 +8625,9 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                else
                                        vty_out(vty, "%u", bgp->vrf_id);
                                vty_out(vty, "\n");
+                               vty_out(vty, "Default local pref %u, ",
+                                       bgp->default_local_pref);
+                               vty_out(vty, "local AS %u\n", bgp->as);
                                vty_out(vty, BGP_SHOW_SCODE_HEADER);
                                vty_out(vty, BGP_SHOW_NCODE_HEADER);
                                vty_out(vty, BGP_SHOW_OCODE_HEADER);
@@ -8414,14 +8649,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++;
                }
@@ -8432,14 +8667,32 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                continue;
 
                        p = &rn->p;
-                       sprintf(buf2, "%s/%d",
-                               inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
-                               p->prefixlen);
-                       if (first)
-                               vty_out(vty, "\"%s\": ", buf2);
-                       else
-                               vty_out(vty, ",\"%s\": ", buf2);
-
+                       /* encode prefix */
+                       if (p->family == AF_FLOWSPEC) {
+                               char retstr[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
+
+                               bgp_fs_nlri_get_string((unsigned char *)
+                                                      p->u.prefix_flowspec.ptr,
+                                                      p->u.prefix_flowspec
+                                                      .prefixlen,
+                                                      retstr,
+                                                      NLRI_STRING_FORMAT_MIN,
+                                                      NULL);
+                               if (first)
+                                       vty_out(vty, "\"%s/%d\": ",
+                                               retstr,
+                                               p->u.prefix_flowspec.prefixlen);
+                               else
+                                       vty_out(vty, ",\"%s/%d\": ",
+                                               retstr,
+                                               p->u.prefix_flowspec.prefixlen);
+                       } else {
+                               prefix2str(p, buf2, sizeof(buf2));
+                               if (first)
+                                       vty_out(vty, "\"%s\": ", buf2);
+                               else
+                                       vty_out(vty, ",\"%s\": ", buf2);
+                       }
                        vty_out(vty, "%s",
                                json_object_to_json_string(json_paths));
                        json_object_free(json_paths);
@@ -8491,6 +8744,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
        unsigned long output_cum = 0;
        unsigned long total_cum = 0;
        unsigned long json_header_depth = 0;
+       struct bgp_table *itable;
        bool show_msg;
 
        show_msg = (!use_json && type == bgp_show_type_normal);
@@ -8499,16 +8753,17 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
                next = bgp_route_next(rn);
                if (prd_match && memcmp(rn->p.u.val, prd_match->val, 8) != 0)
                        continue;
-               if (rn->info != NULL) {
+
+               itable = bgp_node_get_bgp_table_info(rn);
+               if (itable != NULL) {
                        struct prefix_rd prd;
                        char rd[RD_ADDRSTRLEN];
 
                        memcpy(&prd, &(rn->p), sizeof(struct prefix_rd));
                        prefix_rd2str(&prd, rd, sizeof(rd));
-                       bgp_show_table(vty, bgp, safi, rn->info, type,
-                                      output_arg, use_json, rd, next == NULL,
-                                      &output_cum, &total_cum,
-                                      &json_header_depth);
+                       bgp_show_table(vty, bgp, safi, itable, type, output_arg,
+                                      use_json, rd, next == NULL, &output_cum,
+                                      &total_cum, &json_header_depth);
                        if (next == NULL)
                                show_msg = false;
                }
@@ -8583,12 +8838,12 @@ static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi,
 
                        vty_out(vty, "\"%s\":",
                                (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
-                                       ? "Default"
+                                       ? VRF_DEFAULT_NAME
                                        : bgp->name);
                } else {
                        vty_out(vty, "\nInstance %s:\n",
                                (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
-                                       ? "Default"
+                                       ? VRF_DEFAULT_NAME
                                        : bgp->name);
                }
                bgp_show(vty, bgp, afi, safi, bgp_show_type_normal, NULL,
@@ -8606,7 +8861,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 +8928,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 = bgp_node_get_bgp_path_info(rn); 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);
                }
        }
@@ -8723,7 +8978,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
                                vty_out(vty, ", table %s",
                                        (bgp->inst_type
                                         == BGP_INSTANCE_TYPE_DEFAULT)
-                                               ? "Default-IP-Routing-Table"
+                                               ? VRF_DEFAULT_NAME
                                                : bgp->name);
                } else
                        vty_out(vty, ", no best path");
@@ -8775,7 +9030,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
         * show what peers we advertised the bestpath to.  If we are using
         * addpath
         * though then we must display Advertised to on a path-by-path basis. */
-       if (!bgp->addpath_tx_used[afi][safi]) {
+       if (!bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
                        if (bgp_adj_out_lookup(peer, rn, 0)) {
                                if (json && !json_adv_to)
@@ -8814,7 +9069,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;
@@ -8837,8 +9092,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
                for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
                        if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
                                continue;
-
-                       if ((table = rn->info) == NULL)
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (!table)
                                continue;
 
                        header = 1;
@@ -8852,7 +9107,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
                                continue;
                        }
 
-                       for (ri = rm->info; ri; ri = ri->next) {
+                       for (pi = bgp_node_get_bgp_path_info(rm); pi;
+                            pi = pi->next) {
                                if (header) {
                                        route_vty_out_detail_header(
                                                vty, bgp, rm,
@@ -8864,15 +9120,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 +9146,8 @@ 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 = bgp_node_get_bgp_path_info(rn); pi;
+                                    pi = pi->next) {
                                        if (header) {
                                                route_vty_out_detail_header(
                                                        vty, bgp, rn, NULL, afi,
@@ -8903,18 +9160,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);
                                }
                        }
@@ -9512,7 +9769,7 @@ static int bgp_show_community(struct vty *vty, struct bgp *bgp,
                       (exact ? bgp_show_type_community_exact
                              : bgp_show_type_community),
                       com, use_json);
-       community_free(com);
+       community_free(&com);
 
        return ret;
 }
@@ -9692,14 +9949,14 @@ 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;
 
-               if (!rn->info)
+               if (!bgp_node_has_bgp_path_info_data(rn))
                        continue;
 
                ts->counts[BGP_STATS_PREFIXES]++;
@@ -9713,7 +9970,7 @@ static int bgp_table_stats_walker(struct thread *t)
 #endif
 
                /* check if the prefix is included by any other announcements */
-               while (prn && !prn->info)
+               while (prn && !bgp_node_has_bgp_path_info_data(prn))
                        prn = bgp_node_parent_nolock(prn);
 
                if (prn == NULL || prn == top) {
@@ -9722,26 +9979,26 @@ static int bgp_table_stats_walker(struct thread *t)
                        if (space)
                                ts->total_space +=
                                        pow(2.0, space - rn->p.prefixlen);
-               } else if (prn->info)
+               } else if (bgp_node_has_bgp_path_info_data(prn))
                        ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
 
-               for (ri = rn->info; ri; ri = ri->next) {
-                       rinum++;
+               for (pi = bgp_node_get_bgp_path_info(rn); 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 +10159,40 @@ 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 = bgp_node_get_bgp_path_info(rn); 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");
@@ -10230,6 +10488,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                            table->version);
                        json_object_string_add(json, "bgpLocalRouterId",
                                               inet_ntoa(bgp->router_id));
+                       json_object_int_add(json, "defaultLocPrf",
+                                               bgp->default_local_pref);
+                       json_object_int_add(json, "localAS", bgp->as);
                        json_object_object_add(json, "bgpStatusCodes",
                                               json_scode);
                        json_object_object_add(json, "bgpOriginCodes",
@@ -10246,6 +10507,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                        else
                                vty_out(vty, "%u", bgp->vrf_id);
                        vty_out(vty, "\n");
+                       vty_out(vty, "Default local pref %u, ",
+                               bgp->default_local_pref);
+                       vty_out(vty, "local AS %u\n", bgp->as);
                        vty_out(vty, BGP_SHOW_SCODE_HEADER);
                        vty_out(vty, BGP_SHOW_NCODE_HEADER);
                        vty_out(vty, BGP_SHOW_OCODE_HEADER);
@@ -10273,6 +10537,11 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                                        "bgpLocalRouterId",
                                                        inet_ntoa(
                                                                bgp->router_id));
+                                               json_object_int_add(json,
+                                               "defaultLocPrf",
+                                               bgp->default_local_pref);
+                                               json_object_int_add(json,
+                                               "localAS", bgp->as);
                                                json_object_object_add(
                                                        json, "bgpStatusCodes",
                                                        json_scode);
@@ -10291,6 +10560,11 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                                        vty_out(vty, "%u",
                                                                bgp->vrf_id);
                                                vty_out(vty, "\n");
+                                               vty_out(vty,
+                                               "Default local pref %u, ",
+                                               bgp->default_local_pref);
+                                               vty_out(vty, "local AS %u\n",
+                                               bgp->as);
                                                vty_out(vty,
                                                        BGP_SHOW_SCODE_HEADER);
                                                vty_out(vty,
@@ -10336,7 +10610,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                output_count++;
                        }
                } else if (type == bgp_show_adj_route_advertised) {
-                       for (adj = rn->adj_out; adj; adj = adj->next)
+                       RB_FOREACH (adj, bgp_adj_out_rb, &rn->adj_out)
                                SUBGRP_FOREACH_PEER (adj->subgroup, paf) {
                                        if (paf->peer != peer || !adj->attr)
                                                continue;
@@ -10352,6 +10626,13 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                                                "bgpLocalRouterId",
                                                                inet_ntoa(
                                                                        bgp->router_id));
+                                                       json_object_int_add(
+                                                       json, "defaultLocPrf",
+                                                       bgp->default_local_pref
+                                                       );
+                                                       json_object_int_add(
+                                                       json, "localAS",
+                                                       bgp->as);
                                                        json_object_object_add(
                                                                json,
                                                                "bgpStatusCodes",
@@ -10377,6 +10658,13 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                                                "%u",
                                                                bgp->vrf_id);
                                                        vty_out(vty, "\n");
+                                                       vty_out(vty,
+                                                       "Default local pref %u, ",
+                                                       bgp->default_local_pref
+                                                       );
+                                                       vty_out(vty,
+                                                       "local AS %u\n",
+                                                       bgp->as);
                                                        vty_out(vty,
                                                                BGP_SHOW_SCODE_HEADER);
                                                        vty_out(vty,
@@ -10809,12 +11097,12 @@ static int bgp_distance_set(struct vty *vty, const char *distance_str,
 
        /* Get BGP distance node. */
        rn = bgp_node_get(bgp_distance_table[afi][safi], (struct prefix *)&p);
-       bdistance = bgp_distance_get_node(rn);
+       bdistance = bgp_node_get_bgp_distance_info(rn);
        if (bdistance)
                bgp_unlock_node(rn);
        else {
                bdistance = bgp_distance_new();
-               bgp_distance_set_node_info(rn, bdistance);
+               bgp_node_set_bgp_distance_info(rn, bdistance);
        }
 
        /* Set distance value. */
@@ -10859,7 +11147,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       bdistance = bgp_distance_get_node(rn);
+       bdistance = bgp_node_get_bgp_distance_info(rn);
        distance = atoi(distance_str);
 
        if (bdistance->distance != distance) {
@@ -10871,7 +11159,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
                XFREE(MTYPE_AS_LIST, bdistance->access_list);
        bgp_distance_free(bdistance);
 
-       rn->info = NULL;
+       bgp_node_set_bgp_path_info(rn, NULL);
        bgp_unlock_node(rn);
        bgp_unlock_node(rn);
 
@@ -10879,7 +11167,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,13 +11180,13 @@ 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);
        rn = bgp_node_match(bgp_distance_table[afi][safi], &q);
        if (rn) {
-               bdistance = bgp_distance_get_node(rn);
+               bdistance = bgp_node_get_bgp_distance_info(rn);
                bgp_unlock_node(rn);
 
                if (bdistance->access_list) {
@@ -10913,7 +11201,7 @@ uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *rinfo,
        /* Backdoor check. */
        rn = bgp_node_lookup(bgp->route[afi][safi], p);
        if (rn) {
-               bgp_static = bgp_static_get_node_info(rn);
+               bgp_static = bgp_node_get_bgp_static_info(rn);
                bgp_unlock_node(rn);
 
                if (bgp_static->backdoor) {
@@ -11158,8 +11446,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;
 
@@ -11194,23 +11482,24 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
                     rn = bgp_route_next(rn)) {
                        if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
                                continue;
-                       if ((table = rn->info) == NULL)
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (!table)
                                continue;
                        if ((rm = bgp_node_match(table, &match)) == NULL)
                                continue;
 
                        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 = bgp_node_get_bgp_path_info(rm);
+                               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 +11510,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 = bgp_node_get_bgp_path_info(rn);
+                               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;
                                }
                        }
 
@@ -11307,6 +11596,36 @@ DEFUN (clear_ip_bgp_dampening_address_mask,
                                    NULL, 0);
 }
 
+static void show_bgp_peerhash_entry(struct hash_backet *backet, void *arg)
+{
+       struct vty *vty = arg;
+       struct peer *peer = backet->data;
+       char buf[SU_ADDRSTRLEN];
+
+       vty_out(vty, "\tPeer: %s %s\n", peer->host,
+              sockunion2str(&peer->su, buf, sizeof(buf)));
+}
+
+DEFUN (show_bgp_peerhash,
+       show_bgp_peerhash_cmd,
+       "show bgp peerhash",
+       SHOW_STR
+       BGP_STR
+       "Display information about the BGP peerhash\n")
+{
+       struct list *instances = bm->bgp;
+       struct listnode *node;
+       struct bgp *bgp;
+
+       for (ALL_LIST_ELEMENTS_RO(instances, node, bgp)) {
+               vty_out(vty, "BGP: %s\n", bgp->name);
+               hash_iterate(bgp->peerhash, show_bgp_peerhash_entry,
+                            vty);
+       }
+
+       return CMD_SUCCESS;
+}
+
 /* also used for encap safi */
 static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
                                         afi_t afi, safi_t safi)
@@ -11324,11 +11643,12 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
        /* Network configuration. */
        for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
             prn = bgp_route_next(prn)) {
-               if ((table = prn->info) == NULL)
+               table = bgp_node_get_bgp_table_info(prn);
+               if (!table)
                        continue;
 
                for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
-                       bgp_static = bgp_static_get_node_info(rn);
+                       bgp_static = bgp_node_get_bgp_static_info(rn);
                        if (bgp_static == NULL)
                                continue;
 
@@ -11374,11 +11694,12 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
        /* Network configuration. */
        for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
             prn = bgp_route_next(prn)) {
-               if ((table = prn->info) == NULL)
+               table = bgp_node_get_bgp_table_info(prn);
+               if (!table)
                        continue;
 
                for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
-                       bgp_static = bgp_static_get_node_info(rn);
+                       bgp_static = bgp_node_get_bgp_static_info(rn);
                        if (bgp_static == NULL)
                                continue;
 
@@ -11454,7 +11775,7 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
        /* Network configuration. */
        for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
             rn = bgp_route_next(rn)) {
-               bgp_static = bgp_static_get_node_info(rn);
+               bgp_static = bgp_node_get_bgp_static_info(rn);
                if (bgp_static == NULL)
                        continue;
 
@@ -11501,7 +11822,7 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
        /* Aggregate-address configuration. */
        for (rn = bgp_table_top(bgp->aggregate[afi][safi]); rn;
             rn = bgp_route_next(rn)) {
-               bgp_aggregate = bgp_aggregate_get_node_info(rn);
+               bgp_aggregate = bgp_node_get_bgp_aggregate_info(rn);
                if (bgp_aggregate == NULL)
                        continue;
 
@@ -11553,7 +11874,7 @@ void bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
 
        for (rn = bgp_table_top(bgp_distance_table[afi][safi]); rn;
             rn = bgp_route_next(rn)) {
-               bdistance = bgp_distance_get_node(rn);
+               bdistance = bgp_node_get_bgp_distance_info(rn);
                if (bdistance != NULL) {
                        char buf[PREFIX_STRLEN];
 
@@ -11701,6 +12022,7 @@ void bgp_route_init(void)
        /* show bgp ipv4 flowspec detailed */
        install_element(VIEW_NODE, &show_ip_bgp_flowspec_routes_detailed_cmd);
 
+       install_element(VIEW_NODE, &show_bgp_peerhash_cmd);
 }
 
 void bgp_route_finish(void)