+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2003 Yasuhiro Ohara
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
zlog_debug(
"%s: Remove the blackhole route",
__func__);
+
ospf6_zebra_route_update_remove(aggr->route, ospf6);
+ if (aggr->route->route_option)
+ XFREE(MTYPE_OSPF6_EXTERNAL_INFO,
+ aggr->route->route_option);
ospf6_route_delete(aggr->route);
aggr->route = NULL;
}
struct ospf6_external_aggr_rt *aggr)
{
struct ospf6_route *rt_aggr;
+ struct ospf6_route *old_rt = NULL;
struct ospf6_external_info *info;
+ /* Check if a route is already present. */
+ if (aggr->route)
+ old_rt = aggr->route;
+
/* Create summary route and save it. */
rt_aggr = ospf6_route_create(ospf6);
rt_aggr->type = OSPF6_DEST_TYPE_NETWORK;
/* Add next-hop to Null interface. */
ospf6_add_route_nexthop_blackhole(rt_aggr);
+ /* Free the old route, if any. */
+ if (old_rt) {
+ ospf6_zebra_route_update_remove(old_rt, ospf6);
+
+ if (old_rt->route_option)
+ XFREE(MTYPE_OSPF6_EXTERNAL_INFO, old_rt->route_option);
+
+ ospf6_route_delete(old_rt);
+ }
+
ospf6_zebra_route_update_add(rt_aggr, ospf6);
}
(void)ospf6_originate_type5_type7_lsas(rt, ospf6);
}
-static void
-ospf6_asbr_summary_config_delete(struct ospf6 *ospf6, struct route_node *rn)
+void ospf6_asbr_summary_config_delete(struct ospf6 *ospf6,
+ struct route_node *rn)
{
struct ospf6_external_aggr_rt *aggr = rn->info;
hash_clean(aggr->match_extnl_hash,
ospf6_aggr_unlink_external_info);
- if (aggr->route) {
- if (aggr->route->route_option)
- XFREE(MTYPE_OSPF6_EXTERNAL_INFO,
- aggr->route->route_option);
-
- ospf6_route_delete(aggr->route);
- }
-
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug("%s: Release the aggregator Address(%pFX)",
__func__,