Skip to content

[Nexthop][fboss2-dev] Add a fboss2 config interface <name> switchport access vlan <N> command.#791

Closed
benoit-nexthop wants to merge 1 commit intofacebook:mainfrom
nexthop-ai:fboss2-cli-prototype_part12
Closed

[Nexthop][fboss2-dev] Add a fboss2 config interface <name> switchport access vlan <N> command.#791
benoit-nexthop wants to merge 1 commit intofacebook:mainfrom
nexthop-ai:fboss2-cli-prototype_part12

Conversation

@benoit-nexthop
Copy link
Contributor

@benoit-nexthop benoit-nexthop commented Jan 8, 2026

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

Implements a new fboss2-dev CLI command to configure the access VLAN for an interface (switchport). This allows operators to change which VLAN a port belongs to.

The command syntax is:

config interface <port> switchport access vlan <vlan-id>

Where:

  • <port> is the interface name (e.g., eth1/1/1)
  • <vlan-id> is the VLAN ID (1-4094)

Note: This command doesn't yet automatically create the VLAN if it doesn't exist. The VLAN must already be configured in the system.

Since VLAN membership changes cannot be applied dynamically via reloadConfig(), this change requires an agent warmboot to take effect.

Note: this change is part of a series, the previous one is #789, the next one is #805.

Test Plan

New unit tests

Note: Google Test filter = *SwitchportAccessVlan*
[==========] Running 13 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 13 tests from CmdConfigInterfaceSwitchportAccessVlanTestFixture
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMin
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMin (3 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMax
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMax (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdZeroInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdZeroInvalid (7 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdTooHighInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdTooHighInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNegativeInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNegativeInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdEmptyInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdEmptyInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdMultipleValuesInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdMultipleValuesInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdOutOfRangeErrorMessage
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdOutOfRangeErrorMessage (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericErrorMessage
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericErrorMessage (0 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientSetsIngressVlanMultiplePorts
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientSetsIngressVlanMultiplePorts (21 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientThrowsOnEmptyInterfaceList
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientThrowsOnEmptyInterfaceList (5 ms)
[----------] 13 tests from CmdConfigInterfaceSwitchportAccessVlanTestFixture (49 ms total)

[----------] Global test environment tear-down
[==========] 13 tests from 1 test suite ran. (49 ms total)
[  PASSED  ] 13 tests.

New end-to-end tests on minipack3

============================================================
CLI E2E Test: config interface <name> switchport access vlan <N>
============================================================

[Step 1] Finding an interface to test...
[CLI] Running: show interface
[CLI] Completed in 0.08s: show interface
  Using interface: eth1/1/1 (VLAN: 2005)

[Step 2] Getting current access VLAN...
[CLI] Running: show interface eth1/1/1
[CLI] Completed in 0.07s: show interface eth1/1/1
  Current access VLAN: 2005

[Step 3] Setting access VLAN to 2006...
[CLI] Running: config interface eth1/1/1 switchport access vlan 2006
[CLI] Completed in 0.06s: config interface eth1/1/1 switchport access vlan 2006
[CLI] Running: config session commit
[CLI] Completed in 8.49s: config session commit
[CLI] Agent is ready (waited 7.6s)
[CLI] Applied info: {"localhost": {"lastAppliedInMs": 1771036580360}}
  Access VLAN set to 2006

[Step 4] Verifying access VLAN via 'show interface'...
[CLI] Running: show interface eth1/1/1
[CLI] Completed in 0.07s: show interface eth1/1/1
  Verified: Access VLAN is 2006

[Step 5] Restoring original access VLAN (2005)...
[CLI] Running: config interface eth1/1/1 switchport access vlan 2005
[CLI] Completed in 0.06s: config interface eth1/1/1 switchport access vlan 2005
[CLI] Running: config session commit
[CLI] Completed in 9.92s: config session commit
[CLI] Agent is ready (waited 7.7s)
[CLI] Applied info: {"localhost": {"lastAppliedInMs": 1771036598267}}
  Restored access VLAN to 2005
[CLI] Running: show interface eth1/1/1
[CLI] Completed in 0.08s: show interface eth1/1/1

============================================================
TEST PASSED
============================================================

Sample usage

[admin@fboss101 ~]$ /opt/fboss/bin/fboss2-dev config interface eth1/1/1 switchport access vlan 2007
Successfully set access VLAN for interface(s) eth1/1/1 to 2007

[admin@fboss101 ~]$ /opt/fboss/bin/fboss2-dev config session diff
--- current live config
+++ session config
@@ -2178,7 +2178,7 @@
           "2": "eth1/5/1"
         },
         "expectedNeighborReachability": [],
-        "ingressVlan": 2005,
+        "ingressVlan": 2007,
         "logicalID": 9,
         "lookupClasses": [],
         "loopbackMode": 0,
@@ -7061,7 +7061,7 @@
         "emitTags": false,
         "logicalPort": 9,
         "spanningTreeState": 2,
-        "vlanID": 2005
+        "vlanID": 2007
       }
     ],
     "vlans": [

@meta-cla meta-cla bot added the CLA Signed label Jan 8, 2026
@benoit-nexthop benoit-nexthop force-pushed the fboss2-cli-prototype_part12 branch 7 times, most recently from 64abb83 to 7376261 Compare January 15, 2026 18:00
@benoit-nexthop benoit-nexthop force-pushed the fboss2-cli-prototype_part12 branch 4 times, most recently from a7e307c to 1ab3393 Compare January 23, 2026 09:58
@benoit-nexthop benoit-nexthop force-pushed the fboss2-cli-prototype_part12 branch 2 times, most recently from 6be0581 to c64dd21 Compare January 28, 2026 18:47
# Summary

Implements a new fboss2-dev CLI command to configure the access VLAN for
an interface (switchport). This allows operators to change which VLAN a
port belongs to.

The command syntax is:
```
config interface <port> switchport access vlan <vlan-id>
```

Where:
- `<port>` is the interface name (e.g., eth1/1/1)
- `<vlan-id>` is the VLAN ID (1-4094)

Note: This command doesn't yet automatically create the VLAN if it
doesn't exist. The VLAN must already be configured in the system.

Since VLAN membership changes cannot be applied dynamically via
reloadConfig(), this change requires an agent warmboot to take effect.

# Test Plan

## New unit tests

```
Note: Google Test filter = *SwitchportAccessVlan*
[==========] Running 13 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 13 tests from CmdConfigInterfaceSwitchportAccessVlanTestFixture
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMin
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMin (3 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMax
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMax (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdValidMid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdZeroInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdZeroInvalid (7 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdTooHighInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdTooHighInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNegativeInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNegativeInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdEmptyInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdEmptyInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdMultipleValuesInvalid
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdMultipleValuesInvalid (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdOutOfRangeErrorMessage
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdOutOfRangeErrorMessage (1 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericErrorMessage
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.vlanIdNonNumericErrorMessage (0 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientSetsIngressVlanMultiplePorts
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientSetsIngressVlanMultiplePorts (21 ms)
[ RUN      ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientThrowsOnEmptyInterfaceList
[       OK ] CmdConfigInterfaceSwitchportAccessVlanTestFixture.queryClientThrowsOnEmptyInterfaceList (5 ms)
[----------] 13 tests from CmdConfigInterfaceSwitchportAccessVlanTestFixture (49 ms total)

[----------] Global test environment tear-down
[==========] 13 tests from 1 test suite ran. (49 ms total)
[  PASSED  ] 13 tests.
```

## New end-to-end tests on minipack3

```
============================================================
CLI E2E Test: config interface <name> switchport access vlan <N>
============================================================

[Step 1] Finding an interface to test...
[CLI] Running: show interface
[CLI] Completed in 0.08s: show interface
  Using interface: eth1/1/1 (VLAN: 2005)

[Step 2] Getting current access VLAN...
[CLI] Running: show interface eth1/1/1
[CLI] Completed in 0.07s: show interface eth1/1/1
  Current access VLAN: 2005

[Step 3] Setting access VLAN to 2006...
[CLI] Running: config interface eth1/1/1 switchport access vlan 2006
[CLI] Completed in 0.06s: config interface eth1/1/1 switchport access vlan 2006
[CLI] Running: config session commit
[CLI] Completed in 8.49s: config session commit
[CLI] Agent is ready (waited 7.6s)
[CLI] Applied info: {"localhost": {"lastAppliedInMs": 1771036580360}}
  Access VLAN set to 2006

[Step 4] Verifying access VLAN via 'show interface'...
[CLI] Running: show interface eth1/1/1
[CLI] Completed in 0.07s: show interface eth1/1/1
  Verified: Access VLAN is 2006

[Step 5] Restoring original access VLAN (2005)...
[CLI] Running: config interface eth1/1/1 switchport access vlan 2005
[CLI] Completed in 0.06s: config interface eth1/1/1 switchport access vlan 2005
[CLI] Running: config session commit
[CLI] Completed in 9.92s: config session commit
[CLI] Agent is ready (waited 7.7s)
[CLI] Applied info: {"localhost": {"lastAppliedInMs": 1771036598267}}
  Restored access VLAN to 2005
[CLI] Running: show interface eth1/1/1
[CLI] Completed in 0.08s: show interface eth1/1/1

============================================================
TEST PASSED
============================================================
```

## Sample usage

```
[admin@fboss101 ~]$ /opt/fboss/bin/fboss2-dev config interface eth1/1/1 switchport access vlan 2007
Successfully set access VLAN for interface(s) eth1/1/1 to 2007

[admin@fboss101 ~]$ /opt/fboss/bin/fboss2-dev config session diff
--- current live config
+++ session config
@@ -2178,7 +2178,7 @@
           "2": "eth1/5/1"
         },
         "expectedNeighborReachability": [],
-        "ingressVlan": 2005,
+        "ingressVlan": 2007,
         "logicalID": 9,
         "lookupClasses": [],
         "loopbackMode": 0,
@@ -7061,7 +7061,7 @@
         "emitTags": false,
         "logicalPort": 9,
         "spanningTreeState": 2,
-        "vlanID": 2005
+        "vlanID": 2007
       }
     ],
     "vlans": [
```
@benoit-nexthop benoit-nexthop force-pushed the fboss2-cli-prototype_part12 branch from c64dd21 to 2de8999 Compare February 14, 2026 02:39
@meta-codesync
Copy link

meta-codesync bot commented Feb 17, 2026

@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D93503282.

@meta-codesync
Copy link

meta-codesync bot commented Feb 17, 2026

@joseph5wu merged this pull request in 0ab7c19.

meta-codesync bot pushed a commit that referenced this pull request Feb 18, 2026
Summary:
**Pre-submission checklist**
- [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install`
- [x] `pre-commit run`

A recent merge introduced a duplicate command by mistake (bad merge on my part) and this escaped because of lack of test coverage.

Also make sure we keep `cmake/CliFboss2Test.cmake` sorted.

Note: this change is part of a series, the previous one is #791, the next one is #809.

Pull Request resolved: #805

Test Plan: New regression unit test.

Reviewed By: AarjunC

Differential Revision: D93523408

Pulled By: joseph5wu

fbshipit-source-id: 87c4920c1fa1730631eafbf0a31e8c179145dc0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants