Skip to content

fix(mesh): don't evict ACKs when a background-priority packet arrives full#10435

Open
DatanoiseTV wants to merge 1 commit into
meshtastic:developfrom
DatanoiseTV:fix/router-priority-aware-drop
Open

fix(mesh): don't evict ACKs when a background-priority packet arrives full#10435
DatanoiseTV wants to merge 1 commit into
meshtastic:developfrom
DatanoiseTV:fix/router-priority-aware-drop

Conversation

@DatanoiseTV
Copy link
Copy Markdown
Contributor

fromRadioQueue is a plain FIFO of size 4. When it fills, the prior
behaviour was to drop the oldest packet — usually a routing ACK or
reply — to make room for whatever just arrived, even if the new packet
was BACKGROUND priority. Reverse that for the low-priority case: if
the incoming packet's priority is at or below BACKGROUND, drop it
instead. Higher-priority arrivals still evict to fit. PointerQueue
doesn't expose iteration, so a full priority-queue refactor would be a
larger change; this addresses the worst case.

Split out from #10424 per @thebentern's request — single-concern PR.

Build verification

pio run -e t-deck-tft succeeds, no new warnings.

Attestations

  • I have tested that my proposed changes behave as described — review/static-analysis only, not on-air.
  • On-hardware testing requested from community: build-verified t-deck-tft only.

fromRadioQueue is a plain FIFO of size 4. When it fills, the prior
behaviour was to drop the oldest packet — usually a routing ACK or
reply — to make room for whatever just arrived, even if the new packet
was BACKGROUND priority. Reverse that for the low-priority case: if
the incoming packet's priority is at or below BACKGROUND, drop it
instead. Higher-priority arrivals still evict to fit. PointerQueue
doesn't expose iteration, so a full priority-queue refactor would be a
larger change; this addresses the worst case.
@github-actions github-actions Bot added needs-review Needs human review bugfix Pull request that fixes bugs labels May 9, 2026
@thebentern thebentern requested review from GUVWAF and Copilot May 9, 2026 18:36
Copy link
Copy Markdown
Contributor

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 improves receive-side routing reliability by changing Router::enqueueReceivedMessage() to avoid evicting already-queued packets (often ACKs/routing replies) when fromRadioQueue is full and the newly arrived packet is low priority (≤ BACKGROUND). This targets a worst-case behavior where a burst of low-priority traffic could displace higher-value control-plane packets.

Changes:

  • Drop incoming packets with priority ≤ BACKGROUND when fromRadioQueue is full, instead of evicting the oldest queued packet.
  • Preserve the prior “evict oldest until it fits” behavior for higher-priority incoming packets.

Comment thread src/mesh/Router.cpp
if (!fromRadioQueue.enqueue(p, 0)) {
if (p->priority != meshtastic_MeshPacket_Priority_UNSET && p->priority <= meshtastic_MeshPacket_Priority_BACKGROUND) {
printPacket("fromRadioQ full, drop incoming low-prio!", p);
packetPool.release(p);
@GUVWAF
Copy link
Copy Markdown
Member

GUVWAF commented May 9, 2026

Are you observing that the FIFO ever gets full?
This should really not happen: it means we're too slow handling incoming packets. If we're really seeing this (often), IMO we should increase the FIFO size rather than throwing away the "least important one".

@caveman99 caveman99 added needs-info Needs information before we can proceed triaged Reviewed by the team, has enough information and ready to work on now. and removed needs-review Needs human review labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs needs-info Needs information before we can proceed triaged Reviewed by the team, has enough information and ready to work on now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants