diff --git a/README.md b/README.md index 0bfcd65..46f459d 100644 --- a/README.md +++ b/README.md @@ -287,37 +287,50 @@ pattern. logic — a blacklisted TG is never forwarded, accepted, or advertised as interest, regardless of `ROUTABLE_PREFIXES`. -**Ownership caveat:** do not set a routable prefix that is a longer -decimal-string match of a TG this reflector itself owns — the -longest-prefix-match ownership check would then incorrectly route that TG -away from the local owner. Keep routable prefixes pointed at TGs owned by -other reflectors (the same discipline that already applies to `REMOTE_PREFIX`). +**Delegation note:** a routable prefix more specific than this reflector's own +`LOCAL_PREFIX` intentionally delegates that sub-range elsewhere +(longest-prefix-match: the more specific routable prefix wins). Point such a +prefix at the reflector that actually owns those TGs. -Example — three-hop chain where `leaf` (prefix `240`) needs to reach TG `2630xx` -owned by `far` (prefix `263`), transiting through `natl` (prefix `262`): +Example — four-node chain where `leaf` (prefix `222100`) needs to reach TG +`263xx` owned by `far` (prefix `263`), transiting through both `natlit` +(prefix `222`) and `natlde` (prefix `262`): ```ini -# On leaf — default route via the only uplink -[TRUNK_LEAF_NATL] -HOST=natl.example.com -SECRET=secret_leaf_natl -REMOTE_PREFIX=262 +# On leaf — default route via the only uplink toward natlit +[TRUNK_LEAF_NATLIT] +HOST=natlit.example.com +SECRET=secret_leaf_natlit +REMOTE_PREFIX=222 ROUTABLE_PREFIXES=* -# On natl — explicit transit toward 263 via the natlde link -[TRUNK_NATL_NATLDE] +# On natlit — explicit transit toward 263 via the natlde link +[TRUNK_NATLIT_NATLDE] HOST=natlde.example.com -SECRET=secret_natl_natlde +SECRET=secret_natlit_natlde REMOTE_PREFIX=262 ROUTABLE_PREFIXES=263 -# On natlde — native REMOTE_PREFIX=263 already covers the last hop +# On natlde — transit 263 back toward natlit (return path) and onward to far +[TRUNK_NATLDE_NATLIT] +HOST=natlit.example.com +SECRET=secret_natlit_natlde +REMOTE_PREFIX=222 +ROUTABLE_PREFIXES=263 + [TRUNK_NATLDE_FAR] HOST=far.example.com SECRET=secret_natlde_far REMOTE_PREFIX=263 +# far owns 263 natively — no ROUTABLE_PREFIXES needed on this last hop ``` +The `*` wildcard on leaf's uplink also handles the return leg: leaf advertises +interest in `263xx` toward natlit via `MsgPeerTgInterest`, and — on top of that +— accepts the returning audio via the wildcard match (`matchesRoutable`) on its +inbound-accept gate, since `*` is excluded from the mesh prefix set and +`hasPrefixRoute` alone cannot serve this role. + ### Network requirements **Trunk links** require **mutual reachability**: each reflector both listens for diff --git a/docs/PEER_PROTOCOL.md b/docs/PEER_PROTOCOL.md index 9bb90b4..d8a9989 100644 --- a/docs/PEER_PROTOCOL.md +++ b/docs/PEER_PROTOCOL.md @@ -229,7 +229,10 @@ lowest-precedence prefix — a real prefix always wins — and is **never** adde - The **return leg** to a `*`-leaf relies on peer interest: because `*` matches every TG in the send/interest gate, the leaf advertises interest in the TG toward the parent (`MsgPeerTgInterest`), and the parent's `isPeerInterestedTG` carries the - return audio back without needing any routable entry on the parent side. + return audio back. The leaf also accepts the returning audio via the wildcard match + (`matchesRoutable`) on its inbound-accept gate — because `*` is never added to + `m_all_prefixes`, `hasPrefixRoute` cannot serve this role, so the wildcard accept + is the mechanism that lets the leaf receive the return audio. A startup `WARNING` is emitted when `*` is set on a reflector with more than one trunk, as that is outside the intended single-uplink leaf pattern and may produce @@ -239,10 +242,10 @@ unexpected fanout behaviour. logic. A blacklisted TG is dropped before `isSharedTG`, `hasPrefixRoute`, or interest advertisement are consulted. -**Ownership caveat.** A routable prefix must not be a longer decimal-string match -of a TG the local reflector owns: `isSharedTG` (and `hasPrefixRoute`) would then -route that TG away from the local owner. Keep routable prefixes pointed at TGs -owned by other reflectors — the same discipline that governs `REMOTE_PREFIX`. +**Delegation note.** A routable prefix more specific than this reflector's own +`LOCAL_PREFIX` intentionally delegates that sub-range elsewhere: longest-prefix-match +honors it and the more specific routable prefix wins. Point such a prefix at the +reflector that actually owns those TGs. ### Cluster TGs diff --git a/src/svxlink/reflector/svxreflector.conf.in b/src/svxlink/reflector/svxreflector.conf.in index faa178f..6b99fa7 100644 --- a/src/svxlink/reflector/svxreflector.conf.in +++ b/src/svxlink/reflector/svxreflector.conf.in @@ -135,9 +135,9 @@ CERT_CA_HOOK=@SVX_SHARE_INSTALL_DIR@/ca-hook.py # sibling reflector (e.g. reach 263 via the 262 peer). "*" is never relayed # between trunks (loop-safe) and only affects this node's local clients; # explicit prefixes transit toward the owner and must be declared on each hop. -# Keep routable prefixes pointed at TGs owned by OTHER reflectors (do not let a -# routable prefix be a longer match of a TG this reflector owns). -# BLACKLIST_TGS still vetoes regardless of routable settings. +# A more specific routable prefix intentionally delegates that sub-range to the +# declared peer (longest-prefix-match honors it); point it at the reflector +# that actually owns those TGs. BLACKLIST_TGS still vetoes regardless. #ROUTABLE_PREFIXES=263 # backbone transit toward 263 #ROUTABLE_PREFIXES=* # regional leaf default route via this uplink diff --git a/tests/TESTS.md b/tests/TESTS.md index 57613c9..c1e9153 100644 --- a/tests/TESTS.md +++ b/tests/TESTS.md @@ -12,7 +12,7 @@ The integration tests verify the trunk protocol, satellite links, twin (HA-pair) A separate harness (`run_redis_tests.sh`) runs `test_redis.py` (13 tests) against a single-reflector + Redis stack. See [Redis Integration Tests](#redis-integration-tests) below. -A separate harness runs `test_routable.py` (2 tests) against a dedicated routable-prefix topology. See [Routable Prefixes](#routable-prefixes) below. +A separate stack runs `test_routable.py` (2 tests) against a dedicated routable-prefix topology (defined in `topology.py`). See [Routable Prefixes](#routable-prefixes) below. **Requirements:** Docker, Docker Compose, Python 3.7+ (stdlib only, no pip packages). @@ -133,7 +133,7 @@ Internal port for `[TWIN]` is always 5304; satellite is 5303. | `docker-compose.test.yml` | Generated compose file (do not edit manually) | | `topology_redis.py` | Topology for the Redis test harness (single reflector + Redis). | | `generate_redis_configs.py` | Generates `configs-redis/*.conf` and `docker-compose.redis.yml`. | -| `test_routable.py` | Routable-prefix tests (2 cases): explicit multi-hop transit (forward + return) and `*` wildcard with blacklist veto. Runs on a dedicated compose stack generated from `topology_routable.py`. | +| `test_routable.py` | Routable-prefix tests (2 cases): explicit multi-hop transit (forward + return) and `*` wildcard with blacklist veto. Runs on a dedicated compose stack; configs and `docker-compose.routable.yml` are generated by `python3 generate_configs.py` (routable topology defined in `topology.py` under `ROUTABLE_REFLECTORS`), then started via `docker compose -f docker-compose.routable.yml up -d --build` and exercised with `python3 -m pytest test_routable.py`. | | `test_redis.py` | Redis-backed config-store tests (13 cases): users, trunk filters, live-state hashes, outage/resync, import idempotence, peer-node mirroring + sanitization, dynamic trunk add/remove. | | `run_redis_tests.sh` | Redis test orchestrator with `up`/`test`/`down`/`all` subcommands. | | `configs-redis/` | Generated Redis-harness configs (do not edit manually) | @@ -273,7 +273,7 @@ Run separately via `test_routable.py` against a dedicated topology. | # | Test | What it verifies | |---|------|-----------------| -| R1 | Explicit transit forward + return | A client on a leaf reflector activates a TG owned by a far reflector two hops away; audio traverses both transit hops (explicit `ROUTABLE_PREFIXES` on each intermediate trunk) and the return audio reaches the leaf via peer interest | +| R1 | Explicit transit forward + return | A client on a leaf reflector activates a TG owned by a far reflector two transit nodes away (three trunk links); audio traverses both transit hops (explicit `ROUTABLE_PREFIXES` on each intermediate trunk) and the return audio reaches the leaf via peer interest | | R2 | `*` wildcard + blacklist veto | A client on a `*`-configured leaf reaches a remote TG via its single uplink; a TG listed in `BLACKLIST_TGS` on the same link is dropped regardless of the wildcard, confirming blacklist-before-routable evaluation order | ### Twin Protocol (HA-pair)