[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
Closed
Conversation
2 tasks
2 tasks
64abb83 to
7376261
Compare
a7e307c to
1ab3393
Compare
6be0581 to
c64dd21
Compare
# 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": [
```
c64dd21 to
2de8999
Compare
|
@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D93503282. |
|
@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
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
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:
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
New end-to-end tests on minipack3
Sample usage