diff options
author | Donald Sharp <sharpd@nvidia.com> | 2023-03-21 13:54:21 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2023-03-21 13:54:21 +0100 |
commit | d8bc11a592110abdd14d11dfcb2ce623653ecab5 (patch) | |
tree | eee3628586497e48192f65326316f0eb91114011 /bgpd/bgp_pbr.c | |
parent | Merge pull request #12816 from gpnaveen/stc_rte_err_msg (diff) | |
download | frr-d8bc11a592110abdd14d11dfcb2ce623653ecab5.tar.xz frr-d8bc11a592110abdd14d11dfcb2ce623653ecab5.zip |
*: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it. This function also takes a double
pointer to the hash to set it NULL. Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bgpd/bgp_pbr.c')
-rw-r--r-- | bgpd/bgp_pbr.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 7bced6cd3..bc9ecff7d 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -1014,7 +1014,7 @@ static void bgp_pbr_match_free(void *arg) bpm->action = NULL; } } - hash_free(bpm->entry_hash); + hash_clean_and_free(&bpm->entry_hash, NULL); XFREE(MTYPE_PBR_MATCH, bpm); } @@ -1386,23 +1386,13 @@ struct bgp_pbr_match *bgp_pbr_match_iptable_lookup(vrf_id_t vrf_id, void bgp_pbr_cleanup(struct bgp *bgp) { - if (bgp->pbr_match_hash) { - hash_clean(bgp->pbr_match_hash, bgp_pbr_match_free); - hash_free(bgp->pbr_match_hash); - bgp->pbr_match_hash = NULL; - } - if (bgp->pbr_rule_hash) { - hash_clean(bgp->pbr_rule_hash, bgp_pbr_rule_free); - hash_free(bgp->pbr_rule_hash); - bgp->pbr_rule_hash = NULL; - } - if (bgp->pbr_action_hash) { - hash_clean(bgp->pbr_action_hash, bgp_pbr_action_free); - hash_free(bgp->pbr_action_hash); - bgp->pbr_action_hash = NULL; - } + hash_clean_and_free(&bgp->pbr_match_hash, bgp_pbr_match_free); + hash_clean_and_free(&bgp->pbr_rule_hash, bgp_pbr_rule_free); + hash_clean_and_free(&bgp->pbr_action_hash, bgp_pbr_action_free); + if (bgp->bgp_pbr_cfg == NULL) return; + bgp_pbr_reset(bgp, AFI_IP); bgp_pbr_reset(bgp, AFI_IP6); XFREE(MTYPE_PBR, bgp->bgp_pbr_cfg); |