vlan: a range typed high-to-low is refused, not silently reversed #1831

Merged
jaylouisw merged 1 commit from rev/1117-1100 into main 2026-11-17 11:23:28 +00:00
Owner

One question

switchport trunk allowed vlan 30-20 — a VLAN range whose two ids are the wrong way round. Does the box read it as 20-30, or refuse the line?

Verdict

It refuses. PacketForge flipped it: engine/vlan.js swapped the pair and carried on, so

sw1(config-if)#switchport trunk allowed vlan 30-20
Trunk on Fa0/1 allows VLANs 20-30

configured VLANs nobody named, and show interfaces / show running-config then reported the swap as though it were what was typed. Nothing in the lab showed the line had been rewritten.

Evidence

  • Cisco defines the vlan-list range as "two VLAN numbers, the lower one first" — Catalyst 2960-X 15.2(2)E, 3850 16.9 and 9200 17.5 config guides, word for word.
  • An input the grammar cannot read is "an error message" and no configuration change (Catalyst 9500 command reference).
  • No Cisco document shows a descending range being accepted.

The box's own wording for the refusal was not found, so the console uses its own sentence (its established style for refusals) rather than inventing a Cisco string.

Change

  • engine/vlan.js: parseVlanList fails with E_VLAN_RANGE_ORDER on a descending pair instead of swapping it; the range is quoted and the ascending form named. Applies to <list>, add <list> and remove <list> — one parser.
  • docs/CLI.md: the rule and the refusal, next to the trunk-list section.
  • research/vlan-range-order.md: evidence, what is inferred (exact wording), what is unresolved (wording; whether 20-20 is legal; other vlan-list consumers).
  • Tests: test/vlan.test.js (the old test asserting the silent swap is replaced), test/trunk-allowed-add-remove.test.js (set/add/remove refused, list untouched, ascending range still works).

Gates

  • node scripts/syntax-check.js — 384 files, all OK
  • node scripts/check-control-bytes.js — clean
  • npm test — 312 suites, 10,905 assertions, 0 failed

Unresolved: the box's exact sentence for a transposed range (careted parse error vs % line); nothing public collected here shows one.

## One question `switchport trunk allowed vlan 30-20` — a VLAN range whose two ids are the wrong way round. Does the box read it as `20-30`, or refuse the line? ## Verdict It refuses. PacketForge flipped it: `engine/vlan.js` swapped the pair and carried on, so ``` sw1(config-if)#switchport trunk allowed vlan 30-20 Trunk on Fa0/1 allows VLANs 20-30 ``` configured VLANs nobody named, and `show interfaces` / `show running-config` then reported the swap as though it were what was typed. Nothing in the lab showed the line had been rewritten. ## Evidence * Cisco defines the vlan-list range as "two VLAN numbers, **the lower one first**" — Catalyst 2960-X 15.2(2)E, [3850 16.9](https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst3850/software/release/16-9/configuration_guide/vlan/b_169_vlan_3850_cg/configuring_vlan_trunks.html) and [9200 17.5](https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9200/software/release/17-5/configuration_guide/vlan/b_175_vlan_9200_cg/configuring_vlan_trunks.pdf) config guides, word for word. * An input the grammar cannot read is "an error message" and no configuration change ([Catalyst 9500 command reference](http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9500/software/release/16-6/command_reference/b_166_9500_cr/b_166_9500_cr_chapter_011000.pdf)). * No Cisco document shows a descending range being accepted. The box's own wording for the refusal was not found, so the console uses its own sentence (its established style for refusals) rather than inventing a Cisco string. ## Change * `engine/vlan.js`: `parseVlanList` fails with `E_VLAN_RANGE_ORDER` on a descending pair instead of swapping it; the range is quoted and the ascending form named. Applies to `<list>`, `add <list>` and `remove <list>` — one parser. * `docs/CLI.md`: the rule and the refusal, next to the trunk-list section. * `research/vlan-range-order.md`: evidence, what is inferred (exact wording), what is unresolved (wording; whether `20-20` is legal; other vlan-list consumers). * Tests: `test/vlan.test.js` (the old test asserting the silent swap is replaced), `test/trunk-allowed-add-remove.test.js` (set/add/remove refused, list untouched, ascending range still works). ## Gates * `node scripts/syntax-check.js` — 384 files, all OK * `node scripts/check-control-bytes.js` — clean * `npm test` — 312 suites, **10,905 assertions, 0 failed** Unresolved: the box's exact sentence for a transposed range (careted parse error vs `%` line); nothing public collected here shows one.
vlan: a range typed high-to-low is refused, not silently reversed
All checks were successful
CI / Classify the change (pull_request) Successful in 8s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 9s
CI / Server smoke test (pull_request) Successful in 7s
CI / Docker build (pull_request) Successful in 25s
CI / Test (Node 20) (pull_request) Successful in 48s
CI / Test (Node 22) (pull_request) Successful in 55s
CI / Test (Node 18) (pull_request) Successful in 57s
CI / Arm auto-merge (pull_request) Successful in 5s
b74433ab44
switchport trunk allowed vlan 30-20 configured 20-30: parseVlanList swapped the pair and carried on, so a transposed range set the VLANs nobody named and every view then reported the swap as if it were what was typed. Cisco's vlan-list note says the range is 'two VLAN numbers, the lower one first' on the 2960-X, 3850 and 9200 alike, and an input the grammar cannot read is answered with an error and no change. The parser now refuses the pair with E_VLAN_RANGE_ORDER, naming the order that would work, and the CLI quotes it back. The same input was already refused by 'vlan 10-5' and by the DHCP pool range (E_DHCP_RANGE_ORDER). research/vlan-range-order.md records the evidence and what is still unverified: the box's own wording.
jaylouisw force-pushed rev/1117-1100 from b74433ab44
All checks were successful
CI / Classify the change (pull_request) Successful in 8s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 9s
CI / Server smoke test (pull_request) Successful in 7s
CI / Docker build (pull_request) Successful in 25s
CI / Test (Node 20) (pull_request) Successful in 48s
CI / Test (Node 22) (pull_request) Successful in 55s
CI / Test (Node 18) (pull_request) Successful in 57s
CI / Arm auto-merge (pull_request) Successful in 5s
to 39cb6cacde
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 7s
CI / Server smoke test (pull_request) Successful in 9s
CI / Docker build (pull_request) Successful in 23s
CI / Test (Node 18) (pull_request) Successful in 51s
CI / Test (Node 20) (pull_request) Successful in 53s
CI / Test (Node 22) (pull_request) Successful in 50s
CI / Arm auto-merge (pull_request) Successful in 16s
2026-11-17 11:21:11 +00:00
Compare
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!1831
No description provided.