Commit ceec311
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 0817373 commit ceec311
14 files changed
Lines changed: 633 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 | |
|---|---|---|---|
| |||
993 | 993 | | |
994 | 994 | | |
995 | 995 | | |
| 996 | + | |
| 997 | + | |
996 | 998 | | |
997 | 999 | | |
998 | 1000 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
| 1140 | + | |
1140 | 1141 | | |
1141 | 1142 | | |
1142 | 1143 | | |
| |||
1253 | 1254 | | |
1254 | 1255 | | |
1255 | 1256 | | |
| 1257 | + | |
1256 | 1258 | | |
1257 | 1259 | | |
1258 | 1260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
923 | 924 | | |
924 | 925 | | |
925 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
926 | 933 | | |
927 | 934 | | |
928 | 935 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
0 commit comments