From 4a61b0d00ef4f398e994cd632386c5a51e322f2f Mon Sep 17 00:00:00 2001 From: rgirada Date: Tue, 6 Apr 2021 05:40:31 -0700 Subject: [PATCH] ospfd: Fixing few valgrind issues Description: All matching external routes are added to matching external hash table of aggregate route when aggregation is enabled. But these external info pointers are not delinked from this hash table before freeing the corresponding memory while disabling redistribution. Addressing these memory issues in this change. Signed-off-by: Rajesh Girada --- ospfd/ospf_asbr.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 0b4e5d7762..1faf6bfc12 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -314,20 +314,29 @@ void ospf_redistribute_withdraw(struct ospf *ospf, uint8_t type, if (EXTERNAL_INFO(ext)) for (rn = route_top(EXTERNAL_INFO(ext)); rn; rn = route_next(rn)) - if ((ei = rn->info)) - if (ospf_external_info_find_lsa(ospf, &ei->p)) { - if (is_prefix_default(&ei->p) - && ospf->default_originate - != DEFAULT_ORIGINATE_NONE) - continue; + if ((ei = rn->info)) { + struct ospf_external_aggr_rt *aggr; + + if (is_prefix_default(&ei->p) + && ospf->default_originate + != DEFAULT_ORIGINATE_NONE) + continue; + + aggr = ei->aggr_route; + + if (aggr) + ospf_unlink_ei_from_aggr(ospf, aggr, + ei); + else if (ospf_external_info_find_lsa(ospf, + &ei->p)) ospf_external_lsa_flush( ospf, type, &ei->p, ei->ifindex /*, ei->nexthop */); - ospf_external_info_free(ei); - route_unlock_node(rn); - rn->info = NULL; - } + ospf_external_info_free(ei); + route_unlock_node(rn); + rn->info = NULL; + } } /* External Route Aggregator Handlers */ -- 2.39.5