This v1 supersedes the earlier RFC. The RFC dropped rsvd_tbl8s and used tbl8_pool_pos in the pre-check, which loses the worst-case envelope: a compressed /48 under a /28 allocates zero tbl8s but must reserve the boundaries the /48 would need if the /28 is later removed (DEL forces mid-flight decompression in modify_dp() with no rollback).
This v1 keeps rsvd_tbl8s and computes it the way dir24_8 already does for IPv4. dir24_8 counts /24 supernets that contain at least one /25..32 prefix: that count is invariant under unrelated RIB changes, so the counter cannot drift. trie6 has the same need at 13 levels instead of 1 (byte boundaries 24, 32, ..., 120), so v1 counts, for each L in that set, the /L supernets containing at least one prefix with depth > L. ADD/DEL pairs are symmetric by construction. Patch 1 is the minimal self-contained fix (Fixes: + Cc: stable). Patches 2-3 add the reproducer and extended regression tests. Patches 4-5 are an optimization (not for stable): valid_descendants in rte_rib6 + single-descent helper, so trie_modify() walks once instead of up to 13 times per ADD/DEL. Validated on a live BGP router (grout + FRR, 127 IPv6 prefixes): RSVD_TBL8 returned to its pre-cycle value after a zebra-kill / reconverge cycle. Maxime Leroy (5): fib6: fix tbl8 reservation drift in trie test/fib6: add reproducer for tbl8 reservation drift test/fib6: extended drift test cases rib: track valid descendant count per node fib6: speed up tbl8 reservation accounting app/test/test_fib6.c | 335 ++++++++++++++++++++++++++++++++++++++++ app/test/test_rib6.c | 92 +++++++++++ lib/fib/trie.c | 47 +----- lib/rib/rib6_internal.h | 37 +++++ lib/rib/rte_rib6.c | 80 ++++++++++ 5 files changed, 552 insertions(+), 39 deletions(-) create mode 100644 lib/rib/rib6_internal.h --- v1: * Keep rsvd_tbl8s; recompute it via topology-stable empty-supernet count (dir24_8 pattern at 13 levels) instead of RIB-derived depth_diff. * Drop RFC patch 3/3 (no longer needed). * Add extended regression tests. * Add patches 4-5: RIB valid_descendants + single-descent helper (optional perf optimization; not for stable). * Production-validated on a live BGP router. -- 2.43.0

