summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_damp.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-08-02 12:01:38 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2021-08-03 20:54:47 +0200
commit7ab05c74add2617deafc96a7e5037a4d29f37f30 (patch)
tree219ff962eba6d0989322c4e780b5a0ba8918bd29 /bgpd/bgp_damp.c
parentRevert "bgpd: Drop double-pointer for bgp_damp_info_free()" (diff)
downloadfrr-7ab05c74add2617deafc96a7e5037a4d29f37f30.tar.xz
frr-7ab05c74add2617deafc96a7e5037a4d29f37f30.zip
Revert "bgpd: fix double free in dampening code"
This reverts commit 96d6b8cc29bf5124ae93433ecfc16b3fd69be5ea.
Diffstat (limited to 'bgpd/bgp_damp.c')
-rw-r--r--bgpd/bgp_damp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 21e42ae82..2a372c0ba 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -174,9 +174,16 @@ static void bgp_reuse_list_add(struct bgp_damp_info *bdi,
}
/* Delete BGP dampening information from reuse list. */
-static void bgp_reuse_list_delete(struct bgp_damp_info *bdi)
+static void bgp_reuse_list_delete(struct bgp_damp_info *bdi,
+ struct bgp_damp_config *bdc)
{
+ struct reuselist *list;
+ struct reuselist_node *rn;
+
+ list = &bdc->reuse_list[bdi->index];
+ rn = bgp_reuselist_find(list, bdi);
bgp_damp_info_unclaim(bdi);
+ bgp_reuselist_del(list, &rn);
}
static void bgp_no_reuse_list_add(struct bgp_damp_info *bdi,
@@ -369,7 +376,7 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest,
if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)) {
/* If decay rate isn't equal to 0, reinsert brn. */
if (bdi->penalty != last_penalty) {
- bgp_reuse_list_delete(bdi);
+ bgp_reuse_list_delete(bdi, bdc);
bgp_reuse_list_add(bdi, bdc);
}
return BGP_DAMP_SUPPRESSED;
@@ -413,7 +420,7 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
else if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
&& (bdi->penalty < bdc->reuse_limit)) {
bgp_path_info_unset_flag(dest, path, BGP_PATH_DAMPED);
- bgp_reuse_list_delete(bdi);
+ bgp_reuse_list_delete(bdi, bdc);
bgp_no_reuse_list_add(bdi, bdc);
bdi->suppress_time = 0;
status = BGP_DAMP_USED;