show vlan printed VLAN 1 twice, and put every trunk in VLAN 1 (#1261) #1262

Merged
jaylouisw merged 1 commit from fix/show-vlan into main 2026-11-09 19:54:19 +00:00
Owner

show vlan printed VLAN 1 twice, and put every trunk in VLAN 1

Fixes #1261.

VLAN    Name                             Status    Ports
1       default                          active    Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7, Fa0/8
20      twenty                           active    Fa0/1, Fa0/2, Fa0/3
30      thirty                           active    Fa0/2, Fa0/3

What was wrong

The old table, from a lab with one access port in VLAN 20 and two trunks:

VLAN Name                             Status    Ports
1       VLAN0001                         active    Fa0/2(n), Fa0/3, Fa0/4, ... Fa0/8
20      VLAN0020                         active    Fa0/1
1       default                          active    Fa0/2(trunk)
  • VLAN 1 twice, with different names and different port lists. A trunk whose allowed list is all was
    pushed into VLAN 1 under a pseudo-key all, and that key was then rendered as VLAN 1.
  • A trunk carrying every VLAN was therefore reported as a member of VLAN 1 and of nothing else.
  • A trunk appeared in VLAN 1 whether or not its allowed list carried VLAN 1 — the table was describing an
    intent, not what classifyEgress() would forward.
  • (n) / (t) / (trunk) decorations that real show vlan does not print.

And show spanning-tree had the same defect class as the counters in #1252: with no run it said
No bridged ports: this device is not part of any L2 loop. — a claim about the lab, printed when the truth
was that nothing had computed the tree.

Now

  • One row per VLAN, in VLAN order, no pseudo-rows, no decorations.
  • Membership is decided by vlanLib.classifyEgress() — the rule the data plane forwards by — so the
    table cannot list a port the switch would drop for, or omit one it would forward to:
    • an access port appears in its access VLAN only;
    • a trunk appears in exactly the VLANs its allowed list carries, and not in VLAN 1 merely for being a
      trunk
      (the belief that made a native-VLAN mismatch invisible);
    • an all trunk appears in every row.
  • A VLAN exists if it is configured by vlan <id> [name] or if a port uses it; a configured VLAN nothing
    carries prints an empty Ports column rather than an invented port.
  • show vlan brief is the same table — no short form that disagrees with the long one.
  • show spanning-tree prints Not measured (no simulation run): nothing has computed the spanning tree
    until something has, and "no ports are bridging" only afterwards.
  • vlanLib is required once at module level rather than inside each branch that needed it.

Evidence

test/show-vlan.test.js — 29 checks:

  • VLAN 1 appears exactly once; no row carries the old decorations; rows are in VLAN order;
  • the access port is in VLAN 20 and no longer in VLAN 1;
  • a trunk with allowed vlan 20,30 is in 20 and 30 and not in VLAN 1; the all-VLAN trunk is in every
    row;
  • the load-bearing one: for every port and every VLAN, "listed" iff classifyEgress() forwards it — the
    table and the data plane cannot diverge;
  • configured names, default for VLAN 1, generated VLAN0044 for a VLAN that exists only because a port
    uses it, and the ports that really carry it;
  • the table follows a port that moves VLAN; show vlan brief == the full form row for row;
  • a configured VLAN nothing carries has no access port invented into it;
  • show spanning-tree distinguishes "not measured" from "no loop", and a real loop reports a blocking port
    with traffic dropped while the device model has the same port blocked.

Reverting engine/cli.js fails 10 of the 29.

docs/CLI.md gains "Reading show vlan" and "Reading show spanning-tree", plus the two commands in the
command table.

Suite: 144 suites, 6,164 assertions, 0 failed.

`show vlan` printed VLAN 1 twice, and put every trunk in VLAN 1 Fixes #1261. ``` VLAN Name Status Ports 1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7, Fa0/8 20 twenty active Fa0/1, Fa0/2, Fa0/3 30 thirty active Fa0/2, Fa0/3 ``` ## What was wrong The old table, from a lab with one access port in VLAN 20 and two trunks: ``` VLAN Name Status Ports 1 VLAN0001 active Fa0/2(n), Fa0/3, Fa0/4, ... Fa0/8 20 VLAN0020 active Fa0/1 1 default active Fa0/2(trunk) ``` * **VLAN 1 twice**, with different names and different port lists. A trunk whose allowed list is `all` was pushed into VLAN 1 under a pseudo-key `all`, and that key was then *rendered as VLAN 1*. * A trunk carrying every VLAN was therefore reported as a member of VLAN 1 **and of nothing else**. * A trunk appeared in VLAN 1 whether or not its allowed list carried VLAN 1 — the table was describing an intent, not what `classifyEgress()` would forward. * `(n)` / `(t)` / `(trunk)` decorations that real `show vlan` does not print. And `show spanning-tree` had the same defect class as the counters in #1252: with no run it said `No bridged ports: this device is not part of any L2 loop.` — a claim about the lab, printed when the truth was that nothing had computed the tree. ## Now * One row per VLAN, in VLAN order, no pseudo-rows, no decorations. * **Membership is decided by `vlanLib.classifyEgress()`** — the rule the data plane forwards by — so the table cannot list a port the switch would drop for, or omit one it would forward to: * an access port appears in its access VLAN only; * a trunk appears in exactly the VLANs its allowed list carries, and **not in VLAN 1 merely for being a trunk** (the belief that made a native-VLAN mismatch invisible); * an `all` trunk appears in every row. * A VLAN exists if it is configured by `vlan <id> [name]` or if a port uses it; a configured VLAN nothing carries prints an empty Ports column rather than an invented port. * `show vlan brief` is the same table — no short form that disagrees with the long one. * `show spanning-tree` prints `Not measured (no simulation run): nothing has computed the spanning tree` until something has, and "no ports are bridging" only afterwards. * `vlanLib` is required once at module level rather than inside each branch that needed it. ## Evidence `test/show-vlan.test.js` — 29 checks: * VLAN 1 appears exactly once; no row carries the old decorations; rows are in VLAN order; * the access port is in VLAN 20 and no longer in VLAN 1; * a trunk with `allowed vlan 20,30` is in 20 and 30 and **not** in VLAN 1; the all-VLAN trunk is in every row; * the load-bearing one: **for every port and every VLAN, "listed" iff `classifyEgress()` forwards it** — the table and the data plane cannot diverge; * configured names, `default` for VLAN 1, generated `VLAN0044` for a VLAN that exists only because a port uses it, and the ports that really carry it; * the table follows a port that moves VLAN; `show vlan brief` == the full form row for row; * a configured VLAN nothing carries has no access port invented into it; * `show spanning-tree` distinguishes "not measured" from "no loop", and a real loop reports a blocking port with `traffic dropped` while the device model has the same port blocked. Reverting `engine/cli.js` fails 10 of the 29. `docs/CLI.md` gains "Reading `show vlan`" and "Reading `show spanning-tree`", plus the two commands in the command table. Suite: 144 suites, 6,164 assertions, 0 failed.
show vlan printed VLAN 1 twice, and put every trunk in VLAN 1 (#1261)
All checks were successful
CI / Classify the change (pull_request) Successful in 9s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 13s
CI / Test (Node 20) (pull_request) Successful in 1m56s
CI / Test (Node 18) (pull_request) Successful in 2m0s
CI / Server smoke test (pull_request) Successful in 35s
CI / Docker build (pull_request) Successful in 43s
CI / Test (Node 22) (pull_request) Successful in 1m46s
9e37fc6b00
A trunk whose allowed list was `all` was pushed into VLAN 1 under a pseudo-key `all`, which was then
*rendered* as VLAN 1 with VLAN 1's name and ports. The table therefore had two VLAN 1 rows, and a trunk
carrying every VLAN was reported as a member of VLAN 1 and of nothing else.

Membership also disagreed with the data plane: a trunk appeared in VLAN 1 whether or not its allowed list
carried VLAN 1, and the (n)/(t)/(trunk) decorations described an intent rather than what classifyEgress()
forwards. `show spanning-tree` had the same defect class as the counters in #1252: with no run it claimed
"not part of any L2 loop" when the truth was that nothing had computed the tree.

Now:
* one row per VLAN, in VLAN order, no pseudo-rows, no decorations;
* membership is decided by `vlanLib.classifyEgress()` - the rule the data plane forwards by - so the table
  cannot list a port the switch would drop for, or omit one it would forward to. An access port is in its
  access VLAN only; a trunk is in exactly the VLANs its allowed list carries, and NOT in VLAN 1 merely for
  being a trunk; an `all` trunk is in every row;
* a VLAN exists if it is configured or if a port uses it; a configured VLAN nothing carries prints an empty
  Ports column rather than an invented port;
* `show vlan brief` is the same table (there is no short form that disagrees with the long one);
* `show spanning-tree` prints `Not measured (no simulation run)` when nothing has computed the tree, and
  "no ports are bridging" only when something has.

`vlanLib` is now required once at module level instead of inside each branch that needs it.

test/show-vlan.test.js (29 checks): one VLAN 1 row; access and trunk membership including the trunk whose
allowed list excludes VLAN 1; the every-VLAN trunk in every row; configured and generated names; a VLAN that
exists only because a port uses it; the table following a port that moves; brief == full; empty Ports for an
uncarried VLAN; and the load-bearing invariant - for every port and every VLAN, "listed" iff
`classifyEgress()` forwards it. Plus `show spanning-tree` distinguishing "not measured" from "no loop", and
a real loop reporting a blocking port with `traffic dropped`.

Reverting engine/cli.js fails 10 of the 29.

Suite: 144 suites, 6,164 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 19:54:16 +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!1262
No description provided.