Skip to content

[Nexthop][fboss2-dev] Consolidate interface description and MTU config commands into one cpp class - #919

Closed
benoit-nexthop wants to merge 1 commit into
meta:mainfrom
nexthop-ai:fboss2-cli-prototype_part28
Closed

benoit-nexthop wants to merge 1 commit into
meta:mainfrom
nexthop-ai:fboss2-cli-prototype_part28

Conversation

@benoit-nexthop

@benoit-nexthop benoit-nexthop commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

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

This PR consolidates the separate CmdConfigInterfaceDescription and CmdConfigInterfaceMtu commands into a unified CmdConfigInterface command that can set multiple interface attributes in a single invocation.

# Set description
config interface eth1/1/1 description "My port description"

# Set MTU
config interface eth1/1/1 mtu 9000

# Set both in one command
config interface eth1/1/1 description "My port" mtu 9000

# Apply to multiple interfaces
config interface eth1/1/1,eth1/2/1 description "Uplink" mtu 1500

Original change by @hillol-nexthop

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

Implementation Details

  1. New InterfaceConfig class
  • Parses CLI tokens to separate port names from attribute key-value
    pairs
    • Supports description and mtu attributes (case-insensitive)
    • Validates attribute names and detects missing values
    • Wraps InterfaceList for port/interface resolution
  1. Updated CmdConfigInterface
  • Changed from pass-through command to functional command
  • Implements queryClient to process description and mtu attributes
  • Sets port->description() for description attribute
  • Sets interface->mtu() for mtu attribute with validation
  1. Updated subcommands to use InterfaceConfig instead of InterfaceList
  2. Deleted obsolete pairs of .cpp / .h
  3. New comprehensive test suite
  • 23 tests covering InterfaceConfig validation and CmdConfigInterface::queryClient functionality
  • Backward Compatibility
  • Subcommands like switchport, pfc-config, and queuing-policy continue to work as before

Test Plan

Note: The e2e test is already implemented in #893
Above mentioned list of new test file, deleted and updated test files.
Existing unit and end to end tests pass.

@meta-cla meta-cla Bot added the CLA Signed label Feb 10, 2026
meta-codesync Bot pushed a commit that referenced this pull request Mar 26, 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`

Add CLI commands to configure the dscpMaps, expMaps, and pcpMaps attributes of the QosMap object within a QosPolicy. These commands allow configuring bidirectional mappings between codepoint values and internal traffic classes.

New CLI commands:

- DSCP maps (RFC 2474, values 0-63):
  - `config qos policy <name> map dscp <value> traffic-class <tc>`
  - `config qos policy <name> map traffic-class <tc> dscp <value>`
- MPLS EXP maps (RFC 3032/5462, values 0-7):
  - `config qos policy <name> map mpls-exp <value> traffic-class <tc>`
  - `config qos policy <name> map traffic-class <tc> mpls-exp <value>`
- DOT1P/PCP maps (802.1Q, values 0-7):
  - `config qos policy <name> map dot1p <value> traffic-class <tc>`
  - `config qos policy <name> map traffic-class <tc> dot1p <value>`

The first command in each pair is additive (ingress classification - multiple codepoints can map to the same traffic class), while the second is not additive (egress rewrite - one traffic class maps to one codepoint value).

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

Pull Request resolved: #900

Add CLI commands to configure the dscpMaps, expMaps, and pcpMaps
attributes of the QosMap object within a QosPolicy. These commands
allow configuring bidirectional mappings between codepoint values
and internal traffic classes.

New CLI commands:

- DSCP maps (RFC 2474, values 0-63):
  - `config qos policy <name> map dscp <value> traffic-class <tc>`
  - `config qos policy <name> map traffic-class <tc> dscp <value>`
- MPLS EXP maps (RFC 3032/5462, values 0-7):
  - `config qos policy <name> map mpls-exp <value> traffic-class <tc>`
  - `config qos policy <name> map traffic-class <tc> mpls-exp <value>`
- DOT1P/PCP maps (802.1Q, values 0-7):
  - `config qos policy <name> map dot1p <value> traffic-class <tc>`
  - `config qos policy <name> map traffic-class <tc> dot1p <value>`

The first command in each pair is additive (ingress classification -
multiple codepoints can map to the same traffic class), while the
second is not additive (egress rewrite - one traffic class maps to
one codepoint value).

Test Plan:
New end to end tests:
```
Note: Google Test filter = *ConfigQosPolicyMapTest*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ConfigQosPolicyMapTest
[ RUN      ] ConfigQosPolicyMapTest.CreateSamplePolicy
I0204 18:36:53.719844 63663 CliTest.cpp:35] CliTest::SetUp - starting CLI test
I0204 18:36:53.719979 63663 ConfigQosPolicyMapTest.cpp:63] Using test policy name: cli_e2e_test_qos_policy_1770259013719
I0204 18:36:53.719994 63663 ConfigQosPolicyMapTest.cpp:229] ========================================
I0204 18:36:53.719999 63663 ConfigQosPolicyMapTest.cpp:230] ConfigQosPolicyMapTest::CreateSamplePolicy
I0204 18:36:53.720004 63663 ConfigQosPolicyMapTest.cpp:231] ========================================
I0204 18:36:53.720008 63663 ConfigQosPolicyMapTest.cpp:242] [Step 1] Configuring DOT1P/PCP maps...
I0204 18:36:53.720016 63663 CliTest.cpp:118] Running CLI command: config qos policy cli_e2e_test_qos_policy_1770259013719 map dot1p 0 traffic-class 0
I0204 18:36:53.761480 63663 ConfigQosPolicyMapTest.cpp:102] Command: dot1p 0 traffic-class 0
I0204 18:36:53.761503 63663 ConfigQosPolicyMapTest.cpp:104] stdout: {"localhost":"Successfully set QoS policy 'cli_e2e_test_qos_policy_1770259013719' pcpMaps.fromPcpToTrafficClass [tc=0] = 0"}
[... additional map configuration commands ...]
I0204 18:36:53.985447 63663 ConfigQosPolicyMapTest.cpp:276]   DOT1P maps configured
I0204 18:36:53.985452 63663 ConfigQosPolicyMapTest.cpp:279] [Step 2] Configuring traffic-class-to-queue mappings...
I0204 18:36:53.985462 63663 CliTest.cpp:118] Running CLI command: config qos policy cli_e2e_test_qos_policy_1770259013719 map tc-to-queue 0 0
I0204 18:36:54.002140 63663 ConfigQosPolicyMapTest.cpp:128] Command: tc-to-queue 0 0
I0204 18:36:54.002164 63663 ConfigQosPolicyMapTest.cpp:129] stdout: {"localhost":"Successfully set QoS policy 'cli_e2e_test_qos_policy_1770259013719' trafficClassToQueueId [0] = 0"}
[... additional tc-to-queue commands ...]
I0204 18:36:54.091056 63663 ConfigQosPolicyMapTest.cpp:286]   TC-to-queue mappings configured
I0204 18:36:54.091071 63663 ConfigQosPolicyMapTest.cpp:289] [Step 3] Committing config...
I0204 18:36:54.091084 63663 CliTest.cpp:118] Running CLI command: config session commit
I0204 18:36:54.316841 63663 ConfigQosPolicyMapTest.cpp:291]   Config committed
I0204 18:36:54.316868 63663 ConfigQosPolicyMapTest.cpp:294] [Step 4] Verifying config was applied...
I0204 18:36:54.326264 63663 ConfigQosPolicyMapTest.cpp:297]   Got running config from agent
I0204 18:36:54.326306 63663 ConfigQosPolicyMapTest.cpp:303]   Found test policy in running config
I0204 18:36:54.326319 63663 ConfigQosPolicyMapTest.cpp:314]   Verified pcpMaps has 6 entries
I0204 18:36:54.326344 63663 ConfigQosPolicyMapTest.cpp:329]   All pcpMap entries verified
I0204 18:36:54.326363 63663 ConfigQosPolicyMapTest.cpp:347]   trafficClassToQueueId verified
I0204 18:36:54.326374 63663 ConfigQosPolicyMapTest.cpp:349] TEST PASSED
[       OK ] ConfigQosPolicyMapTest.CreateSamplePolicy (607 ms)
[----------] 1 test from ConfigQosPolicyMapTest (607 ms total)

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

## Sample usage

CLI: Add DSCP, EXP, and DOT1P map configuration commands

New end to end tests:
```
Note: Google Test filter = *ConfigQosPolicyMapTest*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ConfigQosPolicyMapTest
[ RUN      ] ConfigQosPolicyMapTest.CreateSamplePolicy
I0204 18:36:53.719844 63663 CliTest.cpp:35] CliTest::SetUp - starting CLI test
I0204 18:36:53.719979 63663 ConfigQosPolicyMapTest.cpp:63] Using test policy name: cli_e2e_test_qos_policy_1770259013719
I0204 18:36:53.719994 63663 ConfigQosPolicyMapTest.cpp:229] ========================================
I0204 18:36:53.719999 63663 ConfigQosPolicyMapTest.cpp:230] ConfigQosPolicyMapTest::CreateSamplePolicy
I0204 18:36:53.720004 63663 ConfigQosPolicyMapTest.cpp:231] ========================================
I0204 18:36:53.720008 63663 ConfigQosPolicyMapTest.cpp:242] [Step 1] Configuring DOT1P/PCP maps...
I0204 18:36:53.720016 63663 CliTest.cpp:118] Running CLI command: config qos policy cli_e2e_test_qos_policy_1770259013719 map dot1p 0 traffic-class 0
I0204 18:36:53.761480 63663 ConfigQosPolicyMapTest.cpp:102] Command: dot1p 0 traffic-class 0
I0204 18:36:53.761503 63663 ConfigQosPolicyMapTest.cpp:104] stdout: {"localhost":"Successfully set QoS policy 'cli_e2e_test_qos_policy_1770259013719' pcpMaps.fromPcpToTrafficClass [tc=0] = 0"}
[... additional map configuration commands ...]
I0204 18:36:53.985447 63663 ConfigQosPolicyMapTest.cpp:276]   DOT1P maps configured
I0204 18:36:53.985452 63663 ConfigQosPolicyMapTest.cpp:279] [Step 2] Configuring traffic-class-to-queue mappings...
I0204 18:36:53.985462 63663 CliTest.cpp:118] Running CLI command: config qos policy cli_e2e_test_qos_policy_1770259013719 map tc-to-queue 0 0
I0204 18:36:54.002140 63663 ConfigQosPolicyMapTest.cpp:128] Command: tc-to-queue 0 0
I0204 18:36:54.002164 63663 ConfigQosPolicyMapTest.cpp:129] stdout: {"localhost":"Successfully set QoS policy 'cli_e2e_test_qos_policy_1770259013719' trafficClassToQueueId [0] = 0"}
[... additional tc-to-queue commands ...]
I0204 18:36:54.091056 63663 ConfigQosPolicyMapTest.cpp:286]   TC-to-queue mappings configured
I0204 18:36:54.091071 63663 ConfigQosPolicyMapTest.cpp:289] [Step 3] Committing config...
I0204 18:36:54.091084 63663 CliTest.cpp:118] Running CLI command: config session commit
I0204 18:36:54.316841 63663 ConfigQosPolicyMapTest.cpp:291]   Config committed
I0204 18:36:54.316868 63663 ConfigQosPolicyMapTest.cpp:294] [Step 4] Verifying config was applied...
I0204 18:36:54.326264 63663 ConfigQosPolicyMapTest.cpp:297]   Got running config from agent
I0204 18:36:54.326306 63663 ConfigQosPolicyMapTest.cpp:303]   Found test policy in running config
I0204 18:36:54.326319 63663 ConfigQosPolicyMapTest.cpp:314]   Verified pcpMaps has 6 entries
I0204 18:36:54.326344 63663 ConfigQosPolicyMapTest.cpp:329]   All pcpMap entries verified
I0204 18:36:54.326363 63663 ConfigQosPolicyMapTest.cpp:347]   trafficClassToQueueId verified
I0204 18:36:54.326374 63663 ConfigQosPolicyMapTest.cpp:349] TEST PASSED
[       OK ] ConfigQosPolicyMapTest.CreateSamplePolicy (607 ms)
[----------] 1 test from ConfigQosPolicyMapTest (607 ms total)

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

## Sample usage

```
admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map dscp 10 traffic-class 1
Successfully set QoS policy 'test-policy' dscpMaps.fromDscpToTrafficClass [tc=1] = 10

admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map dscp 20 traffic-class 1
Successfully set QoS policy 'test-policy' dscpMaps.fromDscpToTrafficClass [tc=1] = 20

admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map traffic-class 1 dscp 10
Successfully set QoS policy 'test-policy' dscpMaps.fromTrafficClassToDscp [tc=1] = 10

admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map mpls-exp 3 traffic-class 2
Successfully set QoS policy 'test-policy' expMaps.fromExpToTrafficClass [tc=2] = 3

admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map traffic-class 2 mpls-exp 3
Successfully set QoS policy 'test-policy' expMaps.fromTrafficClassToExp [tc=2] = 3

admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map dot1p 5 traffic-class 3
Successfully set QoS policy 'test-policy' pcpMaps.fromPcpToTrafficClass [tc=3] = 5

admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map traffic-class 3 dot1p 5
Successfully set QoS policy 'test-policy' pcpMaps.fromTrafficClassToPcp [tc=3] = 5

admin@fboss101:~/benoit$ ./fboss2-dev config session diff
 --- current live config
+++ session config
@@ -6244,6 +6244,41 @@
           }
         },
         "rules": []
+      },
+      {
+        "name": "test-policy",
+        "qosMap": {
+          "dscpMaps": [
+            {
+              "fromDscpToTrafficClass": [
+                10,
+                20
+              ],
+              "fromTrafficClassToDscp": 10,
+              "internalTrafficClass": 1
+            }
+          ],
+          "expMaps": [
+            {
+              "fromExpToTrafficClass": [
+                3
+              ],
+              "fromTrafficClassToExp": 3,
+              "internalTrafficClass": 2
+            }
+          ],
+          "pcpMaps": [
+            {
+              "fromPcpToTrafficClass": [
+                5
+              ],
+              "fromTrafficClassToPcp": 5,
+              "internalTrafficClass": 3
+            }
+          ],
+          "trafficClassToQueueId": {}
+        },
+        "rules": []
       }
     ],
     "sFlowCollectors": [],
[...]
```

Reviewed By: srikrishnagopu

Differential Revision: D98233654

Pulled By: joseph5wu

fbshipit-source-id: 4c036620bd08935f3ac5535d244b51293fb8d542
@benoit-nexthop
benoit-nexthop force-pushed the fboss2-cli-prototype_part28 branch from 4030d7a to 4f83b34 Compare March 26, 2026 12:49
@benoit-nexthop
benoit-nexthop requested review from a team as code owners March 26, 2026 12:49
@benoit-nexthop
benoit-nexthop force-pushed the fboss2-cli-prototype_part28 branch from 4f83b34 to 6399806 Compare March 26, 2026 14:39

@joseph5wu joseph5wu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the main reason to introduce a new class InterfaceConfig util class instead having all the attribute management logic in CmdConfigInterface?
All the other commands which can handle multiple attributes don't have their version of XXXConfig util class. Please keep the style identical across all commands

@benoit-nexthop

Copy link
Copy Markdown
Contributor Author

What's the main reason to introduce a new class InterfaceConfig util class instead having all the attribute management logic in CmdConfigInterface? All the other commands which can handle multiple attributes don't have their version of XXXConfig util class. Please keep the style identical across all commands

The reason for this was that it's a piece of code that is shared by multiple commands, some of which are coming in the next PRs.

origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterface.h:14:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterface.h:21:  using ObjectArgType = utils::InterfacesConfig;
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.cpp:24:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.cpp:31:    const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.h:19:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.h:41:      const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.cpp:32:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.cpp:130:    const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.h:19:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.h:40:      const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/CmdConfigInterfaceSwitchport.h:15:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/CmdConfigInterfaceSwitchport.h:33:      const utils::InterfacesConfig& interfaceConfig) {
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/CmdConfigInterfaceSwitchportAccess.h:15:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/CmdConfigInterfaceSwitchportAccess.h:34:      const utils::InterfacesConfig& interfaceConfig) {
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/vlan/CmdConfigInterfaceSwitchportAccessVlan.cpp:23:    const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/vlan/CmdConfigInterfaceSwitchportAccessVlan.h:16:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/vlan/CmdConfigInterfaceSwitchportAccessVlan.h:43:      const utils::InterfacesConfig& interfaceConfig,

@joseph5wu

Copy link
Copy Markdown
Contributor

What's the main reason to introduce a new class InterfaceConfig util class instead having all the attribute management logic in CmdConfigInterface? All the other commands which can handle multiple attributes don't have their version of XXXConfig util class. Please keep the style identical across all commands

The reason for this was that it's a piece of code that is shared by multiple commands, some of which are coming in the next PRs.

origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterface.h:14:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterface.h:21:  using ObjectArgType = utils::InterfacesConfig;
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.cpp:24:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.cpp:31:    const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.h:19:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceQueuingPolicy.h:41:      const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.cpp:32:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.cpp:130:    const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.h:19:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/pfc_config/CmdConfigInterfacePfcConfig.h:40:      const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/CmdConfigInterfaceSwitchport.h:15:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/CmdConfigInterfaceSwitchport.h:33:      const utils::InterfacesConfig& interfaceConfig) {
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/CmdConfigInterfaceSwitchportAccess.h:15:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/CmdConfigInterfaceSwitchportAccess.h:34:      const utils::InterfacesConfig& interfaceConfig) {
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/vlan/CmdConfigInterfaceSwitchportAccessVlan.cpp:23:    const utils::InterfacesConfig& interfaceConfig,
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/vlan/CmdConfigInterfaceSwitchportAccessVlan.h:16:#include "fboss/cli/fboss2/utils/InterfacesConfig.h"
origin/main:fboss/cli/fboss2/commands/config/interface/switchport/access/vlan/CmdConfigInterfaceSwitchportAccessVlan.h:43:      const utils::InterfacesConfig& interfaceConfig,

@benoit-nexthop This is not a strong reason as these CmdConfigInterfaceXXX are only using getInterfaces() from this InterfaceConfig. And I don't think this is a good design

const auto& interfaces = interfaceConfig.getInterfaces();

…p class

# Summary

This PR consolidates the separate CmdConfigInterfaceDescription and
CmdConfigInterfaceMtu commands into a unified CmdConfigInterface command
that can set multiple interface attributes in a single invocation.
```
# Set description
config interface eth1/1/1 description "My port description"

# Set MTU
config interface eth1/1/1 mtu 9000

# Set both in one command
config interface eth1/1/1 description "My port" mtu 9000

# Apply to multiple interfaces
config interface eth1/1/1,eth1/2/1 description "Uplink" mtu 1500
```

Original change by @hillol-nexthop

## Implementation Details

1. **New `InterfaceConfig` class**
- Parses CLI tokens to separate port names from attribute key-value
pairs
  - Supports description and mtu attributes (case-insensitive)
  - Validates attribute names and detects missing values
  - Wraps `InterfaceList` for port/interface resolution
2. **Updated CmdConfigInterface**
  - Changed from pass-through command to functional command
  - Implements `queryClient` to process description and mtu attributes
  - Sets `port->description()` for description attribute
  - Sets `interface->mtu()` for mtu attribute with validation
3. **Updated subcommands to use `InterfaceConfig` instead of
`InterfaceList`**
4. **Deleted obsolete pairs of `.cpp` / `.h`**
5. **New comprehensive test suite**
- 23 tests covering `InterfaceConfig` validation and
`CmdConfigInterface::queryClient` functionality
  - Backward Compatibility
- Subcommands like switchport, pfc-config, and queuing-policy continue
to work as before

# Test Plan

**Note:** The e2e test is already implemented in meta#893
Above mentioned list of new test file, deleted and updated test files.
Existing unit and end to end tests pass.
@benoit-nexthop
benoit-nexthop force-pushed the fboss2-cli-prototype_part28 branch from 6399806 to 76f46f2 Compare March 26, 2026 18:44
@facebook-github-tools

Copy link
Copy Markdown

@benoit-nexthop has updated the pull request. You must reimport the pull request before landing.

@meta-codesync

meta-codesync Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

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

@meta-codesync

meta-codesync Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

@joseph5wu merged this pull request in 7e0b6c7.

@benoit-nexthop
benoit-nexthop deleted the fboss2-cli-prototype_part28 branch March 27, 2026 01:25
meta-codesync Bot pushed a commit that referenced this pull request Mar 27, 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`

Move explicit template instantiations from the monolithic `CmdHandlerImplConfig.cpp` file to individual command `.cpp` files. This is the first step in refactoring the CLI command registration system to avoid creating a monolithic include file.

The non-config commands will be done in a separate PR.

Changes:
- Created 11 new `.cpp` files for stub commands that were missing them
- Added template instantiations to 20 existing command `.cpp` files
- Updated `cmake/CliFboss2.cmake` and `fboss/cli/fboss2/BUCK` build files
- Deleted `fboss/cli/fboss2/CmdHandlerImplConfig.cpp`

Each command `.cpp` file now includes `CmdHandler.cpp` and has its own explicit template instantiation, following the pattern:
```c++
#include "fboss/cli/fboss2/CmdHandler.cpp"

template void CmdHandler<CmdClass, CmdClassTraits>::run();
```

Original change by manoharan-nexthop

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

Pull Request resolved: #931

Test Plan: Ran all the unit tests.

Reviewed By: KevinYakar

Differential Revision: D98510944

Pulled By: joseph5wu

fbshipit-source-id: 18f33d1014eb81a81b264c65adb4bd5b78e824c4
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.

3 participants