Skip to content

fix router's gc function#204

Open
tommasoclini wants to merge 2 commits into
jamesmunns:mainfrom
tommasoclini:router_gc_fix
Open

fix router's gc function#204
tommasoclini wants to merge 2 commits into
jamesmunns:mainfrom
tommasoclini:router_gc_fix

Conversation

@tommasoclini

Copy link
Copy Markdown
Collaborator

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

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
@tommasoclini tommasoclini marked this pull request as ready for review June 6, 2026 20:10
@tommasoclini

Copy link
Copy Markdown
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant