Repository navigation
[Nexthop][fboss2-dev] Add dscp, exp, and dot1p map configuration commands - #900
Closed
benoit-nexthop wants to merge 1 commit into
Closed
benoit-nexthop wants to merge 1 commit into
benoit-nexthop wants to merge 1 commit into
Conversation
2 tasks done
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part27
branch
from
February 5, 2026 03:05
2b0bafb to
bbff78a
Compare
2 tasks done
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part27
branch
from
March 24, 2026 19:06
4624279 to
4dc8dec
Compare
meta-codesync Bot
pushed a commit
that referenced
this pull request
Mar 25, 2026
…-mode (#896) 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` Implements two new fboss2-dev CLI commands for switch configuration. ## 1. config vlan <vlanId> port <portId> taggingMode <mode> Configures the VLAN tagging mode for a port within a VLAN. This controls whether packets are tagged or untagged when egressing the port. Where `<mode>` can be: - `tagged` - Packets egress with VLAN tag - `untagged` - Packets egress without VLAN tag This is a hitless configuration change (no agent restart required). ## 2. config l2 learning-mode <mode> Configures the L2 learning mode (`l2LearningMode` in `SwitchSettings`). This controls how the switch learns MAC addresses. Where `<mode>` can be: - `hardware` - MAC learning is performed by the hardware ASIC - `software` - MAC learning is performed by the software agent - `disabled` - MAC learning is disabled Note: Changing L2 learning mode requires an agent restart (not hitless) because the FBOSS agent does not permit changing this setting after initial config application. Note: this change is part of a series, the previous one is #893, the next one is #900. This change was originally developed by manoharan-nexthop Pull Request resolved: #896 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: ## Unit tests - **config vlan port taggingMode** (15 test cases): Argument validation, mode conversion, error handling - **config l2 learning-mode** (14 test cases): Argument validation, mode conversion, error handling ## End-to-end tests **config vlan port taggingMode:** ``` ============================================================ CLI E2E Test: config vlan <id> port <port> taggingMode ============================================================ [Step 1] Finding an interface to test... Using CLI from FBOSS_CLI_PATH: /home/admin/manoharan/fboss2-dev [CLI] Running: show interface [CLI] Completed in 0.08s: show interface Using interface: eth1/1/1 (VLAN: 2001) [Step 2] Getting current tagging mode... [CLI] Running: show running-config [CLI] Completed in 0.07s: show running-config Current mode: untagged [Step 3] Setting tagging mode to 'tagged'... [CLI] Running: config vlan 2001 port eth1/1/1 taggingMode tagged [CLI] Completed in 0.08s: config vlan 2001 port eth1/1/1 taggingMode tagged [CLI] Running: config session commit [CLI] Completed in 0.16s: config session commit Tagging mode set to 'tagged' [Step 4] Verifying tagging mode is 'tagged'... [CLI] Running: show running-config [CLI] Completed in 0.06s: show running-config Verified: Tagging mode is 'tagged' [Step 5] Setting tagging mode to 'untagged'... [CLI] Running: config vlan 2001 port eth1/1/1 taggingMode untagged [CLI] Completed in 0.08s: config vlan 2001 port eth1/1/1 taggingMode untagged [CLI] Running: config session commit [CLI] Completed in 0.15s: config session commit Tagging mode set to 'untagged' [Step 6] Verifying tagging mode is 'untagged'... [CLI] Running: show running-config [CLI] Completed in 0.06s: show running-config Verified: Tagging mode is 'untagged' ============================================================ TEST PASSED ============================================================ ``` **config l2 learning-mode:** ``` ============================================================ CLI E2E Test: config l2 learning-mode <mode> ============================================================ [Step 1] Getting current L2 learning mode... Using CLI from FBOSS_CLI_PATH: /home/admin/manoharan/fboss2-dev [CLI] Running: show running-config [CLI] Completed in 0.06s: show running-config Current mode: hardware [Step 2] Setting L2 learning mode to 'software'... [CLI] Running: config l2 learning-mode software [CLI] Completed in 0.07s: config l2 learning-mode software [CLI] Running: config session commit [CLI] Completed in 2.88s: config session commit Waiting for agent to be ready after restart... Sleeping 30s for agent restart... L2 learning mode set to 'software' [Step 3] Verifying L2 learning mode is 'software'... [CLI] Running: show running-config [CLI] Completed in 0.06s: show running-config Verified: L2 learning mode is 'software' [Step 4] Setting L2 learning mode to 'hardware'... [CLI] Running: config l2 learning-mode hardware [CLI] Completed in 0.08s: config l2 learning-mode hardware [CLI] Running: config session commit [CLI] Completed in 3.51s: config session commit Waiting for agent to be ready after restart... Sleeping 30s for agent restart... L2 learning mode set to 'hardware' [Step 5] Verifying L2 learning mode is 'hardware'... [CLI] Running: show running-config [CLI] Completed in 0.06s: show running-config Verified: L2 learning mode is 'hardware' ============================================================ TEST PASSED ============================================================ ``` ## 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 ~]$ fboss2-dev config vlan 2001 port eth1/1/1 taggingMode untagged Successfully set tagging mode for port 'eth1/1/1' in VLAN 2001 to 'untagged' [admin@fboss101 ~]$ fboss2-dev config l2 learning-mode software Successfully set L2 learning mode to 'software' [admin@fboss101 ~]$ fboss2-dev config session commit wedge_agent restarted, config committed ``` Reviewed By: KevinYakar Differential Revision: D98023658 Pulled By: joseph5wu fbshipit-source-id: 57b01b9f2a9acbfd3c39622fdf86ae0001b3a7a6
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part27
branch
from
March 25, 2026 13:01
4dc8dec to
f9434a6
Compare
joseph5wu
reviewed
Mar 25, 2026
joseph5wu
left a comment
Contributor
There was a problem hiding this comment.
Overall it looks good to me. Please consider add more user friendly details in the command --help
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part27
branch
from
March 25, 2026 22:59
f9434a6 to
09b400f
Compare
# Summary
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
```
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": [],
[...]
```
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part27
branch
from
March 26, 2026 00:10
09b400f to
d8f03e5
Compare
Contributor
|
@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D98233654. |
Contributor
|
@joseph5wu merged this pull request in bc4b447. |
meta-codesync Bot
pushed a commit
that referenced
this pull request
Mar 26, 2026
…p class (#919) 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` 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 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 Pull Request resolved: #919 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. Reviewed By: KevinYakar Differential Revision: D98340162 Pulled By: joseph5wu fbshipit-source-id: 82d10267ae00fb6e81710f61781f0746d591f836
2 tasks done
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
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:
config qos policy <name> map dscp <value> traffic-class <tc>config qos policy <name> map traffic-class <tc> dscp <value>config qos policy <name> map mpls-exp <value> traffic-class <tc>config qos policy <name> map traffic-class <tc> mpls-exp <value>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.
Test Plan
New end to end tests:
Sample usage
CLI: Add DSCP, EXP, and DOT1P map configuration commands
Summary
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:
config qos policy <name> map dscp <value> traffic-class <tc>config qos policy <name> map traffic-class <tc> dscp <value>config qos policy <name> map mpls-exp <value> traffic-class <tc>config qos policy <name> map traffic-class <tc> mpls-exp <value>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:
Sample usage