What the tables say, once: MAC, ARP and LLDP rows come from the engine (#1327) #1328

Merged
jaylouisw merged 1 commit from fix/runtime-rows into main 2026-11-10 03:26:44 +00:00
Owner

What the tables say, once: MAC, ARP and LLDP rows come from the engine.

Fixes #1327.

The runtime half of the state payload, after the config half (#1321, #1323, #1325). The console has printed honest
MAC, ARP and LLDP tables since #1253–#1255 — which port an entry was learned on, and whether that port can still carry
a frame — while the payload the browser reads published the raw maps:

runtime[d].macTable = { "02:00:00:00:01:00": "1/1/1" }     <- no port state, no note
runtime[d].arp      = { "10.0.0.2": "02:00:00:00:02:00" }  <- no port, no reason, no age
runtime[d].lldp     = undefined                            <- not published at all

Measured on a CX 6000 with two hosts, one port shut:

console: 1  02:00:00:00:01:00  DYNAMIC  1/1/1 (administratively down)
payload: {"02:00:00:00:01:00": "1/1/1"}

Same fault class as the Routes table (#1300): the fact is computed in the console, so every other surface is left to
restate it — or, as here, to not have it.

Fixes

  • Device.portCarrierNote(port, topo, extra) — the note, written once, from ifaceStatus(), the same rule the
    front panel and console already use. The CLI's _staleNote delegates to it.
  • Device.macRows(topo) / arpRows(topo) / lldpRows(topo) return the rows as data, sorted, so two callers never
    disagree.
  • show mac address-table, show arp, show lldp print those rows instead of building their own — console output is
    byte-identical after the change.
  • fullState() publishes runtime[d].mac, runtime[d].arpRows, runtime[d].lldp as arrays, empty rather than
    absent. The bare maps stay: "which port" is a fair question to ask without reading rows.

Evidence

test/runtime-agreement.test.js — 10 checks over a situation matrix (nothing wrong, port administratively down,
far end shut down, port moved to another VLAN, port made a trunk that does not carry VLAN 1). For each, the engine's
row and the console's line must carry the same port and the same sentence — not a similar one — and the same fact
must appear in show arp and show lldp. Plus: a row carries its VLAN; an ARP row carries an honest age; a row
pointing at a port that is not on the device says (gone); rows come back sorted; over HTTP every device has
mac / arpRows / lldp arrays agreeing with the bare map's size.

Recorded in the test so nobody rediscovers it: link down is absent from the matrix because a link state change
flushes what was learned on that port (#1256) — the entry is gone, not stale.

With server/index.js and engine/device.js reverted the suite cannot run at all: x.sw.macRows is not a function.

docs/ARCHITECTURE.md: "What the tables say".

Suite: 179 suites, 7,053 assertions, 0 failed.

What the tables say, once: MAC, ARP and LLDP rows come from the engine. Fixes #1327. The runtime half of the state payload, after the config half (#1321, #1323, #1325). The console has printed honest MAC, ARP and LLDP tables since #1253–#1255 — which port an entry was learned on, and whether that port can still carry a frame — while the payload the browser reads published the **raw maps**: ``` runtime[d].macTable = { "02:00:00:00:01:00": "1/1/1" } <- no port state, no note runtime[d].arp = { "10.0.0.2": "02:00:00:00:02:00" } <- no port, no reason, no age runtime[d].lldp = undefined <- not published at all ``` Measured on a CX 6000 with two hosts, one port shut: ``` console: 1 02:00:00:00:01:00 DYNAMIC 1/1/1 (administratively down) payload: {"02:00:00:00:01:00": "1/1/1"} ``` Same fault class as the Routes table (#1300): the fact is computed in the console, so every other surface is left to restate it — or, as here, to not have it. ## Fixes * `Device.portCarrierNote(port, topo, extra)` — the note, written **once**, from `ifaceStatus()`, the same rule the front panel and console already use. The CLI's `_staleNote` delegates to it. * `Device.macRows(topo)` / `arpRows(topo)` / `lldpRows(topo)` return the rows as data, sorted, so two callers never disagree. * `show mac address-table`, `show arp`, `show lldp` print those rows instead of building their own — console output is **byte-identical** after the change. * `fullState()` publishes `runtime[d].mac`, `runtime[d].arpRows`, `runtime[d].lldp` as arrays, empty rather than absent. The bare maps stay: "which port" is a fair question to ask without reading rows. ## Evidence `test/runtime-agreement.test.js` — **10 checks** over a situation matrix (nothing wrong, port administratively down, far end shut down, port moved to another VLAN, port made a trunk that does not carry VLAN 1). For each, the engine's row and the console's line must carry the same port and the **same sentence** — not a similar one — and the same fact must appear in `show arp` and `show lldp`. Plus: a row carries its VLAN; an ARP row carries an honest age; a row pointing at a port that is not on the device says `(gone)`; rows come back sorted; over HTTP every device has `mac` / `arpRows` / `lldp` arrays agreeing with the bare map's size. Recorded in the test so nobody rediscovers it: `link down` is absent from the matrix because a link state change **flushes** what was learned on that port (#1256) — the entry is gone, not stale. With `server/index.js` and `engine/device.js` reverted the suite cannot run at all: `x.sw.macRows is not a function`. `docs/ARCHITECTURE.md`: "What the tables say". Suite: 179 suites, 7,053 assertions, 0 failed.
What the tables say, once: MAC, ARP and LLDP rows come from the engine (#1327)
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 26s
CI / Classify the change (pull_request) Successful in 29s
CI / Test (Node 18) (pull_request) Failing after 34s
CI / Test (Node 20) (pull_request) Successful in 3m25s
CI / Test (Node 22) (pull_request) Successful in 2m57s
CI / Server smoke test (pull_request) Successful in 35s
CI / Docker build (pull_request) Successful in 1m12s
81b092e226
The runtime half of the state payload, after the config half (#1321, #1323, #1325). The console has printed honest
MAC, ARP and LLDP tables since #1253-#1255 - which port an entry was learned on, and whether that port can still
carry a frame - while the payload the browser reads published the raw maps:

  runtime[d].macTable = { "02:00:00:00:01:00": "1/1/1" }     <- no port state, no note
  runtime[d].arp      = { "10.0.0.2": "02:00:00:00:02:00" }  <- no port, no reason, no age
  runtime[d].lldp     = undefined                            <- not published at all

So a switch with one live entry and one entry whose port was shut gave a client the same two strings, and the
neighbours the device has heard from were not in the payload at all. Measured on a CX 6000 with two hosts:

  console: 1  02:00:00:00:01:00  DYNAMIC  1/1/1 (administratively down)
  payload: {"02:00:00:00:01:00": "1/1/1"}

This is the Routes-table fault (#1300) in a different table: the fact is computed in the console, so every other
surface is left to restate it - or, as here, to not have it.

Fixes:

  * Device.portCarrierNote(port, topo, extra) - the note, written once, from ifaceStatus(), which is the same rule
    the front panel and the console already use for a port's state. The CLI's _staleNote delegates to it;
  * Device.macRows(topo) / arpRows(topo) / lldpRows(topo) return the rows as data: VLAN, MAC, port, note; address,
    MAC, port, honest age; neighbour, port, port ID, management address. Sorted, so two callers never disagree;
  * show mac address-table, show arp and show lldp print those rows instead of building their own - the console
    output is byte-identical after the change, which is how a refactor should look;
  * fullState() publishes runtime[d].mac, runtime[d].arpRows and runtime[d].lldp as arrays, empty rather than
    absent, so a client does not have to test for existence. The bare maps stay: "which port" is a fair question to
    ask without reading rows.

test/runtime-agreement.test.js: 10 checks over a situation matrix (nothing wrong, port administratively down, far end
shut down, port moved to another VLAN, port made a trunk that does not carry VLAN 1). For each, the row the engine
returns and the line the console prints must carry the same port and the same sentence - not a similar one - and the
same fact must appear in show arp and show lldp. A row carries its VLAN; an ARP row carries an honest age; a row
pointing at a port that is not on the device says (gone); rows come back sorted; and over HTTP every device has
mac / arpRows / lldp as arrays that agree with the bare map's size.

One consequence recorded by the test so nobody rediscovers it: `link down` is absent from the matrix because a link
state change flushes what was learned on that port (#1256) - the entry is gone, not stale.

With server/index.js and engine/device.js reverted the suite cannot run at all: `x.sw.macRows is not a function`.

docs/ARCHITECTURE.md: "What the tables say".

Suite: 179 suites, 7,053 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-10 03:26: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!1328
No description provided.