show lldp marks stale neighbours, and its columns no longer run together (#1265) #1266

Merged
jaylouisw merged 1 commit from fix/show-lldp-stale into main 2026-11-09 20:14:30 +00:00
Owner

show lldp marks stale neighbours, and its columns no longer run together

Fixes #1265.

LLDP neighbours on Switch (L2)-sw:
  Neighbour                                  Local port               Port ID  Mgmt address
  ASR 1001-X aggregation services router-r1  Fa0/1 (down: link down)  Gi0      10.0.0.1
  PC-pc                                      Fa0/2                    eth0     -

What was wrong

Pull a cable and the table did not change. Shut the far port and it still did not change. And the row itself
was unreadable, because Neighbour was padded to 20 characters and a real device name is 55:

  ASR 1001-X aggregation services router-r1Fa0/1           Gi0             10.0.0.1

show arp (#1254) and show mac address-table (#1256) were both taught to mark an entry whose port can no
longer carry a frame. This table — the third one that reports learned state — was not.

Now

  • a neighbour is still listed when its link drops: real switches hold the entry until its TTL expires, and
    this model has no clock to age it with. The Local port carries the reason instead, in the same sentence
    the other tables use — (down: link down), (down: peer shut down), (administratively down);
  • the reason comes from _staleNote(iface) and the port is resolved through dev.resolveIface(), so a
    vendor spelling resolves and a port that no longer exists reads (gone) instead of a device being invented
    for it;
  • the mark clears when the link comes back;
  • column widths are computed from the data (never narrower than the old header), so no name can run into the
    next column whatever the catalogue grows to;
  • the empty table still prints a header above the honest (none - no LLDP has been heard on any port).

Evidence

test/show-lldp.test.js — 23 checks. The parser reads rows by the table's own header offsets, not by a
regex, so it fails on unreadable output as well as on a missing mark:

  • a 55-character router name and a short PC name in one table, both parsed into four fields; the name is
    asserted to be longer than 20 characters, so the defect is reproducible rather than assumed; nothing is
    concatenated (r1Fa0/1 must not appear);
  • a pulled cable, a shut far port and a local shutdown each say their own thing, while a healthy neighbour
    in the same table stays unmarked — the mark is per row, not per table;
  • the mark clears on restore;
  • a neighbour recorded against a port that no longer exists reads (gone);
  • the table does not invent or drop neighbours when a port changes state, and a neighbour heard on a second
    port appears twice with the unusable row marked;
  • the empty table keeps its header.

Reverting engine/cli.js fails 12 of the 23.

docs/CLI.md gains "Reading show lldp" and the command in the table.

Suite: 146 suites, 6,217 assertions, 0 failed.

`show lldp` marks stale neighbours, and its columns no longer run together Fixes #1265. ``` LLDP neighbours on Switch (L2)-sw: Neighbour Local port Port ID Mgmt address ASR 1001-X aggregation services router-r1 Fa0/1 (down: link down) Gi0 10.0.0.1 PC-pc Fa0/2 eth0 - ``` ## What was wrong Pull a cable and the table did not change. Shut the far port and it still did not change. And the row itself was unreadable, because `Neighbour` was padded to 20 characters and a real device name is 55: ``` ASR 1001-X aggregation services router-r1Fa0/1 Gi0 10.0.0.1 ``` `show arp` (#1254) and `show mac address-table` (#1256) were both taught to mark an entry whose port can no longer carry a frame. This table — the third one that reports learned state — was not. ## Now * a neighbour is **still listed** when its link drops: real switches hold the entry until its TTL expires, and this model has no clock to age it with. The **Local port carries the reason** instead, in the same sentence the other tables use — `(down: link down)`, `(down: peer shut down)`, `(administratively down)`; * the reason comes from `_staleNote(iface)` and the port is resolved through `dev.resolveIface()`, so a vendor spelling resolves and a port that no longer exists reads `(gone)` instead of a device being invented for it; * the mark **clears** when the link comes back; * column widths are computed from the data (never narrower than the old header), so no name can run into the next column whatever the catalogue grows to; * the empty table still prints a header above the honest `(none - no LLDP has been heard on any port)`. ## Evidence `test/show-lldp.test.js` — 23 checks. The parser reads rows by the **table's own header offsets**, not by a regex, so it fails on unreadable output as well as on a missing mark: * a 55-character router name and a short PC name in one table, both parsed into four fields; the name is asserted to be longer than 20 characters, so the defect is reproducible rather than assumed; nothing is concatenated (`r1Fa0/1` must not appear); * a pulled cable, a shut **far** port and a local shutdown each say their own thing, while a healthy neighbour in the same table stays unmarked — the mark is per row, not per table; * the mark clears on restore; * a neighbour recorded against a port that no longer exists reads `(gone)`; * the table does not invent or drop neighbours when a port changes state, and a neighbour heard on a second port appears twice with the unusable row marked; * the empty table keeps its header. Reverting `engine/cli.js` fails 12 of the 23. `docs/CLI.md` gains "Reading `show lldp`" and the command in the table. Suite: 146 suites, 6,217 assertions, 0 failed.
show lldp marks stale neighbours, and its columns no longer run together (#1265)
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 12s
CI / Test (Node 20) (pull_request) Successful in 1m54s
CI / Test (Node 18) (pull_request) Successful in 1m57s
CI / Server smoke test (pull_request) Successful in 33s
CI / Docker build (pull_request) Successful in 39s
CI / Test (Node 22) (pull_request) Successful in 1m44s
cc4e6ef43c
Two defects in one small table. Pull a cable and the table did not change - the neighbour was listed
identically whether its port could still carry a frame or not, which is the one question the table answers.
And the Neighbour column was padded to 20 characters while a real device name is 55, so the row printed
`...router-r1Fa0/1`: the system name and the local port were one field, and the header was misaligned the
same way.

Now:
* a neighbour is still listed when its link drops - real switches hold the entry until its TTL expires and
  this model has no clock to age it with - but the Local port carries the reason, in the same sentence
  `show arp` and `show mac address-table` use: `(down: link down)`, `(down: peer shut down)`,
  `(administratively down)`;
* the mark comes from `_staleNote(iface)` and from `dev.resolveIface()`, so a vendored spelling resolves and a
  port that no longer exists is marked `(gone)` rather than inventing a device;
* the mark clears when the link comes back;
* column widths are computed from the data (and never narrower than the old header), so no name can run into
  the next column whatever the catalogue grows to;
* the empty table still prints a header above the honest "(none - no LLDP has been heard on any port)".

test/show-lldp.test.js (23 checks) parses rows by the table's own header offsets rather than by a regex, so
it fails on unreadable output as well as on missing marks: a 55-character router name and a short PC name in
one table, both parsed into four fields; the name really is longer than 20 characters, so the defect is
reproducible; nothing is concatenated; a pulled cable and a shut far port and a local shutdown each say their
own thing while a healthy neighbour in the same table stays unmarked; the mark clears on restore; a ghost port
reads `(gone)`; the empty table keeps its header; and a link going down changes neither the number of
neighbours nor invents one. Reverting engine/cli.js fails 12 of the 23.

Suite: 146 suites, 6,217 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 20:14:26 +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!1266
No description provided.