[Nexthop][fboss2-dev] Add fboss2-dev delete vlan subcommand - #1418
Open
vybhav-nexthop wants to merge 4 commits into
Open
[Nexthop][fboss2-dev] Add fboss2-dev delete vlan subcommand#1418vybhav-nexthop wants to merge 4 commits into
vybhav-nexthop wants to merge 4 commits into
Conversation
vybhav-nexthop
force-pushed
the
delete-vlan-subtree
branch
from
July 27, 2026 06:46
4401dfd to
672cf8d
Compare
Delete-side counterpart for config vlan: delete vlan <id> removes the whole sw.vlans[] entry. VlanManager::deleteVlan pairs with the existing createVlan: it also drops the barebone L3 interface that createVlan generates for every VLAN (matching vlanID, no IP addresses) and cascade-removes static MAC entries scoped to the VLAN, since those are child objects that cannot outlive it. To avoid silently orphaning references, the delete is refused (with a message naming the referrers) when the VLAN is still in use: - it is the global default VLAN (SwitchConfig.defaultVlan) - a port lists it as its untagged ingress VLAN (Port.ingressVlan) - a port is a member of it (VlanPort.vlanID) - it backs a routed SVI, i.e. an interface with IP addresses Saves with the default HITLESS action level, matching the config vlan subcommands. Verified on a DUT that committing the delete reloads the config hitlessly (no agent restart, no crash).
vybhav-nexthop
force-pushed
the
delete-vlan-subtree
branch
from
July 27, 2026 08:13
672cf8d to
5e217b4
Compare
Always program a barebone unreferenced VLAN, assert present, delete, assert gone. Drop the session-only IT. Co-authored-by: Cursor <cursoragent@cursor.com>
Switchport membership rows carry no configuration the user would have to re-supply, and dropping one leaves the port valid in its remaining VLANs, so refusing the delete only forced a manual `switchport trunk allowed vlan remove` on every member port first. Cascade them like the static MAC entries already are. The other refusals stay. defaultVlan and Port.ingressVlan are required scalars whose only fallback value (0) means routed port, so clearing them would change what the port is. An SVI with IP addresses carries user L3 config. Access ports keep their protection either way: the ingressVlan refusal runs before the cascade.
Contributor
|
@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D113981193. |
An interface's vlanID must reference an existing VLAN, so the interface cannot outlive it. Refusing when the SVI carried IP addresses only added friction: the user deleting the VLAN has already opted to drop its L3 interface. Remove the refusal and cascade-delete the interface regardless of configured addresses.
|
@vybhav-nexthop has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
|
@vybhav-nexthop has updated the pull request. You must reimport the pull request before landing. |
vybhav-nexthop
force-pushed
the
delete-vlan-subtree
branch
from
July 29, 2026 12:04
6308a15 to
5211924
Compare
|
@vybhav-nexthop has updated the pull request. You must reimport the pull request before landing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
What: Adds
fboss2-dev delete vlan <id>— removes a VLAN (the wholesw.vlans[]entry) from the config session.Why: Delete-side counterpart for
config vlan; created VLANs could not be removed.How:
VlanManager::deleteVlanpairs with the existingcreateVlan. It cascade-removes the child objects that can't outlive the VLAN:Interface.vlanID) — both the barebone onecreateVlangenerates and a routed SVI carrying IP addresses; an interface'svlanIDmust reference an existing VLAN, so it cannot outlive itVlanPort.vlanID) — same effect asconfig interface <port> switchport trunk allowed vlan remove <id>on every member portStaticMacEntry.vlanID)The delete is refused (with a message naming the referrers) only where cascading would orphan a reference or change what a sibling object means. Each of those has an existing CLI path to clear it first:
SwitchConfig.defaultVlan)config vlan default <other-id>Port.ingressVlan) — a required scalar whose only fallback value,0, means routed portconfig interface <port> switchport access vlan <other-id>Known/accepted edge: an ACL redirect action referencing the deleted interface as a nexthop (
RedirectNextHop.intfID) is not checked — such an ACL stops resolving and the agent disables it at config apply. That reference can only come from configs authored outside fboss2 (the CLI sets redirect nexthops by IP only), and repairing the ACL is the operator's responsibility.Saves with the default HITLESS action level, matching the
config vlansubcommands.Also:
stable_sortfor the command trees. The CLI registers "config vlan" twice on purpose:config vlan <vlan-id> <attr...>— this entry owns the<vlan-id>positionalconfig vlan default <value>— separate entry so its value registers at a different arg depthThe root command list is sorted by name only (
RootCommand::operator<ignores the verb), andstd::sortgives no ordering guarantee for equal names. Addingdelete vlan— a third entry named "vlan" — flipped the order of the two "config vlan" entries. What then happened at registration:defaultentry is processed first → it creates thevlanCLI node. It has no<vlan-id>positional, so none is registered.<vlan-id>entry is processed second → the node already exists, so it takes the merge path. The merge copies subcommands (port,static-mac) but never runs the entry's arg registrar — positionals are registered only when an entry creates the node. The<vlan-id>positional is silently dropped.End state:
config vlan default 300works, butconfig vlan 2 static-mac add ...fails with "The following argument was not expected: 2" — everyconfig vlan <vlan-id>command broke (caught by the vlan integration tests in CI).stable_sortkeeps equal-named entries in source order, so the<vlan-id>-owning entry always creates the node.Test Plan
Unit tests (8 new;
VlanManagercreate-side tests still green):Covered: not-found, refuse default / ingress-port, happy-path removal of VLAN + barebone interface + cascade static-MAC + cascade membership, SVI-with-IP deletes via interface cascade, member-only VLAN deletes via cascade, and two handler (
queryClient) cases.The happy-path test seeds a trunk port in both the target VLAN and the default VLAN, so it asserts the membership cascade is scoped: the target's row goes, the default VLAN's row for the same port survives.
The membership and SVI cascades are covered by unit tests only — they have not been re-run on hardware. The integration test exercises neither switchport membership nor an IP-bearing SVI, so there is nothing there for them to catch either way. The device results below predate them.
Integration tests — executed on an Nexthop device, both PASSED:
CommitDeleteExistingVlan: deletes a committed, unreferenced VLAN, commits, and verifies it disappears from the running config. The commit was hitless — both agents keptNRestartsunchanged and stayedactive. Skips when the running config has no deletable VLAN.No issues found above confidence threshold (pre-publication automated review).