Skip to content

[Nexthop][fboss2-dev] Add loopback interface creation and addressing to config interface - #1565

Open
hillol-nexthop wants to merge 3 commits into
meta:mainfrom
nexthop-ai:loopback-interface-config
Open

hillol-nexthop wants to merge 3 commits into
meta:mainfrom
nexthop-ai:loopback-interface-config

Conversation

@hillol-nexthop

@hillol-nexthop hillol-nexthop commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds loopback interface support to the existing config interface / delete interface families, reusing the config interface <name> ip-address <A.B.C.D/N> syntax. Loopbacks follow the deployment convention: loopback<N> is the virtual (isVirtual=true) interface at intfID == vlanID == 10 + N, backed by the same-numbered routable VLAN named fbossLoopback<N>.

  • Resolution (shared by config and delete): a loopback<N> token now resolves in InterfaceList — by literal interface name, by the conventional fbossLoopback<N> name (Meta-style configs), or by the conventional intfID with isVirtual set (the bootstrap loopback0 ships unnamed).
  • Creation: config interface loopback<N> ... creates the virtual interface plus its backing VLAN when absent, then applies the requested attributes; a bare config interface loopback<N> just creates it. Occupied conventional ids — a non-loopback interface at intfID 10+N, a same-numbered VLAN owned by another interface, or a data VLAN with member ports — are refused with specific errors, since the agent requires every VLAN-type interface to reference an existing VLAN and be its only interface.
  • Addressing: ip-address / ipv6-address add and delete work on loopbacks through the existing attribute paths once the token resolves; multiple mixed v4/v6 host addresses per loopback are supported, and re-applying an address is a clean no-op.
  • Deletion: a bare delete interface loopback<N> removes the virtual interface together with its backing VLAN (via VlanManager::deleteVlan, so the pair goes as a unit). Refused, with the config untouched, when the VLAN has member ports, is the default VLAN, or is a port's ingress VLAN — those are data VLANs and belong to delete vlan. Ports and loopbacks may be mixed in one command.
  • Everything commits HITLESS (config reload, no agent restart), matching the rest of the config interface family.

Test Plan

Unit tests (new CmdConfigInterfaceLoopbackTest.cpp, seed mirroring the deployed loopback layout plus a Meta-style named loopback with production-shaped /32 + /128 addresses):

$ cmd_config_test
[==========] 893 tests from 77 test suites ran.
[  PASSED  ] 893 tests.

Integration tests (new ConfigLoopbackInterfaceTest), run on a lab:

[ RUN      ] ConfigLoopbackInterfaceTest.AddressRoundTripOnLoopback0
[       OK ] ConfigLoopbackInterfaceTest.AddressRoundTripOnLoopback0 (248 ms)
[ RUN      ] ConfigLoopbackInterfaceTest.CreateLoopbackWithAddresses
[       OK ] ConfigLoopbackInterfaceTest.CreateLoopbackWithAddresses (174 ms)
[  PASSED  ] 2 tests.

Sample usage on the same device (bootstrap loopback0 is unnamed, intfID 10):

$ fboss2-dev config interface loopback0 ip-address 10.254.113.31/32 ipv6-address fc00:0:0:31::/128
Successfully configured interface(s) loopback0: ip-address=10.254.113.31/32, ipv6-address=fc00:0:0:31::/128
$ fboss2-dev config session diff
       {
         "intfID": 10,
-        "ipAddresses": [],
+        "ipAddresses": [
+          "10.254.113.31/32",
+          "fc00:0:0:31::/128"
+        ],
         "isStateSyncDisabled": false,
         "isVirtual": true,
$ fboss2-dev config session commit
Config session committed successfully as 17ea3d8 and config reloaded for fboss_sw_agent.
$ fboss2-dev show config running agent | jq '.sw.interfaces[] | select(.intfID==10 or .intfID==19) | {intfID, vlanID, isVirtual, name, ipAddresses}'
{
  "intfID": 10, "vlanID": 10, "isVirtual": true, "name": null,
  "ipAddresses": [ "10.254.113.31/32", "fc00:0:0:31::/128" ]
}
{
  "intfID": 19, "vlanID": 19, "isVirtual": true, "name": "loopback9",
  "ipAddresses": []
}
$ fboss2-dev delete interface loopback0 ip-address 10.254.113.31/32
Successfully removed IP address 10.254.113.31/32 from interface(s): loopback0
$ fboss2-dev delete interface loopback0 ipv6-address fc00:0:0:31::/128
Successfully removed IPv6 address fc00:0:0:31::/128 from interface(s): loopback0
$ fboss2-dev config session commit
Config session committed successfully as 42eadaf and config reloaded for fboss_sw_agent.

(loopback9 above was created by the CLI via config interface loopback9 ip-address ... in the integration run — interface + backing VLAN created at the conventional ids, committed hitlessly; the test then removes it with delete interface loopback9 and verifies both the interface and VLAN 19 are gone from the running config.)

Review Findings

Pre-publication automated review (7 reviewer passes; no blocking correctness defects found on the tested paths). Known concerns listed for reviewer attention:

File:Line Severity Issue
CmdConfigInterface.cpp:343 Medium A pre-existing same-id VLAN with no ports/interface is adopted as the loopback's backing VLAN as-is (name/routable not fixed up to the fbossLoopback<N>/routable=true convention).
CmdConfigInterface.cpp:317 Low Duplicate tokens for one index in a single command (loopback5 Loopback5) yield a misleading "already in use by a non-loopback interface" error; nothing is saved.
CmdConfigInterface.cpp:731 Low Loopback creation mutates the in-memory session config before later attribute validation (e.g. bad mtu, profile on a loopback) can throw; on-disk config is untouched since saveConfig is skipped.
CmdConfigInterface.cpp:750 Low Bare config interface loopback<N> on an already-existing loopback throws "Incomplete command" rather than being an idempotent no-op.
InterfaceList.cpp:42 Low Name-based fbossLoopback<N> resolution does not check isVirtual, unlike the intfID fallback.

@hillol-nexthop
hillol-nexthop requested review from a team as code owners August 27, 2026 15:48
@meta-cla meta-cla Bot added the CLA Signed label Aug 27, 2026
@hillol-nexthop
hillol-nexthop marked this pull request as draft August 27, 2026 17:08
@hillol-nexthop
hillol-nexthop force-pushed the loopback-interface-config branch from c7f9716 to 5532ea1 Compare August 27, 2026 17:15
@hillol-nexthop
hillol-nexthop marked this pull request as ready for review August 27, 2026 17:16
@hillol-nexthop
hillol-nexthop force-pushed the loopback-interface-config branch 2 times, most recently from 6f3f8c0 to 4a9857b Compare August 27, 2026 17:41
@rabbit-nexthop
rabbit-nexthop force-pushed the loopback-interface-config branch 2 times, most recently from ae075a5 to 1647144 Compare September 2, 2026 08:00
@hillol-nexthop
hillol-nexthop force-pushed the loopback-interface-config branch from 1647144 to d5c5fd3 Compare October 12, 2026 05:41
hillol-nexthop and others added 2 commits October 22, 2026 08:02
Adds loopback support to the existing `config interface` / `delete
interface` families, following the bootstrap-config convention: loopback<N>
is the virtual (isVirtual=true) interface at intfID == vlanID == 10 + N,
backed by the same-numbered VLAN named fbossLoopback<N>.

- `loopback<N>` tokens now resolve in InterfaceList: by literal interface
  name, by the conventional fbossLoopback<N> name (Meta-style configs), or
  by the conventional intfID for the unnamed bootstrap loopback0.
- `config interface loopback<N> ...` creates the virtual interface (plus
  its backing routable VLAN) when absent, then applies the requested
  attributes; a bare `config interface loopback<N>` just creates it.
  Occupied conventional ids (a non-loopback interface at intfID 10+N, or a
  data VLAN at the same id) are refused with a specific error.
- ip-address / ipv6-address add and delete work on loopbacks through the
  existing attribute paths once the token resolves; multiple mixed v4/v6
  host addresses per loopback are supported and re-adding an address is a
  clean no-op.
- A bare `delete interface loopback<N>` removes the virtual interface
  together with its backing VLAN (via VlanManager::deleteVlan). It is
  refused, leaving the config untouched, when that VLAN has member ports,
  is the default VLAN, or is a port's ingress VLAN; ports and loopbacks may
  be mixed in one delete command.

All changes commit HITLESS, matching the rest of the config interface
family.
- Drop the bare `config interface loopback<N>` early return; the common
  save/return path already handles it once the incomplete-command guard
  skips created loopbacks.
- Split the validation half of VlanManager::deleteVlan into
  VlanManager::checkDeletable and call it from the loopback delete path
  instead of re-implementing the default-VLAN and ingress-VLAN refusals.
- Remove the interface erase after deleteVlan; deleteVlan already cascades
  the interface, and a loopback without a backing VLAN is now refused.
- Merge the two loopback integration tests into one create/address/delete
  round trip.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hillol-nexthop
hillol-nexthop force-pushed the loopback-interface-config branch from d5c5fd3 to 5f3096b Compare October 22, 2026 08:03
@hillol-nexthop

Copy link
Copy Markdown
Contributor Author

Rebased onto main and ported the internal review fixes: the bare-loopback create now shares the common save path, VlanManager::checkDeletable holds the VLAN delete validation reused by the loopback delete, the redundant interface erase after deleteVlan is gone, and the two integration tests are merged into one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added the project:fboss2-dev FBOSS project: fboss2-dev label Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant