fix router's gc function#204
Open
tommasoclini wants to merge 2 commits into
Open
Conversation
before this, any new device that wanted to connect after net ids were exhausted couldn't. now the gc_seed_routes function checks if an active route expires and if so turns it into a tombstone
Collaborator
Author
|
@okhsunrog can you take a look at this? |
okhsunrog
added a commit
to okhsunrog/ergot
that referenced
this pull request
Jun 10, 2026
The router allocated net_ids from a strictly monotonic counter that was never reused, so a long-running router with device churn would eventually exhaust the u16 space. Switch to lowest-free allocation that reclaims a net_id once its slot is removed or its seed-route tombstone clears, and make the tombstone grace period genuinely reserve the net_id until reuse is safe. - Replace the monotonic net_id_ctr with net_id_in_use + a lowest-free alloc_net_id (skips direct slots, seed routes incl. tombstones, and the upstream net_id — the last also fixes a latent bridge collision) - gc_seed_routes now tombstones expired active routes before removing them (adapted from jamesmunns#204 by @tommasoclini), the prerequisite for reclaiming a net_id - Anchor the tombstone grace to expiration + GRACE at every lease-expiry site (find, seed/node refresh, gc) so the reservation window starts when authority is lost; deregister keeps now + GRACE (no expiration exists) - register_interface runs gc_seed_routes first so cleared tombstones release their net_ids - Tests: reuse a freed direct net_id; tombstone reserves a seed net_id while a freed net_id is reused
okhsunrog
added a commit
to okhsunrog/ergot
that referenced
this pull request
Jun 10, 2026
jamesmunns#204 (router_gc_fix, by @tommasoclini) is an open PR, not a merged upstream fix, and it only tombstones expired seed routes (freeing table slots) — it does not reclaim net_id values, since the monotonic counter remains. State that accurately: the gc fix is adapted/generalized here, and this work supersedes jamesmunns#204 by also reusing net_ids via lowest-free allocation.
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.
before this, any new device that wanted to connect after net ids were exhausted couldn't. now the gc_seed_routes function checks if an active route expires and if so turns it into a tombstone