]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Abstract bgp_table retrieving/setting from info pointer
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 26 Sep 2018 00:37:16 +0000 (20:37 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Nov 2018 14:43:35 +0000 (09:43 -0500)
Convert the set/get of bgp_table's from the info pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
14 files changed:
bgpd/bgp_evpn.c
bgpd/bgp_evpn_vty.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_route.c
bgpd/bgp_table.h
bgpd/bgp_updgrp_adv.c
bgpd/bgp_vpn.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/rfapi/rfapi.c
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/vnc_export_bgp.c
bgpd/rfapi/vnc_import_bgp.c
bgpd/rfapi/vnc_zebra.c

index 729e61a56fd412677ca8141b1e71df9dd10bd57d..7d11cb71d1a9e7b19b5309531e4ca49630b02e84 100644 (file)
@@ -2134,7 +2134,7 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
 
        rdrn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd);
        if (rdrn && bgp_node_has_bgp_path_info_data(rdrn)) {
-               table = (struct bgp_table *)rdrn->info;
+               table = bgp_node_get_bgp_table_info(rdrn);
                for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
                        struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
 
@@ -2908,7 +2908,7 @@ static int install_uninstall_routes_for_es(struct bgp *bgp,
         */
        for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
             rd_rn = bgp_route_next(rd_rn)) {
-               table = (struct bgp_table *)(rd_rn->info);
+               table = bgp_node_get_bgp_table_info(rd_rn);
                if (!table)
                        continue;
 
@@ -2981,7 +2981,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
         */
        for (rd_rn = bgp_table_top(bgp_def->rib[afi][safi]); rd_rn;
             rd_rn = bgp_route_next(rd_rn)) {
-               table = (struct bgp_table *)(rd_rn->info);
+               table = bgp_node_get_bgp_table_info(rd_rn);
                if (!table)
                        continue;
 
@@ -3065,7 +3065,7 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp,
        /* EVPN routes are a 2-level table. */
        for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
             rd_rn = bgp_route_next(rd_rn)) {
-               table = (struct bgp_table *)(rd_rn->info);
+               table = bgp_node_get_bgp_table_info(rd_rn);
                if (!table)
                        continue;
 
@@ -5230,7 +5230,7 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
        /* EVPN routes are a 2-level table. */
        for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
             rd_rn = bgp_route_next(rd_rn)) {
-               table = (struct bgp_table *)(rd_rn->info);
+               table = bgp_node_get_bgp_table_info(rd_rn);
                if (!table)
                        continue;
 
index d26a2e98e6252e5ba4c15b89bf63dc6a11c207ff..f37c4f651a4d7e62408164221204eccf7ee0a5f5 100644 (file)
@@ -1041,7 +1041,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
                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;
 
                rd_header = 1;
@@ -2039,7 +2040,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
        /* See if route exists. */
        build_evpn_type3_prefix(&p, orig_ip);
        rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
-       if (!rn || !rn->info) {
+       if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
                if (!json)
                        vty_out(vty, "%% Network not in table\n");
                return;
@@ -2109,7 +2110,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
        /* See if route exists. Look for both non-sticky and sticky. */
        build_evpn_type2_prefix(&p, mac, ip);
        rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
-       if (!rn || !rn->info) {
+       if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
                if (!json)
                        vty_out(vty, "%% Network not in table\n");
                return;
@@ -2213,7 +2214,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
        build_evpn_type2_prefix(&p, mac, ip);
        rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
                                 (struct prefix *)&p, prd);
-       if (!rn || !rn->info) {
+       if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
                if (!json)
                        vty_out(vty, "%% Network not in table\n");
                return;
@@ -2284,7 +2285,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
        if (!rd_rn)
                return;
 
-       table = (struct bgp_table *)rd_rn->info;
+       table = bgp_node_get_bgp_table_info(rd_rn);
        if (table == NULL)
                return;
 
@@ -2408,7 +2409,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
                int add_rd_to_json = 0;
                uint64_t tbl_ver;
 
-               table = (struct bgp_table *)rd_rn->info;
+               table = bgp_node_get_bgp_table_info(rd_rn);
                if (table == NULL)
                        continue;
 
index 24ac4ca07806c0e87f4c4cf6dfa3cb4f456017b9..c763d9fc726943294ff5274a22d25930754a20cd 100644 (file)
@@ -961,7 +961,7 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
                struct bgp_path_info *bpi;
 
                /* This is the per-RD table of prefixes */
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
 
                if (!table)
                        continue;
@@ -1381,7 +1381,7 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
                memcpy(prd.val, prn->p.u.val, 8);
 
                /* This is the per-RD table of prefixes */
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
 
                if (!table)
                        continue;
index b59a59e6a70dec2b5b74f5b3634d450a01f3c0b2..8cb65262cd971407ea0155f405a2fe855b85203f 100644 (file)
@@ -120,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);
@@ -157,7 +158,7 @@ struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
                        return NULL;
                }
 
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
        }
 
        rn = bgp_node_lookup(table, p);
@@ -2743,8 +2744,8 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *pi,
 
                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, pi);
@@ -3174,8 +3175,8 @@ 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, pi);
@@ -3324,8 +3325,8 @@ 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, pi);
@@ -3461,8 +3462,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);
@@ -3802,9 +3803,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);
@@ -3812,6 +3815,7 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
                                bgp_soft_reconfig_table(peer, afi, safi, table,
                                                        &prd);
                        }
+               }
 }
 
 
@@ -4031,9 +4035,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)
@@ -4093,7 +4101,8 @@ 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;
@@ -4154,6 +4163,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)
@@ -4168,26 +4178,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);
                                }
                        }
@@ -4195,12 +4201,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);
                }
        }
@@ -5007,12 +5012,12 @@ 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)) {
@@ -5044,12 +5049,12 @@ 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)) {
@@ -5086,12 +5091,12 @@ 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)) {
@@ -5227,15 +5232,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 {
@@ -5325,11 +5331,12 @@ 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);
 
@@ -6020,7 +6027,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);
@@ -8722,6 +8729,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);
@@ -8730,16 +8738,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;
                }
@@ -9068,8 +9077,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;
@@ -11428,7 +11437,8 @@ 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;
@@ -11588,7 +11598,8 @@ 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)) {
@@ -11638,7 +11649,8 @@ 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)) {
index 87fbc39f4305b5562044bc8a9809e93be55fe7eb..ee21e74a157f7e8b174a3f554d249f69bac7b95d 100644 (file)
@@ -388,6 +388,18 @@ static inline void bgp_node_set_bgp_path_info(struct bgp_node *node,
        node->info = bi;
 }
 
+static inline struct bgp_table *
+bgp_node_get_bgp_table_info(struct bgp_node *node)
+{
+       return node->info;
+}
+
+static inline void bgp_node_set_bgp_table_info(struct bgp_node *node,
+                                              struct bgp_table *table)
+{
+       node->info = table;
+}
+
 static inline bool bgp_node_has_bgp_path_info_data(struct bgp_node *node)
 {
        return !!node->info;
index ff7d18761ca3302ad5fcf783cac55561b0316045..a6542f48a01b17134c025d9231df9adfe43570ed 100644 (file)
@@ -690,9 +690,12 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
                subgroup_announce_table(subgrp, NULL);
        else
                for (rn = bgp_table_top(update_subgroup_rib(subgrp)); rn;
-                    rn = bgp_route_next(rn))
-                       if ((table = (rn->info)) != NULL)
-                               subgroup_announce_table(subgrp, table);
+                    rn = bgp_route_next(rn)) {
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (!table)
+                               continue;
+                       subgroup_announce_table(subgrp, table);
+               }
 }
 
 void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
index 99bcefe70c83cd32946148a9d71f6073df2789e8..21f289fb9f64c1d2493c227063f861da2b42c57d 100644 (file)
@@ -79,7 +79,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
                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 != NULL) {
                        if (use_json)
                                json_array = json_object_new_array();
                        else
index 4dd148bb413984744b9c6b84dbe8d19935eb71bf..da28fdb1939c1b46a9333cb30187114dd1d416c3 100644 (file)
@@ -7209,7 +7209,9 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
                        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 != NULL) {
+
                                if ((rm = bgp_node_match(table, &match))
                                    != NULL) {
                                        if (rm->p.prefixlen
index a078c4f58743b8c7065f241556709a109941cc7e..e2229afa05a97bafd825bd844635f47061513248 100644 (file)
@@ -1432,16 +1432,17 @@ static void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi,
                                               safi_t safi)
 {
        struct bgp_node *rn, *nrn;
+       struct bgp_table *table;
 
        for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
             rn = bgp_route_next(rn)) {
-               if (rn->info != NULL) {
+               table = bgp_node_get_bgp_table_info(rn);
+               if (table != NULL) {
                        /* Special handling for 2-level routing
                         * tables. */
                        if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
                            || safi == SAFI_EVPN) {
-                               for (nrn = bgp_table_top(
-                                            (struct bgp_table *)(rn->info));
+                               for (nrn = bgp_table_top(table);
                                     nrn; nrn = bgp_route_next(nrn))
                                        bgp_process(bgp, nrn, afi, safi);
                        } else
@@ -3319,7 +3320,7 @@ void bgp_free(struct bgp *bgp)
                    || safi == SAFI_EVPN) {
                        for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
                             rn = bgp_route_next(rn)) {
-                               table = (struct bgp_table *)rn->info;
+                               table = bgp_node_get_bgp_table_info(rn);
                                bgp_table_finish(&table);
                        }
                }
index 4fffe94a8368dd4f005194b14937641fe9865eb1..a41473fa4ff8a6691306f8c2a5c24b997bda2239 100644 (file)
@@ -472,12 +472,10 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
 
                        prn = bgp_node_get(bgp->rib[afi][safi],
                                           (struct prefix *)prd);
-                       if (prn->info) {
-                               table = (struct bgp_table *)(prn->info);
-
+                       table = bgp_node_get_bgp_table_info(prn);
+                       if (table)
                                vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
                                        bgp, prd, table, p, bpi);
-                       }
                        bgp_unlock_node(prn);
                }
 
@@ -1018,12 +1016,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
 
                                prn = bgp_node_get(bgp->rib[afi][safi],
                                                   (struct prefix *)prd);
-                               if (prn->info) {
-                                       table = (struct bgp_table *)(prn->info);
-
+                               table = bgp_node_get_bgp_table_info(prn);
+                               if (table)
                                        vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
                                                bgp, prd, table, p, bpi);
-                               }
                                bgp_unlock_node(prn);
                        }
 
@@ -1043,12 +1039,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
 
                                prn = bgp_node_get(bgp->rib[afi][safi],
                                                   (struct prefix *)prd);
-                               if (prn->info) {
-                                       table = (struct bgp_table *)(prn->info);
-
+                               table = bgp_node_get_bgp_table_info(prn);
+                               if (table)
                                        vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
                                                bgp, prd, table, p, bpi);
-                               }
                                bgp_unlock_node(prn);
                        }
 
@@ -1094,12 +1088,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
                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);
-
+               table = bgp_node_get_bgp_table_info(prn);
+               if (table)
                        vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
                                bgp, prd, table, p, new);
-               }
                bgp_unlock_node(prn);
                encode_label(label_val, &bn->local_label);
        }
@@ -3697,10 +3689,13 @@ static void rfapi_print_exported(struct bgp *bgp)
 
        for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rdn;
             rdn = bgp_route_next(rdn)) {
-               if (!rdn->info)
+               struct bgp_table *table;
+
+               table = bgp_node_get_bgp_table_info(rdn);
+               if (!table)
                        continue;
                fprintf(stderr, "%s: vpn rdn=%p\n", __func__, rdn);
-               for (rn = bgp_table_top(rdn->info); rn;
+               for (rn = bgp_table_top(table); rn;
                     rn = bgp_route_next(rn)) {
                        bpi = bgp_node_get_bgp_path_info(rn);
 
@@ -3714,10 +3709,13 @@ static void rfapi_print_exported(struct bgp *bgp)
        }
        for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_ENCAP]); rdn;
             rdn = bgp_route_next(rdn)) {
-               if (!rdn->info)
+               struct bgp_table *table;
+
+               table = bgp_node_get_bgp_table_info(rdn);
+               if (!table)
                        continue;
                fprintf(stderr, "%s: encap rdn=%p\n", __func__, rdn);
-               for (rn = bgp_table_top(rdn->info); rn;
+               for (rn = bgp_table_top(table)); rn;
                     rn = bgp_route_next(rn)) {
                        bpi = bgp_node_get_bgp_path_info(rn);
                        if (!bpi)
index aa20a9d36cf7c71274466cb6519be6c95945d7d7..c49b6e354db635a5ce17988ae15f66b96a5dc047 100644 (file)
@@ -4246,7 +4246,7 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
 
                if (bgp_node_has_bgp_path_info_data(rn1)) {
 
-                       for (rn2 = bgp_table_top(rn1->info); rn2;
+                       for (rn2 = bgp_table_top(bgp_node_get_bgp_table_info(rn1)); rn2;
                             rn2 = bgp_route_next(rn2)) {
 
                                struct bgp_path_info *bpi;
index 9f55634aac467dfa9699da54931851c93d7126bb..3d8d5bccb0febfa42e6758985ce82c009d1faf7f 100644 (file)
@@ -1847,7 +1847,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
                memcpy(prd.val, prn->p.u.val, 8);
 
                /* This is the per-RD table of prefixes */
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
 
                if (!table)
                        continue;
index e54e3b615194f61ce451dfc6aca3182051e3cc30..eb2d0fd8894666f3a7732a6e135ce8dcf0a8dc59 100644 (file)
@@ -676,7 +676,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
 
                struct bgp_table *table;
 
-               table = (struct bgp_table *)(bnp->info);
+               table = bgp_node_get_bgp_table_info(bnp);
 
                if (!table)
                        continue;
@@ -1377,7 +1377,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
 
                struct bgp_table *table;
 
-               table = (struct bgp_table *)(bnp->info);
+               table = bgp_node_get_bgp_table_info(bnp);
 
                if (!table)
                        continue;
@@ -2907,8 +2907,9 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
 
                if (bgp_node_has_bgp_path_info_data(rn1)) {
 
-                       for (rn2 = bgp_table_top(rn1->info); rn2;
-                            rn2 = bgp_route_next(rn2)) {
+                       for (rn2 = bgp_table_top(
+                                    bgp_node_get_bgp_table_info(rn1));
+                            rn2; rn2 = bgp_route_next(rn2)) {
 
                                struct bgp_path_info *bpi;
                                struct bgp_path_info *nextbpi;
index 77bec4842a7f39b2749f5c374918828ecfc94925..98f719969c0cb1ff6b1e7c921199f1f38370a400 100644 (file)
@@ -312,7 +312,7 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
                memcpy(prd.val, prn->p.u.val, 8);
 
                /* This is the per-RD table of prefixes */
-               table = prn->info;
+               table = bgp_node_get_bgp_table_info(prn);
                if (!table)
                        continue;