Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] ipv6: remove dst_ops gc handler
@ 2026-12-02  1:55 David Ahern
  2026-12-02  1:55 ` [PATCH net-next 1/2] " David Ahern
  2026-12-02  1:55 ` [PATCH net-next 2/2] selftests: Add stress test for dst_entries David Ahern
  0 siblings, 2 replies; 3+ messages in thread
From: David Ahern @ 2026-12-02  1:55 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, willemb, horms

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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02  1:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  1:55 [PATCH net-next 0/2] ipv6: remove dst_ops gc handler David Ahern
2026-12-02  1:55 ` [PATCH net-next 1/2] " David Ahern
2026-12-02  1:55 ` [PATCH net-next 2/2] selftests: Add stress test for dst_entries David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox