From: Donatas Abraitis Date: Tue, 30 Apr 2024 07:52:46 +0000 (+0300) Subject: bgpd: Drop double-pointer for bgp_damp_info_free() X-Git-Tag: base_10.1~71^2~10 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=391b4fa7a657a34e6bba1ed70d8e7847bbdeb384;p=matthieu%2Ffrr.git bgpd: Drop double-pointer for bgp_damp_info_free() This causes a crash using `clear ip bgp dampening `. Signed-off-by: Donatas Abraitis Signed-off-by: Donatas Abraitis --- diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 08859324af..20d80eb5db 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -262,7 +262,7 @@ static void bgp_reuse_timer(struct event *t) } if (bdi->penalty <= bdc->reuse_limit / 2.0) { - bgp_damp_info_free(&bdi, bdc, 1, bdi->afi, + bgp_damp_info_free(bdi, bdc, 1, bdi->afi, bdi->safi); bgp_reuselist_del(&plist, &node); } else { @@ -406,29 +406,29 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest, bdi->t_updated = t_now; else { bgp_damp_info_unclaim(bdi); - bgp_damp_info_free(&bdi, bdc, 0, afi, safi); + bgp_damp_info_free(bdi, bdc, 0, afi, safi); } return status; } -void bgp_damp_info_free(struct bgp_damp_info **bdi, struct bgp_damp_config *bdc, +void bgp_damp_info_free(struct bgp_damp_info *bdi, struct bgp_damp_config *bdc, int withdraw, afi_t afi, safi_t safi) { - assert(bdc && bdi && *bdi); + assert(bdc && bdi); - if ((*bdi)->path == NULL) { - XFREE(MTYPE_BGP_DAMP_INFO, (*bdi)); + if (bdi->path == NULL) { + XFREE(MTYPE_BGP_DAMP_INFO, bdi); return; } - (*bdi)->path->extra->damp_info = NULL; - bgp_path_info_unset_flag((*bdi)->dest, (*bdi)->path, + bdi->path->extra->damp_info = NULL; + bgp_path_info_unset_flag(bdi->dest, bdi->path, BGP_PATH_HISTORY | BGP_PATH_DAMPED); - if ((*bdi)->lastrecord == BGP_RECORD_WITHDRAW && withdraw) { - bgp_path_info_delete((*bdi)->dest, (*bdi)->path); - bgp_process((*bdi)->path->peer->bgp, (*bdi)->dest, (*bdi)->path, afi, safi); + if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw) { + bgp_path_info_delete(bdi->dest, bdi->path); + bgp_process(bdi->path->peer->bgp, bdi->dest, bdi->path, afi, safi); } XFREE(MTYPE_BGP_DAMP_INFO, bdi); @@ -539,21 +539,23 @@ void bgp_damp_info_clean(struct bgp *bgp, struct bgp_damp_config *bdc, while ((rn = SLIST_FIRST(list)) != NULL) { bdi = rn->info; if (bdi->lastrecord == BGP_RECORD_UPDATE) { - bgp_aggregate_increment(bgp, &bdi->dest->p, + bgp_aggregate_increment(bgp, + bgp_dest_get_prefix( + bdi->dest), bdi->path, bdi->afi, bdi->safi); - bgp_process(bgp, bdi->dest, bdi->afi, + bgp_process(bgp, bdi->dest, bdi->path, bdi->afi, bdi->safi); } bgp_reuselist_del(list, &rn); - bgp_damp_info_free(&bdi, bdc, 1, afi, safi); + bgp_damp_info_free(bdi, bdc, 1, afi, safi); } } while ((rn = SLIST_FIRST(&bdc->no_reuse_list)) != NULL) { bdi = rn->info; bgp_reuselist_del(&bdc->no_reuse_list, &rn); - bgp_damp_info_free(&bdi, bdc, 1, afi, safi); + bgp_damp_info_free(bdi, bdc, 1, afi, safi); } /* Free decay array */ diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h index ae057a01f7..22b2efebbc 100644 --- a/bgpd/bgp_damp.h +++ b/bgpd/bgp_damp.h @@ -133,7 +133,7 @@ extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest, afi_t afi, safi_t safi, int attr_change); extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest, afi_t afi, safi_t saff); -extern void bgp_damp_info_free(struct bgp_damp_info **path, +extern void bgp_damp_info_free(struct bgp_damp_info *bdi, struct bgp_damp_config *bdc, int withdraw, afi_t afi, safi_t safi); extern void bgp_damp_info_clean(struct bgp *bgp, struct bgp_damp_config *bdc, diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 81a99604ef..ee255b59b8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -15826,7 +15826,7 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name, if (pi->extra && pi->extra->damp_info) { pi_temp = pi->next; bgp_damp_info_free( - &pi->extra->damp_info, + pi->extra->damp_info, &bgp->damp[afi][safi], 1, afi, safi); pi = pi_temp; @@ -15854,17 +15854,19 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name, == BGP_RECORD_UPDATE) { bgp_aggregate_increment( bgp, - &bdi->dest->p, + bgp_dest_get_prefix( + bdi->dest), bdi->path, bdi->afi, bdi->safi); bgp_process(bgp, bdi->dest, + bdi->path, bdi->afi, bdi->safi); } bgp_damp_info_free( - &pi->extra->damp_info, + pi->extra->damp_info, &bgp->damp[afi][safi], 1, afi, safi); pi = pi_temp;