Release packets the interface declines to send (#11087)

This commit is contained in:
Thomas Göttgens authored and GitHub committed 2026-07-20 13:42:59 +02:00
1 parent 829ff80a09
commit 290967f739
5 files changed
+129 -17

No files matched your search

+27 -15
View File
@@ -159,6 +159,9 @@ bool NextHopRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
}
#endif
if (p->to == NODENUM_BROADCAST_NO_LORA)
return false;
// Allow rebroadcast if hop_limit > 0 OR if we're exhausting hops (which sets hop_limit = 0 but still needs one relay)
if (!isToUs(p) && !isFromUs(p) && (p->hop_limit > 0 || exhaustHops)) {
if (p->id != 0) {
@@ -192,11 +195,10 @@ bool NextHopRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
}
#endif
if (p->next_hop == NO_NEXT_HOP_PREFERENCE) {
FloodingRouter::send(tosend);
} else {
NextHopRouter::send(tosend);
}
ErrorCode res =
(p->next_hop == NO_NEXT_HOP_PREFERENCE) ? FloodingRouter::send(tosend) : NextHopRouter::send(tosend);
if (res == ERRNO_SHOULD_RELEASE)
packetPool.release(tosend);
return true;
}
@@ -401,8 +403,10 @@ int32_t NextHopRouter::doRetransmissions()
trafficManagementModule->clearNextHop(p.packet->to);
}
#endif
if (auto *copy = packetPool.allocCopy(*p.packet))
FloodingRouter::send(copy);
if (auto *copy = packetPool.allocCopy(*p.packet)) {
if (FloodingRouter::send(copy) == ERRNO_SHOULD_RELEASE)
packetPool.release(copy);
}
} else {
#if NEXTHOP_EARLY_FLOOD_ON_UNVERIFIED
// M4 (gated): if the route isn't proven healthy, don't spend a second directed
@@ -416,22 +420,30 @@ int32_t NextHopRouter::doRetransmissions()
meshtastic_NodeInfoLite *sentTo = nodeDB->getMeshNode(p.packet->to);
if (sentTo)
sentTo->next_hop = NO_NEXT_HOP_PREFERENCE;
if (auto *copy = packetPool.allocCopy(*p.packet))
FloodingRouter::send(copy);
if (auto *copy = packetPool.allocCopy(*p.packet)) {
if (FloodingRouter::send(copy) == ERRNO_SHOULD_RELEASE)
packetPool.release(copy);
}
} else {
if (auto *copy = packetPool.allocCopy(*p.packet))
NextHopRouter::send(copy);
if (auto *copy = packetPool.allocCopy(*p.packet)) {
if (NextHopRouter::send(copy) == ERRNO_SHOULD_RELEASE)
packetPool.release(copy);
}
}
#else
if (auto *copy = packetPool.allocCopy(*p.packet))
NextHopRouter::send(copy);
if (auto *copy = packetPool.allocCopy(*p.packet)) {
if (NextHopRouter::send(copy) == ERRNO_SHOULD_RELEASE)
packetPool.release(copy);
}
#endif
}
} else {
// Note: we call the superclass version because we don't want to have our version of send() add a new
// retransmission record
if (auto *copy = packetPool.allocCopy(*p.packet))
FloodingRouter::send(copy);
if (auto *copy = packetPool.allocCopy(*p.packet)) {
if (FloodingRouter::send(copy) == ERRNO_SHOULD_RELEASE)
packetPool.release(copy);
}
}
// Queue again