Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switchport mode update for 'show interfaces status' #3788

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cshivashgit
Copy link

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:

  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]

How to verify it

Configure "switchport mode" for an interface/portchannel and verify the output in below show commands

  1. show interfaces switchport status
  2. 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 #3787

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]
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

linux-foundation-easycla bot commented Feb 27, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@cshivashgit
Copy link
Author

@wen587 @xwjiang-ms please review

vlan_member_table = config_db.get_table('VLAN_MEMBER')

vlan_member_keys = []
for _, key in vlan_member_table:
Copy link
Contributor

Choose a reason for hiding this comment

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

if vlan_member_table returned is dict, maybe it's better to use

vlan_member_keys = list(vlan_member_table.keys())

Copy link
Author

Choose a reason for hiding this comment

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

@FengPan-Frank : Vlan Member table has two parts in the key - (VlanName, MemberInterfaceName) , in above code we are extracting the member interfaces , so using vlan_member_table.keys() will not give the same result

Sample VLAN_MEMBER table :

{('Vlan100', 'PortChannel100'): {'tagging_mode': 'untagged'}, ('Vlan100', 'Ethernet16'): {'tagging_mode': 'tagged'}}

@wen587
Copy link
Contributor

wen587 commented Mar 11, 2025

Could we add some ut for the new support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"show interfaces status" always shows port as trunk port
4 participants