OSPF can be read back from the console (#1371) #1372

Merged
jaylouisw merged 1 commit from feat/show-ospf into main 2026-11-10 19:10:01 +00:00
Owner

OSPF can now be read back from the console. Fixes #1371.

OSPF has been configurable since it was modelled — ospf router-id, ospf area, and per interface
ip ospf cost | area | passive — and computeOspf() turns those numbers into adjacencies, an SPF tree and
installed routes. None of it could be read: the only place OSPF appeared was an O in show ip route. You
could set a cost and had no way to find out whether the engine used it, which port an adjacency formed on, or who
the neighbour was. Same shape as show power inline (#1295) and the STP election (#1365).

Three reports

r1> show ip ospf
Routing Process "ospf 0" with ID 1.1.1.1
  Areas: 0
  Interfaces: 2 (1 passive)
  Neighbours: 1
  Routes installed from OSPF: 1
r1> show ip ospf neighbour
Neighbor ID     Address          Interface   State
2.2.2.2         10.1.0.2         Gi0/0/0     Full

1 neighbour(s), all Fully adjacent
r1> show ip ospf interface
Interface   IP Address       Area  Cost  Cost from   Adjacent  Passive
Gi0/0/0     10.1.0.1/24      0     25    configured  yes       no
Gi0/0/1     192.168.1.1/24   0     10    link rate   no        yes

Cost from is the column that answers the question the number alone cannot: 25 because someone typed
ip ospf cost 25, or 10 because the wire is 100 Mbps and nobody typmed anything (100 Mbps reference
bandwidth: 100 Mbps → 100, 1 Gbps → 10, 2.5 Gbps → 4, 5 Gbps → 2, 10 Gbps+ → 1). A derived cost moves when the
link renegotiates; a configured one does not.

Every row comes from what computeOspf() recorded — dev.ospfInterfaces, dev.ospfNeighbors,
dev.ospfConverged — so the console and show ip route cannot describe the same topology differently. That
includes the wait: on a lab that has not settled the summary prints (withheld: still converging) beside the route
count, because that is what the engine did.

A port you name that is not contributing gets the reason, not an empty table:

r1> show ip ospf neighbour Gi0/0/1
% Gi0/0/1 is passive: it advertises its prefix and forms no adjacency
r1> show ip ospf interface Gi0/0/2
% Gi0/0/2 has no address: OSPF needs one to form an adjacency
sw1> show ip ospf
% OSPF is not enabled (use "ospf router-id <ip>" in config mode)

One defect found while writing it

With a single OSPF router in the lab, computeOspf() returned early (routers.length < 2) before publishing
anything, so a box with two OSPF ports reported that nothing had been evaluated. The interface view is now
published where it is computed, in the first pass; the adjacency pass fills in neighbours and flips the adjacent
flag afterwards.

Evidence

test/show-ospf.test.js — 36 checks: the summary counts exactly what the engine computed; the neighbour table
lists the peer by its own router id and every engine neighbour appears with nothing extra; a configured cost
reads configured at 25 while an unset port reads link rate at 10; moving the costs moves the chosen path and
the report shows both numbers; a passive port is named and explained; a lone router still reports its ports; the
withheld sentence appears exactly when dev.ospfConverged is false.

  • reverting engine/cli.js → 27 of 36 fail
  • reverting engine/simulator.js → 6 of 36 fail

help gains the command; docs/CLI.md gains "Reading OSPF" with the three reports, the derived-cost table and the
explanations.

Suite: 189 suites, 7,301 assertions, 0 failed. Syntax: 257 files, OK.

OSPF can now be read back from the console. Fixes #1371. OSPF has been configurable since it was modelled — `ospf router-id`, `ospf area`, and per interface `ip ospf cost | area | passive` — and `computeOspf()` turns those numbers into adjacencies, an SPF tree and installed routes. **None of it could be read:** the only place OSPF appeared was an `O` in `show ip route`. You could set a cost and had no way to find out whether the engine used it, which port an adjacency formed on, or who the neighbour was. Same shape as `show power inline` (#1295) and the STP election (#1365). ## Three reports ``` r1> show ip ospf Routing Process "ospf 0" with ID 1.1.1.1 Areas: 0 Interfaces: 2 (1 passive) Neighbours: 1 Routes installed from OSPF: 1 ``` ``` r1> show ip ospf neighbour Neighbor ID Address Interface State 2.2.2.2 10.1.0.2 Gi0/0/0 Full 1 neighbour(s), all Fully adjacent ``` ``` r1> show ip ospf interface Interface IP Address Area Cost Cost from Adjacent Passive Gi0/0/0 10.1.0.1/24 0 25 configured yes no Gi0/0/1 192.168.1.1/24 0 10 link rate no yes ``` `Cost from` is the column that answers the question the number alone cannot: **25** because someone typed `ip ospf cost 25`, or **10** because the wire is 100 Mbps and nobody typmed anything (100 Mbps reference bandwidth: 100 Mbps → 100, 1 Gbps → 10, 2.5 Gbps → 4, 5 Gbps → 2, 10 Gbps+ → 1). A derived cost moves when the link renegotiates; a configured one does not. Every row comes from what `computeOspf()` recorded — `dev.ospfInterfaces`, `dev.ospfNeighbors`, `dev.ospfConverged` — so the console and `show ip route` cannot describe the same topology differently. That includes the wait: on a lab that has not settled the summary prints `(withheld: still converging)` beside the route count, because that is what the engine did. A port you name that is not contributing gets the reason, not an empty table: ``` r1> show ip ospf neighbour Gi0/0/1 % Gi0/0/1 is passive: it advertises its prefix and forms no adjacency r1> show ip ospf interface Gi0/0/2 % Gi0/0/2 has no address: OSPF needs one to form an adjacency sw1> show ip ospf % OSPF is not enabled (use "ospf router-id <ip>" in config mode) ``` ## One defect found while writing it With a **single** OSPF router in the lab, `computeOspf()` returned early (`routers.length < 2`) *before* publishing anything, so a box with two OSPF ports reported that nothing had been evaluated. The interface view is now published where it is computed, in the first pass; the adjacency pass fills in neighbours and flips the `adjacent` flag afterwards. ## Evidence `test/show-ospf.test.js` — **36 checks**: the summary counts exactly what the engine computed; the neighbour table lists the peer by **its own** router id and every engine neighbour appears with nothing extra; a configured cost reads `configured` at 25 while an unset port reads `link rate` at 10; moving the costs moves the chosen path and the report shows both numbers; a passive port is named and explained; a lone router still reports its ports; the `withheld` sentence appears exactly when `dev.ospfConverged` is false. * reverting `engine/cli.js` → **27 of 36 fail** * reverting `engine/simulator.js` → **6 of 36 fail** `help` gains the command; `docs/CLI.md` gains "Reading OSPF" with the three reports, the derived-cost table and the explanations. Suite: **189 suites, 7,301 assertions, 0 failed**. Syntax: 257 files, OK.
OSPF can be read back from the console (#1371)
All checks were successful
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 15s
CI / Test (Node 20) (pull_request) Successful in 2m53s
CI / Test (Node 18) (pull_request) Successful in 3m1s
CI / Server smoke test (pull_request) Successful in 26s
CI / Docker build (pull_request) Successful in 44s
CI / Test (Node 22) (pull_request) Successful in 2m28s
05364bfc59
OSPF has been configurable since it was modelled - 'ospf router-id', 'ospf area', and per interface
'ip ospf cost | area | passive' - and computeOspf() turns those into adjacencies, an SPF tree and
installed routes. None of it could be read: the only place OSPF appeared was an 'O' in show ip route.
An operator could set a cost and had no way to find out whether the engine used it, which port an
adjacency formed on, or who the neighbour was. Same shape as show power inline and the STP election.

Three commands, every row taken from what computeOspf() recorded (dev.ospfInterfaces,
dev.ospfNeighbors, dev.ospfConverged), so the console and the route table cannot describe the same
topology differently:

  show ip ospf                 process summary: router-id, areas, interfaces (passive count),
                               neighbours, routes installed - and '(withheld: still converging)'
                               when the engine has not settled
  show ip ospf neighbour [p]   Neighbor ID (the PEER's router id), address, interface, state
  show ip ospf interface [p]   area, cost, ADJACENT, PASSIVE, and a 'Cost from' column saying whether
                               that number was configured or derived from the link rate

A named port that is not contributing is named with the reason - passive (advertises its prefix, forms
no adjacency), no address, administratively down, not in OSPF, or does not exist - rather than an empty
table. Without a simulation the answer is 'no OSPF state has been evaluated yet', and a box with no
OSPF at all says so and names the command that would enable it.

One defect found while writing it: with a single OSPF router in the lab, computeOspf() returned before
publishing anything, so a box with two OSPF ports reported that nothing had been evaluated. The
interface view is now published where it is computed; the adjacency pass fills in neighbours and flips
the flag afterwards.

Evidence: test/show-ospf.test.js, 36 checks - the summary counts what the engine computed, the
neighbour table lists the peer by its own router id and every engine neighbour appears with nothing
extra, a configured cost reads 'configured' at 25 while an unset port reads 'link rate' at 10, moving
the costs moves the chosen path and the report shows both numbers, a passive port is named and
explained, a lone router still reports its ports, and the 'withheld' sentence appears exactly when
dev.ospfConverged is false. Reverting engine/cli.js fails 27 of 36; reverting engine/simulator.js
fails 6.

help gains the command; docs/CLI.md gains 'Reading OSPF' with the three reports and the derived-cost
table (100 Mbps -> 100, 1 Gbps -> 10, 2.5 Gbps -> 4, 5 Gbps -> 2, 10 Gbps and above -> 1).

Suite: 189 suites, 7,301 assertions, 0 failed. Syntax: 257 files, OK.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-10 19:09:57 +00:00
Sign in to join this conversation.
No description provided.