+// 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>
#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");
}
}
-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;
/* 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)
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;
}
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",
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];
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++;
int arg_end = use_json ? (argc - 1) : argc;
json_object *json = NULL;
- memset(&prefix, 0, sizeof(struct prefix));
+ memset(&prefix, 0, sizeof(prefix));
if (use_json)
json = json_object_new_object();
int i, ret;
struct prefix router, id, prefix;
- memset(&router, 0, sizeof(struct prefix));
- memset(&id, 0, sizeof(struct prefix));
- memset(&prefix, 0, sizeof(struct prefix));
+ memset(&router, 0, sizeof(router));
+ memset(&id, 0, sizeof(id));
+ memset(&prefix, 0, sizeof(prefix));
for (i = idx_ipv4; i < argc; i++) {
if (strmatch(argv[i]->text, "detail")) {