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

+43
View File
@@ -0,0 +1,43 @@
// HA twin pair — DE is run as a twin pair (DE-A and DE-B both own
// LOCAL_PREFIX=262). External peers (IT, SE) hold one [TRUNK_x] section
// with PAIRED=1 and HOST=de-a,de-b — each frame is sticky-routed to one
// of the two TCP sockets with instant failover on socket failure.
graph TwinPair {
layout = neato;
bgcolor = "transparent";
margin = 0.3;
overlap = false;
splines = true;
node [shape=box, style="filled,rounded", fontname="Helvetica-Bold",
fontsize=13, penwidth=2, width=1.05, height=0.7, fixedsize=true];
// External peers on the left
SE [label="SE\n240", fillcolor="#dde8fb", color="#1a4fa3", pos="-3.5, 1.5!"];
IT [label="IT\n222", fillcolor="#fde2d4", color="#c0531c", pos="-3.5,-1.5!"];
// Twin pair on the right (both own LOCAL_PREFIX=262)
DEA [label="DE-A\n262", fillcolor="#e6dcff", color="#5430a8", pos="3.0, 1.5!"];
DEB [label="DE-B\n262", fillcolor="#e6dcff", color="#5430a8", pos="3.0,-1.5!"];
// Annotation node sitting to the right of the twin link
TWINANN [label="[TWIN] link\nfull-state mirror\nheartbeat:\n send every 2 s\n fail after 5 s silence",
shape=plaintext, fontsize=10, fontcolor="#5430a8",
fontname="Helvetica-Bold",
pos="5.6, 0!", width=2.0, height=1.4];
// External trunk edges — each external peer holds ONE [TRUNK_x] toward
// the pair, manifested as two TCP sockets (sticky, failover).
edge [color="#5f6368", penwidth=1.2];
IT -- SE;
IT -- DEA; IT -- DEB;
SE -- DEA; SE -- DEB;
// Twin link (purpose-built, symmetric, full-state mirror).
edge [color="#5430a8", penwidth=3.0, style=bold];
DEA -- DEB;
// Invisible edge to anchor the annotation near the twin link
edge [style=invis, len=0.5];
DEB -- TWINANN;
}