show running-config is now a config you can paste back (#1230) #1231
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!1231
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/running-config-pasteable"
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?
show running-configis now a config you can paste backFixes #1230.
Pasting a running-config into a fresh device reported an error on almost every line, and the lines that
were accepted applied themselves to the wrong port: an address meant for
Gi0/0/0and ashutdownmeant for
Gi0/0/1both landed on the first interface in the file.Three causes, all in
engine/cli.jsThe printer never emitted
exit. Interface blocks came back to back, so a reader never leftinterface mode; everything after the first block — global commands included — was parsed as an
interface command. Each block now closes with
exit.The printer's own header was rejected.
! PacketForge running-configcame back as% Unrecognized config command. Comment lines (!and#) are now ignored before dispatch, in everymode.
interface <name>inside interface mode was an error. It is a mode switch in every real CLI, andthe config-mode handler already knows how to open an interface (dot1q subinterfaces included), so it is
reused. A line that is not an interface command now falls through to the config-mode dispatcher before
being refused — which is what makes a config copied out before this fix still replayable. Those
backups are block-after-block with no
exit, so accepting only the corrected shape would haveinvalidated every config anyone had already copied.
A fourth, found by the sweep
The catalogue sweep turned up interfaces whose names contain spaces — Ubiquiti's
Port 1,SFP+ 1.interface Port 1was read as an interface calledPortand refused, so those devices could neverreplay their own config. An interface name is now the whole rest of the line (
tokens.slice(1).join(' '),and the same for
no interface).Evidence
New
test/config-roundtrip.test.js, 22 checks:show running-config— header comment included — is accepted with zerorejections and reproduces itself byte for byte;
Gi0/0/0and the shutdown onGi0/0/1, and nothing landed on the parent;exitlines stripped (the pre-fix shape) also replays cleanly, globalsection included;
interface Gi0/0/1inside interfacemode switches instead of erroring, and the following
shutdownapplies to the new interface; aninterface that does not exist is still refused;
back: no rejections, and identical output.
That sweep is the test that found the space-in-name bug, which is why it is kept rather than replaced
with a fixture.
docs/CLI.mddocuments the invariant and what makes it hold.Suite: 132 suites, 5,757 assertions, 0 failed.
show running-configis now a config you can paste backshow running-confignow prints the whole config: VLANs, DHCP pools, DNS zones and VRRP (#1232) #1233