An OSPF adjacency needs a wire, and a route over a dead port says so (#1271) #1272

Merged
jaylouisw merged 1 commit from fix/ospf-link-state into main 2026-11-09 20:43:42 +00:00
Owner

An OSPF adjacency needs a wire, and a route over a dead port says so

Fixes #1271.

C   10.0.0.0       /24  is directly connected, Gi0  (down: link down)
S  172.20.0.0     /16  [1/0] via 10.0.0.1  (down: link down)

The bug

Two routers with OSPF on the shared segment; r2 learns r1's LAN. Pull the cable:

O  192.168.9.0    /24  [110/0] via 10.0.0.1  Gi0      <- unchanged

…while a ping to that LAN fails with no ARP reply from 10.0.0.1. The data plane knew the path was gone; the
control plane went on believing it.

computeOspf() collected interfaces that were enabled and addressed, then formed an adjacency for every
topology link between two such interfaces. A topology link still exists while its state is down, and nothing
asked. Hellos need a wire that can carry them.

BGP had exactly this defect one iteration earlier (#1269); OSPF had no link-state check at all.

A second, wider symptom

show ip route could not say that any installed route's next hop is unreachable. A static route or a
connected route over a port with no cable read exactly like a working path — which is why this bug was found
by a ping that disagreed with the table.

Now

  • an adjacency needs both ends able to carry a frame (Device.ifaceStatus(iface, topo) — the rule
    show interfaces, show arp, show mac address-table, the canvas and BGP already share), so a pulled
    cable, a down link or a shut far port withdraws the route. A learned route is withdrawn, not annotated:
    a router does not keep advertising a path it learned over a cable that has been pulled;
  • show ip route marks a route whose egress cannot carry a frame — (down: link down), (down: no cable),
    (administratively down) — on connected and static rows. Those stay listed, because they are
    configuration rather than learned state, but a row that reads as a working path while every packet to
    it is dropped is the defect;
  • the mark is _staleNote()'s own words — the helper the ARP and MAC tables already use for the same port —
    so three tables cannot describe one port three ways;
  • nothing is marked when nothing is wrong.

Evidence

test/ospf-adjacency-link-state.test.js — 20 checks:

  • a live adjacency installs an O route and marks nothing;
  • a pulled cable withdraws it, the prefix is gone rather than annotated, and a ping to it fails;
  • a shut far port forms no adjacency either;
  • restoring the cable restores the adjacency;
  • a static route over a dead port stays listed and marked, still naming its next hop;
  • a connected route on a port with no cable is marked, and the one on a live cable is not;
  • the marker is exactly what _staleNote() returns for that port, and is what the row prints;
  • a healthy lab carries no warnings at all — the fix must not cry wolf.

Reverting engine/simulator.js fails 3; engine/cli.js fails 4. show-ip-route still passes its 30 checks,
so the legend, distances and gateway line are untouched.

docs/CLI.md gains "Reading show ip route when a path is not there", including the deliberate difference
between a learned route (withdrawn) and a configured one (marked).

Suite: 149 suites, 6,285 assertions, 0 failed.

An OSPF adjacency needs a wire, and a route over a dead port says so Fixes #1271. ``` C 10.0.0.0 /24 is directly connected, Gi0 (down: link down) S 172.20.0.0 /16 [1/0] via 10.0.0.1 (down: link down) ``` ## The bug Two routers with OSPF on the shared segment; `r2` learns `r1`'s LAN. **Pull the cable:** ``` O 192.168.9.0 /24 [110/0] via 10.0.0.1 Gi0 <- unchanged ``` …while a ping to that LAN fails with `no ARP reply from 10.0.0.1`. The data plane knew the path was gone; the control plane went on believing it. `computeOspf()` collected interfaces that were `enabled` and addressed, then formed an adjacency for every topology link between two such interfaces. A topology link still exists while its state is `down`, and nothing asked. Hellos need a wire that can carry them. BGP had exactly this defect one iteration earlier (#1269); OSPF had no link-state check **at all**. ## A second, wider symptom `show ip route` could not say that *any* installed route's next hop is unreachable. A static route or a connected route over a port with no cable read exactly like a working path — which is why this bug was found by a ping that disagreed with the table. ## Now * an adjacency needs **both ends able to carry a frame** (`Device.ifaceStatus(iface, topo)` — the rule `show interfaces`, `show arp`, `show mac address-table`, the canvas and BGP already share), so a pulled cable, a down link or a shut far port **withdraws** the route. A learned route is withdrawn, not annotated: a router does not keep advertising a path it learned over a cable that has been pulled; * `show ip route` marks a route whose egress cannot carry a frame — `(down: link down)`, `(down: no cable)`, `(administratively down)` — on connected and static rows. Those stay listed, because they are **configuration** rather than learned state, but a row that reads as a working path while every packet to it is dropped is the defect; * the mark is `_staleNote()`'s own words — the helper the ARP and MAC tables already use for the same port — so three tables cannot describe one port three ways; * nothing is marked when nothing is wrong. ## Evidence `test/ospf-adjacency-link-state.test.js` — 20 checks: * a live adjacency installs an `O` route and marks nothing; * a pulled cable withdraws it, the prefix is gone rather than annotated, and a ping to it fails; * a shut **far** port forms no adjacency either; * restoring the cable restores the adjacency; * a static route over a dead port stays listed and marked, still naming its next hop; * a connected route on a port with no cable is marked, and the one on a live cable is not; * the marker is **exactly** what `_staleNote()` returns for that port, and is what the row prints; * a healthy lab carries no warnings at all — the fix must not cry wolf. Reverting `engine/simulator.js` fails 3; `engine/cli.js` fails 4. `show-ip-route` still passes its 30 checks, so the legend, distances and gateway line are untouched. `docs/CLI.md` gains "Reading `show ip route` when a path is not there", including the deliberate difference between a learned route (withdrawn) and a configured one (marked). Suite: 149 suites, 6,285 assertions, 0 failed.
An OSPF adjacency needs a wire, and a route over a dead port says so (#1271)
All checks were successful
CI / Classify the change (pull_request) Successful in 11s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 15s
CI / Test (Node 20) (pull_request) Successful in 1m53s
CI / Test (Node 18) (pull_request) Successful in 2m0s
CI / Server smoke test (pull_request) Successful in 37s
CI / Docker build (pull_request) Successful in 39s
CI / Test (Node 22) (pull_request) Successful in 1m48s
acef03105e
Two routers with OSPF on the shared segment: pull the cable and `show ip route` still carried
`O 192.168.9.0/24 [110/0] via 10.0.0.1 Gi0` - a next hop that answered nothing - while a ping to that LAN
failed with `no ARP reply from 10.0.0.1`. The data plane knew the path was gone; the control plane went on
believing it.

`computeOspf()` collected interfaces that were `enabled` and addressed, then formed an adjacency for every
topology link between two such interfaces. A topology link exists while its state is `down`, and nothing
asked. BGP had the same defect one iteration earlier (#1269); OSPF had no link-state check at all.

Now:
* an adjacency needs both ends to be able to carry a frame (`Device.ifaceStatus(iface, topo)` - the rule
  `show interfaces`, `show arp`, `show mac address-table`, the canvas and BGP already share), so a pulled
  cable, a down link or a shut far port withdraws the route. A learned route is withdrawn, not annotated:
  a router does not keep advertising a path it learned over a cable that has been pulled;
* `show ip route` marks a route whose egress cannot carry a frame - `(down: link down)`, `(down: no cable)`,
  `(administratively down)` - on connected and static rows. Those stay listed, because they are
  configuration rather than learned state, but a row that reads as a working path while every packet to it
  is dropped is the defect. The mark is `_staleNote()`'s own words, the same helper the ARP and MAC tables
  use for the same port, so three tables cannot describe one port three ways;
* nothing is marked when nothing is wrong.

test/ospf-adjacency-link-state.test.js (20 checks): a live adjacency installs an O route with no marks; a
pulled cable withdraws it and the ping fails; a shut far port forms no adjacency; restoring the cable brings
it back; a static route over a dead port stays listed and marked while a connected route on a port with no
cable is marked and the one on a live cable is not; the route marker is exactly what `_staleNote()` returns
for that port; and a healthy lab carries no warnings at all. Reverting engine/simulator.js fails 3,
engine/cli.js fails 4; `show-ip-route` still passes its 30 checks.

Suite: 149 suites, 6,285 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 20:43:38 +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!1272
No description provided.