diff options
author | G. Paul Ziemba <paulz@labn.net> | 2023-03-02 22:23:08 +0100 |
---|---|---|
committer | G. Paul Ziemba <paulz@labn.net> | 2023-03-03 16:03:40 +0100 |
commit | cd886395378c4829c000613f3a18315784bf0c45 (patch) | |
tree | 682bf036fa9b228c2e047b99818a5e58454a88c4 /bgpd/rfapi | |
parent | Merge pull request #12760 from opensourcerouting/fix/switch_to_pr_for_commitlint (diff) | |
download | frr-cd886395378c4829c000613f3a18315784bf0c45.tar.xz frr-cd886395378c4829c000613f3a18315784bf0c45.zip |
bgpd: rfapi memleak: clean CE tables at exit
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
Diffstat (limited to 'bgpd/rfapi')
-rw-r--r-- | bgpd/rfapi/rfapi_import.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 5c6854539..25a440304 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -874,33 +874,39 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it) for (afi = AFI_IP; afi < AFI_MAX; ++afi) { struct agg_node *rn; + struct agg_table *at; - for (rn = agg_route_top(it->imported_vpn[afi]); rn; - rn = agg_route_next(rn)) { - /* - * Each route_node has: - * aggregate: points to rfapi_it_extra with monitor - * chain(s) - * info: points to chain of bgp_path_info - */ - /* free bgp_path_info and its children */ - rfapiBgpInfoChainFree(rn->info); - rn->info = NULL; + at = it->imported_vpn[afi]; + if (at) { + for (rn = agg_route_top(at); rn; + rn = agg_route_next(rn)) { + /* + * Each route_node has: + * aggregate: points to rfapi_it_extra with + * monitor chain(s) + * info: points to chain of bgp_path_info + */ + /* free bgp_path_info and its children */ + rfapiBgpInfoChainFree(rn->info); + rn->info = NULL; - rfapiMonitorExtraFlush(SAFI_MPLS_VPN, rn); + rfapiMonitorExtraFlush(SAFI_MPLS_VPN, rn); + } + agg_table_finish(at); } - for (rn = agg_route_top(it->imported_encap[afi]); rn; - rn = agg_route_next(rn)) { - /* free bgp_path_info and its children */ - rfapiBgpInfoChainFree(rn->info); - rn->info = NULL; + if (at) { + at = it->imported_encap[afi]; + for (rn = agg_route_top(at); rn; + rn = agg_route_next(rn)) { + /* free bgp_path_info and its children */ + rfapiBgpInfoChainFree(rn->info); + rn->info = NULL; - rfapiMonitorExtraFlush(SAFI_ENCAP, rn); + rfapiMonitorExtraFlush(SAFI_ENCAP, rn); + } + agg_table_finish(at); } - - agg_table_finish(it->imported_vpn[afi]); - agg_table_finish(it->imported_encap[afi]); } if (it->monitor_exterior_orphans) { skiplist_free(it->monitor_exterior_orphans); @@ -4260,10 +4266,7 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h) h->resolve_nve_nexthop = NULL; } - agg_table_finish(h->it_ce->imported_vpn[AFI_IP]); - agg_table_finish(h->it_ce->imported_vpn[AFI_IP6]); - agg_table_finish(h->it_ce->imported_encap[AFI_IP]); - agg_table_finish(h->it_ce->imported_encap[AFI_IP6]); + rfapiImportTableFlush(h->it_ce); if (h->import_mac) { struct rfapi_import_table *it; |