feat(reflector): gateway prefix routing via shouldRelayInbound

A non-owner reflector with two trunk legs (a country gateway sitting
between an international mesh and a national mesh) now forwards inbound
trunk traffic toward the actual prefix owner — automatically, via
longest-prefix-match in its own [TRUNK_x] table. Cluster TGs keep their
deliberate single-hop semantic to prevent loops in cyclic meshes.

Implementation
- Reflector::shouldRelayInbound(tg) composes the inbound relay decision:
  * isLocalTG          -> fan out (existing owner-relay)
  * isClusterTG        -> stop (anti-loop; cluster TGs broadcast outbound
                                from local clients only)
  * hasPrefixRoute     -> gateway forwarding via per-trunk isSharedTG
- The four isLocalTG gates in TrunkLink::handleMsgPeer{TalkerStart,
  TalkerStop,Audio,Flush} are replaced by shouldRelayInbound. Source
  exclusion in forwardTrunk*ToOtherTrunks plus per-link interest
  tracking keep the topology naturally loop-free.

Tests
- topology.py: per-reflector `peers` filter for sparse layouts; new
  reflector `d` (prefix 1219, trunked only to `b`) demonstrating
  gateway-only reachability from `a` to `d`.
- generate_configs.py: honours the peers filter.
- test_trunk.py:
  * setUpClass and test_01 skip non-existent pairs in sparse layouts.
  * test_37_gateway_prefix_routing: a-client (122) <-> d-client (1219)
    over TG 121950 in both directions, no CLUSTER_TGS.
  * test_38_cluster_tg_local_client_broadcast: explicit coverage for
    the outbound local-client cluster broadcast path.
- All previously passing tests still pass: 41/41 trunk + 7/7
  mqtt-deltas + 14/14 twin.

Docs
- docs/TOPOLOGY_EXAMPLES.md (new) + .pdf + topology_pdf/ build sources +
  build_topology_pdf.sh: visual cookbook of the five topology shapes
  (international full-mesh, national mesh joined at gateway, satellite
  tree, hybrid satellite-under-regional, HA twin pair). Includes an
  MCC-range appendix with the recommendation to draw cluster TGs from
  100-199 / 800-999 to avoid country-prefix collisions.
- docs/PEER_PROTOCOL.md: rewrote the "Owner-Relay Fanout" section as
  "Inbound Relay (shouldRelayInbound)" with the three-regime
  composition and clarified the single-mesh fanout caveat.
- README.md: feature bullet now describes gateway prefix routing and
  links to TOPOLOGY_EXAMPLES.md (also added to the documentation list).
This commit is contained in:
Audric committed 2026-05-07 16:12:14 +02:00
1 parent 658a1b153f
commit 52b5e4f3cf
22 files changed
+2191 -38

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.42.4 (0)
-->
<!-- Title: IntlMesh Pages: 1 -->
<svg width="238pt" height="226pt"
viewBox="21.60 21.60 216.75 204.48" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(25.6 200.48)">
<title>IntlMesh</title>
<!-- IT -->
<g id="node1" class="node">
<title>IT</title>
<path fill="#fde2d4" stroke="#c0531c" stroke-width="2" d="M67,-50C67,-50 12,-50 12,-50 6,-50 0,-44 0,-38 0,-38 0,-12 0,-12 0,-6 6,0 12,0 12,0 67,0 67,0 73,0 79,-6 79,-12 79,-12 79,-38 79,-38 79,-44 73,-50 67,-50"/>
<text text-anchor="middle" x="39.5" y="-30.2" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="16.00">IT</text>
<text text-anchor="middle" x="39.5" y="-12.2" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="16.00">222</text>
</g>
<!-- SE -->
<g id="node2" class="node">
<title>SE</title>
<path fill="#dde8fb" stroke="#1a4fa3" stroke-width="2" d="M67,-174.88C67,-174.88 12,-174.88 12,-174.88 6,-174.88 0,-168.88 0,-162.88 0,-162.88 0,-136.88 0,-136.88 0,-130.88 6,-124.88 12,-124.88 12,-124.88 67,-124.88 67,-124.88 73,-124.88 79,-130.88 79,-136.88 79,-136.88 79,-162.88 79,-162.88 79,-168.88 73,-174.88 67,-174.88"/>
<text text-anchor="middle" x="39.5" y="-155.08" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="16.00">SE</text>
<text text-anchor="middle" x="39.5" y="-137.08" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="16.00">240</text>
</g>
<!-- IT&#45;&#45;SE -->
<g id="edge1" class="edge">
<title>IT&#45;&#45;SE</title>
<path fill="none" stroke="#5f6368" stroke-width="1.6" d="M39.5,-50.27C39.5,-71.94 39.5,-102.99 39.5,-124.64"/>
</g>
<!-- DE -->
<g id="node3" class="node">
<title>DE</title>
<path fill="#dde8fb" stroke="#1a4fa3" stroke-width="2" d="M175.15,-112.44C175.15,-112.44 120.15,-112.44 120.15,-112.44 114.15,-112.44 108.15,-106.44 108.15,-100.44 108.15,-100.44 108.15,-74.44 108.15,-74.44 108.15,-68.44 114.15,-62.44 120.15,-62.44 120.15,-62.44 175.15,-62.44 175.15,-62.44 181.15,-62.44 187.15,-68.44 187.15,-74.44 187.15,-74.44 187.15,-100.44 187.15,-100.44 187.15,-106.44 181.15,-112.44 175.15,-112.44"/>
<text text-anchor="middle" x="147.65" y="-92.64" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="16.00">DE</text>
<text text-anchor="middle" x="147.65" y="-74.64" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="16.00">262</text>
</g>
<!-- IT&#45;&#45;DE -->
<g id="edge2" class="edge">
<title>IT&#45;&#45;DE</title>
<path fill="none" stroke="#5f6368" stroke-width="1.6" d="M79.16,-47.9C88.56,-53.32 98.59,-59.12 108,-64.55"/>
</g>
<!-- SE&#45;&#45;DE -->
<g id="edge3" class="edge">
<title>SE&#45;&#45;DE</title>
<path fill="none" stroke="#5f6368" stroke-width="1.6" d="M79.16,-126.98C88.56,-121.55 98.59,-115.76 108,-110.33"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB