]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: Prune duplicate next-hops when installing into zebra
authorAcee Lindem <acee@lindem.com>
Wed, 22 Jan 2025 20:41:47 +0000 (20:41 +0000)
committerAcee Lindem <acee@lindem.com>
Thu, 23 Jan 2025 15:13:53 +0000 (15:13 +0000)
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>
ospfd/ospf_zebra.c

index b718d498ae0de0e7be09a63af55c10aacaecd6dd..f45135f44f7d69fe1566880958bf4ebebe752bab 100644 (file)
@@ -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)) {