mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-23 15:19:08 +02:00
Address CodeRabbit review on #6799. Decrement now decides whether to reprogram based on whether the currently installed peer still holds references (e.peers[e.active] > 0) instead of whether the released peer was the active one. If a prior swap's remove/add failed, e.active was left pointing at a peer with zero references and every later Decrement returned early, permanently stranding the prefix and leaking the entry. The active peer is now detached only when e.active != "", and a failed hand-off is retried on the next Decrement/Increment. Also clear currentPeerKey unconditionally in the static handler's RemoveAllowedIPs (matching dynamic/dnsinterceptor) and assert Increment errors in the tests. Added self-heal tests for the failed remove/add paths.