mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 18:17:20 +00:00
bgpd: Move extra free code and fix a bug.
The bgp_info_extra_free code was the correct place to free up data associated with the bgp_info pointer when we are deleting the bgp_info node. Additionally, if we have a parent pointer, we may not have a net pointer. So make sure we do. Finally clean up the bgp_info_extra_free code so it is a bit easier to read. Use variables instead of multiple level of casting. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
efb02f8814
commit
c93a3b77e6
@ -174,16 +174,31 @@ static struct bgp_info_extra *bgp_info_extra_new(void)
|
||||
|
||||
static void bgp_info_extra_free(struct bgp_info_extra **extra)
|
||||
{
|
||||
if (extra && *extra) {
|
||||
if ((*extra)->damp_info)
|
||||
bgp_damp_info_free((*extra)->damp_info, 0);
|
||||
struct bgp_info_extra *e;
|
||||
|
||||
(*extra)->damp_info = NULL;
|
||||
if (!extra || !*extra)
|
||||
return;
|
||||
|
||||
XFREE(MTYPE_BGP_ROUTE_EXTRA, *extra);
|
||||
e = *extra;
|
||||
if (e->damp_info)
|
||||
bgp_damp_info_free(e->damp_info, 0);
|
||||
|
||||
*extra = NULL;
|
||||
e->damp_info = NULL;
|
||||
if (e->parent) {
|
||||
struct bgp_info *bi = (struct bgp_info *)e->parent;
|
||||
|
||||
if (bi->net)
|
||||
bgp_unlock_node((struct bgp_node *)bi->net);
|
||||
bi->net = NULL;
|
||||
bgp_info_unlock(e->parent);
|
||||
e->parent = NULL;
|
||||
}
|
||||
|
||||
if (e->bgp_orig)
|
||||
bgp_unlock(e->bgp_orig);
|
||||
XFREE(MTYPE_BGP_ROUTE_EXTRA, *extra);
|
||||
|
||||
*extra = NULL;
|
||||
}
|
||||
|
||||
/* Get bgp_info extra information for the given bgp_info, lazy allocated
|
||||
@ -205,22 +220,6 @@ struct bgp_info *bgp_info_new(void)
|
||||
/* Free bgp route information. */
|
||||
static void bgp_info_free(struct bgp_info *binfo)
|
||||
{
|
||||
/* unlink reference to parent, if any. */
|
||||
if (binfo->extra) {
|
||||
if (binfo->extra->parent) {
|
||||
bgp_unlock_node(
|
||||
(struct bgp_node *)((struct bgp_info *)binfo
|
||||
->extra->parent)
|
||||
->net);
|
||||
bgp_info_unlock(
|
||||
(struct bgp_info *)binfo->extra->parent);
|
||||
binfo->extra->parent = NULL;
|
||||
}
|
||||
|
||||
if (binfo->extra->bgp_orig)
|
||||
bgp_unlock(binfo->extra->bgp_orig);
|
||||
}
|
||||
|
||||
if (binfo->attr)
|
||||
bgp_attr_unintern(&binfo->attr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user