Apply wildcard deny and hop limits to zero-scope floods

This commit is contained in:
mikecarper committed 2026-10-15 17:37:54 -07:00
1 parent 755895c7e0
commit 0eace6b694
4 files changed
+93 -3

No files matched your search

+4 -1
View File
@@ -288,7 +288,10 @@ int RegionMap::getTransportKeysFor(const RegionEntry& src, TransportKey dest[],
}
RegionEntry* RegionMap::findMatch(const mesh::Packet* packet, uint8_t mask) {
if (packet->transport_codes[0] == 0) return &wildcard;
if (packet->transport_codes[0] == 0) {
// Zero means unscoped, not an exemption from the wildcard's deny policy.
return (wildcard.flags & mask) == 0 ? &wildcard : NULL;
}
for (int i = 0; i < num_regions; i++) {
auto region = &regions[i];
if ((region->flags & mask) == 0) { // does region allow this? (per 'mask' param)
+5 -2
View File
@@ -8,7 +8,7 @@ namespace mesh {
* \brief Test a flood packet against the configured hop limits.
* \param packet inbound flood packet (caller has already checked isRouteFlood())
* \param flood_max max hops for any flood packet
* \param flood_max_unscoped max hops for ROUTE_TYPE_FLOOD (ie. un-scoped) packets
* \param flood_max_unscoped max hops for ordinary or zero-code transport floods
* \param flood_max_advert max hops for ADVERT packets
* \returns true if the packet has exceeded a limit, and must not be forwarded
*/
@@ -16,7 +16,10 @@ inline bool isFloodHopLimitExceeded(const Packet* packet, uint8_t flood_max,
uint8_t flood_max_unscoped, uint8_t flood_max_advert) {
uint8_t hops = packet->getPathHashCount();
if (hops >= flood_max) return true;
if (packet->getRouteType() == ROUTE_TYPE_FLOOD && hops >= flood_max_unscoped) return true;
const uint8_t route_type = packet->getRouteType();
const bool unscoped = route_type == ROUTE_TYPE_FLOOD
|| (route_type == ROUTE_TYPE_TRANSPORT_FLOOD && packet->transport_codes[0] == 0);
if (unscoped && hops >= flood_max_unscoped) return true;
if (packet->getPayloadType() == PAYLOAD_TYPE_ADVERT && hops >= flood_max_advert) return true;
return false;
}