On Thu, Nov 19, 2026 at 05:32:31PM +0200, Kapetanakis Giannis wrote:
> Hi,
>
> Reporting 2 bugs that I had with ospf6d over the last years.
> From my side it wasn't easy to replicate, so I used Claude for this today.
>
> We managed to find a way to replicate the issues.
> Claude also produced two patches which I've tested and at least didn't
> reproduce the problem.
>
> Tell me if you need more information.
>
> regards,
>
> G
>
> Here is the report by claude:
>
> TL;DR
> -----
>
> ospf6d can install a p2p next hop with the link-local address of a
> *different* neighbor (right interface, wrong address), which silently
> blackholes all routes via that neighbor until ospf6d is restarted.
>
> Cause: calc_nexthop_lladdr() looks up the neighbor's Link-LSA with our
> own interface ID instead of the neighbor's (nbr_iface_id), so the
> lookup always misses on p2p links and falls back to the address of
> whichever neighbor delivered the Router-LSA.
>
> A second, related issue:
> rt_nexthop_add() merges equal-cost next hops by address only, ignoring
> the interface. Both date back to 2007/2009, affect ospf6d only, and are
> reproducible on 8.0. Two small diffs below, tested on 8.0.
>
Thanks for the report and suggested diff. I think the diff below is
better. It keeps the API for calc_nexthop_lladdr and moves the selection
of the correct rtr_link information into the calc_nexthop_lladdr function.
Transit networks store the DR in the neighbor info while on P2P and
virtual links the neighbor data is identifying the remote router of the
link. So in the first case one needs to use the adv_rtr and its interface
id to find the link LSA while for all others the nbr information needs to
be used.
The rt_nexthop_add function I swapped the comperison order to be more like
the kroute code. So first scope then address.
I did not test this yet so I hope you could give this a spin and verify
that it indeed works as expected.
--
:wq Claudio
Index: rde_spf.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/rde_spf.c,v
diff -u -p -r1.29 rde_spf.c
--- rde_spf.c 8 Mar 2023 04:43:14 -0000 1.29
+++ rde_spf.c 24 Nov 2026 08:29:09 -0000
@@ -463,6 +463,7 @@ calc_nexthop_lladdr(struct vertex *dst,
struct iface *iface;
struct vertex *link;
struct rde_nbr *nbr;
+ uint32_t rtr_id, iface_id;
/* Find outgoing interface, we need its LSA tree */
LIST_FOREACH(iface, &dst->area->iface_list, entry) {
@@ -471,15 +472,27 @@ calc_nexthop_lladdr(struct vertex *dst,
}
if (!iface) {
log_warnx("calc_nexthop_lladdr: no interface found for "
- "ifindex %d", ntohl(rtr_link->iface_id));
+ "ifindex %u", ifindex);
return (NULL);
}
+ /*
+ * p2p and virtual links use the data from the rtr_link,
+ * transit networks use the adv router and interface id since
+ * the rtr_link data points to the DR and its interface.
+ */
+ if (rtr_link->type == LINK_TYPE_TRANSIT_NET) {
+ iface_id = rtr_link->iface_id;
+ rtr_id = htonl(dst->adv_rtr);
+ } else {
+ iface_id = rtr_link->nbr_iface_id;
+ rtr_id = rtr_link->nbr_rtr_id;
+ }
+
/* Determine neighbor's link-local address.
* Try to get it from link LSA first. */
link = lsa_find_tree(&iface->lsa_tree,
- htons(LSA_TYPE_LINK), rtr_link->iface_id,
- htonl(dst->adv_rtr));
+ htons(LSA_TYPE_LINK), iface_id, rtr_id);
if (link)
return &link->lsa->data.link.lladdr;
@@ -873,7 +886,8 @@ rt_nexthop_add(struct rt_node *r, struct
TAILQ_FOREACH(vn, vnh, entry) {
TAILQ_FOREACH(rn, &r->nexthop, entry) {
- if (!IN6_ARE_ADDR_EQUAL(&rn->nexthop, &vn->nexthop))
+ if (rn->ifindex != vn->ifindex ||
+ !IN6_ARE_ADDR_EQUAL(&rn->nexthop, &vn->nexthop))
continue;
rn->adv_rtr.s_addr = adv_rtr.s_addr;