One naming table, not two (#1247) #1248
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1248
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor/one-iface-name-table"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
One naming table, not two
Fixes #1247.
engine/iface-name.jsholds the spelling rules;engine/cli.jsheld a hand-copied second version ofPORT_NAME_RULES,portKeyandresolvePortName. They agree today by luck. The copy is gone and the CLIimports the shared module — still re-exporting the three names, because
test/mikrotik-naming.test.jsimports them from there, and a re-export cannot drift.
The asymmetry it hid
Device.resolveIface()accepted exact names only, so the engine was stricter than the console that writesthe config. A topology file storing a VRRP group under the spelling somebody typed elected nothing, and
show vrrpcalled that groupInit— a static naming problem reported as a dynamic state.resolveIface()now resolves through the same table: exact name first, then case, then the vendor fold, and
nullwhennothing matches or two ports fold together (an ambiguous spelling is refused, not guessed).
Evidence
test/iface-name-agreement.test.js— 16 checks:===, and the same forportKey). A pasted copy fails thesuite immediately — that is the check this PR exists for.
console spelling where the table has one;
null— a typo is an error, not aguess — and a third spelling folding onto two ports (
sfpplus1where bothsfp+1andsfp-sfpplus1exist) is refused;
interface combo1on a MikroTik sets the address on the port the panel callsCOMBO1, and the tables goon printing the panel spelling;
Init.Reverting the device change fails 4 of the 16.
docs/CLI.mdgains a note on the spellings under "Interface-mode commands".Suite: 137 suites, 5,933 assertions, 0 failed.
engine/iface-name.js holds the rules that fold a console spelling ("ether1") onto the panel spelling ("eth1"), and engine/cli.js held a hand-copied second version of `PORT_NAME_RULES`, `portKey` and `resolvePortName`. They had not drifted yet, by luck. Two copies of one rule is the failure mode this repo has already been bitten by twice - the fabric rule and the port-state rule both needed an agreement test after diverging - so the copy goes, and the CLI imports the shared module (still re-exporting it, because `test/mikrotik-naming.test.js` imports it from there and a re-export cannot drift). The asymmetry it hid: `Device.resolveIface()` accepted exact names only, while the console accepted every spelling. So the engine was stricter than the thing that writes the config. A topology file storing a VRRP group under the spelling somebody typed elected nothing, and `show vrrp` called the group Init - a static config error reported as a dynamic state. `resolveIface()` now resolves through the same table: exact name first, then case, then the vendor fold, and null when nothing matches or two ports fold together. test/iface-name-agreement.test.js (16 checks): * the CLI's resolver *is* the shared function (`===`), so a pasted copy fails the suite immediately; * a sweep of all 20,233 ports in the catalogue: each resolves by its own name, in any case, and by its console spelling where the table has one; * a name that matches nothing, an empty name and no name all resolve to null - a typo is an error, not a guess - and a spelling that folds onto two ports is refused rather than picking one; * a console spelling configures the port it names (`interface combo1` on a MikroTik sets the address on COMBO1) and the tables keep printing the panel spelling; * a group stored under a differently-spelled interface name still takes part, and is not reported as Init. Reverting the device change fails 4 of the 16. Suite: 137 suites, 5,933 assertions, 0 failed.