A VLAN parameter is not a mode change, and a port has one method (#1285) #1286
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!1286
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/switchport-mode-and-one-method"
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?
A VLAN parameter is not a mode change, and a port has one method.
Fixes #1285.
1.
switchport trunk native vlanon an access port made it a trunkvlan.modewasaccessbefore the command andtrunkafter. The same forswitchport trunk allowed vlan 10,20, and in the other directionswitchport access vlan 30on a trunk turned the trunk into an accessport.
20 — a change in a column nobody typed into;
value is stored, the mode is left alone;
backup and never came back on restore.
2. A port held a static address and a DHCP client at once
state afterwards:
{ ip: "10.0.0.1", dhcp: true }.routeTo()would route for it;show ip interface briefreported MethodDHCPbeside that address;show running-configprinted only the static line, so restoring the backup lost the DHCP intent.The reverse direction already cleared the flag, but silently.
no ip addressanswered "IP address removedfrom Gi0/0" whether or not there was an address and whether or not the port was a DHCP client.
3. Found while testing (2): the backup baked in a leased address
A DHCP host that had leased
10.0.0.100printedip address 10.0.0.100 255.255.255.0. Restored on anothernetwork, that host claims a stale address and never asks for a new one.
After
switchport modechanges the mode; the three parameter commands store and say when the value is notyet in use, and say nothing when it is;
no ip addressnames what it removed, or refuses when there is nothing;show running-configprintsip address dhcpfor a leased host, never the leased address.Evidence
test/switchport-mode.test.js— 32 checks.test/interface-method.test.js— 26 checks. Withengine/cli.jsreverted, the two suites report 17 and 13 failures respectively.
used immediately gets no note;
switchport mode trunkcarries 20 while still dropping what the allowed list omits;show vlanlists the port under the VLAN it carries, not the one it is staged for;the same parameters; the default trunk and access cases print exactly what they printed before (the existing
45-check round-trip suite still passes unchanged);
ip address dhcpand the displaced address is named; a DHCP client doesnot survive a static address;
no ip addressdistinguishes nothing / static / dhcp;out, not the one it used to have — pings successfully, and prints
ip address dhcpin its backup.docs/CLI.md: the interface and VLAN sections now state the one-method rule, that the backup prints the methodrather than a leased address, and that a VLAN parameter is not a mode change.
Suite: 158 suites, 6,629 assertions, 0 failed.
Two commands were changing something the operator did not ask about. 1. switchport trunk native vlan, switchport trunk allowed vlan and switchport access vlan each set the port's `mode` as a side effect, so staging a trunk on an access port - which is what the command is for, and what real gear accepts, so the trunk can be built before the cable is patched - silently turned the port into a trunk: a different command, in a different column of the table, changed what the port forwards. Measured on a plain access port: vlan.mode was `access` before the command and `trunk` after, and frames for VLAN 20 started leaving a port that carries VLAN 1. In the other direction, `switchport access vlan 30` on a trunk turned the trunk into an access port. Worse, the parameter was then lost: the printer emitted trunk parameters only in trunk mode, so `show running-config` printed `interface Fa0/1` and nothing else, and a restore brought the port back without the value it had been staged with. Now the parameters are stored and the mode is left alone; only `switchport mode` changes the mode. When the value cannot be used yet the console says so and names the command that would use it: Trunk native VLAN 20 on Fa0/1 (stored; the port is in access mode - set "switchport mode trunk" to use it) and says nothing when the value is already in use. The mode and the VLAN parameters are printed independently, so a staged trunk survives a backup in either mode, byte-identically. 2. `ip address dhcp` set the DHCP flag and left the static address on the interface, so one port held two methods at once: it kept an address it did not own (`routeTo()` would route for it), `show ip interface brief` reported Method DHCP beside that address, and `show running-config` printed only the static line, so restoring the backup lost the DHCP intent. The reverse direction already cleared the flag, but silently. Both directions now displace the other method and say which: Interface Gi0/0 set to DHCP (static address 10.0.0.1/24 removed) IP address set on Gi0/0: 10.0.0.1/24 (DHCP client removed) `no ip address` names what it removed ("IP address 10.0.0.9/24 removed", "DHCP client removed") or refuses when there is nothing to remove, instead of claiming to remove an address that was never there. 3. Found while testing (2): the printer preferred the address over the method, so a DHCP host that had leased 10.0.0.100 printed `ip address 10.0.0.100 255.255.255.0`. Restored on another network that host claims a stale address and never asks for a new one. `show running-config` now prints `ip address dhcp`, because a backup describes what was configured, not what the last exchange produced. test/switchport-mode.test.js: 32 checks - staging leaves the mode alone in both directions and says what it stored and what would use it; a value used immediately gets no note; the data plane follows the mode, so a staged trunk carries VLAN 1 and drops 20 until `switchport mode trunk`, then carries 20 and still drops what the allowed list omits; `show vlan` lists the port under the VLAN it carries, not the one it is staged for; all four settings print under an access port and the backup replays byte-for-byte into the same mode and the same parameters; the default trunk and access cases still print exactly what they printed before. test/interface-method.test.js: 26 checks - a static address does not survive `ip address dhcp` and the displaced address is named; a DHCP client does not survive a static address; `no ip address` distinguishes nothing/static/dhcp; fifteen port histories leave exactly one method and never an address without a mask; and a host moved from a static address to DHCP gets a real lease from a real pool (an address the pool hands out, not the one it used to have), pings successfully, and prints `ip address dhcp` in its backup. With engine/cli.js reverted: switchport-mode 17 failures, interface-method 13 failures. docs/CLI.md: the interface and VLAN sections now state the one-method rule, that the backup prints the method rather than a leased address, and that a VLAN parameter is not a mode change. Suite: 158 suites, 6,629 assertions, 0 failed.show ip interface brief: a port with no address has no method, and every row lands under its heading #1562