Skip to content

ipv6: remove dst_ops gc handler

David Ahern netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ipv6: remove dst_ops gc handlerinclude/net/netns/ipv6.h net/ipv6/ip6_fib.c net/ipv6/route.c+42 -350 replies
2/2selftests: Add stress test for dst_entriestools/testing/selftests/net/fib_tests.sh+177 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net-next 0/2] ipv6: remove dst_ops gc handler

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(-)
Signature · 1 line
2.54.0 (Apple Git-157)