]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_asbr.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospf6d / ospf6_asbr.c
index c210b4476c176210971057acb457120805afd49c..05275c52eaa94bbf0992d2fd137f564c77787913 100644 (file)
@@ -1,21 +1,6 @@
+// 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>
@@ -65,9 +50,7 @@ static void ospf6_asbr_redistribute_set(struct ospf6 *ospf6, int type);
 static void ospf6_asbr_redistribute_unset(struct ospf6 *ospf6,
                                          struct ospf6_redist *red, int type);
 
-#ifndef VTYSH_EXTRACT_PL
 #include "ospf6d/ospf6_asbr_clippy.c"
-#endif
 
 unsigned char conf_debug_ospf6_asbr = 0;
 
@@ -1587,7 +1570,11 @@ ospf6_asbr_summary_remove_lsa_and_route(struct ospf6 *ospf6,
                        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;
        }
@@ -1661,7 +1648,7 @@ void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
 
 DEFPY (ospf6_redistribute,
        ospf6_redistribute_cmd,
-       "redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)$metric_type|route-map WORD$rmap_str}]",
+       "redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)$metric_type|route-map RMAP_NAME$rmap_str}]",
        "Redistribute\n"
        FRR_REDIST_HELP_STR_OSPF6D
        "Metric for redistributed routes\n"
@@ -1715,7 +1702,7 @@ DEFPY (ospf6_redistribute,
 
 DEFUN (no_ospf6_redistribute,
        no_ospf6_redistribute_cmd,
-       "no redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
+       "no redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]",
        NO_STR
        "Redistribute\n"
        FRR_REDIST_HELP_STR_OSPF6D
@@ -1893,7 +1880,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate)
 /* Default Route originate. */
 DEFPY (ospf6_default_route_originate,
        ospf6_default_route_originate_cmd,
-       "default-information originate [{always$always|metric (0-16777214)$mval|metric-type (1-2)$mtype|route-map WORD$rtmap}]",
+       "default-information originate [{always$always|metric (0-16777214)$mval|metric-type (1-2)$mtype|route-map RMAP_NAME$rtmap}]",
        "Control distribution of default route\n"
        "Distribute a default route\n"
        "Always advertise default route\n"
@@ -1951,7 +1938,7 @@ DEFPY (ospf6_default_route_originate,
 
 DEFPY (no_ospf6_default_information_originate,
        no_ospf6_default_information_originate_cmd,
-       "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
+       "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]",
        NO_STR
        "Control distribution of default information\n"
        "Distribute a default route\n"
@@ -2206,10 +2193,10 @@ static const struct route_map_rule_cmd ospf6_routemap_rule_set_tag_cmd = {
 /* add "set metric-type" */
 DEFUN_YANG (ospf6_routemap_set_metric_type, ospf6_routemap_set_metric_type_cmd,
       "set metric-type <type-1|type-2>",
-      "Set value\n"
-      "Type of metric\n"
-      "OSPF6 external type 1 metric\n"
-      "OSPF6 external type 2 metric\n")
+       SET_STR
+       "Type of metric for destination routing protocol\n"
+       "OSPF[6] external type 1 metric\n"
+       "OSPF[6] external type 2 metric\n")
 {
        char *ext = argv[2]->text;
 
@@ -2228,10 +2215,10 @@ DEFUN_YANG (ospf6_routemap_set_metric_type, ospf6_routemap_set_metric_type_cmd,
 DEFUN_YANG (ospf6_routemap_no_set_metric_type, ospf6_routemap_no_set_metric_type_cmd,
       "no set metric-type [<type-1|type-2>]",
       NO_STR
-      "Set value\n"
-      "Type of metric\n"
-      "OSPF6 external type 1 metric\n"
-      "OSPF6 external type 2 metric\n")
+      SET_STR
+      "Type of metric for destination routing protocol\n"
+      "OSPF[6] external type 1 metric\n"
+      "OSPF[6] external type 2 metric\n")
 {
        const char *xpath =
                "./set-action[action='frr-ospf-route-map:metric-type']";
@@ -2738,8 +2725,13 @@ ospf6_summary_add_aggr_route_and_blackhole(struct ospf6 *ospf6,
                                           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;
@@ -2758,6 +2750,16 @@ ospf6_summary_add_aggr_route_and_blackhole(struct ospf6 *ospf6,
        /* 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);
 }
 
@@ -3026,8 +3028,8 @@ static void ospf6_aggr_handle_external_info(void *data)
        (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;