Skip to content

feat: add flood path hop limit and related preferences#2341

Open
OverkillFPV wants to merge 1 commit intomeshcore-dev:devfrom
OverkillFPV:Flood-Logins-Limit
Open

feat: add flood path hop limit and related preferences#2341
OverkillFPV wants to merge 1 commit intomeshcore-dev:devfrom
OverkillFPV:Flood-Logins-Limit

Conversation

@OverkillFPV
Copy link
Copy Markdown

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.

Copilot AI review requested due to automatic review settings April 20, 2026 10:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_max to NodePrefs, plus CLI set/get flood.path.max.
  • Persist the new preference in /com_prefs load/save.
  • Enforce the hop limit for flood REQ/RESPONSE/PATH packets in the simple_repeater example.

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.

Comment thread src/helpers/CommonCLI.h
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 thread src/helpers/CommonCLI.cpp
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 thread src/helpers/CommonCLI.cpp
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!",
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.

2 participants