mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-11-02 16:25:18 +00:00
Merge pull request #2778 from donaldsharp/pim_leaks_and_invalids
Pim leaks and invalids
This commit is contained in:
commit
8669b45833
@ -4810,9 +4810,5 @@ void bgp_route_map_init(void)
|
||||
void bgp_route_map_terminate(void)
|
||||
{
|
||||
/* ToDo: Cleanup all the used memory */
|
||||
|
||||
route_map_add_hook(NULL);
|
||||
route_map_delete_hook(NULL);
|
||||
route_map_event_hook(NULL);
|
||||
route_map_finish();
|
||||
}
|
||||
|
||||
@ -2741,6 +2741,15 @@ void route_map_finish(void)
|
||||
vector_free(route_set_vec);
|
||||
route_set_vec = NULL;
|
||||
|
||||
/*
|
||||
* All protocols are setting these to NULL
|
||||
* by default on shutdown( route_map_finish )
|
||||
* Why are we making them do this work?
|
||||
*/
|
||||
route_map_master.add_hook = NULL;
|
||||
route_map_master.delete_hook = NULL;
|
||||
route_map_master.event_hook = NULL;
|
||||
|
||||
/* cleanup route_map */
|
||||
while (route_map_master.head) {
|
||||
struct route_map *map = route_map_master.head;
|
||||
|
||||
@ -169,6 +169,12 @@ DECLARE_QOBJ_TYPE(route_map)
|
||||
|
||||
/* Prototypes. */
|
||||
extern void route_map_init(void);
|
||||
|
||||
/*
|
||||
* This should only be called on shutdown
|
||||
* Additionally this function sets the hooks to NULL
|
||||
* before any processing is done.
|
||||
*/
|
||||
extern void route_map_finish(void);
|
||||
|
||||
/* Add match statement to route map. */
|
||||
|
||||
@ -1861,9 +1861,6 @@ void ospf6_asbr_redistribute_reset(void)
|
||||
void ospf6_asbr_terminate(void)
|
||||
{
|
||||
/* Cleanup route maps */
|
||||
route_map_add_hook(NULL);
|
||||
route_map_delete_hook(NULL);
|
||||
route_map_event_hook(NULL);
|
||||
route_map_finish();
|
||||
}
|
||||
|
||||
|
||||
@ -561,9 +561,6 @@ void ospf_terminate(void)
|
||||
ospf_finish(ospf);
|
||||
|
||||
/* Cleanup route maps */
|
||||
route_map_add_hook(NULL);
|
||||
route_map_delete_hook(NULL);
|
||||
route_map_event_hook(NULL);
|
||||
route_map_finish();
|
||||
|
||||
/* reverse prefix_list_init */
|
||||
|
||||
@ -99,9 +99,9 @@ void pim_bfd_info_nbr_create(struct pim_interface *pim_ifp,
|
||||
/*
|
||||
* pim_bfd_info_free - Free BFD info structure
|
||||
*/
|
||||
void pim_bfd_info_free(void **bfd_info)
|
||||
void pim_bfd_info_free(struct bfd_info **bfd_info)
|
||||
{
|
||||
bfd_info_free((struct bfd_info **)bfd_info);
|
||||
bfd_info_free(bfd_info);
|
||||
}
|
||||
|
||||
static void pim_bfd_reg_dereg_nbr(struct pim_neighbor *nbr, int command)
|
||||
@ -151,7 +151,7 @@ int pim_bfd_reg_dereg_all_nbr(struct interface *ifp, int command)
|
||||
if (command != ZEBRA_BFD_DEST_DEREGISTER)
|
||||
pim_bfd_info_nbr_create(pim_ifp, neigh);
|
||||
else
|
||||
bfd_info_free((struct bfd_info **)&neigh->bfd_info);
|
||||
pim_bfd_info_free((struct bfd_info **)&neigh->bfd_info);
|
||||
|
||||
pim_bfd_reg_dereg_nbr(neigh, command);
|
||||
}
|
||||
@ -170,7 +170,7 @@ void pim_bfd_trigger_event(struct pim_interface *pim_ifp,
|
||||
pim_bfd_info_nbr_create(pim_ifp, nbr);
|
||||
pim_bfd_reg_dereg_nbr(nbr, ZEBRA_BFD_DEST_REGISTER);
|
||||
} else {
|
||||
pim_bfd_info_free((void *)&nbr->bfd_info);
|
||||
pim_bfd_info_free(&nbr->bfd_info);
|
||||
pim_bfd_reg_dereg_nbr(nbr, ZEBRA_BFD_DEST_DEREGISTER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,5 +36,5 @@ void pim_bfd_trigger_event(struct pim_interface *pim_ifp,
|
||||
struct pim_neighbor *nbr, uint8_t nbr_up);
|
||||
void pim_bfd_info_nbr_create(struct pim_interface *pim_ifp,
|
||||
struct pim_neighbor *neigh);
|
||||
void pim_bfd_info_free(void **bfd_info);
|
||||
void pim_bfd_info_free(struct bfd_info **bfd_info);
|
||||
#endif /* _PIM_BFD_H */
|
||||
|
||||
@ -54,10 +54,10 @@ static void pim_instance_terminate(struct pim_instance *pim)
|
||||
pim->rpf_hash = NULL;
|
||||
}
|
||||
|
||||
pim_oil_terminate(pim);
|
||||
|
||||
pim_if_terminate(pim);
|
||||
|
||||
pim_oil_terminate(pim);
|
||||
|
||||
pim_msdp_exit(pim);
|
||||
|
||||
XFREE(MTYPE_PIM_PIM_INSTANCE, pim);
|
||||
|
||||
@ -1242,8 +1242,10 @@ static int pim_msdp_peer_comp(const void *p1, const void *p2)
|
||||
}
|
||||
|
||||
/************************** Mesh group management **************************/
|
||||
static void pim_msdp_mg_free(struct pim_instance *pim, struct pim_msdp_mg *mg)
|
||||
static void pim_msdp_mg_free(struct pim_instance *pim)
|
||||
{
|
||||
struct pim_msdp_mg *mg = pim->msdp.mg;
|
||||
|
||||
/* If the mesh-group has valid member or src_ip don't delete it */
|
||||
if (!mg || mg->mbr_cnt || (mg->src_ip.s_addr != INADDR_ANY)) {
|
||||
return;
|
||||
@ -1258,8 +1260,7 @@ static void pim_msdp_mg_free(struct pim_instance *pim, struct pim_msdp_mg *mg)
|
||||
if (mg->mbr_list)
|
||||
list_delete_and_null(&mg->mbr_list);
|
||||
|
||||
XFREE(MTYPE_PIM_MSDP_MG, mg);
|
||||
pim->msdp.mg = NULL;
|
||||
XFREE(MTYPE_PIM_MSDP_MG, pim->msdp.mg);
|
||||
}
|
||||
|
||||
static struct pim_msdp_mg *pim_msdp_mg_new(const char *mesh_group_name)
|
||||
@ -1299,7 +1300,7 @@ enum pim_msdp_err pim_msdp_mg_del(struct pim_instance *pim,
|
||||
mg->src_ip.s_addr = INADDR_ANY;
|
||||
|
||||
/* free up the mesh-group */
|
||||
pim_msdp_mg_free(pim, mg);
|
||||
pim_msdp_mg_free(pim);
|
||||
return PIM_MSDP_ERR_NONE;
|
||||
}
|
||||
|
||||
@ -1438,7 +1439,7 @@ enum pim_msdp_err pim_msdp_mg_mbr_del(struct pim_instance *pim,
|
||||
|
||||
pim_msdp_mg_mbr_do_del(mg, mbr);
|
||||
/* if there are no references to the mg free it */
|
||||
pim_msdp_mg_free(pim, mg);
|
||||
pim_msdp_mg_free(pim);
|
||||
|
||||
return PIM_MSDP_ERR_NONE;
|
||||
}
|
||||
@ -1475,7 +1476,7 @@ enum pim_msdp_err pim_msdp_mg_src_del(struct pim_instance *pim,
|
||||
mg->src_ip.s_addr = INADDR_ANY;
|
||||
pim_msdp_mg_src_do_del(pim);
|
||||
/* if there are no references to the mg free it */
|
||||
pim_msdp_mg_free(pim, mg);
|
||||
pim_msdp_mg_free(pim);
|
||||
}
|
||||
return PIM_MSDP_ERR_NONE;
|
||||
}
|
||||
@ -1598,7 +1599,10 @@ void pim_msdp_exit(struct pim_instance *pim)
|
||||
|
||||
/* XXX: stop listener and delete all peer sessions */
|
||||
|
||||
pim_msdp_mg_free(pim);
|
||||
|
||||
if (pim->msdp.peer_hash) {
|
||||
hash_clean(pim->msdp.peer_hash, NULL);
|
||||
hash_free(pim->msdp.peer_hash);
|
||||
pim->msdp.peer_hash = NULL;
|
||||
}
|
||||
@ -1608,6 +1612,7 @@ void pim_msdp_exit(struct pim_instance *pim)
|
||||
}
|
||||
|
||||
if (pim->msdp.sa_hash) {
|
||||
hash_clean(pim->msdp.sa_hash, NULL);
|
||||
hash_free(pim->msdp.sa_hash);
|
||||
pim->msdp.sa_hash = NULL;
|
||||
}
|
||||
@ -1615,4 +1620,8 @@ void pim_msdp_exit(struct pim_instance *pim)
|
||||
if (pim->msdp.sa_list) {
|
||||
list_delete_and_null(&pim->msdp.sa_list);
|
||||
}
|
||||
|
||||
if (pim->msdp.work_obuf)
|
||||
stream_free(pim->msdp.work_obuf);
|
||||
pim->msdp.work_obuf = NULL;
|
||||
}
|
||||
|
||||
@ -409,6 +409,9 @@ void pim_neighbor_free(struct pim_neighbor *neigh)
|
||||
list_delete_and_null(&neigh->upstream_jp_agg);
|
||||
THREAD_OFF(neigh->jp_timer);
|
||||
|
||||
if (neigh->bfd_info)
|
||||
pim_bfd_info_free(&neigh->bfd_info);
|
||||
|
||||
XFREE(MTYPE_PIM_NEIGHBOR, neigh);
|
||||
}
|
||||
|
||||
|
||||
@ -52,8 +52,5 @@ void pim_route_map_init(void)
|
||||
|
||||
void pim_route_map_terminate(void)
|
||||
{
|
||||
route_map_add_hook(NULL);
|
||||
route_map_delete_hook(NULL);
|
||||
route_map_event_hook(NULL);
|
||||
route_map_finish();
|
||||
}
|
||||
|
||||
@ -62,6 +62,9 @@ void pim_rp_list_hash_clean(void *data)
|
||||
|
||||
static void pim_rp_info_free(struct rp_info *rp_info)
|
||||
{
|
||||
if (rp_info->plist)
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, rp_info->plist);
|
||||
|
||||
XFREE(MTYPE_PIM_RP, rp_info);
|
||||
}
|
||||
|
||||
@ -600,7 +603,6 @@ int pim_rp_del(struct pim_instance *pim, const char *rp,
|
||||
|
||||
if (rp_info->plist) {
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, rp_info->plist);
|
||||
rp_info->plist = NULL;
|
||||
was_plist = true;
|
||||
}
|
||||
|
||||
|
||||
@ -146,6 +146,11 @@ void *pim_ssm_init(void)
|
||||
|
||||
void pim_ssm_terminate(struct pim_ssm *ssm)
|
||||
{
|
||||
if (ssm && ssm->plist_name)
|
||||
if (!ssm)
|
||||
return;
|
||||
|
||||
if (ssm->plist_name)
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, ssm->plist_name);
|
||||
|
||||
XFREE(MTYPE_PIM_SSM_INFO, ssm);
|
||||
}
|
||||
|
||||
@ -192,7 +192,8 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
|
||||
up->rpf.source_nexthop.interface = NULL;
|
||||
|
||||
if (up->sg.src.s_addr != INADDR_ANY) {
|
||||
wheel_remove_item(pim->upstream_sg_wheel, up);
|
||||
if (pim->upstream_sg_wheel)
|
||||
wheel_remove_item(pim->upstream_sg_wheel, up);
|
||||
notify_msdp = true;
|
||||
}
|
||||
|
||||
@ -1546,6 +1547,10 @@ void pim_upstream_terminate(struct pim_instance *pim)
|
||||
if (pim->upstream_hash)
|
||||
hash_free(pim->upstream_hash);
|
||||
pim->upstream_hash = NULL;
|
||||
|
||||
if (pim->upstream_sg_wheel)
|
||||
wheel_delete(pim->upstream_sg_wheel);
|
||||
pim->upstream_sg_wheel = NULL;
|
||||
}
|
||||
|
||||
int pim_upstream_equal(const void *arg1, const void *arg2)
|
||||
|
||||
@ -79,8 +79,6 @@ static void pim_free()
|
||||
pim_route_map_terminate();
|
||||
|
||||
zclient_lookup_free();
|
||||
|
||||
zprivs_terminate(&pimd_privs);
|
||||
}
|
||||
|
||||
void pim_init()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user