diff options
Diffstat (limited to 'staticd/static_vrf.c')
| -rw-r--r-- | staticd/static_vrf.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c index 39b86787ff..83894e9267 100644 --- a/staticd/static_vrf.c +++ b/staticd/static_vrf.c @@ -38,6 +38,10 @@ static void zebra_stable_node_cleanup(struct route_table *table, struct static_nexthop *nh; struct static_path *pn; struct static_route_info *si; + struct route_table *src_table; + struct route_node *src_node; + struct static_path *src_pn; + struct static_route_info *src_si; si = node->info; @@ -51,6 +55,37 @@ static void zebra_stable_node_cleanup(struct route_table *table, static_path_list_del(&si->path_list, pn); XFREE(MTYPE_STATIC_PATH, pn); } + + /* clean up for dst table */ + src_table = srcdest_srcnode_table(node); + if (src_table) { + /* This means the route_node is part of the top + * hierarchy and refers to a destination prefix. + */ + for (src_node = route_top(src_table); src_node; + src_node = route_next(src_node)) { + src_si = src_node->info; + + frr_each_safe(static_path_list, + &src_si->path_list, src_pn) { + frr_each_safe(static_nexthop_list, + &src_pn->nexthop_list, + nh) { + static_nexthop_list_del( + &src_pn->nexthop_list, + nh); + XFREE(MTYPE_STATIC_NEXTHOP, nh); + } + static_path_list_del(&src_si->path_list, + src_pn); + XFREE(MTYPE_STATIC_PATH, src_pn); + } + + XFREE(MTYPE_STATIC_ROUTE, src_node->info); + } + } + + XFREE(MTYPE_STATIC_ROUTE, node->info); } } @@ -203,14 +238,12 @@ int static_vrf_has_config(struct static_vrf *svrf) * NOTE: This is a don't care for the default VRF, but we go through * the motions to keep things consistent. */ - for (afi = AFI_IP; afi < AFI_MAX; afi++) { - for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - table = svrf->stable[afi][safi]; - if (!table) - continue; - if (route_table_count(table)) - return 1; - } + FOREACH_AFI_SAFI (afi, safi) { + table = svrf->stable[afi][safi]; + if (!table) + continue; + if (route_table_count(table)) + return 1; } return 0; |
