interfaces: a shortened type opens the same port (g1/0/1 -> Gi1/0/1), expanded against this device's own types #1841

Merged
jaylouisw merged 1 commit from rev/1117-1200 into main 2026-11-17 12:29:51 +00:00
Owner

Question

An operator types interface g1/0/1, interface f0/1, interface s0/0/0. Does a real IOS-like box accept a shortened interface TYPE, and which prefixes does it accept? This console accepted only the documented gi/fa spellings, so the spelling people actually type was refused with % Interface not found.

Evidence

What changed

engine/iface-name.js gains expandTypePrefix() and deviceTypeSet(); resolvePortName() retries the key lookup on the expanded name. The prefix is expanded against the types this device actually carries, so the answer is uniqueness, not a table:

  • g1/0/1 -> Gi1/0/1 on a 2960-X; f0/1 -> Fa0/1 and s0/0/0 -> Se0/0/0 on a 2811;
  • the space form (interface g 1/0/2) and subinterfaces (interface g1/0/24.10) work the same;
  • a prefix that matches two of the device's types resolves to neither (TenGigabitEthernet vs TwentyFiveGigE);
  • a prefix that matches none is refused exactly as before;
  • the expansion is not in portKey(): that key is device-free (saved labs are folded with it before any device exists) and a prefix rule there would reach names the table never knew - a UniFi Port 1 must not be p1. Only a type already in TYPE_SPELLINGS can be reached, and only through a device.

A spelling that folds onto two ports is still refused rather than rescued into one of them (matchKey now distinguishes "absent" from "ambiguous").

Tests

  • new test/iface-type-prefix.test.js - 8 assertions (one-letter and longer prefixes, the space form, per-device types, subinterface, ambiguity, no-such-type, Port 1 guard, view word).
  • test/iface-type-spelling.test.js no longer asserts that Gig1/0/1 is refused (10 pass).
  • node scripts/syntax-check.js: 386 files, all OK. check-doc-citations: 349 citations, exit 0. check-control-bytes: clean.
  • full npm test: 314 suites, 10,954 assertions, 0 failed.

Docs

research/interface-type-spellings.md: the "Partial spellings" item it left unresolved is now settled, with the sources above and the rule as implemented. docs/CLI.md says the same in the interface-naming section.

Still unresolved

Types the table does not carry (TFGigabitEthernet, XGigabitEthernet/xge, mge, PON/DSL) still need their vendor's own abbreviation before they can be added, and whether show running-config should print the long name is a separate question.

## Question An operator types `interface g1/0/1`, `interface f0/1`, `interface s0/0/0`. Does a real IOS-like box accept a shortened interface TYPE, and which prefixes does it accept? This console accepted only the documented `gi`/`fa` spellings, so the spelling people actually type was refused with `% Interface not found`. ## Evidence * "You can abbreviate commands and keywords to the number of characters that allow a unique abbreviation" - Cisco IOS Configuration Fundamentals, *Using the Cisco IOS Command-Line Interface* (12.2SX). https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/fundamentals/configuration/12-2sx/cf-12-2sx-book/Using_the_Cisco_IOS_Command-Line_Interface.html * `Router(config)# interface g 0/1/0` and "use the show run interface g0/1/0, show interface g0/1/0 ... commands to verify" - Cisco Embedded Service 6300 Series Software Configuration Guide, *Configuring Ethernet Switch Ports*. https://cisco.com/c/en/us/td/docs/IIOT/routers/embedded/6300/software/config/b_ESR6300_config/b_ESR6300_config_chapter_01111.html * `Switch(config)# interface g0/12` on a Catalyst 6500 - Cisco support community, *Port-Security for mobile devices as laptops*. https://community.cisco.com/t5/physical-security/port-security-for-mobile-devices-as-laptops/td-p/3774460 * Single letters, so every longer prefix (`gi`, `gig`, `gigabit`) follows on the same rule. ## What changed `engine/iface-name.js` gains `expandTypePrefix()` and `deviceTypeSet()`; `resolvePortName()` retries the key lookup on the expanded name. The prefix is expanded against the types **this device** actually carries, so the answer is uniqueness, not a table: * `g1/0/1` -> `Gi1/0/1` on a 2960-X; `f0/1` -> `Fa0/1` and `s0/0/0` -> `Se0/0/0` on a 2811; * the space form (`interface g 1/0/2`) and subinterfaces (`interface g1/0/24.10`) work the same; * a prefix that matches two of the device's types resolves to neither (TenGigabitEthernet vs TwentyFiveGigE); * a prefix that matches none is refused exactly as before; * the expansion is **not** in `portKey()`: that key is device-free (saved labs are folded with it before any device exists) and a prefix rule there would reach names the table never knew - a UniFi `Port 1` must not be `p1`. Only a type already in `TYPE_SPELLINGS` can be reached, and only through a device. A spelling that folds onto two ports is still refused rather than rescued into one of them (`matchKey` now distinguishes "absent" from "ambiguous"). ## Tests * new `test/iface-type-prefix.test.js` - 8 assertions (one-letter and longer prefixes, the space form, per-device types, subinterface, ambiguity, no-such-type, `Port 1` guard, view word). * `test/iface-type-spelling.test.js` no longer asserts that `Gig1/0/1` is refused (10 pass). * `node scripts/syntax-check.js`: 386 files, all OK. `check-doc-citations`: 349 citations, exit 0. `check-control-bytes`: clean. * full `npm test`: **314 suites, 10,954 assertions, 0 failed**. ## Docs `research/interface-type-spellings.md`: the "Partial spellings" item it left unresolved is now settled, with the sources above and the rule as implemented. `docs/CLI.md` says the same in the interface-naming section. ## Still unresolved Types the table does not carry (`TFGigabitEthernet`, `XGigabitEthernet`/`xge`, `mge`, PON/DSL) still need their vendor's own abbreviation before they can be added, and whether `show running-config` should print the long name is a separate question.
interfaces: a shortened type is the same port (g1/0/1 -> Gi1/0/1), expanded against this device's own types
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 16s
CI / Server smoke test (pull_request) Successful in 8s
CI / Docker build (pull_request) Successful in 25s
CI / Test (Node 18) (pull_request) Successful in 57s
CI / Test (Node 20) (pull_request) Successful in 51s
CI / Test (Node 22) (pull_request) Successful in 52s
CI / Arm auto-merge (pull_request) Successful in 10s
9dfba46947
IOS abbreviates every keyword to the number of characters that keep it unique, and the type word
in an interface name is a keyword: Cisco's Embedded Service 6300 guide writes `interface g 0/1/0`
and `show interface g0/1/0`, and a Catalyst 6500 config in Cisco's support library opens
`interface g0/12`. This console refused every prefix shorter than the documented `gi`/`ga`
spellings - `interface g1/0/1`, `f0/1`, `s0/0/0` - which is exactly what an operator types.

A table cannot decide a prefix, because the answer is uniqueness: `g` is GigabitEthernet on a box
with no other G-type, and `t` is ambiguous on a box carrying both TenGigabitEthernet and
TwentyFiveGigE. So `expandTypePrefix()` in engine/iface-name.js expands the prefix against the
types the device in front of the caller actually has, and only when exactly one matches; a prefix
that matches two of them resolves to neither, and one that matches none is refused as before.
`resolvePortName()` retries the key lookup on the expanded name, so the space form, subinterfaces
and every existing spelling are unchanged, and a spelling that folds onto two ports stays refused
instead of being rescued into one of them.

Deliberately not in `portKey()`: that key is device-free (saved labs are folded with it before any
device exists) and a prefix rule there would reach names the table never knew - `p1` must not find
a UniFi `Port 1`. Only a type already in TYPE_SPELLINGS can be reached this way, and only through
a device.

research/interface-type-spellings.md called this out as unresolved and named the evidence that
would settle it; the note now carries that evidence and the rule, and docs/CLI.md says the same.
jaylouisw force-pushed rev/1117-1200 from 9dfba46947
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 16s
CI / Server smoke test (pull_request) Successful in 8s
CI / Docker build (pull_request) Successful in 25s
CI / Test (Node 18) (pull_request) Successful in 57s
CI / Test (Node 20) (pull_request) Successful in 51s
CI / Test (Node 22) (pull_request) Successful in 52s
CI / Arm auto-merge (pull_request) Successful in 10s
to da59f4c990
All checks were successful
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 7s
CI / Classify the change (pull_request) Successful in 10s
CI / Server smoke test (pull_request) Successful in 8s
CI / Test (Node 18) (pull_request) Successful in 1m2s
CI / Docker build (pull_request) Successful in 20s
CI / Test (Node 20) (pull_request) Successful in 42s
CI / Test (Node 22) (pull_request) Successful in 43s
CI / Arm auto-merge (pull_request) Successful in 18s
2026-11-17 12:26:00 +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!1841
No description provided.