bgpd: fix missing delete from the list in dampening

When bgp_damp_info_free is called from bgp_route.c, we were never
deleting the BDI from the list.

Move the deletion inside bgp_damp_info_free to cover all cases.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2021-07-29 01:43:59 +03:00
parent 97766ac8aa
commit 755a977b8a

View File

@ -227,7 +227,6 @@ static int bgp_reuse_timer(struct thread *t)
}
if (bdi->penalty <= bdc->reuse_limit / 2.0) {
bgp_reuselist_del(&plist, bdi);
bgp_damp_info_free(bdi, 1);
} else {
bdi->index = BGP_DAMP_NO_REUSE_LIST_INDEX;
@ -376,10 +375,8 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
if (bdi->penalty > bdc->reuse_limit / 2.0)
bdi->t_updated = t_now;
else {
bgp_damp_info_unclaim(bdi);
else
bgp_damp_info_free(bdi, 0);
}
return status;
}
@ -388,6 +385,8 @@ void bgp_damp_info_free(struct bgp_damp_info *bdi, int withdraw)
{
assert(bdi);
bgp_damp_info_unclaim(bdi);
bdi->path->extra->damp_info = NULL;
bgp_path_info_unset_flag(bdi->dest, bdi->path,
BGP_PATH_HISTORY | BGP_PATH_DAMPED);
@ -505,15 +504,12 @@ void bgp_damp_info_clean(struct bgp *bgp, struct bgp_damp_config *bdc,
bgp_process(bgp, bdi->dest, bdi->afi,
bdi->safi);
}
bgp_reuselist_del(list, bdi);
bgp_damp_info_free(bdi, 1);
}
}
while ((bdi = SLIST_FIRST(&bdc->no_reuse_list)) != NULL) {
bgp_reuselist_del(&bdc->no_reuse_list, bdi);
while ((bdi = SLIST_FIRST(&bdc->no_reuse_list)) != NULL)
bgp_damp_info_free(bdi, 1);
}
/* Free decay array */
XFREE(MTYPE_BGP_DAMP_ARRAY, bdc->decay_array);