On Mon, 30 Nov 2026 12:31:58 -0700, David Ahern <dsah…@kernel.org> wrote:
> On 11/27/26 4:03 AM, Ralf Lici wrote:
> > On Wed, 25 Nov 2026 18:33:32 -0700, David Ahern <dsah…@kernel.org> wrote:
> >> @@ -1476,7 +1483,11 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res) > >> > >> pcpu_rt = this_cpu_read(*res->nh->rt6i_pcpu); > >> > >> - if (pcpu_rt && READ_ONCE(pcpu_rt->sernum) && !rt6_is_valid(pcpu_rt)) { > >> + /* A dst stamped with an older genid stays stale for everyone still > >> + * holding it, as in IPv4. Never re-stamp it; drop it and build a > >> + * new one. > >> + */ > >> + if (pcpu_rt && !rt6_is_valid(pcpu_rt)) { > >> struct rt6_info *prev, **p;
> > > > This now evicts the pcpu dst of every route after any generation change, > > and the eviction still drops the slot's reference right away > > (rt6_uncached_list_add and dst_release from 02/13). A reader that took > > the dst from the slot without a reference can then see it freed, when > > the only other reference is the child reference of an xfrm bundle: > > > > 1. Bundle X, whose child is the pcpu dst P of CPU0, drops its last > > reference, and dst_release queues dst_destroy_rcu. > > 2. After that grace period has started, a lookup with > > RT6_LOOKUP_F_DST_NOREF on CPU0 gets P from the slot inside its RCU > > section, and is preempted (PREEMPT_RCU) before dst_hold_safe. > > 3. A lookup on CPU0 after a generation change evicts P and drops the > > slot's reference, so X's child reference is the last one. > > 4. X's grace period ends without waiting for the first lookup, and > > dst_destroy(X) frees P with dst_release_immediate. > > > > Mainline only evicts nexthop-object dsts this way, and > > fib6_nh_release_dsts has the same pattern, as Sashiko pointed out on my
> > I do not recall that being intentional. If anything we want consistency > across built-in nexthops and separate nexthop objects. >
Ok but the objection is not about the eviction itself. The issue is how the slot's reference is dropped: lookups with RT6_LOOKUP_F_DST_NOREF rely on RCU to keep the pcpu dst alive, and dropping the slot's reference right away breaks that when the only other reference is an xfrm bundle's child, since dst_destroy releases the child with dst_release_immediate. Dropping the slot's reference after a grace period, from a call_rcu callback, would fix it for both kinds of nexthops, and in fib6_nh_release_dsts as well.
-- Ralf Lici Mandelbit Srl