diff options
| author | Louis Scalbert <louis.scalbert@6wind.com> | 2025-04-11 17:30:15 +0200 |
|---|---|---|
| committer | Louis Scalbert <louis.scalbert@6wind.com> | 2025-04-14 13:09:36 +0200 |
| commit | 442d8bce364ea3bb98d96462cddfab04d4717ed9 (patch) | |
| tree | e0494456d167c750096eaed4b93c8c5fdb1093a1 | |
| parent | 8d9df5cf047d27b305bb79c37021ac960002bd9f (diff) | |
bgpd: fix bgp_pbr_rule memory leak
Fix bgp_pbr_rule memory leak. Found by code review.
Fixes: 27e376d4e1 ("bgpd: an hash list of pbr iprule is created")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
| -rw-r--r-- | bgpd/bgp_pbr.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 76d414a926..07de1e426e 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -1029,7 +1029,12 @@ static void *bgp_pbr_match_alloc_intern(void *arg) return new; } -static void bgp_pbr_rule_free(void *arg) +static void bgp_pbr_rule_free(struct bgp_pbr_rule *pbr) +{ + XFREE(MTYPE_PBR_RULE, pbr); +} + +static void bgp_pbr_rule_hash_free(void *arg) { struct bgp_pbr_rule *bpr; @@ -1042,7 +1047,7 @@ static void bgp_pbr_rule_free(void *arg) bpr->action->refcnt--; bpr->action = NULL; } - XFREE(MTYPE_PBR_RULE, bpr); + bgp_pbr_rule_free(bpr); } static void *bgp_pbr_rule_alloc_intern(void *arg) @@ -1383,7 +1388,7 @@ struct bgp_pbr_match *bgp_pbr_match_iptable_lookup(vrf_id_t vrf_id, void bgp_pbr_cleanup(struct bgp *bgp) { hash_clean_and_free(&bgp->pbr_match_hash, bgp_pbr_match_hash_free); - hash_clean_and_free(&bgp->pbr_rule_hash, bgp_pbr_rule_free); + hash_clean_and_free(&bgp->pbr_rule_hash, bgp_pbr_rule_hash_free); hash_clean_and_free(&bgp->pbr_action_hash, bgp_pbr_action_free); if (bgp->bgp_pbr_cfg == NULL) @@ -1666,6 +1671,8 @@ static void bgp_pbr_flush_iprule(struct bgp *bgp, struct bgp_pbr_action *bpa, } } hash_release(bgp->pbr_rule_hash, bpr); + bgp_pbr_rule_free(bpr); + bgp_pbr_bpa_remove(bpa); } |
