Mitigate Direct Routing Instability from One-Byte Hop Hash Collisions#1776
Open
robekl wants to merge 1 commit intomeshcore-dev:devfrom
Open
Mitigate Direct Routing Instability from One-Byte Hop Hash Collisions#1776robekl wants to merge 1 commit intomeshcore-dev:devfrom
robekl wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
…ous paths Direct routing currently uses one-byte hop hashes, which can collide in larger or mixed-topology meshes and cause mis-forwarding or unstable delivery when a stored path includes ambiguous hop bytes. This change adds a compatibility-safe mitigation in route selection logic for chat-style workflows: detect ambiguous direct paths using known contact prefixes and avoid direct sends when ambiguity is present. When ambiguity is detected, outbound traffic that would have used stored direct paths now falls back to scoped flood for message send APIs, ACK sending, response-path decisions, keep-alive traffic, and return-path retries. The mitigation is intentionally conservative: it does not alter packet format or routing protocol semantics, and it reduces risk of direct-route blackholing, route flapping, and repeated retry/fallback churn in collision-prone neighborhoods. A lightweight internal counter was added to track how often direct sends are avoided due to ambiguity, enabling future operational tuning and observability.
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
This change introduces a protocol-compatible mitigation for direct-routing instability caused by one-byte hop-hash ambiguity.
Problem
Direct paths currently identify each hop using only a single byte of node identity.
A one-byte space has only 256 possible values, so collisions are not edge cases in realistic meshes:
When this happens, direct-routing behavior can degrade in several ways:
Preferred long-term fix
The robust fix is a protocol evolution that carries larger hop identifiers (for example 2+ bytes per hop, ideally versioned with capability handling).
That would reduce hop aliasing at the source instead of handling ambiguity heuristically at runtime.
Why this change is a mitigation
This implementation does not alter packet format or route encoding.
Instead, it reduces harm by detecting when a stored direct path is likely ambiguous and avoiding direct transmission in those cases.
Mitigation behavior
The routing decision now distinguishes between:
This reduces the chance of direct-path misforwarding and avoids wasting retries on routes that are likely unstable due to hop-byte aliasing.
Scenarios where this helps
Implementation overview
The change adds a direct-path ambiguity check in contact-routing logic and applies it consistently across outbound behaviors that rely on stored direct paths:
When ambiguity is detected for a known direct path, direct send is skipped and flood/scoped-flood is used instead.
A lightweight internal metric is also maintained for observability of “direct avoided due to ambiguity,” helping operators and maintainers evaluate how often this mitigation is active.
Expected impact