Skip to content

Commit 0975ac5

Browse files
authored
Merge pull request #19577 from mjstapp/fix_bgp_term_refs
bgpd: fix refcounts at termination
2 parents f5dc586 + b60d0e1 commit 0975ac5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

bgpd/bgp_table.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ inline struct bgp_dest *bgp_dest_unlock_node(struct bgp_dest *dest)
101101
* bgp_node_destroy
102102
*/
103103
static void bgp_node_destroy(route_table_delegate_t *delegate,
104-
struct route_table *table, struct route_node *node)
104+
struct route_table *table, struct route_node *node)
105105
{
106106
struct bgp_dest *dest;
107107
struct bgp_table *rt;
@@ -110,8 +110,8 @@ static void bgp_node_destroy(route_table_delegate_t *delegate,
110110
if (dest) {
111111
if (rt->bgp) {
112112
bgp_addpath_free_node_data(&rt->bgp->tx_addpath,
113-
&dest->tx_addpath,
114-
rt->afi, rt->safi);
113+
&dest->tx_addpath,
114+
rt->afi, rt->safi);
115115
}
116116
XFREE(MTYPE_BGP_NODE, dest);
117117
node->info = NULL;

bgpd/bgpd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,6 +4205,15 @@ int bgp_delete(struct bgp *bgp)
42054205
event_cancel(&bgp->t_maxmed_onstartup);
42064206
event_cancel(&bgp->t_update_delay);
42074207
event_cancel(&bgp->t_establish_wait);
4208+
4209+
/* If the clearing event is scheduled, there's an extra ref to
4210+
* this 'bgp' - ensure we unlock.
4211+
*/
4212+
if (event_is_scheduled(bgp->clearing_end)) {
4213+
assert(bgp->lock > 1);
4214+
bgp_unlock(bgp);
4215+
}
4216+
42084217
event_cancel(&bgp->clearing_end);
42094218

42104219
/* Set flag indicating bgp instance delete in progress */

0 commit comments

Comments
 (0)