feat: add flood path hop limit and related preferences#2341
Open
OverkillFPV wants to merge 1 commit intomeshcore-dev:devfrom
Open
feat: add flood path hop limit and related preferences#2341OverkillFPV wants to merge 1 commit intomeshcore-dev:devfrom
OverkillFPV wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a configurable hop-limit for flood-routed REQ/RESPONSE/PATH packets to reduce propagation of very long-hop traffic that is unlikely to be useful.
Changes:
- Add a persisted preference
flood_path_maxtoNodePrefs, plus CLIset/get flood.path.max. - Persist the new preference in
/com_prefsload/save. - Enforce the hop limit for flood REQ/RESPONSE/PATH packets in the
simple_repeaterexample.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/helpers/CommonCLI.h |
Adds the new persisted preference field to NodePrefs. |
src/helpers/CommonCLI.cpp |
Reads/writes the new pref in the prefs file and exposes CLI commands to set/get it. |
examples/simple_repeater/MyMesh.h |
Adds a default constant for the repeater’s hop limit. |
examples/simple_repeater/MyMesh.cpp |
Drops over-limit flood REQ/RESPONSE/PATH packets based on the new preference and sets a default value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uint8_t rx_boosted_gain; // power settings | ||
| uint8_t path_hash_mode; // which path mode to use when sending | ||
| uint8_t loop_detect; | ||
| uint8_t flood_path_max; // max path hops for flood REQ/RESPONSE/PATH, 0 = off. Default 12. |
Comment on lines
+611
to
+618
| } else if (memcmp(config, "flood.path.max ", 15) == 0) { | ||
| int val = _atoi(&config[15]); | ||
| if (val < 0 || val > 255) { | ||
| strcpy(reply, "Error: range is 0-255 (0=off, default=12)"); | ||
| } else { | ||
| _prefs->flood_path_max = (uint8_t)val; | ||
| savePrefs(); | ||
| strcpy(reply, "OK"); |
Comment on lines
+611
to
+619
| } else if (memcmp(config, "flood.path.max ", 15) == 0) { | ||
| int val = _atoi(&config[15]); | ||
| if (val < 0 || val > 255) { | ||
| strcpy(reply, "Error: range is 0-255 (0=off, default=12)"); | ||
| } else { | ||
| _prefs->flood_path_max = (uint8_t)val; | ||
| savePrefs(); | ||
| strcpy(reply, "OK"); | ||
| } |
Comment on lines
+561
to
+566
| // Drop flood REQ/RESPONSE/PATH packets that exceed the path hop limit | ||
| if (_prefs.flood_path_max > 0 && pkt->isRouteFlood()) { | ||
| uint8_t pt = pkt->getPayloadType(); | ||
| if (pt == PAYLOAD_TYPE_REQ || pt == PAYLOAD_TYPE_RESPONSE || pt == PAYLOAD_TYPE_PATH) { | ||
| if (pkt->getPathHashCount() > _prefs.flood_path_max) { | ||
| MESH_DEBUG_PRINTLN("filterRecvFloodPacket: flood path too long (%d > %d), dropping!", |
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.
I noticed recently that i was seeing a bunch of request, response, and path packets that were ranging from 10 to even one was 33 hops!! As far as i understand logging into a repeater further than 12 hops away is unlikely to succeed, so therefore these packets don't serve any function going further.