]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_abr.c
Merge pull request #5288 from SumitAgarwal123/bfd_docs
[mirror_frr.git] / ospf6d / ospf6_abr.c
index b3aa3b21d2b5221e1d3eb76cf9395cd6764b1a23..ff82bb179821ee391b02ef6ba3607792fbf7f922 100644 (file)
@@ -161,32 +161,35 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
            && route->type != OSPF6_DEST_TYPE_RANGE
            && ((route->type != OSPF6_DEST_TYPE_ROUTER)
                || !CHECK_FLAG(route->path.router_bits, OSPF6_ROUTER_BIT_E))) {
-               if (is_debug)
-                       zlog_debug(
-                               "Route type is none of network, range nor ASBR, ignore");
+#if 0
+               zlog_debug(
+                       "Route type is none of network, range nor ASBR, ignore");
+#endif
                return 0;
        }
 
        /* AS External routes are never considered */
        if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1
            || route->path.type == OSPF6_PATH_TYPE_EXTERNAL2) {
-               if (is_debug)
-                       zlog_debug("Path type is external, skip");
+#if 0
+               zlog_debug("Path type is external, skip");
+#endif
                return 0;
        }
 
        /* do not generate if the path's area is the same as target area */
        if (route->path.area_id == area->area_id) {
-               if (is_debug)
-                       zlog_debug("The route is in the area itself, ignore");
+#if 0
+               zlog_debug("The route is in the area itself, ignore");
+#endif
                return 0;
        }
 
        /* do not generate if the nexthops belongs to the target area */
        if (ospf6_abr_nexthops_belong_to_area(route, area)) {
-               if (is_debug)
-                       zlog_debug(
-                               "The route's nexthop is in the same area, ignore");
+#if 0
+               zlog_debug("The route's nexthop is in the same area, ignore");
+#endif
                return 0;
        }
 
@@ -237,6 +240,20 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
                        }
                }
 
+               if (route->path.origin.type ==
+                   htons(OSPF6_LSTYPE_INTRA_PREFIX)) {
+                       if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
+                               if (is_debug) {
+                                       prefix2str(&route->prefix, buf,
+                                                  sizeof(buf));
+                                       zlog_debug("%s: intra-prefix route %s with cost %u is not best, ignore."
+                                          , __PRETTY_FUNCTION__, buf,
+                                          route->path.cost);
+                               }
+                               return 0;
+                       }
+               }
+
                if (is_debug) {
                        prefix2str(&route->prefix, buf, sizeof(buf));
                        zlog_debug("Originating summary in area %s for %s cost %u",
@@ -268,9 +285,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
                                ospf6_abr_delete_route(route, summary,
                                                       summary_table, old);
                        }
-               } else if (old)
+               } else if (old) {
+                       ospf6_route_remove(summary, summary_table);
                        ospf6_lsa_purge(old);
-
+               }
                return 0;
        }
 
@@ -318,7 +336,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
 
        /* if this is a route to ASBR */
        if (route->type == OSPF6_DEST_TYPE_ROUTER) {
-               /* Only the prefered best path is considered */
+               /* Only the preferred best path is considered */
                if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
                        if (is_debug)
                                zlog_debug(
@@ -641,6 +659,11 @@ void ospf6_abr_originate_summary(struct ospf6_route *route)
 
        if (route->type == OSPF6_DEST_TYPE_NETWORK) {
                oa = ospf6_area_lookup(route->path.area_id, ospf6);
+               if (!oa) {
+                       zlog_err("OSPFv6 area lookup failed");
+                       return;
+               }
+
                range = ospf6_route_lookup_bestmatch(&route->prefix,
                                                     oa->range_table);
                if (range) {
@@ -864,7 +887,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
                                lsa->header);
                prefix.family = AF_INET6;
                prefix.prefixlen = prefix_lsa->prefix.prefix_length;
-               ospf6_prefix_in6_addr(&prefix.u.prefix6, &prefix_lsa->prefix);
+               ospf6_prefix_in6_addr(&prefix.u.prefix6, prefix_lsa,
+                                     &prefix_lsa->prefix);
                if (is_debug)
                        prefix2str(&prefix, buf, sizeof(buf));
                table = oa->ospf6->route_table;
@@ -910,9 +934,6 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
                         * old as the route.
                         */
                        if (listcount(route->paths) > 1) {
-                               struct listnode *anode;
-                               struct ospf6_path *o_path;
-
                                for (ALL_LIST_ELEMENTS_RO(route->paths, anode,
                                                          o_path)) {
                                        inet_ntop(AF_INET,
@@ -999,6 +1020,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
 
        if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_ROUTER)) {
                /* To pass test suites */
+               assert(router_lsa);
                if (!OSPF6_OPT_ISSET(router_lsa->options, OSPF6_OPT_R)
                    || !OSPF6_OPT_ISSET(router_lsa->options, OSPF6_OPT_V6)) {
                        if (is_debug)
@@ -1284,7 +1306,7 @@ static char *ospf6_inter_area_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
                        (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
                                lsa->header);
 
-               ospf6_prefix_in6_addr(&in6, &prefix_lsa->prefix);
+               ospf6_prefix_in6_addr(&in6, prefix_lsa, &prefix_lsa->prefix);
                if (buf) {
                        inet_ntop(AF_INET6, &in6, buf, buflen);
                        sprintf(&buf[strlen(buf)], "/%d",
@@ -1398,7 +1420,7 @@ void install_element_ospf6_debug_abr(void)
        install_element(CONFIG_NODE, &no_debug_ospf6_abr_cmd);
 }
 
-struct ospf6_lsa_handler inter_prefix_handler = {
+static const struct ospf6_lsa_handler inter_prefix_handler = {
        .lh_type = OSPF6_LSTYPE_INTER_PREFIX,
        .lh_name = "Inter-Prefix",
        .lh_short_name = "IAP",
@@ -1406,7 +1428,7 @@ struct ospf6_lsa_handler inter_prefix_handler = {
        .lh_get_prefix_str = ospf6_inter_area_prefix_lsa_get_prefix_str,
        .lh_debug = 0};
 
-struct ospf6_lsa_handler inter_router_handler = {
+static const struct ospf6_lsa_handler inter_router_handler = {
        .lh_type = OSPF6_LSTYPE_INTER_ROUTER,
        .lh_name = "Inter-Router",
        .lh_short_name = "IAR",