One prefix, one installed route (#1407) #1408

Merged
jaylouisw merged 1 commit from fix/one-installed-route into main 2026-11-11 01:08:49 +00:00
Owner

One prefix, one installed route. Fixes #1407.

Found by asking whether a report's own summary matches the table under it. Two surfaces failed the same way.

show ip route printed every candidate the device held, as equals:

C   10.0.12.0      /24  is directly connected, Gi0
B  10.0.12.0      /24  [20/0] via 10.0.12.2  Gi0

Two rows, one destination. routeTo() — the lookup that actually forwards — has always chosen by longest prefix then
lowest distance, so the engine knew which route was installed and the table did not say it. The same shape covers
static-over-connected, OSPF-over-BGP and BGP-over-OSPF, all reachable in a two-router lab.

And show ip bgp summary said "3 prefix(es) installed from BGP" when only 1 was installed, because it counted what the
peer sent rather than what survived selection.

What changed

  • routesTable() computes the preference once, per prefix, using the distances routeTo() uses (connected 0, static
    1, eBGP 20, OSPF 110, iBGP 200, configured gateway 254) and marks every row: installed, shadowedBy (the row
    that beat it) and shadow (the sentence). A losing route is not deleted — dropping it would hide what the peer
    sent and leave an operator asking where their BGP route went — it is marked:
B  10.0.12.0      /24  [20/0] via 10.0.12.2  Gi0  (not installed: the C route for this prefix has distance 0)
O   10.3.3.0       /24  [110/0] via 10.0.12.2  Gi0  (not installed: the B route for this prefix has distance 20)
  • show ip bgp summary counts installed prefixes and accounts for the rest: 1 prefix(es) installed from BGP (2 more received, not installed: a better route holds the prefix).

  • The mark is data, not console formatting, so the inspector's Routes table reads the same flag — and a shadowed
    row is not styled as a fault. The first draft put the sentence in note, which means "this row cannot carry a
    packet" and drives the red styling; test/routes-agreement.test.js caught a healthy candidate default being
    painted as broken, so shadow is its own field on the engine row, on the panel row, and its own (quiet) span.

Evidence

test/route-selection.test.js — 30 checks. The lab holds four sources for three prefixes, so every pair
collides. For each prefix: exactly one row is installed, and routeTo() agrees with it by type and by port — the
invariant that makes the mark mean something rather than being a second opinion. Then: shadowed rows are still
listed, each naming the code and distance that beat it and none presented as a fault; the console's marks and the
panel's marks are the same words; the BGP count equals the unmarked B rows in the table; longest-prefix match does
not shadow (a /25 static inside a connected /24 — both installed, each taking the traffic in its own range); two
statics for one prefix leave exactly one installed and routeTo() picks the same next hop; the default route follows
the same rule; and a sweep over the catalogue (1,700+ models, each with a connected net and two statics) asserts one
installed row per prefix and agreement with the lookup.

Reverting engine/device.js fails 12 of the 30, engine/cli.js 5, and web/app.js 1 of the 19 in
routes-agreement.

docs/CLI.md: "One prefix, one installed route" under "Reading show ip route".

Suite: 205 suites, 7,899 assertions, 0 failed. Syntax: 273 files, OK.

One prefix, one installed route. Fixes #1407. Found by asking whether a report's own summary matches the table under it. Two surfaces failed the same way. `show ip route` printed every candidate the device held, as equals: ``` C 10.0.12.0 /24 is directly connected, Gi0 B 10.0.12.0 /24 [20/0] via 10.0.12.2 Gi0 ``` Two rows, one destination. `routeTo()` — the lookup that actually forwards — has always chosen by longest prefix then lowest distance, so the engine knew which route was installed and the table did not say it. The same shape covers static-over-connected, OSPF-over-BGP and BGP-over-OSPF, all reachable in a two-router lab. And `show ip bgp summary` said "3 prefix(es) installed from BGP" when only 1 was installed, because it counted what the peer sent rather than what survived selection. ## What changed * `routesTable()` computes the preference once, per prefix, using the distances `routeTo()` uses (connected 0, static 1, eBGP 20, OSPF 110, iBGP 200, configured gateway 254) and marks every row: `installed`, `shadowedBy` (the row that beat it) and `shadow` (the sentence). A losing route is **not deleted** — dropping it would hide what the peer sent and leave an operator asking where their BGP route went — it is marked: ``` B 10.0.12.0 /24 [20/0] via 10.0.12.2 Gi0 (not installed: the C route for this prefix has distance 0) O 10.3.3.0 /24 [110/0] via 10.0.12.2 Gi0 (not installed: the B route for this prefix has distance 20) ``` * `show ip bgp summary` counts installed prefixes and accounts for the rest: `1 prefix(es) installed from BGP (2 more received, not installed: a better route holds the prefix)`. * The mark is **data**, not console formatting, so the inspector's Routes table reads the same flag — and a shadowed row is not styled as a fault. The first draft put the sentence in `note`, which means "this row cannot carry a packet" and drives the red styling; `test/routes-agreement.test.js` caught a healthy candidate default being painted as broken, so `shadow` is its own field on the engine row, on the panel row, and its own (quiet) span. ## Evidence `test/route-selection.test.js` — **30 checks**. The lab holds four sources for three prefixes, so every pair collides. For each prefix: exactly one row is installed, and `routeTo()` agrees with it by type *and* by port — the invariant that makes the mark mean something rather than being a second opinion. Then: shadowed rows are still listed, each naming the code and distance that beat it and none presented as a fault; the console's marks and the panel's marks are the same words; the BGP count equals the unmarked B rows in the table; longest-prefix match does not shadow (a /25 static inside a connected /24 — both installed, each taking the traffic in its own range); two statics for one prefix leave exactly one installed and `routeTo()` picks the same next hop; the default route follows the same rule; and a sweep over the catalogue (1,700+ models, each with a connected net and two statics) asserts one installed row per prefix and agreement with the lookup. Reverting `engine/device.js` fails **12 of the 30**, `engine/cli.js` **5**, and `web/app.js` **1 of the 19** in `routes-agreement`. `docs/CLI.md`: "One prefix, one installed route" under "Reading `show ip route`". Suite: **205 suites, 7,899 assertions, 0 failed**. Syntax: 273 files, OK.
One prefix, one installed route (#1407)
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 12s
CI / Test (Node 20) (pull_request) Successful in 2m50s
CI / Test (Node 18) (pull_request) Successful in 3m0s
CI / Server smoke test (pull_request) Successful in 30s
CI / Docker build (pull_request) Successful in 36s
CI / Test (Node 22) (pull_request) Successful in 2m23s
afa4849323
Found by asking whether a report's own summary matches the table under it. Two surfaces failed the same way.

`show ip route` printed every candidate the device held, as equals:

    C   10.0.12.0      /24  is directly connected, Gi0
    B  10.0.12.0      /24  [20/0] via 10.0.12.2  Gi0

Two rows, one destination. `routeTo()` - the lookup that actually forwards - has always chosen by longest prefix
then lowest distance, so the engine knew which route was installed and the table did not say it. The same shape
covers static-over-connected, OSPF-over-BGP and BGP-over-OSPF, all reachable in a two-router lab.

And `show ip bgp summary` said "3 prefix(es) installed from BGP" when only 1 was installed, because it counted
what the peer sent rather than what survived selection - the word "installed" over a count of "received".

Fixed:

* `routesTable()` computes the preference once, per prefix, using the distances `routeTo()` uses (connected 0,
  static 1, eBGP 20, OSPF 110, iBGP 200, gateway 254), and marks every row: `installed`, plus `shadowedBy` (the
  row that beat it) and `shadow` (the sentence). A losing route is **not deleted** - dropping it would hide what
  the peer sent and leave an operator asking where their BGP route went - it is marked:

      B  10.0.12.0      /24  [20/0] via 10.0.12.2  Gi0  (not installed: the C route for this prefix has distance 0)
      O   10.3.3.0       /24  [110/0] via 10.0.12.2  Gi0  (not installed: the B route for this prefix has distance 20)

* `show ip bgp summary` counts installed prefixes, and accounts for the rest:
  `1 prefix(es) installed from BGP (2 more received, not installed: a better route holds the prefix)`.

* The mark is data, not console formatting, so the inspector's Routes table reads it too - and a shadowed row is
  not styled as a fault. The first draft put the sentence in `note`, which means "this row cannot carry a packet"
  and drives the red styling; `test/routes-agreement.test.js` caught a healthy candidate default being painted as
  broken, so `shadow` is its own field on the engine row, on the panel row, and its own (quiet) span in the CSS.

Evidence: `test/route-selection.test.js`, 30 checks. The lab holds four sources for three prefixes, so every pair
collides. For each prefix: exactly one row is installed, and `routeTo()` agrees with it by type *and* by port - the
invariant that makes the mark mean something rather than being a second opinion. Then: shadowed rows are still
listed, each naming the code and distance that beat it, none presented as a fault; the console's marks and the
panel's marks are the same; the BGP count equals the unmarked B rows in the table; longest-prefix match does not
shadow (a /25 static inside a connected /24 - both installed, and each takes the traffic in its own range); two
statics for one prefix leave exactly one installed and `routeTo()` picks the same next hop; the default route
follows the same rule; and a sweep over the catalogue (1,700+ models, each with a connected net and two statics)
asserts one installed row per prefix and agreement with the lookup.

Reverting `engine/device.js` fails 12 of the 30, `engine/cli.js` 5, and `web/app.js` 1 of the 19 in
`routes-agreement`.

docs/CLI.md: "One prefix, one installed route" under "Reading `show ip route`".

Suite: 205 suites, 7,899 assertions, 0 failed. Syntax: 273 files, OK.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-11 01:08:45 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1408
No description provided.