A blocked port was painted green #1442

Merged
jaylouisw merged 1 commit from fix/stp-port-state into main 2026-11-12 00:11:04 +00:00
Owner

Closes #1441

A port the tree blocks cannot carry a frame, and the board painted it green while show spanning-tree said the frames were dropped.

s1> show spanning-tree
Port          Role          State
Fa0/1         root          forwarding
Fa0/2         alternate     blocking   (traffic dropped)     <- canvas: green, "up", healthy

portState() in web/faceplate.js is the single rule the faceplate cell, the canvas tooltip and the inspector footer all ask (#1238). It knew about a shut port, an unplugged socket, a link-down cable and a shut peer — and nothing about the tree. The payload did not carry the tree either, so no view could have known.

The change

The tree is published per bridge and per physical port, from the same computation the console reads:

"runtime": { "s1": { "stp": {
  "Fa0/1": { "state": "forwarding", "role": "root",      "blocked": false, "text": "forwarding" },
  "Fa0/2": { "state": "blocking",   "role": "alternate", "blocked": true,  "text": "blocking (traffic dropped)" }
} } }
surface before now
state payload (runtime[id].stp) absent per port: state, role, blocked, the console's sentence
portState(facts) up blocked → blocking (traffic dropped)
canvas tooltip, panel cell, inspector footer "up" the sentence, in amber — not the alarm red
a router — stp: null, not an empty tree

Three decisions worth keeping:

  • blocked is its own state, not down. A redundant lab blocks ports by design; painting 22 ports red on a healthy triangle reports a working tree as a broken board — the trap notconnect avoids for empty sockets. Amber is the panel's "look here" colour; red stays for alarms.
  • The other facts keep their verdicts. A shut port is still administratively down, an unplugged socket still not connected, a shut peer still wins — the tree does not overrule any of them.
  • An unknown tree is not a forwarding tree. stpVerdict() answers undefined for a box or port the payload never mentioned and portState() treats that as "nothing to say", so an older payload leaves a view exactly as it was.

A blocked physical port may be a member of a bundle the tree shut, so the payload marks every physical member (the ports the board draws) rather than the logical port name. The tree is also recomputed for the instant being read, for the same reason show spanning-tree does (#1335): a value left behind by a request at another instant describes a network that no longer exists.

Evidence

test/stp-port-state.test.js, 31 checks: the payload names the single blocked port of a triangle and its role, the console row and the payload sentence match word for word, a router publishes no tree, all four fact combinations keep their own verdicts, undefined changes nothing, and the canvas and the inspector both route through the shared rule (checked statically, so neither can drift back to asking enabled alone).

Reverts: the payload change and the rule change each break the file outright; the two call sites failing back to the old code fails 4/31.

Docs: docs/ARCHITECTURE.md § "A blocked port was painted green".

Closes #1441 A port the tree blocks cannot carry a frame, and the board painted it green while `show spanning-tree` said the frames were dropped. ``` s1> show spanning-tree Port Role State Fa0/1 root forwarding Fa0/2 alternate blocking (traffic dropped) <- canvas: green, "up", healthy ``` `portState()` in `web/faceplate.js` is the single rule the faceplate cell, the canvas tooltip and the inspector footer all ask (#1238). It knew about a shut port, an unplugged socket, a link-down cable and a shut peer — and nothing about the tree. The payload did not carry the tree either, so no view could have known. ### The change The tree is published per bridge and per physical port, from the same computation the console reads: ```json "runtime": { "s1": { "stp": { "Fa0/1": { "state": "forwarding", "role": "root", "blocked": false, "text": "forwarding" }, "Fa0/2": { "state": "blocking", "role": "alternate", "blocked": true, "text": "blocking (traffic dropped)" } } } } ``` | surface | before | now | | --- | --- | --- | | state payload (`runtime[id].stp`) | absent | per port: state, role, blocked, the console's sentence | | `portState(facts)` | `up` | `blocked` → `blocking (traffic dropped)` | | canvas tooltip, panel cell, inspector footer | "up" | the sentence, in amber — not the alarm red | | a router | — | `stp: null`, not an empty tree | Three decisions worth keeping: * **`blocked` is its own state, not `down`.** A redundant lab blocks ports by design; painting 22 ports red on a healthy triangle reports a working tree as a broken board — the trap `notconnect` avoids for empty sockets. Amber is the panel's "look here" colour; red stays for alarms. * **The other facts keep their verdicts.** A shut port is still administratively down, an unplugged socket still not connected, a shut peer still wins — the tree does not overrule any of them. * **An unknown tree is not a forwarding tree.** `stpVerdict()` answers `undefined` for a box or port the payload never mentioned and `portState()` treats that as "nothing to say", so an older payload leaves a view exactly as it was. A blocked physical port may be a member of a bundle the tree shut, so the payload marks every physical member (the ports the board draws) rather than the logical port name. The tree is also recomputed for the instant being read, for the same reason `show spanning-tree` does (#1335): a value left behind by a request at another instant describes a network that no longer exists. ### Evidence `test/stp-port-state.test.js`, **31 checks**: the payload names the single blocked port of a triangle and its role, the console row and the payload sentence match word for word, a router publishes no tree, all four fact combinations keep their own verdicts, `undefined` changes nothing, and the canvas and the inspector both route through the shared rule (checked statically, so neither can drift back to asking `enabled` alone). Reverts: the payload change and the rule change each break the file outright; the two call sites failing back to the old code fails 4/31. Docs: `docs/ARCHITECTURE.md` § *"A blocked port was painted green"*.
A blocked port was painted green (#1441)
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 14s
CI / Test (Node 20) (pull_request) Successful in 2m50s
CI / Test (Node 18) (pull_request) Successful in 2m58s
CI / Server smoke test (pull_request) Successful in 32s
CI / Docker build (pull_request) Successful in 46s
CI / Test (Node 22) (pull_request) Successful in 2m39s
a3dc5bfbfb
Three switches in a triangle, and the tree shuts one port to keep the loop out.
The console said so:

  Port          Role          State
  Fa0/1         root          forwarding
  Fa0/2         alternate     blocking   (traffic dropped)

The board drew Fa0/2 exactly like Fa0/1: green, patched, healthy. portState()
in web/faceplate.js - the one rule the faceplate cell, the canvas tooltip and
the inspector footer all ask - knew about a shut port, an unplugged socket, a
link-down cable and a shut peer, and nothing about the tree. The payload did
not carry the tree either, so no view could have known.

The tree is now published per bridge and per physical port (state, role,
blocked, and the console's sentence), and portState() takes it as one more
fact. Three decisions:

  * blocked is its own state, not down - a redundant lab blocks ports by
    design, so it gets amber and red stays for alarms;
  * the other facts keep their verdicts: a shut port is still administratively
    down, an unplugged socket still not connected, a shut peer still wins;
  * an unknown tree is not a forwarding tree - stpVerdict() answers undefined
    for a box or port the payload never mentioned.

Evidence: test/stp-port-state.test.js, 31 checks. Suite 221 suites, 8258
assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-12 00:10:53 +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!1442
No description provided.