diff options
Diffstat (limited to 'staticd')
| -rw-r--r-- | staticd/static_memory.h | 1 | ||||
| -rw-r--r-- | staticd/static_routes.c | 51 | ||||
| -rw-r--r-- | staticd/static_vrf.c | 49 | ||||
| -rw-r--r-- | staticd/static_zebra.c | 3 |
4 files changed, 65 insertions, 39 deletions
diff --git a/staticd/static_memory.h b/staticd/static_memory.h index e9cc7ba469..077cd0f32b 100644 --- a/staticd/static_memory.h +++ b/staticd/static_memory.h @@ -23,6 +23,7 @@ DECLARE_MGROUP(STATIC) +DECLARE_MTYPE(STATIC_ROUTE); DECLARE_MTYPE(STATIC_NEXTHOP); DECLARE_MTYPE(STATIC_PATH); diff --git a/staticd/static_routes.c b/staticd/static_routes.c index d105b2123f..05355c48fe 100644 --- a/staticd/static_routes.c +++ b/staticd/static_routes.c @@ -35,7 +35,7 @@ #include "static_zebra.h" #include "static_debug.h" -DEFINE_MTYPE_STATIC(STATIC, STATIC_ROUTE, "Static Route Info"); +DEFINE_MTYPE(STATIC, STATIC_ROUTE, "Static Route Info"); DEFINE_MTYPE(STATIC, STATIC_PATH, "Static Path"); /* Install static path into rib. */ @@ -546,19 +546,15 @@ void static_fixup_vrf_ids(struct static_vrf *enable_svrf) svrf = vrf->info; /* Install any static routes configured for this VRF. */ - for (afi = AFI_IP; afi < AFI_MAX; afi++) { - for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - stable = svrf->stable[afi][safi]; - if (!stable) - continue; + FOREACH_AFI_SAFI (afi, safi) { + stable = svrf->stable[afi][safi]; + if (!stable) + continue; - static_fixup_vrf(enable_svrf, stable, - afi, safi); + static_fixup_vrf(enable_svrf, stable, afi, safi); - if (enable_svrf == svrf) - static_enable_vrf(svrf, stable, - afi, safi); - } + if (enable_svrf == svrf) + static_enable_vrf(svrf, stable, afi, safi); } } } @@ -649,20 +645,17 @@ void static_cleanup_vrf_ids(struct static_vrf *disable_svrf) svrf = vrf->info; /* Uninstall any static routes configured for this VRF. */ - for (afi = AFI_IP; afi < AFI_MAX; afi++) { - for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - struct route_table *stable; + FOREACH_AFI_SAFI (afi, safi) { + struct route_table *stable; - stable = svrf->stable[afi][safi]; - if (!stable) - continue; + stable = svrf->stable[afi][safi]; + if (!stable) + continue; - static_cleanup_vrf(disable_svrf, stable, - afi, safi); + static_cleanup_vrf(disable_svrf, stable, afi, safi); - if (disable_svrf == svrf) - static_disable_vrf(stable, afi, safi); - } + if (disable_svrf == svrf) + static_disable_vrf(stable, afi, safi); } } } @@ -725,14 +718,12 @@ void static_install_intf_nh(struct interface *ifp) continue; /* Install any static routes configured for this interface. */ - for (afi = AFI_IP; afi < AFI_MAX; afi++) { - for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - stable = svrf->stable[afi][safi]; - if (!stable) - continue; + FOREACH_AFI_SAFI (afi, safi) { + stable = svrf->stable[afi][safi]; + if (!stable) + continue; - static_fixup_intf_nh(stable, ifp, afi, safi); - } + static_fixup_intf_nh(stable, ifp, afi, safi); } } } 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; diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index a9b570de83..0bccbfbead 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -110,7 +110,8 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS) enum zapi_route_notify_owner note; uint32_t table_id; - if (!zapi_route_notify_decode(zclient->ibuf, &p, &table_id, ¬e)) + if (!zapi_route_notify_decode(zclient->ibuf, &p, &table_id, ¬e, + NULL, NULL)) return -1; switch (note) { |
