Skip to content

Release the opaque relay copy the interface declines to send - #11262

Merged
vidplace7 merged 1 commit into
developfrom
fix-opaque-relay-pool-leak
Jul 27, 2026
Merged

Release the opaque relay copy the interface declines to send#11262
vidplace7 merged 1 commit into
developfrom
fix-opaque-relay-pool-leak

Conversation

@caveman99

@caveman99 caveman99 commented Jul 27, 2026

Copy link
Copy Markdown
Member

relayOpaquePacket() allocates a copy and returns Router::send(relay) == ERRNO_OK, discarding ERRNO_SHOULD_RELEASE. The interface returns that for NODENUM_BROADCAST_NO_LORA (RadioLibInterface.cpp), so the copy is never freed and one pool slot leaks per frame.

The opaque path is taken when passesRoutingAuthGate returns OPAQUE_RELAY_ONLY, which is the verdict for a packet on a channel we hold no key for. No key, PSK or admin access is required: a frame with an unknown channel hash, to=NODENUM_BROADCAST_NO_LORA, a nonzero id and hop_limit > 0 leaks a slot on every default-configured rebroadcaster, and roughly MAX_PACKETS of them exhaust the pool until reboot.

#11087 fixed this same pattern in perhapsRebroadcast and the retransmission paths, and added the NODENUM_BROADCAST_NO_LORA guard now at NextHopRouter.cpp:180, but relayOpaquePacket was not covered.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed packet handling during relay operations to prevent resource leaks.
    • Improved relay result processing for more reliable packet delivery.

relayOpaquePacket() allocates a copy and returns Router::send(relay) == ERRNO_OK, discarding ERRNO_SHOULD_RELEASE. The interface returns that for NODENUM_BROADCAST_NO_LORA, so the copy is never freed and one pool slot leaks per frame.

The opaque path is reached for packets on a channel we have no key for, so no key or PSK is needed: a frame with an unknown channel hash, to=NODENUM_BROADCAST_NO_LORA, a nonzero id and hop_limit>0 leaks a slot, and roughly MAX_PACKETS of them exhaust the pool until reboot.

#11087 fixed this pattern in perhapsRebroadcast and the retransmission paths but did not cover relayOpaquePacket, which was added separately with the opaque relay path.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ae9fc256-6339-4259-be08-02418df1ce93

📥 Commits

Reviewing files that changed from the base of the PR and between ae16c05 and 315e3a9.

📒 Files selected for processing (1)
  • src/mesh/NextHopRouter.cpp

📝 Walkthrough

Walkthrough

relayOpaquePacket now handles the special Router::send release result by returning the relay packet to packetPool, while preserving success reporting for ERRNO_OK.

Changes

Opaque packet relay cleanup

Layer / File(s) Summary
Relay send cleanup
src/mesh/NextHopRouter.cpp
relayOpaquePacket captures the send result, releases relay when the result is ERRNO_SHOULD_RELEASE, and returns whether the result is ERRNO_OK.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

  • meshtastic/firmware#11087: Updates related relay and retransmission paths to release cloned packets on ERRNO_SHOULD_RELEASE.

Suggested labels: bugfix

Suggested reviewers: nomdetom

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change by describing the release of the opaque relay copy when the interface declines to send.
Description check ✅ Passed The description clearly explains the bug, impact, and fix, but it omits the template's testing attestations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-opaque-relay-pool-leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vidplace7 vidplace7 added the bugfix Pull request that fixes bugs label Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Note

Building this pull request… the flash button, badges and supported-board
list will appear here automatically once CI finishes.

@vidplace7
vidplace7 merged commit cdd9962 into develop Jul 27, 2026
102 of 104 checks passed
@vidplace7
vidplace7 deleted the fix-opaque-relay-pool-leak branch July 27, 2026 19:57
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants