Repository navigation
fix(region): code-0 floods obey denyf * and flood.max.unscoped - #22
Merged
Merged
Conversation
Upstream meshcore-dev#3568 made RegionMap::findMatch() return the wildcard for a TRANSPORT_FLOOD with transport code 0, without checking the wildcard's flags. isFloodHopLimitExceeded() only applied flood.max.unscoped to ROUTE_TYPE_FLOOD. A code-0 packet therefore passed 'region denyf *', skipped flood.max.unscoped, and ignored the duty-cycle gate on '*'. - findMatch(): code 0 returns the wildcard only when its effective flags (config + runtime gate) allow the mask, otherwise NULL. - RoutingPolicy: new isUnscopedFlood() (FLOOD, or TRANSPORT_FLOOD with code 0), used for the flood.max.unscoped check. Tests: findMatch code-0 cases in test_region_gating; isUnscopedFlood and code-0 hop limits in test_routing_policy. makeFlood() now sets an explicit transport code, since Packet() leaves transport_codes uninitialised.
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.
Problem
Upstream meshcore-dev#3568 (in v1.18) made
RegionMap::findMatch()return the wildcard for a TRANSPORT_FLOOD whosetransport_codes[0]is 0 ("treat code 0 the same as un-scoped"). It does this without checking the wildcard's flags. On top of that,isFloodHopLimitExceeded()only appliesflood.max.unscopedtoROUTE_TYPE_FLOOD.So a code-0 packet:
region denyf *flood.max.unscoped(onlyflood.max64 /flood.max.advertapply)dc.gateruntime gate on*Stock clients never send code 0, but any modified client can. The gap is still present on upstream
mainanddev.Fix
findMatch(): code 0 returns the wildcard only whenwildcard.effectiveFlags()(config + runtime gate) allows the mask, otherwise NULL. That's the same ruleonRecvPacket()already applies to plain unscoped floods.RoutingPolicy.h: newisUnscopedFlood()(FLOOD, or TRANSPORT_FLOOD with code 0), used for theflood.max.unscopedcheck.Scoped traffic is unchanged: a real code still matches its region even while
*is denied. Replies to an allowed code-0 request still go back unscoped (chooseReplyScope).Tests
test_region_gating: code 0 with*allowed / denied (denyf *) / held bydc.gate, code 0 with acodes[1]hint, and a named region still matching while*is denied. The three deny cases failed before the fix.test_routing_policy:isUnscopedFlood()cases, and code-0 hop limits at 0 and N.makeFlood()now sets an explicit transport code for scoped packets, becausePacket()leavestransport_codesuninitialised.native252/252,native_region_gating25/25.Follow-ups
dmc-observer-dev/ packetlog after merge (same gap there).dev(text drafted; upstream has nort_flags, so it useswildcard.flags).🤖 Generated with Claude Code