From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
willemb@google.com, horms@kernel.org
Subject: [PATCH net-next 0/2] ipv6: remove dst_ops gc handler
Date: Tue, 1 Dec 2026 18:55:21 -0700 [thread overview]
Message-ID: <20261202015529.7846-1-dsahern@kernel.org> (raw)
IPv6 is the only address family that still uses dst_ops->gc to
limit dst entries. ip6_dst_gc() runs from dst_alloc() whenever
the entry count exceeds gc_thresh. It never fails an allocation
(max_size is already INT_MAX); it only forces a fib6_run_gc()
pass. That pass can free expired exceptions and expired routes
on the FIB6 gc list. It cannot free uncached dsts, which are
held by sockets and skbs.
Remove the handler and rely on the structural limits that
already bound the dst count, the same way IPv4 does.
How the dst count is bounded
----------------------------
Per-cpu routes are DST_NOCOUNT and are limited to one per cpu
per nexthop.
Cached exceptions (PMTU, redirect) live in a per-nexthop hash.
Each bucket is limited to a randomized depth and the oldest
entry is evicted on insert:
IPv6 IPv4
buckets 1024 (shift 10) 2048 (shift 11)
max depth FIB6_MAX_DEPTH (5) FNHE_RECLAIM_DEPTH (5)
+ random(0..4) + random(0..4)
Time-based expiry:
- IPv6: FIB6 gc timer every gc_interval (30s) while the gc
list is non-empty. It also runs on route flush, ndisc
device events and exception insert.
- IPv4: fnhe_expires is checked on lookup and update, and
fnhe_genid invalidates stale entries. There is no timer.
Uncached dsts (icmp6_dst_alloc(), FLOWI_FLAG_KNOWN_NH clones)
are counted but not capped, in both families. They are bounded
only by the users holding references. The old gc could not
reclaim them either.
Behavior changes
----------------
- dst_ops gc_thresh defaults to ~0, as in IPv4. Reading
net.ipv6.route.gc_thresh now returns -1 instead of 1024.
- gc_thresh, gc_min_interval, gc_min_interval_ms, gc_timeout and
gc_elasticity are kept so existing scripts still work. They
have no effect, and a write logs a one-time warning.
gc_interval is unchanged.
- Expired exceptions are no longer reclaimed early under
allocation pressure. They stay until the gc timer runs, up to
gc_interval plus the exception timeout. Memory is capped at
roughly 1024 x 9 entries per nexthop, the same order as IPv4.
Patches
-------
1: remove ip6_dst_gc() and its per-netns state, and mark the
gc sysctls deprecated
2: selftests: add a stress test for dst_entries
David Ahern (2):
ipv6: remove dst_ops gc handler
selftests: Add stress test for dst_entries
include/net/netns/ipv6.h | 2 -
net/ipv6/ip6_fib.c | 1 -
net/ipv6/route.c | 74 ++++++----
tools/testing/selftests/net/fib_tests.sh | 178 ++++++++++++++++++++++-
4 files changed, 219 insertions(+), 36 deletions(-)
--
2.54.0 (Apple Git-157)
next reply other threads:[~2026-12-02 1:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 1:55 David Ahern [this message]
2026-12-02 1:55 ` [PATCH net-next 1/2] ipv6: remove dst_ops gc handler David Ahern
2026-12-02 1:55 ` [PATCH net-next 2/2] selftests: Add stress test for dst_entries David Ahern
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=20261202015529.7846-1-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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