mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
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>
This commit is contained in:
parent
8d9df5cf04
commit
442d8bce36
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue