Skip to content

Shrink source routing table to 0 when source routing is disabled - #778

Open
puddly wants to merge 3 commits into
devfrom
puddly/source-routing-fixes2
Open

puddly wants to merge 3 commits into
devfrom
puddly/source-routing-fixes2

Conversation

@puddly

@puddly puddly commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Fixes #772.

Source routing in EmberZNet is a little broken/odd and is kind of already half-enabled by default:

  • even when it is not enabled, other EmberZNet devices on the network send Route Status messages until they hear a a MTORR go out with the high-RAM bit set.
  • even when it is not enabled, the coordinator will still populate the source route table with incoming route status messages.
  • the coordinator will still always prefer these sources routes even if a fresher AODV route is known. It doesn't matter if source routing is disabled or enabled. More importantly, they are still preferred even if the source route is broken.
  • there is no mechanism for evicting source routes, even if they are broken. The stack doesn't appear to react to SOURCE_ROUTE_FAILURE properly.

The end result is as the above issue described, bad source routes are used and there's no way to evict them. The only way I can find to do so is to completely disable source routing if it is not enabled by setting the table size to 0 on startup. zbee_nwk.src_route == True in Wireshark finds no source routing packets sent at all.

AODV route discovery seems to help in the case where a source route is unknown and the stack hasn't performed a MTORR to discover a source route to the destination. With our (now) short MTORR intervals this should be less of a problem but it should still help.


Since this is a bugfix PR for source routing, I've rolled in #716.

Should be released along with zigpy/zigpy#1982, as AODV-only routing is less performant 1.

Footnotes

  1. I actually see less popcorning with source routing fully disabled than I did in the "hybrid" mode EmberZNet uses by default, for some reason! Routing in this mode feels more stable and stutters less, somehow. ↩

Copilot AI balanced review requested due to automatic review settings November 19, 2026 22:04
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.59%. Comparing base (1374aae) to head (a74409f).

Files with missing lines Patch % Lines
bellows/zigbee/application.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #778   +/-   ##
=======================================
  Coverage   99.59%   99.59%           
=======================================
  Files          64       64           
  Lines        4417     4423    +6     
=======================================
+ Hits         4399     4405    +6     
  Misses         18       18           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are identified for the source-route configuration and discovery changes.

No open issues 🎉

What changed in this PR

This PR addresses stale source routes by defaulting the NCP source-route table to zero when source routing is disabled, while preserving explicit table-size overrides.

Changes:

  • Apply the adjusted table configuration during connection and reset.
  • Schedule immediate source-route discovery when enabled and honor forced route discovery regardless of source-routing mode.
  • Add configuration and packet-option tests, and update the discovery-mode assertion.
File Description
tests/​test_ezsp.py Expect RESCHEDULE when enabling source routing.
tests/​test_application.py Cover table-size defaults, explicit overrides, and forced discovery with source routing.
bellows/​zigbee/​application.py Adjust table configuration and honor forced route discovery.
bellows/​ezsp/​__init__.py Request immediate discovery with RESCHEDULE.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale NCP source route is never invalidated after SOURCE_ROUTE_FAILURE; end device unreachable until re-pair

4 participants