Switchport mode update for 'show interfaces status'#3788
Switchport mode update for 'show interfaces status'#3788qiluo-msft merged 4 commits intosonic-net:masterfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@wen587 @xwjiang-ms please review |
|
Could we add some ut for the new support? |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
RCA: According to present design port was conisdered as "trunk" if its part of a VLAN, there was no handling to fetch the acutal mode from Redis DB regarding the configured switchport mode. Solution: Configured "switchport mode" is fetched from DB for all front panel ports and PortChannel interfaces. "Vlan" column in "show interface status" is displayed based on below considerations: 1. If interface is part of PortChannel - display PortChannel interface name [present behavior] 2. If "switchport mode" is configured on interface [Ethernet/PortChannel] - display configured mode [new behavior] 3. If "switchport mode" is NOT configured on interface but part of a VLAN [Ethernet/PortChannel] - display as "trunk" [present behavior]
2e980db to
5f3096f
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
5f3096f to
76d9279
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
76d9279 to
4344831
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
@wen587 : UT cases are added, please review. |
|
@wsycqyz |
|
Hi @prgeor can you please check and merge this. Thanks |
|
Sonic-Mgmt testcases for this PR |
|
Hi @prsunny Can you kindly help in merging this. |
|
@vrajeshe , can you update one more line in description
Basically want to ensure we don't change the existing behavior if switchport is not configured to 'access'. @FengPan-Frank to review/approve |
@prsunny Updated the description. Yes that is the present behaviour, we have not changed that. |
|
@qiluo-msft to merge |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the "show interfaces status" command to properly display switchport modes in the "Vlan" column. Previously, interfaces configured with "switchport mode access" would incorrectly show as "trunk" in the status output.
Key changes:
- Refactored interface vlan/mode determination logic to prioritize configured switchport modes
- Added comprehensive test coverage for switchport mode verification
- Updated the display logic to show configured switchport modes instead of inferring from VLAN membership
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/intfutil | Refactored vlan determination logic to use switchport mode configuration and updated function signatures |
| tests/vlan_test.py | Added test helper function and switchport mode verification to existing tests |
| def setup_class(cls): | ||
| os.environ['UTILITIES_UNIT_TESTING'] = "1" | ||
| os.environ["PATH"] += os.pathsep + scripts_path | ||
| os.environ['UTILITIES_UNIT_TESTING'] = "2" |
There was a problem hiding this comment.
The environment variable value changed from "1" to "2" without explanation. This magic number should be documented or use a descriptive constant to clarify why this change was made.
| os.environ['UTILITIES_UNIT_TESTING'] = "2" | |
| os.environ['UTILITIES_UNIT_TESTING'] = UNIT_TESTING_MODE_ENABLED |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2e81b49
|
/azp run |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@qiluo-msft : Can you please help me in merging this PR to 202505 branch as well? CC: @prsunny |
|
@yejianquan please help check 202505. |
|
@yejianquan - Could you please help to cherry-pick for 202505? |
|
Cherry-pick PR to 202505: #4035 |
What I did Fixed "show interfaces status" output for interfaces with switchport mode configuration. How I did it Configured "switchport mode" is fetched from DB for all front panel ports and PortChannel interfaces. "Vlan" column in "show interface status" is displayed based on below considerations: If interface is part of PortChannel - display PortChannel interface name [present behavior] If "switchport mode" is configured on interface [Ethernet/PortChannel] - display configured mode [new behavior] If "switchport mode" is NOT configured on interface but part of a VLAN [Ethernet/PortChannel] - display as "trunk" [present behavior] If "switchport mode" is NOT configured on interface and NOT part of a VLAN [Ethernet/PortChannel] - display as "routed" [present behavior] How to verify it Configure "switchport mode" for an interface/portchannel and verify the output in below show commands show interfaces switchport status show interfaces status Previous command output (if the output of a command-line utility has changed) Previously it was always displaying as trunk even if interface is configured as access root@sonic:~# config switchport mode access Ethernet0 Ethernet0 switched to access mode root@sonic:~# show interfaces switchport status | grep Ethernet0 Ethernet0 access root@sonic:~# root@sonic:~# show interfaces status | grep Ethernet0 Ethernet0 2304,2305,2306,2307 100G 9100 N/A etp0 trunk up up QSFP28 or later N/A New command output (if the output of a command-line utility has changed) root@sonic:~# config switchport mode access Ethernet0 Ethernet0 switched to access mode root@sonic:~# show interfaces switchport status | grep Ethernet0 Ethernet0 access root@sonic:~# root@sonic:~# show interfaces status | grep Ethernet0 Ethernet0 2304,2305,2306,2307 100G 9100 N/A etp0 access up up QSFP28 or later N/A closes sonic-net#3787
What I did
Fixed "show interfaces status" output for interfaces with switchport mode configuration.
How I did it
Configured "switchport mode" is fetched from DB for all front panel ports and PortChannel interfaces.
"Vlan" column in "show interface status" is displayed based on below considerations:
How to verify it
Configure "switchport mode" for an interface/portchannel and verify the output in below show commands
Previous command output (if the output of a command-line utility has changed)
Previously it was always displaying as
trunkeven if interface is configured asaccessNew command output (if the output of a command-line utility has changed)
closes #3787