One prefix, one installed route (#1407) #1408
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1408
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/one-installed-route"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 routeprinted every candidate the device held, as equals:Two rows, one destination.
routeTo()— the lookup that actually forwards — has always chosen by longest prefix thenlowest 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 summarysaid "3 prefix(es) installed from BGP" when only 1 was installed, because it counted what thepeer sent rather than what survived selection.
What changed
routesTable()computes the preference once, per prefix, using the distancesrouteTo()uses (connected 0, static1, eBGP 20, OSPF 110, iBGP 200, configured gateway 254) and marks every row:
installed,shadowedBy(the rowthat beat it) and
shadow(the sentence). A losing route is not deleted — dropping it would hide what the peersent and leave an operator asking where their BGP route went — it is marked:
show ip bgp summarycounts 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 apacket" and drives the red styling;
test/routes-agreement.test.jscaught a healthy candidate default beingpainted as broken, so
shadowis 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 paircollides. For each prefix: exactly one row is installed, and
routeTo()agrees with it by type and by port — theinvariant 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 followsthe 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.jsfails 12 of the 30,engine/cli.js5, andweb/app.js1 of the 19 inroutes-agreement.docs/CLI.md: "One prefix, one installed route" under "Readingshow ip route".Suite: 205 suites, 7,899 assertions, 0 failed. Syntax: 273 files, OK.
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.