Commit 0bfa7f9
committed
Add 'config vlan <id> name <value>' CLI command
Adds a new `config vlan <id> name <value>` command to configure
the name attribute of a VLAN. The implementation follows the
`CmdConfigInterface` pattern: a single handler (`CmdConfigVlanConfig`)
dispatches on attribute name, so adding future attributes (e.g.
`routable`) requires only a new subcommand entry in `CmdListConfig.cpp`
and a new `else if` branch in `queryClient` — no new handler class.
If the specified VLAN does not already exist, the command auto-creates
it (via `VlanManager::getOrCreateVlan`) and prints "Created VLAN <id>"
before configuring the attribute — consistent with all other
`config vlan` subcommands.
The auto-create test uses VLAN 3100 (not 3998/3999) because
`getTableIdForNpu` maps IDs in [3000, 3152] to Linux routing table IDs
in [101, 253]. Values above 3152 overflow the 253-table limit and crash
`TunManager` with `Check failed: tableId <= 253`.
```
Note: Google Test filter = *VlanConfig*
[==========] Running 9 tests from 1 test suite.
[----------] 9 tests from CmdConfigVlanConfigTestFixture
[ RUN ] CmdConfigVlanConfigTestFixture.setNameOnExistingVlan
[ OK ] CmdConfigVlanConfigTestFixture.setNameOnExistingVlan (171 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.setNameUpdatesSwConfig
[ OK ] CmdConfigVlanConfigTestFixture.setNameUpdatesSwConfig (308 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.setNameOnSecondVlan
[ OK ] CmdConfigVlanConfigTestFixture.setNameOnSecondVlan (195 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.setNameOnNonExistentVlanAutoCreates
[ OK ] CmdConfigVlanConfigTestFixture.setNameOnNonExistentVlanAutoCreates (105 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.setNameDoesNotAffectOtherVlans
[ OK ] CmdConfigVlanConfigTestFixture.setNameDoesNotAffectOtherVlans (99 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.vlanNameArgGetAttrName
[ OK ] CmdConfigVlanConfigTestFixture.vlanNameArgGetAttrName (29 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.vlanNameArgGetValue
[ OK ] CmdConfigVlanConfigTestFixture.vlanNameArgGetValue (39 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.vlanNameArgRejectsMissingValue
[ OK ] CmdConfigVlanConfigTestFixture.vlanNameArgRejectsMissingValue (33 ms)
[ RUN ] CmdConfigVlanConfigTestFixture.vlanNameArgRejectsTooManyArgs
[ OK ] CmdConfigVlanConfigTestFixture.vlanNameArgRejectsTooManyArgs (36 ms)
[----------] 9 tests from CmdConfigVlanConfigTestFixture (1020 ms total)
[==========] 9 tests from 1 test suite ran. (1020 ms total)
[ PASSED ] 9 tests.
```
```
Note: Google Test filter = ConfigVlanName*
[==========] Running 2 tests from 1 test suite.
[----------] 2 tests from ConfigVlanNameTest
[ RUN ] ConfigVlanNameTest.SetNameOnExistingVlan
I0325 14:00:25 [Step 1] Finding an eth interface...
I0325 14:00:25 Using interface eth1/1/1 (VLAN 2122)
I0325 14:00:25 [Step 2] Reading current VLAN 2122 name...
I0325 14:00:25 Current name: vlan2122
I0325 14:00:25 [Step 3] Setting VLAN 2122 name to "TestVlanName"...
I0325 14:00:25 Output: {"localhost":"Successfully configured VLAN 2122: name=\"TestVlanName\""}
I0325 14:00:25 [Step 4] Committing...
I0325 14:00:25 Committed.
I0325 14:00:25 [Step 5] Restoring original name "vlan2122"...
I0325 14:00:25 Restored. TEST PASSED
[ OK ] ConfigVlanNameTest.SetNameOnExistingVlan (375 ms)
[ RUN ] ConfigVlanNameTest.AutoCreateVlanAndSetName
I0325 14:00:25 [Step 0] Ensuring VLAN 3100 is absent from running config...
I0325 14:00:25 [Cleanup] VLAN 3100 not present — no cleanup needed.
I0325 14:00:25 [Step 1] Setting name on non-existent VLAN 3100...
I0325 14:00:25 Output: Created VLAN 3100
I0325 14:00:25 {"localhost":"Successfully configured VLAN 3100: name=\"TestAutoCreateVlan\""}
I0325 14:00:25 [Step 2] Committing session...
I0325 14:00:25 Config committed.
I0325 14:00:25 [Step 3] Cleaning up VLAN 3100...
I0325 14:00:25 Cleanup complete. TEST PASSED
[ OK ] ConfigVlanNameTest.AutoCreateVlanAndSetName (262 ms)
[----------] 2 tests from ConfigVlanNameTest (637 ms total)
[==========] 2 tests from 1 test suite ran. (638 ms total)
[ PASSED ] 2 tests.
```
```
fboss2-dev config vlan 2122 name myvlan
fboss2-dev config session commit
fboss2-dev config vlan 3100 name newvlan
fboss2-dev config session commit
```1 parent 0d22049 commit 0bfa7f9
14 files changed
Lines changed: 642 additions & 6 deletions
File tree
- cmake
- fboss/cli/fboss2
- commands/config/vlan
- test
- config
- integration_test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
| 980 | + | |
| 981 | + | |
980 | 982 | | |
981 | 983 | | |
982 | 984 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1127 | 1127 | | |
1128 | 1128 | | |
1129 | 1129 | | |
| 1130 | + | |
1130 | 1131 | | |
1131 | 1132 | | |
1132 | 1133 | | |
| |||
1223 | 1224 | | |
1224 | 1225 | | |
1225 | 1226 | | |
| 1227 | + | |
1226 | 1228 | | |
1227 | 1229 | | |
1228 | 1230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
833 | 834 | | |
834 | 835 | | |
835 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
836 | 843 | | |
837 | 844 | | |
838 | 845 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| |||
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
Lines changed: 91 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
0 commit comments