[Nexthop][fboss2-dev] Support deleting an L3 interface with delete interface - #1496
Open
vybhav-nexthop wants to merge 4 commits into
Open
[Nexthop][fboss2-dev] Support deleting an L3 interface with delete interface#1496vybhav-nexthop wants to merge 4 commits into
vybhav-nexthop wants to merge 4 commits into
Conversation
InterfaceList now accepts a purely-numeric argument and resolves it as a port logical ID or an interface ID, so e.g. `fboss2-dev config interface 2001 mtu 9000` works on the interface with ID 2001. Name lookups always take precedence over ID lookups, consistently for both ports and interfaces: port name -> port logical ID -> interface name -> interface ID. Adds PortMap::getPortNameForLogicalId(), the reverse of the existing getPortLogicalId().
delete interface can now remove an L3/SVI interface, not just a physical port. A name resolving to a portless interface deletes the interface; InterfaceManager refuses a delete that would dangle a reference or produce a config the agent rejects. Addressing an interface by a bare ID relies on the shared InterfaceList resolver (port name -> port logical ID -> interface name -> interface ID) rather than a delete-only flag, so a number that is both a port logical ID and an interface ID resolves to the port. Pinned by a new unit test.
vybhav-nexthop
force-pushed
the
delete-interface-svi
branch
from
August 10, 2026 15:17
e1c06f4 to
12f8007
Compare
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:
delete interface <name|id>can now remove an L3/SVI interface, not just a physical port.Why: the command previously only collected ports, so naming an L3 interface returned "No port found for the specified interface(s)". Generated configs frequently leave
Interface.nameunset, so those interfaces have no name at all and the interface ID is the only handle.How:
Some background on how ports, VLANs, and L3 interfaces relate.
SwitchConfigkeeps them as separate lists —sw.ports,sw.vlans, andsw.interfaces(interfaces are where IP addresses live) — tied together like this:sw.vlanPortsjoin list — one{vlanID, logicalPort, emitTags}row per port-VLAN pair — andPort.ingressVlanclassifies untagged frames.VLAN-type interface, its SVI: the shared routed gateway for all of the VLAN's member ports. The SVI belongs to the VLAN (Interface.vlanID), not to any port — the VLAN a frame classifies into decides which SVI routes it.PORT-type interface is bound to it directly viaInterface.portID.Until now
delete interfaceresolved each name to acfg::Portonly, deleting the port viautility::removePortsFromConfig(which also prunes the interfaces only that port used). An SVI or a loopback never resolves to a port, hence the old "No port found" error.What this PR does, in the order a command flows through it:
Resolve. Every argument goes through the shared
utils::InterfaceListresolver (from [Nexthop][fboss2-dev] allow addressing interfaces by port logical ID or interface ID #1471), which now tries, in order: port name → port logical ID (for numeric arguments) → interface name → interface ID. Each argument therefore lands as either a port or a portless L3 interface. A number that is both a port logical ID and an interface ID resolves to the port; a unit test pins that precedence.Split.
CmdDeleteInterfacepartitions the resolved arguments intoportsToDeleteandinterfacesToDelete. Ports keep the existingremovePortsFromConfigpath unchanged; portless interfaces go to the newInterfaceManager::deleteInterfaces.Refuse rather than break the config.
deleteInterfacesvalidates the whole set before mutating anything, so a refusal leaves the session untouched. It refuses any delete that would leave a config the agent rejects — or crashes on — at apply time:PORT-type interface: its port would be left with no router interface (delete the port instead);Tunnel.underlayIntfIDis a required field, so there is nothing to clear (delete the tunnel first);Order the two deletes. Interfaces are removed before ports so the refusal checks see the pre-delete state.
portsToDeleteis passed into the member-port check so a port removed by the same command does not count as keeping its VLAN alive —delete interface <svi> <its-only-port>is accepted rather than wrongly refused.Clean up back-pointers. A deleted VLAN interface's
Vlan.intfIDback-pointer is cleared (it carries no configuration of its own), and both kinds of delete commit hitlessly through the session's existing save path.Stacked on #1471 (the
InterfaceListport-logical-ID / interface-ID resolver) — review that first.Test Plan
Unit —
cmd_config_test, allCmdDelete*suites pass. The whole-interface fixtures (CmdDeleteWholeL3InterfaceTestFixture,CmdDeleteInterfaceIdCollisionTestFixture) cover: delete by interface ID, each refusal reason (port-router, tunnel underlay, VLAN with an enabled member port), the combineddelete interface <svi> <port>accept path, and the port-vs-interface-ID precedence:Integration —
DeleteInterfaceTeston a T1 DUTThe positive whole-interface delete and every refusal reason are covered by the unit tests above rather than by integration tests: a PORT-type interface cannot be created through the CLI, and a session's port map is not rebuilt for interfaces staged later in the same session, so an integration test could only exercise those paths conditionally on the DUT's running config.
Review Findings
Pre-publication review (fboss-review, 6 reviewers) findings, all addressed before this PR:
delete interface <svi> <its-only-port>was wrongly refused because the enabled-member-port check did not exclude ports deleted in the same command — fixed, with a regression test.