]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_route.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospf6d / ospf6_route.c
index 8e964393f100d81076014c633229c3b15e99e011..72dfa240afded489202d3804700cb89dcc442e01 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>
@@ -37,9 +22,7 @@
 #include "ospf6_interface.h"
 #include "ospf6d.h"
 #include "ospf6_zebra.h"
-#ifndef VTYSH_EXTRACT_PL
 #include "ospf6d/ospf6_route_clippy.c"
-#endif
 
 DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_ROUTE,   "OSPF6 route");
 DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_ROUTE_TABLE, "OSPF6 route table");
@@ -248,7 +231,10 @@ void ospf6_merge_nexthops(struct list *dst, struct list *src)
        }
 }
 
-int ospf6_route_cmp_nexthops(struct ospf6_route *a, struct ospf6_route *b)
+/*
+ * If the nexthops are the same return true
+ */
+bool ospf6_route_cmp_nexthops(struct ospf6_route *a, struct ospf6_route *b)
 {
        struct listnode *anode, *bnode;
        struct ospf6_nexthop *anh, *bnh;
@@ -266,14 +252,14 @@ int ospf6_route_cmp_nexthops(struct ospf6_route *a, struct ospf6_route *b)
                                /* Currnet List A element not found List B
                                 * Non-Identical lists return */
                                if (identical == false)
-                                       return 1;
+                                       return false;
                        }
-                       return 0;
+                       return true;
                } else
-                       return 1;
+                       return false;
        }
        /* One of the routes doesn't exist ? */
-       return (1);
+       return false;
 }
 
 int ospf6_num_nexthops(struct list *nh_list)
@@ -579,12 +565,7 @@ ospf6_route_lookup_identical(struct ospf6_route *route,
 
        for (target = ospf6_route_lookup(&route->prefix, table); target;
             target = target->next) {
-               if (target->type == route->type
-                   && prefix_same(&target->prefix, &route->prefix)
-                   && target->path.type == route->path.type
-                   && target->path.cost == route->path.cost
-                   && target->path.u.cost_e2 == route->path.u.cost_e2
-                   && ospf6_route_cmp_nexthops(target, route) == 0)
+               if (ospf6_route_is_identical(target, route))
                        return target;
        }
        return NULL;
@@ -704,6 +685,27 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
        }
 
        if (old) {
+               /* if route does not actually change, return unchanged */
+               if (ospf6_route_is_identical(old, route)) {
+                       if (IS_OSPF6_DEBUG_ROUTE(MEMORY))
+                               zlog_debug(
+                                       "%s %p: route add %p: needless update of %p old cost %u",
+                                       ospf6_route_table_name(table),
+                                       (void *)table, (void *)route,
+                                       (void *)old, old->path.cost);
+                       else if (IS_OSPF6_DEBUG_ROUTE(TABLE))
+                               zlog_debug("%s: route add: needless update",
+                                          ospf6_route_table_name(table));
+
+                       ospf6_route_delete(route);
+                       SET_FLAG(old->flag, OSPF6_ROUTE_ADD);
+                       ospf6_route_table_assert(table);
+
+                       /* to free the lookup lock */
+                       route_unlock_node(node);
+                       return old;
+               }
+
                if (IS_OSPF6_DEBUG_ROUTE(MEMORY))
                        zlog_debug(
                                "%s %p: route add %p cost %u paths %u nh %u: update of %p cost %u paths %u nh %u",
@@ -1360,7 +1362,7 @@ static void ospf6_route_show_table_summary(struct vty *vty,
        struct ospf6_route *route, *prev = NULL;
        int i, pathtype[OSPF6_PATH_TYPE_MAX];
        unsigned int number = 0;
-       int nh_count = 0, nhinval = 0, ecmp = 0;
+       int nh_count = 0, ecmp = 0;
        int alternative = 0, destination = 0;
        char path_str[30];
 
@@ -1374,9 +1376,7 @@ static void ospf6_route_show_table_summary(struct vty *vty,
                else
                        alternative++;
                nh_count = ospf6_num_nexthops(route->nh_list);
-               if (!nh_count)
-                       nhinval++;
-               else if (nh_count > 1)
+               if (nh_count > 1)
                        ecmp++;
                pathtype[route->path.type]++;
                number++;