From: Andrea Mayer <andrea.mayer@uniroma2.it>
To: Yuya Kusakabe <yuya.kusakabe@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Gabriel Goller <g.goller@proxmox.com>,
Andrea Mayer <andrea.mayer@uniroma2.it>
Subject: Re: [PATCH net-next v3 1/2] seg6: skip the route refcount in seg6local IPv6 lookups
Date: Tue, 20 Oct 2026 01:04:29 +0200 [thread overview]
Message-ID: <20261020010429.eeffd6f140ec6157609c310a@uniroma2.it> (raw)
In-Reply-To: <20261015-seg6-lookup-noref-v3-1-6d51a60a67d3@gmail.com>
On Thu, 15 Oct 2026 23:39:27 +0900
Yuya Kusakabe <yuya.kusakabe@gmail.com> wrote:
Hi Yuya,
Thanks for v3 and considering my comments.
> [snip]
> if (!table)
> goto out;
>
> + if (noref)
> + flags |= RT6_LOOKUP_F_DST_NOREF;
Even with the change below, the "out:" branch still takes a reference when
fib6_get_table() returns NULL, because RT6_LOOKUP_F_DST_NOREF is set only
after that call. Setting RT6_LOOKUP_F_DST_NOREF before fib6_get_table(),
inside the table branch, would avoid that reference too. The oif branch
needs the flag clear, because ip6_route_output() returns the dst with a
reference.
> [snip]
> rt = net->ipv6.ip6_blk_hole_entry;
> dst = &rt->dst;
> dst_hold(dst);
> + flags &= ~RT6_LOOKUP_F_DST_NOREF;
> }
With this patch applied, the end of seg6_lookup_any_nexthop() reads:
out:
if (!dst) {
rt = net->ipv6.ip6_blk_hole_entry;
dst = &rt->dst;
dst_hold(dst);
flags &= ~RT6_LOOKUP_F_DST_NOREF;
}
skb_dst_drop(skb);
if ((flags & RT6_LOOKUP_F_DST_NOREF) && !dst->rt_uncached_list)
skb_dst_set_noref(skb, dst);
else
skb_dst_set(skb, dst);
return dst->error;
After a noref lookup, the "out:" branch still takes a reference on
ip6_blk_hole_entry and then clears RT6_LOOKUP_F_DST_NOREF.
This branch can be taken at steady state. The noref lookups, except the
ones in input_action_end_dt6(), run with local_delivery false. For example,
with End and a next segment that is a local address of the node, the lookup
returns a local route, seg6_lookup_any_nexthop() discards it, and every
packet takes and drops a reference on ip6_blk_hole_entry in the "out:"
branch. The commit message describes the same pattern for ip6_null_entry.
For a blackhole rule, __fib6_rule_action() picks ip6_blk_hole_entry and
takes no reference on it when the lookup has RT6_LOOKUP_F_DST_NOREF. The
"out:" branch could do the same, for example:
if (!dst) {
dst = &net->ipv6.ip6_blk_hole_entry->dst;
if (!(flags & RT6_LOOKUP_F_DST_NOREF))
dst_hold(dst);
}
RT6_LOOKUP_F_DST_NOREF then stays set, and the skb_dst_set_noref() at the
end of the function attaches ip6_blk_hole_entry without a reference. The
line that clears RT6_LOOKUP_F_DST_NOREF is removed as well.
What do you think?
Nit: seg6_lookup_any_nexthop_noref() and seg6_lookup_nexthop_noref() can
attach the dst without a reference. They rely on being called under RCU. A
one line comment about this, like the one ip6_route_input() has, could help
the next reader.
Ciao,
Andrea
next prev parent reply other threads:[~2026-10-19 23:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:39 [PATCH net-next v3 0/2] seg6: skip route refcounts in seg6local lookups Yuya Kusakabe
2026-10-15 14:39 ` [PATCH net-next v3 1/2] seg6: skip the route refcount in seg6local IPv6 lookups Yuya Kusakabe
2026-10-19 23:04 ` Andrea Mayer [this message]
2026-10-15 14:39 ` [PATCH net-next v3 2/2] seg6: skip the route refcount in seg6local IPv4 lookups Yuya Kusakabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020010429.eeffd6f140ec6157609c310a@uniroma2.it \
--to=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=g.goller@proxmox.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yuya.kusakabe@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®