activator: fix tunnel ID leak on failed user activation#3265
Merged
Conversation
When a Pending user activation fails (transaction error, race condition, tunnel endpoint rejection, or dz_ip exhaustion), the eagerly-allocated tunnel_id, tunnel_net, and dz_ip were never rolled back. These ghost IDs accumulated in the in-memory device_state.tunnel_ids allocator, eventually pushing new allocations past the controller's tunnel slot range and preventing tunnel config from being pushed to devices. Roll back all eagerly-allocated resources (tunnel_id, tunnel_net, dz_ip, publisher_dz_ip) in every error/early-return path within the Pending activation handler. Extract DeviceState::release_dz_ip() to allow releasing dz_ip independently of tunnel_id during rollback.
juan-malbeclabs
approved these changes
Mar 15, 2026
Contributor
|
@greg, It would be good if you could take a look too. |
elitegreg
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
DeviceState::release_dz_ip()to allow releasing dz_ip independently of tunnel_id during rollbackDiff Breakdown
~83% of the diff is tests.
Key files (click to expand)
activator/src/process/user.rs— add rollback of tunnel_id, tunnel_net, dz_ip, and publisher_dz_ip in 4 error paths within the Pending activation handler; add 5 rollback tests via shared helperactivator/src/states/devicestate.rs— extractrelease_dz_ip()fromrelease()so dz_ip can be freed independently of tunnel_idCHANGELOG.md— add entry for tunnel ID leak fixTesting Verification