Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] rt6_dst_release_deferred() in net/ipv6/route.c (line 162) drops the allocation reference of the uncached FLOWI_FLAG_KNOWN_NH… -- ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only This commit makes RT6_LOOKUP_F_DST_NOREF the only signal for dst ownership, instead of membership in the uncached list. For the uncached FLOWI_FLAG_KNOWN_NH RTF_CACHE clone, ip6_pol_route() no longer hands the allocation reference to a NOREF caller. That reference is now dropped after an RCU grace period by a new helper, rt6_dst_release_deferred(). Link: https://lore.kernel.org/netdev/2026…@shredder/
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index d3c77941d2cf8..39bcfa1ce01b1 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -147,6 +147,21 @@ void rt6_uncached_list_add(struct rt6_info *rt) > spin_unlock_bh(&ul->lock); > } > > +static void rt6_dst_release_rcu(struct rcu_head *head) > +{ > + struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head); > + > + dst_release(dst); > +} > + > +/* Drop a reference after a grace period, so that RCU readers that found the > + * dst without one can still use it and take their own. > + */ > +static void rt6_dst_release_deferred(struct rt6_info *rt) > +{ > + call_rcu(&rt->dst.rcu_head, rt6_dst_release_rcu);
[Severity: Medium] Should this be call_rcu_hurry() rather than call_rcu()? With CONFIG_RCU_LAZY=y on offloaded (rcu_nocbs) CPUs, plain call_rcu() can leave the callback in the lazy bypass for up to the lazy flush interval, which is about 10 seconds. The existing last-reference path for the same object deliberately avoids that: net/core/dst.c:dst_release() { ... dst_count_dec(dst); call_rcu_hurry(&dst->rcu_head, dst_destroy_rcu); ... } dst_destroy_rcu can only be queued once the deferred put has run. Every uncached clone therefore lives for at least two grace periods, and the first one may be lazy. During that window it still pins rt->from (the fib6_info and its nexthop), rt6i_idev, the dst->dev reference and the lwtstate.
> +} > +
[ ... ]
> @@ -2310,12 +2325,14 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, > rt = ip6_rt_cache_alloc(&res, &fl6->daddr, NULL); > > if (rt) { > - /* 1 refcnt is taken during ip6_rt_cache_alloc(). > - * As rt6_uncached_list_add() does not consume refcnt, > - * this refcnt is always returned to the caller even > - * if caller sets RT6_LOOKUP_F_DST_NOREF flag. > - */ > rt6_uncached_list_add(rt); > + /* A RT6_LOOKUP_F_DST_NOREF caller does not inherit the > + * reference ip6_rt_cache_alloc returned. Dropping it > + * after a grace period keeps the dst alive for the > + * caller's RCU section. > + */ > + if (flags & RT6_LOOKUP_F_DST_NOREF) > + rt6_dst_release_deferred(rt);
This path runs on every KNOWN_NH lookup that allocates a clone. It is not limited to explicit NOREF callers, because ip6_route_output_flags_noref() always sets the flag: flags |= RT6_LOOKUP_F_DST_NOREF; That means users of the refcounting ip6_route_output() API reach it once per packet too, through: ip6_route_output()->ip6_route_output_flags()-> ip6_route_output_flags_noref()->fib6_rule_lookup()->ip6_pol_route() Those users include raw hdrincl sends, nf_dup_ipv6 (TEE/dup), IPVS xmit, and seg6local End.X with nh6. Remote traffic can drive several of them.
> rcu_read_unlock(); > > return rt; > @@ -2715,13 +2732,10 @@ struct dst_entry *ip6_route_output_flags(struct net *net, > int flags) > { > struct dst_entry *dst; > - struct rt6_info *rt6; > > rcu_read_lock(); > dst = ip6_route_output_flags_noref(net, sk, fl6, flags); > - rt6 = dst_rt6_info(dst); > - /* For an uncached dst, refcnt is already taken. */ > - if (!rt6->dst.rt_uncached_list && !dst_hold_safe(dst)) { > + if (!dst_hold_safe(dst)) {
Before this patch, these callers inherited the allocation reference. They paid one dst_release() and one hurried grace period per clone. They now pay an extra refcount increment and decrement here, plus one extra RCU callback per packet on top of the final dst_destroy_rcu. The commit message only says the reference "is dropped after a grace period instead". Could it also mention this extra per-packet cost for ip6_route_output() users and explain the choice of call_rcu() over call_rcu_hurry()? The later patch in the series, "ipv6: keep a superseded pcpu dst working until its holders notice", reuses rt6_dst_release_deferred() for replaced per-CPU dsts and keeps call_rcu(). The issue is therefore still present at the end of the series.
> dst = &net->ipv6.ip6_null_entry->dst; > dst_hold(dst); > }
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cove…%40mandelbit.com