Re: [PATCH net-next v3 1/2] seg6: skip the route refcount in seg6local IPv6 lookups

From: Yuya Kusakabe

Date: Wed Oct 21 2026 - 08:05:25 EST


On Tue, 20 Oct 2026 01:04:29 +0200
Andrea Mayer <andrea.mayer@xxxxxxxxxxx> wrote:

> 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.

Agreed. With a local next segment, every End packet goes through the
"out:" branch and takes a reference on a shared entry, which is what
the series removes for ip6_null_entry. On v3, 20000 such packets made
20000 more dst_release() calls than with your suggestion applied.

> 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);
> }

v4 will do that, and will set RT6_LOOKUP_F_DST_NOREF before
fib6_get_table() in the table branch, so that a missing table takes no
reference either. The oif branch will keep the flag clear.

> 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.

v4 will add one to both helpers.