trie_modify() maintained rsvd_tbl8s by computing a depth_diff from the current RIB topology at both ADD and DEL. The two values diverge when the RIB changes between an ADD and its later DEL (a covering parent added or removed), so rsvd_tbl8s eventually wraps to UINT32_MAX and rejects all subsequent /25+ ADDs with -ENOSPC. A zebra-kill / reconverge cycle on a live BGP router reproduces it.
The fix computes the reservation from the RIB node shape: count_empty_levels() returns the number of byte boundaries between the prefix and its covering parent that no other prefix occupies (has_children + parent depth), in O(1). It is the count of tbl8 levels the current route set needs, so ADD/DEL accounting stays consistent and cannot drift. Patch 1 is the minimal self-contained fix (Fixes: + Cc: stable). Patches 2-3 add the reproducer and extended regression tests. Validated on a live BGP router (grout + FRR, 128 IPv6 prefixes): RSVD_TBL8 returned to its pre-cycle value (70) after a zebra-kill / reconverge cycle. Maxime Leroy (3): fib6: fix tbl8 reservation drift in trie test/fib6: add reproducer for tbl8 reservation drift test/fib6: extended drift test cases app/test/test_fib6.c | 335 ++++++++++++++++++++++++++++++++++++++++ lib/fib/trie.c | 83 +++++----- lib/rib/rib6_internal.h | 22 +++ lib/rib/rte_rib6.c | 15 ++ 4 files changed, 415 insertions(+), 40 deletions(-) create mode 100644 lib/rib/rib6_internal.h --- v2: * Compute the empty-level count directly from the RIB node (rte_rib6_node_has_children + rte_rib6_get_parent, O(1)) instead of the v1 multi-level supernet scan over byte boundaries. * Drop v1 patches 4-5 (valid_descendants counter + single-descent helper): no longer needed, the node-based count is already O(1), so rte_rib6 needs no new per-node accounting field. 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

