Article View: linux.kernel.netdev
Article #27380Re: [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 12:31
Date: Sat, 05 Dec 2026 12:31
148 lines
13445 bytes
13445 bytes
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/20261202161942.GA2800642@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/cover.1796382820.git.ralf%40mandelbit.com
Technical Details
Message-ID:
<179647386079.3146.11342277645201573853@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377987-linux-kernel-netdev=dewy.ruReferences:
<4ce33518174bd6b736b3535b3e3ede02c6d23184.1796382820.git.ralf@mandelbit.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377987-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only Date: Sat, 05 Dec 2026 12:31:00 +0000 Organization: Usenet Network Message-ID: <179647386079.3146.11342277645201573853@kernel.org> References: <4ce33518174bd6b736b3535b3e3ede02c6d23184.1796382820.git.ralf@mandelbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3024989"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ax847+LmX7vmZVtwZyTsVVe6kGw= sha256:dsG6Yz0R0P/9v7dsxZ+SJr2bW8hwyTIEYeUukPt+V3M= sha1:Zu9GLVbAoRmmAP6ymgSIWq9LaMo= sha256:Y9MCh+tA+HjbxiuHE5baKDf4qWJA6OKZWs6Q/GR4KHI= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CAD13117E20; Sat, 5 Dec 2026 15:31:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.539 X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bWHqq5v2581t; Sat, 5 Dec 2026 15:31:23 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377987-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 71FEA117E1D; Sat, 5 Dec 2026 15:31:12 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E04E035AF4; Sat, 5 Dec 2026 12:31:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796473868; b=vSy5N4VnS86XZaZKcfMnNpFT7phr/kJ/zBiBBq+7JMkm3FtTa442evDyMmOJgGybf7y8 KH1E6LDKGCy7hn3KpeioFq/OCs4B07sh+1jnXc+7gjjjgJBlOiZWbXyL0BzShYDv+QFN9 XVen74S+X4gazsUG4SxBs7ubC+x6uhlQrzBS4bcqD3iNPlTya+uVMiAIEI4KM0f5SCVlm k6NP0e9v//KhTKqVeqnPdq7UTBiaR8/uUyrAYbMFdY3PpHSbjMafn8Fvk+BnWEdglYglR CYNA7e6H3oVCbZcnuq7LNTnS7HgG0krO97VXE1QxjPShbUyJaLb3vTZocfgkg7rOD+Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796473868; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=r4pEDHcT+jXvHMJb6t95YG0AuEb4Mqdq3HJS8eujI8c=; b=ghTH9oHcAGlHs51j18nDMLG/IgodMjviCBfKdpkGnFFqNQMSygfwa4wH6zk+yOTdo5iH /UH//gWR8RrWU68qfhApY989CL9aj5YMSBGzCZBqmffLU9gH/gSnPbOlEXS7z/cZ7crwP WPDbqAFJnPlHMo6sx+iKc/AvJpO8mXGkxyr4OWaBu6g3stkR6fcYUIkFLtETHox41dGLm DVAuew+MKyGAvPePUMmuV/MTVVKxjkpmmix4eDtpHjGf2joj6ZKKCutLVwvtz8Xbwqr1T sWh4Z2EGsmZ6XYN4qKoLtnnC9pua5xegWY2DlUWblGP5Jan4Z8q7psmxQawQv53hs+g== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqMtGs7w; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CE9F606A33B; Sat, 5 Dec 2026 12:31:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqMtGs7w X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796473862; b=ZfMrvraGzRydhLDZFNQMqiA2kzeA8f44eR/ravbXDuMFDLv3VA8D6kEVoyThDmt+9Xen fBBqaKNAlcL0jpnh/sxiZdNeYOtB/6mX/1HW8Aoe6aHNCHy1493r3LcmSIXD/6l2GWtWn +4T/DLO1Z/uerMFM9EriNuipKk/++L6QmaFUHTneyhgdzb+LnXbE4WXcKlKEGNJ7gEW4t V+z9mi9JbE1ZRorWwOIAprV/IG/BzMiOyGUPmBhrc88RLJgyfcmbQdxk1lavFr9Qxir/D s/jk9HKbuH4tf4TSSSXAQ5XPuJL6UANF4aRuLv5ioayOLXGnS+qWYt6RYzQ1u+UzBfw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796473862; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=r4pEDHcT+jXvHMJb6t95YG0AuEb4Mqdq3HJS8eujI8c=; b=QDX7FSSOB7LlkR82b5+5/IzZqyIFU/r3eKfrtje37nWc1GGQAuxIPlyVqketqX+QVgXR SLJFI1GWDIfZCLWXeMcla39Ejdhfo1yt9owcOHIDYMda6SROg1+KTgFHpKMFdHt4rGlf3 zlnb7w2A9Mr7NCEXyw1/WZWciESn1VxY/N/3SSORTdwheVWRUJAhAOXIN31JglZm2kzlZ QGvKQC/o5H1xvw4z5sJM0dcPFjF/nuxJ5hPZPpdc6WiiBMXUA1f20qJDAE7XZQxeK7BiK Lr6JSbQ70JNP9OhHeJScnYiW394ACcCGdJBu0X5DoMYB8fwfpd4uWIEUfMlGr9pfsXA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqMtGs7w; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59D49606A322; Sat, 5 Dec 2026 12:31:02 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 499711F0092B; Sat, 5 Dec 2026 12:31:01 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796473862; bh=r4pEDHcT+jXvHMJb6t95YG0AuEb4Mqdq3HJS8eujI8c=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ZqMtGs7wHZ8tem+emn05HcXZzPgUex5DkyOW5o5Rik9Y+rhtdaGSzpf/QoprwLhDn qrKlvKsrCjoqazFNANN6uq6mBFfG3Igdw3UcRDAGOuA/R9KKOyFahKJY0UuzeKsAVT vVG3wrXltkqotgP9dZyCZ7ytEkE1N6B4XHFbJqaZoB8M77nGxFPK0iOcYgSPLFUYLg 3rNUK1fOJpg2yQ8jj4J47P5U6RbuMOFX7siVlkFbbsvdpGYXtP/fXWpRKB4EY6rF9y AWZczjY3XsdKNfnjacGgPK8o2efKTpfxY7m3w0d110lrGa3Ik+j9C7VK50EANFWYqQ EVKs3xjzeFX9A== X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, linux-kernel@vger.kernel.org, dahern@nvidia.com, andrea.mayer@uniroma2.it, antonio@mandelbit.com X-In-Reply-To: <4ce33518174bd6b736b3535b3e3ede02c6d23184.1796382820.git.ralf@mandelbit.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list