Skip to content

Commit

Permalink
ospfd: Prune duplicate next-hops when installing into zebra
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aceelindem committed Jan 23, 2025
1 parent d86b1f7 commit 8be264c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ospfd/ospf_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 8be264c

Please sign in to comment.