summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAcee Lindem <acee@lindem.com>2025-01-22 20:41:47 +0000
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2025-03-28 15:02:56 +0000
commit89e73dce28ee822acce788da8301a15dfe6dd71f (patch)
treea5b40de7331c5a8da14d9a6fbd745b54c8efc88c
parent1b0d49545c8516c3a377f840ac242b0f1d882cb7 (diff)
ospfd: Prune duplicate next-hops when installing into zebra
Duplicate next-hops are maintained for OSPF inter-area and AS external routes in the OSPF routing table as long as they correspond to LSAs for different adverting routers. The intra-area route computation will not result in duplicate next-hops. Signed-off-by: Acee Lindem <acee@lindem.com> (cherry picked from commit 1c55cf27a207323ab640a6e558c2e7001a3c0c6e)
-rw-r--r--ospfd/ospf_zebra.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index b718d498ae..f45135f44f 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -304,6 +304,27 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p,
if (api.nexthop_num >= ospf->max_multipath)
break;
+ /*
+ * Prune duplicate next-hops from the route that is
+ * installed in the zebra IP route table. OSPF Intra-Area
+ * routes never have duplicates.
+ */
+ if (or->path_type != OSPF_PATH_INTRA_AREA) {
+ struct zapi_nexthop *api_nh = &api.nexthops[0];
+ unsigned int nh_index;
+ bool duplicate_next_hop = false;
+
+ for (nh_index = 0; nh_index < api.nexthop_num; api_nh++, nh_index++) {
+ if (IPV4_ADDR_SAME(&api_nh->gate.ipv4, &path->nexthop) &&
+ (api_nh->ifindex == path->ifindex)) {
+ duplicate_next_hop = true;
+ break;
+ }
+ }
+ if (duplicate_next_hop)
+ continue;
+ }
+
ospf_zebra_add_nexthop(ospf, path, &api);
if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {