Skip to content

Commit e99e2e4

Browse files
[voq][chassis] Remove created ports from the default vlan. (sonic-net#2607)
Signed-off-by: Nathan Wolfe [email protected] What I did -Remove newly created ports from the default vlan on VOQ systems. -Add a test to confirm we're executing removeDefaultVlanMembers when a new port is added on a VOQ system. Why I did it -When a port is created via create_port SAI call the port may be added to the default vlan, this is undesired. How I verified it -On a 7800R3AK-36DM2 linecard with multiple 400G ports I verified that the TX_TAG_ENABLE field in ETPPC_EDITING_PER_PORT_TABLE was not set for and ports. This confirms that no port is a member of any vlan
1 parent a2a483d commit e99e2e4

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

orchagent/portsorch.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,13 @@ bool PortsOrch::addPort(const set<int> &lane_set, uint32_t speed, int an, string
26962696
m_portListLaneMap[lane_set] = port_id;
26972697
m_portCount++;
26982698

2699+
// newly created ports might be put in the default vlan so remove all ports from
2700+
// the default vlan.
2701+
if (gMySwitchType == "voq") {
2702+
removeDefaultVlanMembers();
2703+
removeDefaultBridgePorts();
2704+
}
2705+
26992706
SWSS_LOG_NOTICE("Create port %" PRIx64 " with the speed %u", port_id, speed);
27002707

27012708
return true;

tests/test_virtual_chassis.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ast
44
import time
55
import pytest
6+
import buffer_model
67

78
class TestVirtualChassis(object):
89

@@ -852,7 +853,66 @@ def test_chassis_system_lag_id_allocator_del_id(self, vct):
852853
assert len(lagmemberkeys) == 0, "Stale system lag member entries in asic db"
853854

854855
break
855-
856+
857+
def test_chassis_add_remove_ports(self, vct):
858+
"""Test removing and adding a port in a VOQ chassis.
859+
860+
Test validates that when a port is created the port is removed from the default vlan.
861+
"""
862+
dvss = vct.dvss
863+
for name in dvss.keys():
864+
dvs = dvss[name]
865+
buffer_model.enable_dynamic_buffer(dvs.get_config_db(), dvs.runcmd)
866+
867+
config_db = dvs.get_config_db()
868+
app_db = dvs.get_app_db()
869+
asic_db = dvs.get_asic_db()
870+
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
871+
cfg_switch_type = metatbl.get("switch_type")
872+
873+
if cfg_switch_type == "voq":
874+
num_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT"))
875+
# Get the port info we'll flap
876+
port = config_db.get_keys('PORT')[0]
877+
port_info = config_db.get_entry("PORT", port)
878+
879+
# Remove port's other configs
880+
pgs = config_db.get_keys('BUFFER_PG')
881+
queues = config_db.get_keys('BUFFER_QUEUE')
882+
for key in pgs:
883+
if port in key:
884+
config_db.delete_entry('BUFFER_PG', key)
885+
app_db.wait_for_deleted_entry('BUFFER_PG_TABLE', key)
886+
887+
for key in queues:
888+
if port in key:
889+
config_db.delete_entry('BUFFER_QUEUE', key)
890+
app_db.wait_for_deleted_entry('BUFFER_QUEUE_TABLE', key)
891+
892+
# Remove port
893+
config_db.delete_entry('PORT', port)
894+
app_db.wait_for_deleted_entry('PORT_TABLE', port)
895+
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
896+
num_ports-1)
897+
assert len(num) == num_ports-1
898+
899+
marker = dvs.add_log_marker()
900+
901+
# Create port
902+
config_db.update_entry("PORT", port, port_info)
903+
app_db.wait_for_entry("PORT_TABLE", port)
904+
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
905+
num_ports)
906+
assert len(num) == num_ports
907+
908+
# Check that we see the logs for removing default vlan
909+
matching_log = "removeDefaultVlanMembers: Remove 0 VLAN members from default VLAN"
910+
_, logSeen = dvs.runcmd( [ "sh", "-c",
911+
"awk '/{}/,ENDFILE {{print;}}' /var/log/syslog | grep '{}' | wc -l".format( marker, matching_log ) ] )
912+
assert logSeen.strip() == "1"
913+
914+
buffer_model.disable_dynamic_buffer(dvs.get_config_db(), dvs.runcmd)
915+
856916
# Add Dummy always-pass test at end as workaroud
857917
# for issue when Flaky fail on final test it invokes module tear-down before retrying
858918
def test_nonflaky_dummy():

0 commit comments

Comments
 (0)