Skip to content

Commit f36be98

Browse files
bgpd: Fix route node lock leak in NHT resolved prefix marking
When bgp_afi_node_get() is called, it locks the node via route_lock_node() before returning it to the caller. The caller is responsible for unlocking the node when done. Call chain: bgp_afi_node_get() bgp_node_get() route_node_get() route_lock_node() In bgp_bnc_mark_nht_important() and bgp_nexthop_update(), the route nodes obtained from bgp_afi_node_get() were not being unlocked after use, causing a reference count leak. These issues were introduced by: - Recent commit #19008 (bgp_bnc_mark_nht_important function) - VRF leaking commit #15238 (bgp_nexthop_update function) Signed-off-by: Mike Dubrovsky <[email protected]>
1 parent fc31cac commit f36be98

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bgpd/bgp_nht.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,17 @@ static void bgp_bnc_mark_nht_important(struct bgp_nexthop_cache *bnc, struct zap
599599
return;
600600

601601
dest = bgp_afi_node_get(table, afi, nhr->safi, &bnc->resolved_prefix, NULL);
602-
if (dest)
602+
if (dest) {
603603
UNSET_FLAG(dest->flags, BGP_NODE_NHT_RESOLVED_NODE);
604+
bgp_dest_unlock_node(dest);
605+
}
604606

605607
dest = bgp_afi_node_get(table, afi, nhr->safi, &nhr->prefix, NULL);
606608
if (!dest)
607609
return;
608610

609611
SET_FLAG(dest->flags, BGP_NODE_NHT_RESOLVED_NODE);
612+
bgp_dest_unlock_node(dest);
610613
}
611614

612615
static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
@@ -968,6 +971,7 @@ void bgp_nexthop_update(struct vrf *vrf, struct prefix *match,
968971
pi->sub_type == BGP_ROUTE_STATIC)
969972
vpn_leak_from_vrf_update(bgp_default,
970973
bgp, pi);
974+
bgp_dest_unlock_node(dest);
971975
}
972976
} else if (BGP_DEBUG(nht, NHT))
973977
zlog_debug("parse nexthop update %pFX(%u)(%s): bnc info not found for import check",

0 commit comments

Comments
 (0)