Commit d0cdd0cfc3 for frr
commit d0cdd0cfc342018e5dba9fa5ebfd7fb9205d5672
Author: Donald Sharp <sharpd@nvidia.com>
Date: Fri Nov 27 15:48:14 2026 -0500
zebra: Fix local route handling w/ equiv kernel routes
On some platforms local routes are in the main table, instead
of like linux where the local routes are in a different table.
The code needs to handle them ala what is being handled for
the connected routes.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
diff --git a/zebra/connected.c b/zebra/connected.c
index d022b26992..10040bb3d4 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -345,6 +345,13 @@ void connected_up(struct interface *ifp, struct connected *ifc)
connected_remove_kernel_for_connected(afi, SAFI_MULTICAST, zvrf, &p, &nh);
}
+ if (install_local) {
+ connected_remove_kernel_for_connected(afi, SAFI_UNICAST, zvrf, &plocal,
+ &nh);
+ connected_remove_kernel_for_connected(afi, SAFI_MULTICAST, zvrf, &plocal,
+ &nh);
+ }
+
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("interface %s (%s:%u:%u)%pFX is in %s%s state, not installing connected route",
ifp->name, ifp->vrf->name, ifp->vrf->vrf_id, zvrf->table_id, &p,
@@ -366,8 +373,11 @@ void connected_up(struct interface *ifp, struct connected *ifc)
}
if (install_local) {
+ connected_remove_kernel_for_connected(afi, SAFI_UNICAST, zvrf, &plocal, &nh);
rib_add(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_LOCAL, 0, flags, &plocal,
NULL, &nh, 0, zvrf->table_id, 0, 0, 0, 0, false, true);
+
+ connected_remove_kernel_for_connected(afi, SAFI_MULTICAST, zvrf, &plocal, &nh);
rib_add(afi, SAFI_MULTICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_LOCAL, 0, flags,
&plocal, NULL, &nh, 0, zvrf->table_id, 0, 0, 0, 0, false, true);
}
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 80d00aa1fa..15b92d4896 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -4675,6 +4675,23 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, struct prefix_ip
if (ng && ng->nexthop && ifp->ifindex == ng->nexthop->ifindex)
re->type = ZEBRA_ROUTE_CONNECT;
}
+ } else if (is_host_route(p)) {
+ /*
+ * If we have received a kernel host route( I'm looking at you MacOS )
+ * then there is no need to add it since it is equivalent to the local
+ * route that FRR is installing. As such we do not need it.
+ */
+ ifp = if_lookup_address_local(&p->u.prefix, p->family, re->vrf_id);
+ if (ifp && if_is_operative(ifp)) {
+ zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
+
+ if (zvrf &&
+ (re->table == zvrf->table_id || re->table == RT_TABLE_MAIN)) {
+ zebra_nhg_free(n);
+ zebra_rib_route_entry_free(re);
+ return -1;
+ }
+ }
}
}