zebra: Free up routemap name memory on vrf deletion event

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-12-09 08:51:34 -05:00
parent b3faf1aab6
commit cda0f501fb
3 changed files with 20 additions and 0 deletions

View File

@ -1818,6 +1818,23 @@ static void zebra_route_map_event(const char *rmap_name)
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf)
{
afi_t afi;
uint8_t type;
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
if (PROTO_RM_NAME(zvrf, afi, type))
XFREE(MTYPE_ROUTE_MAP_NAME,
PROTO_RM_NAME(zvrf, afi, type));
if (NHT_RM_NAME(zvrf, afi, type))
XFREE(MTYPE_ROUTE_MAP_NAME,
NHT_RM_NAME(zvrf, afi, type));
}
}
}
/* ip protocol configuration write function */
void zebra_routemap_config_write_protocol(struct vty *vty,
struct zebra_vrf *zvrf)

View File

@ -50,6 +50,8 @@ zebra_nht_route_map_check(afi_t afi, int client_proto, const struct prefix *p,
struct zebra_vrf *zvrf, struct route_entry *,
struct nexthop *nexthop);
extern void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf);
#ifdef __cplusplus
}
#endif

View File

@ -268,6 +268,7 @@ static int zebra_vrf_delete(struct vrf *vrf)
/* Cleanup EVPN states for vrf */
zebra_vxlan_vrf_delete(zvrf);
zebra_routemap_vrf_delete(zvrf);
list_delete_all_node(zvrf->rid_all_sorted_list);
list_delete_all_node(zvrf->rid_lo_sorted_list);