]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: Create/Use accessor functions for lock count
authorDonald Sharp <sharpd@nvidia.com>
Wed, 14 Oct 2020 16:44:23 +0000 (12:44 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Sat, 17 Oct 2020 17:39:10 +0000 (13:39 -0400)
Create appropriate accessor functions for the rn->lock
data.  We should be accessing this data through accessor
functions since it is private data to the data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
15 files changed:
bgpd/bgp_evpn.c
bgpd/bgp_route.c
bgpd/bgp_table.h
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/rfapi_rib.c
bgpd/rfapi/rfapi_vty.c
lib/agg_table.h
lib/routemap.c
lib/table.c
lib/table.h
ospf6d/ospf6_route.c
ospfd/ospf_neighbor.c
pimd/pim_rp.c
tests/lib/test_srcdest_table.c
zebra/zebra_rib.c

index 7f9ef0c9cdbf4cdb0f2c97156f9f613b8ade646c..8f65b3afbab805fefe40cf6d27890013582d2589 100644 (file)
@@ -2481,11 +2481,10 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
        bgp_dest_unlock_node(dest);
 
        if (bgp_debug_zebra(NULL))
-               zlog_debug(
-                       "... %s pi dest %p (l %d) pi %p (l %d, f 0x%x)",
-                       new_pi ? "new" : "update",
-                       dest, bgp_dest_to_rnode(dest)->lock,
-                       pi, pi->lock, pi->flags);
+               zlog_debug("... %s pi dest %p (l %d) pi %p (l %d, f 0x%x)",
+                          new_pi ? "new" : "update", dest,
+                          bgp_dest_get_lock_count(dest), pi, pi->lock,
+                          pi->flags);
 
        return ret;
 }
@@ -2620,10 +2619,9 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
                return 0;
 
        if (bgp_debug_zebra(NULL))
-               zlog_debug(
-                       "... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
-                       dest, bgp_dest_to_rnode(dest)->lock,
-                       pi, pi->lock, pi->flags);
+               zlog_debug("... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
+                          dest, bgp_dest_get_lock_count(dest), pi, pi->lock,
+                          pi->flags);
 
        /* Process for route leaking. */
        vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp_vrf, pi);
index 73f5526fe254da2b2122f69ed2a6988975695721..f998a4d3509a45d2081a2752a8ec797dc6b619db 100644 (file)
@@ -216,7 +216,7 @@ void bgp_path_info_extra_free(struct bgp_path_info_extra **extra)
                        unsigned refcount;
 
                        bpi = bgp_path_info_lock(bpi);
-                       refcount = bpi->net->lock - 1;
+                       refcount = bgp_dest_get_lock_count(bpi->net) - 1;
                        bgp_dest_unlock_node((struct bgp_dest *)bpi->net);
                        if (!refcount)
                                bpi->net = NULL;
index 31ea5554d585e4ff4f99725778fa3ff92c3df155..9dd27628ceb500bc16ca3d73d5333c4107d598e1 100644 (file)
@@ -469,6 +469,11 @@ static inline const struct prefix *bgp_dest_get_prefix(const struct bgp_dest *de
        return &dest->p;
 }
 
+static inline unsigned int bgp_dest_get_lock_count(const struct bgp_dest *dest)
+{
+       return dest->lock;
+}
+
 #ifdef _FRR_ATTRIBUTE_PRINTFRR
 #pragma FRR printfrr_ext "%pRN"  (struct bgp_node *)
 #pragma FRR printfrr_ext "%pBD"  (struct bgp_dest *)
index c3ad95ff28d4b7f0a351ffd1134a3efbf09d3299..1e8a381e2da4db76b8058e720d042a6aa48073b7 100644 (file)
@@ -265,11 +265,12 @@ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset)
                }
        }
 
-       if (count_bpi + count_monitor + lockoffset != rn->lock) {
+       if (count_bpi + count_monitor + lockoffset
+           != agg_node_get_lock_count(rn)) {
                vnc_zlog_debug_verbose(
                        "%s: count_bpi=%d, count_monitor=%d, lockoffset=%d, rn->lock=%d",
                        __func__, count_bpi, count_monitor, lockoffset,
-                       rn->lock);
+                       agg_node_get_lock_count(rn));
                assert(0);
        }
 }
@@ -3665,7 +3666,8 @@ void rfapiBgpInfoFilteredImportVPN(
        }
 
        vnc_zlog_debug_verbose("%s: inserting bpi %p at prefix %pRN #%d",
-                              __func__, info_new, rn, rn->lock);
+                              __func__, info_new, rn,
+                              agg_node_get_lock_count(rn));
 
        rfapiBgpInfoAttachSorted(rn, info_new, afi, SAFI_MPLS_VPN);
        rfapiItBiIndexAdd(rn, info_new);
index e068eb7af62ce8a74e7416b08c65582c8e225d99..8109e7e3d735a04895e38595ca946259f20999ba 100644 (file)
@@ -802,7 +802,7 @@ int rfapiRibPreloadBi(
         */
        trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */
        trn->info = (void *)(uintptr_t)bgp_clock();
-       if (trn->lock > 1)
+       if (agg_node_get_lock_count(trn) > 1)
                agg_unlock_node(trn);
 
        return 0;
@@ -1242,7 +1242,7 @@ callback:
                        trn = agg_node_get(rfd->rsp_times[afi],
                                           p); /* locks trn */
                        trn->info = (void *)(uintptr_t)bgp_clock();
-                       if (trn->lock > 1)
+                       if (agg_node_get_lock_count(trn) > 1)
                                agg_unlock_node(trn);
 
                        rfapiRfapiIpAddr2Str(&new->vn_address, buf, BUFSIZ);
@@ -1833,7 +1833,7 @@ int rfapiRibFTDFilterRecentPrefix(
         */
        trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */
        prefix_time = (time_t)trn->info;
-       if (trn->lock > 1)
+       if (agg_node_get_lock_count(trn) > 1)
                agg_unlock_node(trn);
 
 #ifdef DEBUG_FTD_FILTER_RECENT
@@ -2069,7 +2069,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
                 */
                trn = agg_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */
                trn->info = (void *)(uintptr_t)bgp_clock();
-               if (trn->lock > 1)
+               if (agg_node_get_lock_count(trn) > 1)
                        agg_unlock_node(trn);
 
                {
index d74404ea564d518986d205d2778cea11af1acb2c..850e8325c90ca12902f22d57d97c030e3f8bc968 100644 (file)
@@ -751,7 +751,7 @@ void rfapiShowItNode(void *stream, struct agg_node *rn)
        if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
                return;
 
-       fp(out, "%pRN @%p #%d%s", rn, rn, rn->lock, HVTYNL);
+       fp(out, "%pRN @%p #%d%s", rn, rn, agg_node_get_lock_count(rn), HVTYNL);
 
        for (bpi = rn->info; bpi; bpi = bpi->next) {
                rfapiPrintBi(stream, bpi);
@@ -787,7 +787,8 @@ void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt,
                }
 
                fp(out, "%s/%d @%p #%d%s", buf, p->prefixlen, rn,
-                  rn->lock - 1, /* account for loop iterator locking */
+                  agg_node_get_lock_count(rn)
+                          - 1, /* account for loop iterator locking */
                   HVTYNL);
 
                for (bpi = rn->info; bpi; bpi = bpi->next) {
index e98476f1b7d3e0cda389daa41c866194dcc97177..e0c06449eee22efd97c989b95b11fe1fec86797a 100644 (file)
@@ -161,6 +161,11 @@ agg_node_get_prefix(const struct agg_node *node)
        return &node->p;
 }
 
+static inline unsigned int agg_node_get_lock_count(const struct agg_node *node)
+{
+       return node->lock;
+}
+
 #ifdef _FRR_ATTRIBUTE_PRINTFRR
 #pragma FRR printfrr_ext "%pRN"  (struct agg_node *)
 #endif
index fb70860024d0b0af3a1ede3eaf9db392ebc665f1..3bac243ceed8a0496dcec4fabda1dd5da7805680 100644 (file)
@@ -3176,7 +3176,8 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
                                vty_out(vty, "    %s/%d (%d)\n",
                                        inet_ntop(p->family, &p->u.prefix, buf,
                                                  SU_ADDRSTRLEN),
-                                       p->prefixlen, rn->lock);
+                                       p->prefixlen,
+                                       route_node_get_lock_count(rn));
 
                                vty_out(vty, "(P) ");
                                prn = rn->parent;
@@ -3220,7 +3221,8 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
                                vty_out(vty, "    %s/%d (%d)\n",
                                        inet_ntop(p->family, &p->u.prefix, buf,
                                                  SU_ADDRSTRLEN),
-                                       p->prefixlen, rn->lock);
+                                       p->prefixlen,
+                                       route_node_get_lock_count(rn));
 
                                vty_out(vty, "(P) ");
                                prn = rn->parent;
index 86347cbacda11cde88b0e19de42fc5cd56f92a6f..b315637f19861fce2beb5ec2d47a9354cebb940f 100644 (file)
@@ -119,7 +119,8 @@ static void route_table_free(struct route_table *rt)
                node = node->parent;
 
                tmp_node->table->count--;
-               tmp_node->lock = 0; /* to cause assert if unlocked after this */
+               tmp_node->lock =
+                       0; /* to cause assert if unlocked after this */
                rn_hash_node_del(&rt->hash, tmp_node);
                route_node_free(rt, tmp_node);
 
index 9cd950337607947ede53dac465ec5250a7b6a16a..5d620d332b93379d37eeede238a6f954921ab6e5 100644 (file)
@@ -262,6 +262,11 @@ static inline void route_unlock_node(struct route_node *node)
                route_node_delete(node);
 }
 
+static inline unsigned int route_node_get_lock_count(struct route_node *node)
+{
+       return node->lock;
+}
+
 /*
  * route_table_iter_next
  *
index a443e4c3ba06808b024b942d0e654be0758150a9..4044cdc549f2197dd6a67b81027efc60bcf3c38c 100644 (file)
@@ -714,7 +714,7 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
                                "%s %p: route add %p cost %u: another path: prev %p, next %p node ref %u",
                                ospf6_route_table_name(table), (void *)table,
                                (void *)route, route->path.cost, (void *)prev,
-                               (void *)next, node->lock);
+                               (void *)next, route_node_get_lock_count(node));
                else if (IS_OSPF6_DEBUG_ROUTE(TABLE))
                        zlog_debug("%s: route add cost %u: another path found",
                                   ospf6_route_table_name(table),
index b0ff40afe5d94e296cc496431bebb3fb3e72258f..52ee21473df584356c2841b81fe0f1b94e63f38b 100644 (file)
@@ -285,7 +285,8 @@ void ospf_nbr_add_self(struct ospf_interface *oi, struct in_addr router_id)
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
                                "router_id %s already present in neighbor table. node refcount %u",
-                               inet_ntoa(router_id), rn->lock);
+                               inet_ntoa(router_id),
+                               route_node_get_lock_count(rn));
                route_unlock_node(rn);
        } else
                rn->info = oi->nbr_self;
index 93fe787a93cda97e717cf7458fcc6b9d188de438..11e6d47fc9cad3c493027ecfd39ccd5e6c00dab5 100644 (file)
@@ -134,7 +134,7 @@ void pim_rp_init(struct pim_instance *pim)
        if (PIM_DEBUG_PIM_TRACE)
                zlog_debug(
                        "Allocated: %p for rp_info: %p(224.0.0.0/4) Lock: %d",
-                       rn, rp_info, rn->lock);
+                       rn, rp_info, route_node_get_lock_count(rn));
 }
 
 void pim_rp_free(struct pim_instance *pim)
@@ -254,7 +254,7 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
                zlog_debug("Lookedup: %p for rp_info: %p(%s) Lock: %d", rn,
                           rp_info,
                           prefix2str(&rp_info->group, buf, sizeof(buf)),
-                          rn->lock);
+                          route_node_get_lock_count(rn));
        }
 
        route_unlock_node(rn);
@@ -649,7 +649,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
                zlog_debug("Allocated: %p for rp_info: %p(%s) Lock: %d", rn,
                           rp_info,
                           prefix2str(&rp_info->group, buf, sizeof(buf)),
-                          rn->lock);
+                          route_node_get_lock_count(rn));
        }
 
        frr_each (rb_pim_upstream, &pim->upstream_head, up) {
@@ -845,7 +845,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
                                        __func__, rn, rp_info,
                                        prefix2str(&rp_info->group, buf,
                                                   sizeof(buf)),
-                                       rn->lock);
+                                       route_node_get_lock_count(rn));
                        }
                        rn->info = NULL;
                        route_unlock_node(rn);
index dbfe8533655af1bce207e6cf6e877b060828b2f3..097da113ab0e712f4e3c4b84e5d85810b5c66403 100644 (file)
@@ -271,7 +271,7 @@ static void test_state_verify(struct test_state *test)
                                                       associated with rn */
                                expected_lock++;
 
-                       if (rn->lock != expected_lock)
+                       if (route_node_get_lock_count(rn) != expected_lock)
                                test_failed(
                                        test,
                                        "Dest rnode lock count doesn't match expected count!",
@@ -283,7 +283,7 @@ static void test_state_verify(struct test_state *test)
                            != NULL) /* The route node is not internal */
                                expected_lock++;
 
-                       if (rn->lock != expected_lock) {
+                       if (route_node_get_lock_count(rn) != expected_lock) {
                                srcdest_rnode_prefixes(
                                        rn, (const struct prefix **)&dst_p,
                                        (const struct prefix **)&src_p);
index 8b375e44b634e4cac7c5f021dfc61fbd054b1d50..0503748a69f4c2f972ac1b8a6e7e52f0a1956d97 100644 (file)
@@ -2294,7 +2294,7 @@ static void process_subq_route(struct listnode *lnode, uint8_t qindex)
   else
     {
       zlog_debug ("%s: called for route_node (%p, %d) with no ribs",
-                  __func__, rnode, rnode->lock);
+                  __func__, rnode, route_node_get_lock_count(rnode));
       zlog_backtrace(LOG_DEBUG);
     }
 #endif
@@ -2469,8 +2469,8 @@ int rib_queue_add(struct route_node *rn)
        /* Pointless to queue a route_node with no RIB entries to add or remove
         */
        if (!rnode_to_ribs(rn)) {
-               zlog_debug("%s: called for route_node (%p, %d) with no ribs",
-                          __func__, (void *)rn, rn->lock);
+               zlog_debug("%s: called for route_node (%p, %u) with no ribs",
+                          __func__, (void *)rn, route_node_get_lock_count(rn));
                zlog_backtrace(LOG_DEBUG);
                return -1;
        }