mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 15:58:18 +00:00
*: Create/Use accessor functions for lock count
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>
This commit is contained in:
parent
0894afd4cf
commit
c10e14e96d
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 *)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
{
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user