From 30c8a0ca60a7e6dae9750a11b873fbab70e26295 Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 10 Sep 2020 01:55:50 -0400 Subject: [PATCH 01/21] [voq] Redis instance for global app db Signed-off-by: vedganes --- tests/mock_tests/database_config.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/mock_tests/database_config.json b/tests/mock_tests/database_config.json index b86ae11bba..2e68bb381f 100644 --- a/tests/mock_tests/database_config.json +++ b/tests/mock_tests/database_config.json @@ -4,6 +4,11 @@ "hostname" : "127.0.0.1", "port" : 6379, "unix_socket_path" : "/var/run/redis/redis.sock" + }, + "redis-global_db":{ + "hostname" : "240.127.1.1", + "port" : 6380, + "unix_socket_path" : "/var/run/redis/redis-global_db.sock" } }, "DATABASES" : { @@ -51,6 +56,11 @@ "id" : 7, "separator": "|", "instance" : "redis" + }, + "GLOBAL_APP_DB" : { + "id" : 11, + "separator": ":", + "instance" : "redis-global_db" } }, "VERSION" : "1.0" From bfb6f2f7b9fd87b3a06f5034116a0b5a54c0d7a8 Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 10 Sep 2020 02:41:01 -0400 Subject: [PATCH 02/21] [voq] System port init and orchestration Signed-off-by: vedganes --- orchagent/main.cpp | 149 ++++++++++++++++++++++++++ orchagent/port.h | 18 ++++ orchagent/portsorch.cpp | 230 +++++++++++++++++++++++++++++++++++++++- orchagent/portsorch.h | 7 ++ orchagent/saihelper.cpp | 3 + 5 files changed, 404 insertions(+), 3 deletions(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index 9da230bfb6..dd0a8d496a 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -62,6 +62,11 @@ extern bool gIsNatSupported; ofstream gRecordOfs; string gRecordFile; +string gMySwitchType = ""; +int32_t gVoqMySwitchId = -1; +int32_t gVoqMaxCores = 0; +uint32_t gCfgSystemPorts = 0; + void usage() { cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-i INST_ID] [-s]" << endl; @@ -140,6 +145,121 @@ void init_gearbox_phys(DBConnector *applDb) delete tmpGearboxTable; } +bool getSystemPortConfigList(vector &sysportcfglist) +{ + DBConnector cfgDb("CONFIG_DB", 0); + DBConnector appDb("APPL_DB", 0); + + Table cfgDeviceMetaDataTable(&cfgDb, CFG_DEVICE_METADATA_TABLE_NAME); + Table cfgSystemPortTable(&cfgDb, CFG_SYSTEM_PORT_TABLE_NAME); + Table appSystemPortTable(&appDb, APP_SYSTEM_PORT_TABLE_NAME); + + //At this point of time (i.e, at the time of orchagent start), the CONFIG_DB is completely fully + //populated with the contents of config_db.json. + + string value; + //Get the swith type. + if(!cfgDeviceMetaDataTable.hget("localhost", "switch_type", value)) + { + //Switch type is not configured. Consider it default = "switch" (regular switch) + value = "switch"; + } + + if(value != "voq" && value != "fabric" && value != "switch") + { + cout << "Invalid switch type " << value.c_str() << " configured"; + return false; + } + gMySwitchType = value; + + if(gMySwitchType != "voq") + { + //Non VOQ switch. Nothing to read + return true; + } + + if(!cfgDeviceMetaDataTable.hget("localhost", "switch_id", value)) + { + //VOQ switch id is not configured. + cout << "VOQ switch id is not configured"; + return false; + } + + if(value.size()) + gVoqMySwitchId = stoi(value); + + if(gVoqMySwitchId < 0) + { + cout << "Invalid VOQ switch id " << gVoqMySwitchId << " configured"; + return false; + } + + if(!cfgDeviceMetaDataTable.hget("localhost", "max_cores", value)) + { + //VOQ max cores is not configured. + cout << "VOQ max cores is not configured"; + return false; + } + + if(value.size()) + gVoqMaxCores = stoi(value); + + if(gVoqMaxCores == 0) + { + cout << "Invalid VOQ max cores " << gVoqMaxCores << " configured"; + return false; + } + + vector spKeys; + cfgSystemPortTable.getKeys(spKeys); + + //Retrieve system port configurations + vector spFv; + sai_system_port_config_t sysport; + for ( auto &k : spKeys ) + { + cfgSystemPortTable.get(k, spFv); + + for ( auto &fv : spFv ) + { + if(fv.first == "switch_id") + { + sysport.attached_switch_id = stoi(fv.second); + continue; + } + if(fv.first == "core_index") + { + sysport.attached_core_index = stoi(fv.second); + continue; + } + if(fv.first == "core_port_index") + { + sysport.attached_core_port_index = stoi(fv.second); + continue; + } + if(fv.first == "speed") + { + sysport.speed = stoi(fv.second); + continue; + } + if(fv.first == "system_port_id") + { + sysport.port_id = stoi(fv.second); + continue; + } + } + //Add to system port config list + sysportcfglist.push_back(sysport); + + //Also push to APP DB + appSystemPortTable.set(k, spFv); + } + + SWSS_LOG_NOTICE("Created System Port config list for %d system ports", (int32_t) sysportcfglist.size()); + + return true; +} + int main(int argc, char **argv) { swss::Logger::linkToDbNative("orchagent"); @@ -286,6 +406,35 @@ int main(int argc, char **argv) attrs.push_back(attr); } + //Get info required for VOQ system + vector sysportconfiglist; + if(getSystemPortConfigList(sysportconfiglist)) + { + if (gMySwitchType == "voq") + { + attr.id = SAI_SWITCH_ATTR_TYPE; + attr.value.u32 = SAI_SWITCH_TYPE_VOQ; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_SWITCH_ID; + attr.value.u32 = gVoqMySwitchId; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_MAX_SYSTEM_CORES; + attr.value.u32 = gVoqMaxCores; + attrs.push_back(attr); + + gCfgSystemPorts = (uint32_t) sysportconfiglist.size(); + if(gCfgSystemPorts) + { + attr.id = SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST; + attr.value.sysportconfiglist.count = gCfgSystemPorts; + attr.value.sysportconfiglist.list = sysportconfiglist.data(); + attrs.push_back(attr); + } + } + } + status = sai_switch_api->create_switch(&gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { diff --git a/orchagent/port.h b/orchagent/port.h index 74f805ddec..50a8c7ccc0 100644 --- a/orchagent/port.h +++ b/orchagent/port.h @@ -36,6 +36,19 @@ struct VlanInfo sai_vlan_id_t vlan_id = 0; }; +struct SystemPortInfo +{ + std::string alias = ""; + sai_system_port_type_t type; + sai_object_id_t local_port_oid = 0; + uint32_t port_id = 0; + uint32_t switch_id = 0; + uint32_t core_index = 0; + uint32_t core_port_index = 0; + uint32_t speed = 400000; + uint32_t num_voq = 8; +}; + class Port { public: @@ -47,6 +60,7 @@ class Port VLAN, LAG, SUBPORT, + SYSTEM, UNKNOWN } ; @@ -114,6 +128,10 @@ class Port std::unordered_set m_ingress_acl_tables_uset; std::unordered_set m_egress_acl_tables_uset; + + sai_object_id_t m_system_port_oid = 0; + SystemPortInfo m_system_port_info; + }; } diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index ce86371da6..8e8b617aa7 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -41,6 +41,7 @@ extern IntfsOrch *gIntfsOrch; extern NeighOrch *gNeighOrch; extern CrmOrch *gCrmOrch; extern BufferOrch *gBufferOrch; +extern sai_system_port_api_t *sai_system_port_api; #define VLAN_PREFIX "Vlan" #define DEFAULT_VLAN_ID 1 @@ -367,6 +368,9 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) m_default1QBridge = attrs[0].value.oid; m_defaultVlan = attrs[1].value.oid; + /* Get System ports */ + getSystemPorts(); + removeDefaultVlanMembers(); removeDefaultBridgePorts(); @@ -380,7 +384,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) void PortsOrch::removeDefaultVlanMembers() { /* Get VLAN members in default VLAN */ - vector vlan_member_list(m_portCount); + vector vlan_member_list(m_portCount + m_systemPortCount); sai_attribute_t attr; attr.id = SAI_VLAN_ATTR_MEMBER_LIST; @@ -411,10 +415,10 @@ void PortsOrch::removeDefaultVlanMembers() void PortsOrch::removeDefaultBridgePorts() { /* Get bridge ports in default 1Q bridge - * By default, there will be m_portCount number of SAI_BRIDGE_PORT_TYPE_PORT + * By default, there will be (m_portCount + m_systemPortCount) number of SAI_BRIDGE_PORT_TYPE_PORT * ports and one SAI_BRIDGE_PORT_TYPE_1Q_ROUTER port. The former type of * ports will be removed. */ - vector bridge_port_list(m_portCount + 1); + vector bridge_port_list(m_portCount + m_systemPortCount + 1); sai_attribute_t attr; attr.id = SAI_BRIDGE_ATTR_PORT_LIST; @@ -551,6 +555,7 @@ bool PortsOrch::getPort(sai_object_id_t id, Port &port) switch (portIter.second.m_type) { case Port::PHY: + case Port::SYSTEM: if(portIter.second.m_port_id == id) { port = portIter.second; @@ -2042,6 +2047,7 @@ void PortsOrch::doPortTask(Consumer &consumer) */ if (!m_initDone) { + addSystemPorts(); m_initDone = true; SWSS_LOG_INFO("Get PortInitDone notification from portsyncd."); } @@ -4491,3 +4497,221 @@ bool PortsOrch::initGearboxPort(Port &port) return true; } +bool PortsOrch::getSystemPorts() +{ + sai_status_t status; + sai_attribute_t attr; + uint32_t i; + + m_systemPortCount = 0; + + attr.id = SAI_SWITCH_ATTR_NUMBER_OF_SYSTEM_PORTS; + + status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get number of system ports, rv:%d", status); + return false; + } + + m_systemPortCount = attr.value.u32; + SWSS_LOG_NOTICE("Got %d system ports", m_systemPortCount); + + if(m_systemPortCount) + { + /* Make tuple and system port oid map */ + + vector system_port_list; + system_port_list.resize(m_systemPortCount); + + attr.id = SAI_SWITCH_ATTR_SYSTEM_PORT_LIST; + attr.value.objlist.count = (uint32_t)system_port_list.size(); + attr.value.objlist.list = system_port_list.data(); + + status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get system port list, rv:%d", status); + return false; + } + + uint32_t spcnt = attr.value.objlist.count; + for(i = 0; i < spcnt; i++) + { + attr.id = SAI_SYSTEM_PORT_ATTR_CONFIG_INFO; + + status = sai_system_port_api->get_system_port_attribute(system_port_list[i], 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get system port config info spid:%" PRIx64, system_port_list[i]); + return false; + } + + SWSS_LOG_NOTICE("SystemPort(0x%lx) - port_id:%u, switch_id:%u, core:%u, core_port:%u, speed:%u, voqs:%u", + system_port_list[i], + attr.value.sysportconfig.port_id, + attr.value.sysportconfig.attached_switch_id, + attr.value.sysportconfig.attached_core_index, + attr.value.sysportconfig.attached_core_port_index, + attr.value.sysportconfig.speed, + attr.value.sysportconfig.num_voq); + + tuple sp_key(attr.value.sysportconfig.attached_switch_id, + attr.value.sysportconfig.attached_core_index, + attr.value.sysportconfig.attached_core_port_index); + + m_systemPortOidMap[sp_key] = system_port_list[i]; + } + } + + return true; +} + +bool PortsOrch::addSystemPorts() +{ + vector keys; + vector spFv; + + DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + Table appSystemPortTable(&appDb, APP_SYSTEM_PORT_TABLE_NAME); + + //Retrieve system port configurations from APP DB + appSystemPortTable.getKeys(keys); + for ( auto &alias : keys ) + { + appSystemPortTable.get(alias, spFv); + + int32_t system_port_id = -1; + int32_t switch_id = -1; + int32_t core_index = -1; + int32_t core_port_index = -1; + int32_t speed = -1; + + for ( auto &fv : spFv ) + { + if(fv.first == "switch_id") + { + switch_id = stoi(fv.second); + continue; + } + if(fv.first == "core_index") + { + core_index = stoi(fv.second); + continue; + } + if(fv.first == "core_port_index") + { + core_port_index = stoi(fv.second); + continue; + } + if(fv.first == "speed") + { + speed = stoi(fv.second); + continue; + } + if(fv.first == "system_port_id") + { + system_port_id = stoi(fv.second); + continue; + } + } + + if(system_port_id < 0 || switch_id < 0 || core_index < 0 || core_port_index < 0) + { + SWSS_LOG_ERROR("Invalid or Missing field values for %s! system_port id:%d, switch_id:%d, core_index:%d, core_port_index:%d", + alias.c_str(), system_port_id, switch_id, core_index, core_port_index); + continue; + } + + if(speed < 0) + { + speed = 400000; + } + + tuple sp_key(switch_id, core_index, core_port_index); + + if(m_systemPortOidMap.find(sp_key) != m_systemPortOidMap.end()) + { + + sai_attribute_t attr; + vector attrs; + sai_object_id_t system_port_oid; + sai_status_t status; + + //Retrive system port config info and enable + system_port_oid = m_systemPortOidMap[sp_key]; + + attr.id = SAI_SYSTEM_PORT_ATTR_TYPE; + attrs.push_back(attr); + + attr.id = SAI_SYSTEM_PORT_ATTR_CONFIG_INFO; + attrs.push_back(attr); + + status = sai_system_port_api->get_system_port_attribute(system_port_oid, static_cast(attrs.size()), attrs.data()); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get system port config info spid:%" PRIx64, system_port_oid); + continue; + } + + //Create or update system port and add to the port list. + Port port(alias, Port::SYSTEM); + port.m_port_id = system_port_oid; + port.m_admin_state_up = true; + port.m_oper_status = SAI_PORT_OPER_STATUS_UP; + port.m_speed = attrs[1].value.sysportconfig.speed; + if (attrs[0].value.s32 == SAI_SYSTEM_PORT_TYPE_LOCAL) + { + //Get the local port oid + attr.id = SAI_SYSTEM_PORT_ATTR_PORT; + + status = sai_system_port_api->get_system_port_attribute(system_port_oid, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get local port oid of local system port spid:%" PRIx64, system_port_oid); + continue; + } + + //System port for local port. Update the system port info in the existing physical port + if(!getPort(attr.value.oid, port)) + { + //This is system port for non-front panel local port (CPU or OLP or RCY (Inband)). Not an error + SWSS_LOG_NOTICE("Add port for non-front panel local system port 0x%" PRIx64 "; core: %d, core port: %d", + system_port_oid, core_index, core_port_index); + } + port.m_system_port_info.local_port_oid = attr.value.oid; + } + + port.m_system_port_oid = system_port_oid; + + port.m_system_port_info.alias = alias; + port.m_system_port_info.type = (sai_system_port_type_t) attrs[0].value.s32; + port.m_system_port_info.port_id = attrs[1].value.sysportconfig.port_id; + port.m_system_port_info.switch_id = attrs[1].value.sysportconfig.attached_switch_id; + port.m_system_port_info.core_index = attrs[1].value.sysportconfig.attached_core_index; + port.m_system_port_info.core_port_index = attrs[1].value.sysportconfig.attached_core_port_index; + port.m_system_port_info.speed = attrs[1].value.sysportconfig.speed; + port.m_system_port_info.num_voq = attrs[1].value.sysportconfig.num_voq; + + setPort(port.m_alias, port); + if(m_port_ref_count.find(port.m_alias) == m_port_ref_count.end()) + { + m_port_ref_count[port.m_alias] = 0; + } + + SWSS_LOG_NOTICE("Added system port %" PRIx64 " for %s", system_port_oid, alias.c_str()); + } + else + { + //System port does not exist in the switch + //This can not happen since all the system ports are supposed to be created during switch creation itself + + SWSS_LOG_NOTICE("System port %s does not exist in switch. Port not added!", alias.c_str()); + continue; + } + } + + return true; +} + + diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 936f1ff07e..b0825b484b 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -277,6 +277,13 @@ class PortsOrch : public Orch, public Subject sai_acl_bind_point_type_t &sai_acl_bind_type); void initGearbox(); bool initGearboxPort(Port &port); + + //map key is tuple of + map, sai_object_id_t> m_systemPortOidMap; + sai_uint32_t m_systemPortCount; + bool getSystemPorts(); + bool addSystemPorts(); + }; #endif /* SWSS_PORTSORCH_H */ diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index a776ca701d..d150713b2c 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -51,6 +51,7 @@ sai_bmtor_api_t* sai_bmtor_api; sai_samplepacket_api_t* sai_samplepacket_api; sai_debug_counter_api_t* sai_debug_counter_api; sai_nat_api_t* sai_nat_api; +sai_system_port_api_t* sai_system_port_api; extern sai_object_id_t gSwitchId; extern bool gSairedisRecord; @@ -170,6 +171,7 @@ void initSaiApi() sai_api_query(SAI_API_SAMPLEPACKET, (void **)&sai_samplepacket_api); sai_api_query(SAI_API_DEBUG_COUNTER, (void **)&sai_debug_counter_api); sai_api_query(SAI_API_NAT, (void **)&sai_nat_api); + sai_api_query(SAI_API_SYSTEM_PORT, (void **)&sai_system_port_api); sai_log_set(SAI_API_SWITCH, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_BRIDGE, SAI_LOG_LEVEL_NOTICE); @@ -199,6 +201,7 @@ void initSaiApi() sai_log_set(SAI_API_SAMPLEPACKET, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_DEBUG_COUNTER, SAI_LOG_LEVEL_NOTICE); sai_log_set((sai_api_t)SAI_API_NAT, SAI_LOG_LEVEL_NOTICE); + sai_log_set(SAI_API_SYSTEM_PORT, SAI_LOG_LEVEL_NOTICE); } void initSaiRedis(const string &record_location) From ee967d939aad0b50decf2957d5a3c4b8bfd89a4f Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 10 Sep 2020 09:16:20 -0400 Subject: [PATCH 03/21] [voq] Router interface for system ports, global app db sync Signed-off-by: vedganes --- orchagent/intfsorch.cpp | 125 ++++++++++++++++++++++- orchagent/intfsorch.h | 9 +- orchagent/main.cpp | 10 +- orchagent/orch.cpp | 2 +- orchagent/orch.h | 1 + orchagent/orchdaemon.cpp | 7 +- orchagent/orchdaemon.h | 3 +- tests/mock_tests/aclorch_ut.cpp | 6 +- tests/mock_tests/mock_orchagent_main.cpp | 1 + 9 files changed, 155 insertions(+), 9 deletions(-) diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index 7f25d47c38..40f2b36ac7 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -16,6 +16,7 @@ #include "bufferorch.h" #include "directory.h" #include "vnetorch.h" +#include "subscriberstatetable.h" extern sai_object_id_t gVirtualRouterId; extern Directory gDirectory; @@ -32,6 +33,7 @@ extern RouteOrch *gRouteOrch; extern CrmOrch *gCrmOrch; extern BufferOrch *gBufferOrch; extern bool gIsNatSupported; +extern string gMySwitchType; const int intfsorch_pri = 35; @@ -52,7 +54,7 @@ static const vector rifStatIds = SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS, }; -IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) : +IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *globalAppDb) : Orch(db, tableName, intfsorch_pri), m_vrfOrch(vrf_orch) { SWSS_LOG_ENTER(); @@ -96,6 +98,15 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) : { SWSS_LOG_WARN("RIF flex counter group plugins was not set successfully: %s", e.what()); } + + if(gMySwitchType == "voq") + { + //Add subscriber to process VOQ system interface + tableName = VOQ_SYSTEM_INTERFACE_TABLE_NAME; + Orch::addExecutor(new Consumer(new SubscriberStateTable(globalAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); + m_tableVoqSystemInterfaceTable = unique_ptr(new Table(globalAppDb, VOQ_SYSTEM_INTERFACE_TABLE_NAME)); + } + } sai_object_id_t IntfsOrch::getRouterIntfsId(const string &alias) @@ -497,6 +508,8 @@ void IntfsOrch::doTask(Consumer &consumer) return; } + string table_name = consumer.getTableName(); + auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { @@ -521,6 +534,16 @@ void IntfsOrch::doTask(Consumer &consumer) ip_prefix_in_key = true; } + if(table_name == VOQ_SYSTEM_INTERFACE_TABLE_NAME) + { + if(!isRemoteSystemPortIntf(alias)) + { + //Synced local interface. Skip + it = consumer.m_toSync.erase(it); + continue; + } + } + const vector& data = kfvFieldsValues(t); string vrf_name = "", vnet_name = "", nat_zone = ""; MacAddress mac; @@ -895,6 +918,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port) { case Port::PHY: case Port::LAG: + case Port::SYSTEM: attr.value.s32 = SAI_ROUTER_INTERFACE_TYPE_PORT; attrs.push_back(attr); break; @@ -914,6 +938,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port) switch(port.m_type) { case Port::PHY: + case Port::SYSTEM: attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID; attr.value.oid = port.m_port_id; attrs.push_back(attr); @@ -978,6 +1003,12 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port) SWSS_LOG_NOTICE("Create router interface %s MTU %u", port.m_alias.c_str(), port.m_mtu); + if(gMySwitchType == "voq") + { + //Sync the interface to add to the SYSTEM_INTERFACE table of GLOBAL_APP_DB + voqSyncAddIntf(port.m_alias, port.m_rif_id); + } + return true; } @@ -1008,6 +1039,12 @@ bool IntfsOrch::removeRouterIntfs(Port &port) SWSS_LOG_NOTICE("Remove router interface for port %s", port.m_alias.c_str()); + if(gMySwitchType == "voq") + { + //Sync the interface to del from the SYSTEM_INTERFACE table of GLOBAL_APP_DB + voqSyncDelIntf(port.m_alias); + } + return true; } @@ -1230,6 +1267,7 @@ void IntfsOrch::doTask(SelectableTimer &timer) { case Port::PHY: case Port::LAG: + case Port::SYSTEM: type = "SAI_ROUTER_INTERFACE_TYPE_PORT"; break; case Port::VLAN: @@ -1255,3 +1293,88 @@ void IntfsOrch::doTask(SelectableTimer &timer) } } } + +bool IntfsOrch::isRemoteSystemPortIntf(string alias) +{ + Port port; + if(gPortsOrch->getPort(alias, port)) + { + return(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE); + } + //Given alias is system port alias of the local port + return false; +} + +bool IntfsOrch::voqSyncAddIntf(string &alias, sai_object_id_t &rif_id) +{ + //Sync only local interface. Confirm for the local interface and + //get the system port alias for key for syncing + Port port; + if(gPortsOrch->getPort(alias, port)) + { + if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) + { + return true; + } + alias = port.m_system_port_info.alias; + } + else + { + SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); + return false; + } + + //Get router interface to make sure it exists + sai_attribute_t attr; + sai_status_t status; + + attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID; + + status = sai_router_intfs_api->get_router_interface_attribute(rif_id, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get rif for %s:0x%lx, rv:%d", alias.c_str(), rif_id, status); + return false; + } + + //Get the Real ID of the RIF ID + string value; + const auto id = sai_serialize_object_id(rif_id); + + if (m_vidToRidTable->hget("", id, value)) + { + FieldValueTuple rifIdFv ("rif_id", value); + vector attrs; + attrs.push_back(rifIdFv); + + m_tableVoqSystemInterfaceTable->set(alias, attrs); + return true; + } + SWSS_LOG_ERROR("Failed to get real ID from ASIC DB for RIF id 0x%lx of %s", rif_id, alias.c_str()); + return false; +} + +bool IntfsOrch::voqSyncDelIntf(string &alias) +{ + //Sync only local interface. Confirm for the local interface and + //get the system port alias for key for syncing to GLOBAL_APP_DB + Port port; + if(gPortsOrch->getPort(alias, port)) + { + if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) + { + return true; + } + alias = port.m_system_port_info.alias; + } + else + { + SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); + return false; + } + + m_tableVoqSystemInterfaceTable->del(alias); + + return true; +} + diff --git a/orchagent/intfsorch.h b/orchagent/intfsorch.h index 9db1a3b228..d21aa286ef 100644 --- a/orchagent/intfsorch.h +++ b/orchagent/intfsorch.h @@ -32,7 +32,7 @@ typedef map IntfsTable; class IntfsOrch : public Orch { public: - IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch); + IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *globalAppDb); sai_object_id_t getRouterIntfsId(const string&); bool isPrefixSubnet(const IpPrefix&, const string&); @@ -64,6 +64,8 @@ class IntfsOrch : public Orch bool updateSyncdIntfPfx(const string &alias, const IpPrefix &ip_prefix, bool add = true); + bool isRemoteSystemPortIntf(string alias); + private: SelectableTimer* m_updateMapsTimer = nullptr; @@ -94,6 +96,11 @@ class IntfsOrch : public Orch bool setIntfVlanFloodType(const Port &port, sai_vlan_flood_control_type_t vlan_flood_type); bool setIntfProxyArp(const string &alias, const string &proxy_arp); + + unique_ptr
m_tableVoqSystemInterfaceTable; + bool voqSyncAddIntf(string &alias, sai_object_id_t &rif_id); + bool voqSyncDelIntf(string &alias); + }; #endif /* SWSS_INTFSORCH_H */ diff --git a/orchagent/main.cpp b/orchagent/main.cpp index dd0a8d496a..bac0ea8b96 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -518,9 +518,17 @@ int main(int argc, char **argv) DBConnector config_db("CONFIG_DB", 0); DBConnector state_db("STATE_DB", 0); + shared_ptr global_app_db; + if(gMySwitchType == "voq") + { + //Connection for GLOBAL_APP_DB in redis-server in control/supervisor card as per + //connection info in database_config.json + global_app_db = make_shared("GLOBAL_APP_DB", 0, true); + } + init_gearbox_phys(&appl_db); - auto orchDaemon = make_shared(&appl_db, &config_db, &state_db); + auto orchDaemon = make_shared(&appl_db, &config_db, &state_db, global_app_db.get()); if (!orchDaemon->init()) { diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index fbf278ce94..196f805201 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -557,7 +557,7 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin void Orch::addConsumer(DBConnector *db, string tableName, int pri) { - if (db->getDbName() == "CONFIG_DB" || db->getDbName() == "STATE_DB") + if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB || db->getDbId() == GLOBAL_APP_DB) { addExecutor(new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this, tableName)); } diff --git a/orchagent/orch.h b/orchagent/orch.h index 456885491a..b921013fe9 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -28,6 +28,7 @@ const char comma = ','; const char range_specifier = '-'; const char config_db_key_delimiter = '|'; const char state_db_key_delimiter = '|'; +const char global_app_db_key_delimiter = ':'; #define INVM_PLATFORM_SUBSTRING "innovium" #define MLNX_PLATFORM_SUBSTRING "mellanox" diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 99fbc0a7f6..d1d8f56ab6 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -39,10 +39,11 @@ NatOrch *gNatOrch; bool gIsNatSupported = false; -OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb) : +OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb, DBConnector *globalAppDb) : m_applDb(applDb), m_configDb(configDb), - m_stateDb(stateDb) + m_stateDb(stateDb), + m_globalAppDb(globalAppDb) { SWSS_LOG_ENTER(); } @@ -124,7 +125,7 @@ bool OrchDaemon::init() ChassisOrch* chassis_frontend_orch = new ChassisOrch(m_configDb, m_applDb, chassis_frontend_tables, vnet_rt_orch); gDirectory.set(chassis_frontend_orch); - gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, vrf_orch); + gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, vrf_orch, m_globalAppDb); gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch); gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, vrf_orch); diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 3094692df6..218327f84f 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -37,7 +37,7 @@ using namespace swss; class OrchDaemon { public: - OrchDaemon(DBConnector *, DBConnector *, DBConnector *); + OrchDaemon(DBConnector *, DBConnector *, DBConnector *, DBConnector *); ~OrchDaemon(); bool init(); @@ -51,6 +51,7 @@ class OrchDaemon DBConnector *m_applDb; DBConnector *m_configDb; DBConnector *m_stateDb; + DBConnector *m_globalAppDb; std::vector m_orchList; Select *m_select; diff --git a/tests/mock_tests/aclorch_ut.cpp b/tests/mock_tests/aclorch_ut.cpp index 65c1862e8c..94fd27f8ee 100644 --- a/tests/mock_tests/aclorch_ut.cpp +++ b/tests/mock_tests/aclorch_ut.cpp @@ -20,6 +20,7 @@ extern sai_vlan_api_t *sai_vlan_api; extern sai_bridge_api_t *sai_bridge_api; extern sai_route_api_t *sai_route_api; extern sai_next_hop_group_api_t* sai_next_hop_group_api; +extern string gMySwitchType; namespace aclorch_test { @@ -181,6 +182,7 @@ namespace aclorch_test shared_ptr m_app_db; shared_ptr m_config_db; shared_ptr m_state_db; + shared_ptr m_global_app_db; AclOrchTest() { @@ -188,6 +190,8 @@ namespace aclorch_test m_app_db = make_shared("APPL_DB", 0); m_config_db = make_shared("CONFIG_DB", 0); m_state_db = make_shared("STATE_DB", 0); + if(gMySwitchType == "voq") + m_global_app_db = make_shared("GLOBAL_APP_DB", 0); } static map gProfileMap; @@ -310,7 +314,7 @@ namespace aclorch_test gVrfOrch = new VRFOrch(m_app_db.get(), APP_VRF_TABLE_NAME, m_state_db.get(), STATE_VRF_OBJECT_TABLE_NAME); ASSERT_EQ(gIntfsOrch, nullptr); - gIntfsOrch = new IntfsOrch(m_app_db.get(), APP_INTF_TABLE_NAME, gVrfOrch); + gIntfsOrch = new IntfsOrch(m_app_db.get(), APP_INTF_TABLE_NAME, gVrfOrch, m_global_app_db.get()); ASSERT_EQ(gNeighOrch, nullptr); gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch); diff --git a/tests/mock_tests/mock_orchagent_main.cpp b/tests/mock_tests/mock_orchagent_main.cpp index 86651a7c94..17055e02fd 100644 --- a/tests/mock_tests/mock_orchagent_main.cpp +++ b/tests/mock_tests/mock_orchagent_main.cpp @@ -21,6 +21,7 @@ bool gLogRotate = false; bool gSaiRedisLogRotate = false; ofstream gRecordOfs; string gRecordFile; +string gMySwitchType = "voq"; MirrorOrch *gMirrorOrch; VRFOrch *gVrfOrch; From 45942e75aff75544842c1430bf4520c4944c0b26 Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 10 Sep 2020 10:13:30 -0400 Subject: [PATCH 04/21] [voq] Inband interface config Signed-off-by: vedganes --- cfgmgr/intfmgr.cpp | 55 +++++++++++++++++++++++++++++++++++++++++ cfgmgr/intfmgr.h | 1 + cfgmgr/intfmgrd.cpp | 1 + orchagent/intfsorch.cpp | 15 +++++++++++ orchagent/portsorch.cpp | 30 ++++++++++++++++++++++ orchagent/portsorch.h | 4 +++ 6 files changed, 106 insertions(+) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 72e9123430..9bd43abf86 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -627,6 +627,13 @@ void IntfMgr::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); + string table_name = consumer.getTableName(); + if(table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME) + { + doCfgVoqInbandInterfaceTask(consumer); + return; + } + auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { @@ -660,3 +667,51 @@ void IntfMgr::doTask(Consumer &consumer) it = consumer.m_toSync.erase(it); } } + +void IntfMgr::doCfgVoqInbandInterfaceTask(Consumer &consumer) +{ + SWSS_LOG_ENTER(); + + auto it = consumer.m_toSync.begin(); + while (it != consumer.m_toSync.end()) + { + KeyOpFieldsValuesTuple t = it->second; + + vector keys = tokenize(kfvKey(t), config_db_key_delimiter); + const vector& data = kfvFieldsValues(t); + string op = kfvOp(t); + string alias(keys[0]); + + if (keys.size() == 1) + { + if(op == SET_COMMAND) + { + //No further processing. Just push to orchagent + m_appIntfTableProducer.set(alias, data); + m_stateIntfTable.hset(alias, "vrf", ""); + } + else if(op == DEL_COMMAND) + { + if (!doIntfGeneralTask(keys, data, op)) + { + it++; + continue; + } + } + } + else if (keys.size() == 2) + { + if (!doIntfAddrTask(keys, data, op)) + { + it++; + continue; + } + } + else + { + SWSS_LOG_ERROR("Invalid key %s", kfvKey(t).c_str()); + } + + it = consumer.m_toSync.erase(it); + } +} diff --git a/cfgmgr/intfmgr.h b/cfgmgr/intfmgr.h index 340c4cd04a..44716c16b3 100644 --- a/cfgmgr/intfmgr.h +++ b/cfgmgr/intfmgr.h @@ -32,6 +32,7 @@ class IntfMgr : public Orch bool doIntfAddrTask(const std::vector& keys, const std::vector& data, const std::string& op); void doTask(Consumer &consumer); + void doCfgVoqInbandInterfaceTask(Consumer &consumer); bool isIntfStateOk(const std::string &alias); bool isIntfCreated(const std::string &alias); bool isIntfChangeVrf(const std::string &alias, const std::string &vrfName); diff --git a/cfgmgr/intfmgrd.cpp b/cfgmgr/intfmgrd.cpp index d92aff9ceb..d6ed18526e 100644 --- a/cfgmgr/intfmgrd.cpp +++ b/cfgmgr/intfmgrd.cpp @@ -47,6 +47,7 @@ int main(int argc, char **argv) CFG_VLAN_INTF_TABLE_NAME, CFG_LOOPBACK_INTERFACE_TABLE_NAME, CFG_VLAN_SUB_INTF_TABLE_NAME, + CFG_VOQ_INBAND_INTERFACE_TABLE_NAME, }; DBConnector cfgDb("CONFIG_DB", 0); diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index 40f2b36ac7..b8f96ec9a7 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -552,6 +552,7 @@ void IntfsOrch::doTask(Consumer &consumer) bool adminUp; uint32_t nat_zone_id = 0; string proxy_arp = ""; + string inband_type = ""; for (auto idx : data) { @@ -631,6 +632,10 @@ void IntfsOrch::doTask(Consumer &consumer) { proxy_arp = value; } + else if (field == "inband_type") + { + inband_type = value; + } } if (alias == "eth0" || alias == "docker0") @@ -684,6 +689,16 @@ void IntfsOrch::doTask(Consumer &consumer) continue; } + //Voq Inband interface config processing + if(inband_type.size() && !ip_prefix_in_key) + { + if(!gPortsOrch->setVoqInbandIntf(alias, inband_type)) + { + it++; + continue; + } + } + Port port; if (!gPortsOrch->getPort(alias, port)) { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 8e8b617aa7..0482c8f53b 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4714,4 +4714,34 @@ bool PortsOrch::addSystemPorts() return true; } +bool PortsOrch::setVoqInbandIntf(string &alias, string &type) +{ + if(m_inbandPortName == alias) + { + //Inband interface already exists with this name + SWSS_LOG_NOTICE("Interface %s is already configured as inband!", alias.c_str()); + return true; + } + + Port port; + if(type == "port") + { + if (!getPort(alias, port)) + { + SWSS_LOG_NOTICE("Port configured for inband intf %s is not ready!", alias.c_str()); + return false; + } + } + + // Check for existence of host interface. If does not exist, may create + // host if for the inband here + + // May do the processing for other inband type like type=vlan here + + //Store the name of the local inband port + m_inbandPortName = alias; + + return true; +} + diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index b0825b484b..0a28f2044c 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -127,6 +127,10 @@ class PortsOrch : public Orch, public Subject bool addSubPort(Port &port, const string &alias, const bool &adminUp = true, const uint32_t &mtu = 0); bool removeSubPort(const string &alias); void getLagMember(Port &lag, vector &portv); + + string m_inbandPortName = ""; + bool setVoqInbandIntf(string &alias, string &type); + private: unique_ptr
m_counterTable; unique_ptr
m_counterLagTable; From 10771a8ea4b62e6c6d4c5ad36aa474db2f5f4874 Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 10 Sep 2020 10:50:18 -0400 Subject: [PATCH 05/21] [voq] System port neighbors Signed-off-by: vedganes --- orchagent/intfsorch.cpp | 18 ++ orchagent/neighorch.cpp | 508 +++++++++++++++++++++++++++++++- orchagent/neighorch.h | 15 +- orchagent/orchdaemon.cpp | 2 +- orchagent/portsorch.cpp | 18 ++ orchagent/portsorch.h | 2 + tests/mock_tests/aclorch_ut.cpp | 2 +- 7 files changed, 560 insertions(+), 5 deletions(-) diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index b8f96ec9a7..63a7948a9e 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -33,6 +33,7 @@ extern RouteOrch *gRouteOrch; extern CrmOrch *gCrmOrch; extern BufferOrch *gBufferOrch; extern bool gIsNatSupported; +extern NeighOrch *gNeighOrch; extern string gMySwitchType; const int intfsorch_pri = 35; @@ -441,6 +442,15 @@ bool IntfsOrch::setIntf(const string& alias, sai_object_id_t vrf_id, const IpPre addIp2MeRoute(port.m_vr_id, *ip_prefix); + if(gMySwitchType == "voq") + { + if(gPortsOrch->isInbandPort(alias)) + { + //Need to sync the inband intf neighbor for other asics + gNeighOrch->addInbandNeighbor(alias, ip_prefix->getIp()); + } + } + if (port.m_type == Port::VLAN) { addDirectedBroadcast(port, *ip_prefix); @@ -464,6 +474,14 @@ bool IntfsOrch::removeIntf(const string& alias, sai_object_id_t vrf_id, const Ip { removeIp2MeRoute(port.m_vr_id, *ip_prefix); + if(gMySwitchType == "voq") + { + if(gPortsOrch->isInbandPort(alias)) + { + gNeighOrch->delInbandNeighbor(alias, ip_prefix->getIp()); + } + } + if(port.m_type == Port::VLAN) { removeDirectedBroadcast(port, *ip_prefix); diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index ae0db0751c..885d8b8577 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -4,6 +4,8 @@ #include "swssnet.h" #include "crmorch.h" #include "routeorch.h" +#include "subscriberstatetable.h" +#include "exec.h" extern sai_neighbor_api_t* sai_neighbor_api; extern sai_next_hop_api_t* sai_next_hop_api; @@ -12,13 +14,22 @@ extern PortsOrch *gPortsOrch; extern sai_object_id_t gSwitchId; extern CrmOrch *gCrmOrch; extern RouteOrch *gRouteOrch; +extern string gMySwitchType; const int neighorch_pri = 30; -NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch) : +NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DBConnector *globalAppDb) : Orch(db, tableName, neighorch_pri), m_intfsOrch(intfsOrch) { SWSS_LOG_ENTER(); + + if(gMySwitchType == "voq") + { + //Add subscriber to process VOQ system neigh + tableName = VOQ_SYSTEM_NEIGH_TABLE_NAME; + Orch::addExecutor(new Consumer(new SubscriberStateTable(globalAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); + m_tableVoqSystemNeighTable = unique_ptr
(new Table(globalAppDb, VOQ_SYSTEM_NEIGH_TABLE_NAME)); + } } bool NeighOrch::hasNextHop(const NextHopKey &nexthop) @@ -39,6 +50,15 @@ bool NeighOrch::addNextHop(const IpAddress &ipAddress, const string &alias) } NextHopKey nexthop = { ipAddress, alias }; + if(m_intfsOrch->isRemoteSystemPortIntf(alias)) + { + //For remote system ports kernel nexthops are always on inband. Change the key + Port inbp; + if(gPortsOrch->getInbandPort(inbp)) + { + nexthop.alias = inbp.m_alias; + } + } assert(!hasNextHop(nexthop)); sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(alias); @@ -214,6 +234,16 @@ bool NeighOrch::removeNextHop(const IpAddress &ipAddress, const string &alias) SWSS_LOG_ENTER(); NextHopKey nexthop = { ipAddress, alias }; + if(m_intfsOrch->isRemoteSystemPortIntf(alias)) + { + //For remote system ports kernel nexthops are always on inband. Change the key + Port inbp; + if(gPortsOrch->getInbandPort(inbp)) + { + nexthop.alias = inbp.m_alias; + } + } + assert(hasNextHop(nexthop)); if (m_syncdNextHops[nexthop].ref_count > 0) @@ -293,6 +323,13 @@ void NeighOrch::doTask(Consumer &consumer) return; } + string table_name = consumer.getTableName(); + if(table_name == VOQ_SYSTEM_NEIGH_TABLE_NAME) + { + doVoqSystemNeighTask(consumer); + return; + } + auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { @@ -317,6 +354,14 @@ void NeighOrch::doTask(Consumer &consumer) continue; } + if(gPortsOrch->isInbandPort(alias)) + { + //This is the neigh learned due to the kernel entry added on + //Inband interface for the remote system port neighbors. Skip + it = consumer.m_toSync.erase(it); + continue; + } + IpAddress ip_address(key.substr(found+1)); NeighborEntry neighbor_entry = { ip_address, alias }; @@ -408,7 +453,17 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress if (m_syncdNeighbors.find(neighborEntry) == m_syncdNeighbors.end()) { - status = sai_neighbor_api->create_neighbor_entry(&neighbor_entry, 1, &neighbor_attr); + vector neighbor_attrs; + neighbor_attrs.push_back(neighbor_attr); + if(gMySwitchType == "voq") + { + if(!addVoqEncapIndex(alias, ip_address, neighbor_attrs)) + { + return false; + } + } + + status = sai_neighbor_api->create_neighbor_entry(&neighbor_entry, static_cast(neighbor_attrs.size()), neighbor_attrs.data()); if (status != SAI_STATUS_SUCCESS) { if (status == SAI_STATUS_ITEM_ALREADY_EXISTS) @@ -478,6 +533,12 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress NeighborUpdate update = { neighborEntry, macAddress, true }; notify(SUBJECT_TYPE_NEIGH_CHANGE, static_cast(&update)); + if(gMySwitchType == "voq") + { + //Sync the neighbor to add to the GLOBAL_APP_DB + voqSyncAddNeigh(alias, ip_address, macAddress, neighbor_entry); + } + return true; } @@ -488,7 +549,17 @@ bool NeighOrch::removeNeighbor(const NeighborEntry &neighborEntry) sai_status_t status; IpAddress ip_address = neighborEntry.ip_address; string alias = neighborEntry.alias; + NextHopKey nexthop = { ip_address, alias }; + if(m_intfsOrch->isRemoteSystemPortIntf(alias)) + { + //For remote system ports kernel nexthops are always on inband. Change the key + Port inbp; + if(gPortsOrch->getInbandPort(inbp)) + { + nexthop.alias = inbp.m_alias; + } + } if (m_syncdNeighbors.find(neighborEntry) == m_syncdNeighbors.end()) { @@ -579,5 +650,438 @@ bool NeighOrch::removeNeighbor(const NeighborEntry &neighborEntry) removeNextHop(ip_address, alias); + if(gMySwitchType == "voq") + { + //Sync the neighbor to delete from the GLOBAL_APP_DB + voqSyncDelNeigh(alias, ip_address); + } + + return true; +} + +void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) +{ + SWSS_LOG_ENTER(); + + //Local inband port as the outgoing interface of the static neighbor and static route + Port port; + if(!gPortsOrch->getInbandPort(port)) + { + //Inband port is not ready yet. + return; + } + string nbr_odev = port.m_alias; + MacAddress inband_mac = gMacAddress; + + auto it = consumer.m_toSync.begin(); + while (it != consumer.m_toSync.end()) + { + KeyOpFieldsValuesTuple t = it->second; + string key = kfvKey(t); + string op = kfvOp(t); + + size_t found = key.find(':'); + if (found == string::npos) + { + SWSS_LOG_ERROR("Failed to parse key %s", key.c_str()); + it = consumer.m_toSync.erase(it); + continue; + } + + string alias = key.substr(0, found); + + if(!gIntfsOrch->isRemoteSystemPortIntf(alias)) + { + //Synced local neighbor. Skip + it = consumer.m_toSync.erase(it); + continue; + } + + IpAddress ip_address(key.substr(found+1)); + + NeighborEntry neighbor_entry = { ip_address, alias }; + + if (op == SET_COMMAND) + { + Port p; + if (!gPortsOrch->getPort(alias, p)) + { + SWSS_LOG_INFO("Port %s doesn't exist", alias.c_str()); + it++; + continue; + } + + if (!p.m_rif_id) + { + SWSS_LOG_INFO("Router interface doesn't exist on %s", alias.c_str()); + it++; + continue; + } + + MacAddress mac_address; + uint32_t encap_index = 0; + for (auto i = kfvFieldsValues(t).begin(); + i != kfvFieldsValues(t).end(); i++) + { + if (fvField(*i) == "neigh") + mac_address = MacAddress(fvValue(*i)); + + if(fvField(*i) == "encap_index") + { + encap_index = (uint32_t)stoul(fvValue(*i)); + } + } + + if(!encap_index) + { + //Encap index is not available yet. Since this is remote neighbor, we need to wait till + //Encap index is made available either by dynamic syncing or by static config + it++; + continue; + } + + if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() || m_syncdNeighbors[neighbor_entry] != mac_address) + { + if (!addKernelNeigh(nbr_odev, ip_address, inband_mac)) + { + SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + it++; + continue; + } + else + { + SWSS_LOG_NOTICE("Neigh entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + + if (!addKernelRoute(nbr_odev, ip_address)) + { + SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + delKernelNeigh(nbr_odev, ip_address); + it++; + continue; + } + else + { + SWSS_LOG_NOTICE("Route entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + SWSS_LOG_NOTICE("Added voq neighbor %s to kernel", kfvKey(t).c_str()); + + //Add neigh to SAI + if (addNeighbor(neighbor_entry, mac_address)) + it = consumer.m_toSync.erase(it); + else + { + SWSS_LOG_ERROR("Failed to add voq neighbor %s to SAI", kfvKey(t).c_str()); + delKernelRoute(ip_address); + delKernelNeigh(nbr_odev, ip_address); + it++; + } + } + else + /* Duplicate entry */ + it = consumer.m_toSync.erase(it); + } + else if (op == DEL_COMMAND) + { + if (m_syncdNeighbors.find(neighbor_entry) != m_syncdNeighbors.end()) + { + if (!delKernelRoute(ip_address)) + { + SWSS_LOG_ERROR("Route entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + else + { + SWSS_LOG_NOTICE("Route entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + + if (!delKernelNeigh(nbr_odev, ip_address)) + { + SWSS_LOG_ERROR("Neigh entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + else + { + SWSS_LOG_NOTICE("Neigh entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + SWSS_LOG_DEBUG("Deleted voq neighbor %s from kernel", kfvKey(t).c_str()); + + //Remove neigh from SAI + if (removeNeighbor(neighbor_entry)) + { + it = consumer.m_toSync.erase(it); + } + else + { + SWSS_LOG_ERROR("Failed to remove voq neighbor %s from SAI", kfvKey(t).c_str()); + it++; + } + } + else + /* Cannot locate the neighbor */ + it = consumer.m_toSync.erase(it); + } + else + { + SWSS_LOG_ERROR("Unknown operation type %s", op.c_str()); + it = consumer.m_toSync.erase(it); + } + } +} + +bool NeighOrch::addInbandNeighbor(string alias, IpAddress ip_address) +{ + //For "port" type inband, the inband reachability info syncing can be done through static + //configureation or GLOBAL_APP_DB sync (this function) + + //For "vlan" type inband, the inband reachability info syncinng can be ARP learning of other + //asics inband or static configuration or through GLOBAL_APP_DB sync (this function) + + //May implement inband rechability info syncing through GLOBAL_APP_DB sync here + + return true; +} + +bool NeighOrch::delInbandNeighbor(string alias, IpAddress ip_address) +{ + //Remove inband rechability info sync + + return true; +} + +bool NeighOrch::getSystemPortNeighEncapIndex(string alias, uint32_t &encap_index) +{ + string value; + if(m_tableVoqSystemNeighTable->hget(alias, "encap_index", value)) + { + encap_index = (uint32_t) stoul(value); + return true; + } + return false; +} + +bool NeighOrch::addVoqEncapIndex(string &alias, IpAddress &ip, vector &neighbor_attrs) +{ + sai_attribute_t attr; + uint32_t encap_index = 0; + string appKey = alias + ":" + ip.to_string(); + + if(getSystemPortNeighEncapIndex(appKey, encap_index)) + { + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX; + attr.value.u32 = encap_index; + neighbor_attrs.push_back(attr); + + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_IMPOSE_INDEX; + attr.value.booldata = true; + neighbor_attrs.push_back(attr); + } + else + { + //No Encap index available. Check if remote system port + if(gIntfsOrch->isRemoteSystemPortIntf(alias)) + { + //Encap index not available and the interface is remote. Return false to re-try + SWSS_LOG_NOTICE("System port neighbor encap index is not available for remote neighbor %s. Re-try!", appKey.c_str()); + return false; + } + } + + return true; +} + +bool NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry) +{ + sai_attribute_t attr; + sai_status_t status; + + //Sync only local neigh. Confirm for the local neigh and + //get the system port alias for key for syncing to GLOBAL_APP_DB + Port port; + if(gPortsOrch->getPort(alias, port)) + { + if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) + { + return true; + } + alias = port.m_system_port_info.alias; + } + else + { + SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); + return false; + } + + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX; + + status = sai_neighbor_api->get_neighbor_entry_attribute(&neighbor_entry, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get neighbor attribute for %s on %s, rv:%d", ip_address.to_string().c_str(), alias.c_str(), status); + return false; + } + + vector attrs; + + FieldValueTuple eiFv ("encap_index", to_string(attr.value.u32)); + attrs.push_back(eiFv); + + FieldValueTuple macFv ("neigh", mac.to_string()); + attrs.push_back(macFv); + + string key = alias + ":" + ip_address.to_string(); + m_tableVoqSystemNeighTable->set(key, attrs); + + return true; +} + +bool NeighOrch::voqSyncDelNeigh(string &alias, IpAddress &ip_address) +{ + //Sync only local neigh. Confirm for the local neigh and + //get the system port alias for key for syncing to GLOBAL_APP_DB + Port port; + if(gPortsOrch->getPort(alias, port)) + { + if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) + { + return true; + } + alias = port.m_system_port_info.alias; + } + else + { + SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); + return false; + } + + string key = alias + ":" + ip_address.to_string(); + m_tableVoqSystemNeighTable->del(key); + + return true; +} + +bool NeighOrch::addKernelRoute(string odev, IpAddress ip_addr) +{ + string cmd, res; + + SWSS_LOG_ENTER(); + + string ip_str = ip_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = "ip route add " + ip_str + "/32 dev " + odev; + SWSS_LOG_NOTICE("IPv4 Route Add cmd: %s",cmd.c_str()); + } + else + { + cmd = "ip -6 route add " + ip_str + "/128 dev " + odev; + SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to add route for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Added route for %s on device %s", ip_str.c_str(), odev.c_str()); + return true; +} + +bool NeighOrch::delKernelRoute(IpAddress ip_addr) +{ + string cmd, res; + + SWSS_LOG_ENTER(); + + string ip_str = ip_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = "ip route del " + ip_str + "/32"; + SWSS_LOG_NOTICE("IPv4 Route Del cmd: %s",cmd.c_str()); + } + else + { + cmd = "ip -6 route del " + ip_str + "/128"; + SWSS_LOG_NOTICE("IPv6 Route Del cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to delete route for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Deleted route for %s", ip_str.c_str()); + return true; +} + +bool NeighOrch::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr) +{ + SWSS_LOG_ENTER(); + + string cmd, res; + string ip_str = ip_addr.to_string(); + string mac_str = mac_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = "arp -s " + ip_str + " " + mac_str + " -i " + odev; + SWSS_LOG_NOTICE("IPv4 Nbr Add cmd: %s",cmd.c_str()); + } + else + { + cmd = "ip -6 neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv6 Nbr Add cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Added Nbr for %s on interface %s", ip_str.c_str(), odev.c_str()); + return true; +} + +bool NeighOrch::delKernelNeigh(string odev, IpAddress ip_addr) +{ + string cmd, res; + + SWSS_LOG_ENTER(); + + string ip_str = ip_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = "arp -d " + ip_str + " -i " + odev; + SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str()); + } + else + { + cmd = "ip -6 neigh del " + ip_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to delete Nbr for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Deleted Nbr for %s on interface %s", ip_str.c_str(), odev.c_str()); return true; } diff --git a/orchagent/neighorch.h b/orchagent/neighorch.h index 60c40f9053..87af4b6493 100644 --- a/orchagent/neighorch.h +++ b/orchagent/neighorch.h @@ -35,7 +35,7 @@ struct NeighborUpdate class NeighOrch : public Orch, public Subject { public: - NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch); + NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DBConnector *globalAppDb); bool hasNextHop(const NextHopKey&); @@ -51,6 +51,8 @@ class NeighOrch : public Orch, public Subject bool ifChangeInformNextHop(const string &, bool); bool isNextHopFlagSet(const NextHopKey &, const uint32_t); + bool addInbandNeighbor(string alias, IpAddress ip_address); + bool delInbandNeighbor(string alias, IpAddress ip_address); private: IntfsOrch *m_intfsOrch; @@ -67,6 +69,17 @@ class NeighOrch : public Orch, public Subject bool clearNextHopFlag(const NextHopKey &, const uint32_t); void doTask(Consumer &consumer); + void doVoqSystemNeighTask(Consumer &consumer); + + unique_ptr
m_tableVoqSystemNeighTable; + bool getSystemPortNeighEncapIndex(string alias, uint32_t &encap_index); + bool addVoqEncapIndex(string &alias, IpAddress &ip, vector &neighbor_attrs); + bool addKernelRoute(string odev, IpAddress ip_addr); + bool delKernelRoute(IpAddress ip_addr); + bool addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr); + bool delKernelNeigh(string odev, IpAddress ip_addr); + bool voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry); + bool voqSyncDelNeigh(string &alias, IpAddress &ip_address); }; #endif /* SWSS_NEIGHORCH_H */ diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index d1d8f56ab6..6b0996594f 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -126,7 +126,7 @@ bool OrchDaemon::init() gDirectory.set(chassis_frontend_orch); gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, vrf_orch, m_globalAppDb); - gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch); + gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch, m_globalAppDb); gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, vrf_orch); TableConnector confDbSflowTable(m_configDb, CFG_SFLOW_TABLE_NAME); diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 0482c8f53b..110b96e1fb 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4714,6 +4714,24 @@ bool PortsOrch::addSystemPorts() return true; } +bool PortsOrch::getInbandPort(Port &port) +{ + if (m_portList.find(m_inbandPortName) == m_portList.end()) + { + return false; + } + else + { + port = m_portList[m_inbandPortName]; + return true; + } +} + +bool PortsOrch::isInbandPort(const string &alias) +{ + return (m_inbandPortName == alias); +} + bool PortsOrch::setVoqInbandIntf(string &alias, string &type) { if(m_inbandPortName == alias) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 0a28f2044c..86235a5968 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -92,6 +92,7 @@ class PortsOrch : public Orch, public Subject bool getPortByBridgePortId(sai_object_id_t bridge_port_id, Port &port); void setPort(string alias, Port port); void getCpuPort(Port &port); + bool getInbandPort(Port &port); bool getVlanByVlanId(sai_vlan_id_t vlan_id, Port &vlan); bool getAclBindPortId(string alias, sai_object_id_t &port_id); @@ -129,6 +130,7 @@ class PortsOrch : public Orch, public Subject void getLagMember(Port &lag, vector &portv); string m_inbandPortName = ""; + bool isInbandPort(const string &alias); bool setVoqInbandIntf(string &alias, string &type); private: diff --git a/tests/mock_tests/aclorch_ut.cpp b/tests/mock_tests/aclorch_ut.cpp index 94fd27f8ee..b0a4f646e5 100644 --- a/tests/mock_tests/aclorch_ut.cpp +++ b/tests/mock_tests/aclorch_ut.cpp @@ -317,7 +317,7 @@ namespace aclorch_test gIntfsOrch = new IntfsOrch(m_app_db.get(), APP_INTF_TABLE_NAME, gVrfOrch, m_global_app_db.get()); ASSERT_EQ(gNeighOrch, nullptr); - gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch); + gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch, m_global_app_db.get()); ASSERT_EQ(gRouteOrch, nullptr); gRouteOrch = new RouteOrch(m_app_db.get(), APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, gVrfOrch); From 2ca2a00bb625c1b5100518d079f036e560d2fb51 Mon Sep 17 00:00:00 2001 From: vedganes Date: Tue, 29 Sep 2020 01:06:23 -0400 Subject: [PATCH 06/21] [swss] Review comments fixes Signed-off-by: vedganes --- cfgmgr/intfmgr.cpp | 59 ++---------- cfgmgr/intfmgr.h | 1 - orchagent/intfsorch.cpp | 65 ++++--------- orchagent/intfsorch.h | 6 +- orchagent/main.cpp | 18 ++-- orchagent/neighorch.cpp | 128 ++++++++++++++------------ orchagent/neighorch.h | 6 +- orchagent/orch.cpp | 2 +- orchagent/orch.h | 1 - orchagent/orchdaemon.cpp | 8 +- orchagent/orchdaemon.h | 2 +- tests/mock_tests/aclorch_ut.cpp | 8 +- tests/mock_tests/database_config.json | 12 +-- 13 files changed, 130 insertions(+), 186 deletions(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 9bd43abf86..b08e768ff3 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -628,11 +628,6 @@ void IntfMgr::doTask(Consumer &consumer) SWSS_LOG_ENTER(); string table_name = consumer.getTableName(); - if(table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME) - { - doCfgVoqInbandInterfaceTask(consumer); - return; - } auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) @@ -645,60 +640,22 @@ void IntfMgr::doTask(Consumer &consumer) if (keys.size() == 1) { - if (!doIntfGeneralTask(keys, data, op)) + if((table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME) && + (op == SET_COMMAND)) { - it++; + //No further processing needed. Just relay to orchagent + m_appIntfTableProducer.set(keys[0], data); + m_stateIntfTable.hset(keys[0], "vrf", ""); + + it = consumer.m_toSync.erase(it); continue; } - } - else if (keys.size() == 2) - { - if (!doIntfAddrTask(keys, data, op)) + if (!doIntfGeneralTask(keys, data, op)) { it++; continue; } } - else - { - SWSS_LOG_ERROR("Invalid key %s", kfvKey(t).c_str()); - } - - it = consumer.m_toSync.erase(it); - } -} - -void IntfMgr::doCfgVoqInbandInterfaceTask(Consumer &consumer) -{ - SWSS_LOG_ENTER(); - - auto it = consumer.m_toSync.begin(); - while (it != consumer.m_toSync.end()) - { - KeyOpFieldsValuesTuple t = it->second; - - vector keys = tokenize(kfvKey(t), config_db_key_delimiter); - const vector& data = kfvFieldsValues(t); - string op = kfvOp(t); - string alias(keys[0]); - - if (keys.size() == 1) - { - if(op == SET_COMMAND) - { - //No further processing. Just push to orchagent - m_appIntfTableProducer.set(alias, data); - m_stateIntfTable.hset(alias, "vrf", ""); - } - else if(op == DEL_COMMAND) - { - if (!doIntfGeneralTask(keys, data, op)) - { - it++; - continue; - } - } - } else if (keys.size() == 2) { if (!doIntfAddrTask(keys, data, op)) diff --git a/cfgmgr/intfmgr.h b/cfgmgr/intfmgr.h index 44716c16b3..340c4cd04a 100644 --- a/cfgmgr/intfmgr.h +++ b/cfgmgr/intfmgr.h @@ -32,7 +32,6 @@ class IntfMgr : public Orch bool doIntfAddrTask(const std::vector& keys, const std::vector& data, const std::string& op); void doTask(Consumer &consumer); - void doCfgVoqInbandInterfaceTask(Consumer &consumer); bool isIntfStateOk(const std::string &alias); bool isIntfCreated(const std::string &alias); bool isIntfChangeVrf(const std::string &alias, const std::string &vrfName); diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index 63a7948a9e..12fb7ad904 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -55,7 +55,7 @@ static const vector rifStatIds = SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS, }; -IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *globalAppDb) : +IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *chassisAppDb) : Orch(db, tableName, intfsorch_pri), m_vrfOrch(vrf_orch) { SWSS_LOG_ENTER(); @@ -103,9 +103,9 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBCon if(gMySwitchType == "voq") { //Add subscriber to process VOQ system interface - tableName = VOQ_SYSTEM_INTERFACE_TABLE_NAME; - Orch::addExecutor(new Consumer(new SubscriberStateTable(globalAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); - m_tableVoqSystemInterfaceTable = unique_ptr
(new Table(globalAppDb, VOQ_SYSTEM_INTERFACE_TABLE_NAME)); + tableName = CHASSIS_APP_SYSTEM_INTERFACE_TABLE_NAME; + Orch::addExecutor(new Consumer(new SubscriberStateTable(chassisAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); + m_tableVoqSystemInterfaceTable = unique_ptr
(new Table(chassisAppDb, CHASSIS_APP_SYSTEM_INTERFACE_TABLE_NAME)); } } @@ -552,7 +552,7 @@ void IntfsOrch::doTask(Consumer &consumer) ip_prefix_in_key = true; } - if(table_name == VOQ_SYSTEM_INTERFACE_TABLE_NAME) + if(table_name == CHASSIS_APP_SYSTEM_INTERFACE_TABLE_NAME) { if(!isRemoteSystemPortIntf(alias)) { @@ -1038,8 +1038,8 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port) if(gMySwitchType == "voq") { - //Sync the interface to add to the SYSTEM_INTERFACE table of GLOBAL_APP_DB - voqSyncAddIntf(port.m_alias, port.m_rif_id); + //Sync the interface to add to the SYSTEM_INTERFACE table of CHASSIS_APP_DB + voqSyncAddIntf(port.m_alias); } return true; @@ -1074,7 +1074,7 @@ bool IntfsOrch::removeRouterIntfs(Port &port) if(gMySwitchType == "voq") { - //Sync the interface to del from the SYSTEM_INTERFACE table of GLOBAL_APP_DB + //Sync the interface to del from the SYSTEM_INTERFACE table of CHASSIS_APP_DB voqSyncDelIntf(port.m_alias); } @@ -1338,76 +1338,51 @@ bool IntfsOrch::isRemoteSystemPortIntf(string alias) return false; } -bool IntfsOrch::voqSyncAddIntf(string &alias, sai_object_id_t &rif_id) +void IntfsOrch::voqSyncAddIntf(string &alias) { //Sync only local interface. Confirm for the local interface and - //get the system port alias for key for syncing + //get the system port alias for key for syncing to CHASSIS_APP_DB Port port; if(gPortsOrch->getPort(alias, port)) { if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) { - return true; + return; } alias = port.m_system_port_info.alias; } else { SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); - return false; + return; } - //Get router interface to make sure it exists - sai_attribute_t attr; - sai_status_t status; - - attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID; + FieldValueTuple nullFv ("NULL", "NULL"); + vector attrs; + attrs.push_back(nullFv); - status = sai_router_intfs_api->get_router_interface_attribute(rif_id, 1, &attr); - if (status != SAI_STATUS_SUCCESS) - { - SWSS_LOG_ERROR("Failed to get rif for %s:0x%lx, rv:%d", alias.c_str(), rif_id, status); - return false; - } - - //Get the Real ID of the RIF ID - string value; - const auto id = sai_serialize_object_id(rif_id); - - if (m_vidToRidTable->hget("", id, value)) - { - FieldValueTuple rifIdFv ("rif_id", value); - vector attrs; - attrs.push_back(rifIdFv); - - m_tableVoqSystemInterfaceTable->set(alias, attrs); - return true; - } - SWSS_LOG_ERROR("Failed to get real ID from ASIC DB for RIF id 0x%lx of %s", rif_id, alias.c_str()); - return false; + m_tableVoqSystemInterfaceTable->set(alias, attrs); } -bool IntfsOrch::voqSyncDelIntf(string &alias) +void IntfsOrch::voqSyncDelIntf(string &alias) { //Sync only local interface. Confirm for the local interface and - //get the system port alias for key for syncing to GLOBAL_APP_DB + //get the system port alias for key for syncing to CHASSIS_APP_DB Port port; if(gPortsOrch->getPort(alias, port)) { if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) { - return true; + return; } alias = port.m_system_port_info.alias; } else { SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); - return false; + return; } m_tableVoqSystemInterfaceTable->del(alias); - - return true; } diff --git a/orchagent/intfsorch.h b/orchagent/intfsorch.h index d21aa286ef..088edc5851 100644 --- a/orchagent/intfsorch.h +++ b/orchagent/intfsorch.h @@ -32,7 +32,7 @@ typedef map IntfsTable; class IntfsOrch : public Orch { public: - IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *globalAppDb); + IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *chassisAppDb); sai_object_id_t getRouterIntfsId(const string&); bool isPrefixSubnet(const IpPrefix&, const string&); @@ -98,8 +98,8 @@ class IntfsOrch : public Orch bool setIntfProxyArp(const string &alias, const string &proxy_arp); unique_ptr
m_tableVoqSystemInterfaceTable; - bool voqSyncAddIntf(string &alias, sai_object_id_t &rif_id); - bool voqSyncDelIntf(string &alias); + void voqSyncAddIntf(string &alias); + void voqSyncDelIntf(string &alias); }; diff --git a/orchagent/main.cpp b/orchagent/main.cpp index bac0ea8b96..8b7bc3450c 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -382,11 +382,6 @@ int main(int argc, char **argv) attrs.push_back(attr); } - /* Must be last Attribute */ - attr.id = SAI_REDIS_SWITCH_ATTR_CONTEXT; - attr.value.u64 = gSwitchId; - attrs.push_back(attr); - // SAI_REDIS_SWITCH_ATTR_SYNC_MODE attribute only setBuffer and g_syncMode to true // since it is not using ASIC_DB, we can execute it before create_switch // when g_syncMode is set to true here, create_switch will wait the response from syncd @@ -435,6 +430,11 @@ int main(int argc, char **argv) } } + /* Must be last Attribute */ + attr.id = SAI_REDIS_SWITCH_ATTR_CONTEXT; + attr.value.u64 = gSwitchId; + attrs.push_back(attr); + status = sai_switch_api->create_switch(&gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { @@ -518,17 +518,17 @@ int main(int argc, char **argv) DBConnector config_db("CONFIG_DB", 0); DBConnector state_db("STATE_DB", 0); - shared_ptr global_app_db; + shared_ptr chassis_app_db; if(gMySwitchType == "voq") { - //Connection for GLOBAL_APP_DB in redis-server in control/supervisor card as per + //Connection for CHASSIS_APP_DB in redis-server in control/supervisor card as per //connection info in database_config.json - global_app_db = make_shared("GLOBAL_APP_DB", 0, true); + chassis_app_db = make_shared("CHASSIS_APP_DB", 0, true); } init_gearbox_phys(&appl_db); - auto orchDaemon = make_shared(&appl_db, &config_db, &state_db, global_app_db.get()); + auto orchDaemon = make_shared(&appl_db, &config_db, &state_db, chassis_app_db.get()); if (!orchDaemon->init()) { diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index 885d8b8577..855cfa546f 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -7,6 +7,8 @@ #include "subscriberstatetable.h" #include "exec.h" +#define IP_CMD "/sbin/ip" + extern sai_neighbor_api_t* sai_neighbor_api; extern sai_next_hop_api_t* sai_next_hop_api; @@ -18,7 +20,7 @@ extern string gMySwitchType; const int neighorch_pri = 30; -NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DBConnector *globalAppDb) : +NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DBConnector *chassisAppDb) : Orch(db, tableName, neighorch_pri), m_intfsOrch(intfsOrch) { SWSS_LOG_ENTER(); @@ -26,9 +28,9 @@ NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DB if(gMySwitchType == "voq") { //Add subscriber to process VOQ system neigh - tableName = VOQ_SYSTEM_NEIGH_TABLE_NAME; - Orch::addExecutor(new Consumer(new SubscriberStateTable(globalAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); - m_tableVoqSystemNeighTable = unique_ptr
(new Table(globalAppDb, VOQ_SYSTEM_NEIGH_TABLE_NAME)); + tableName = CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME; + Orch::addExecutor(new Consumer(new SubscriberStateTable(chassisAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); + m_tableVoqSystemNeighTable = unique_ptr
(new Table(chassisAppDb, CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME)); } } @@ -54,10 +56,10 @@ bool NeighOrch::addNextHop(const IpAddress &ipAddress, const string &alias) { //For remote system ports kernel nexthops are always on inband. Change the key Port inbp; - if(gPortsOrch->getInbandPort(inbp)) - { - nexthop.alias = inbp.m_alias; - } + gPortsOrch->getInbandPort(inbp); + assert(inbp.m_alias.length()); + + nexthop.alias = inbp.m_alias; } assert(!hasNextHop(nexthop)); sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(alias); @@ -238,10 +240,10 @@ bool NeighOrch::removeNextHop(const IpAddress &ipAddress, const string &alias) { //For remote system ports kernel nexthops are always on inband. Change the key Port inbp; - if(gPortsOrch->getInbandPort(inbp)) - { - nexthop.alias = inbp.m_alias; - } + gPortsOrch->getInbandPort(inbp); + assert(inbp.m_alias.length()); + + nexthop.alias = inbp.m_alias; } assert(hasNextHop(nexthop)); @@ -324,7 +326,7 @@ void NeighOrch::doTask(Consumer &consumer) } string table_name = consumer.getTableName(); - if(table_name == VOQ_SYSTEM_NEIGH_TABLE_NAME) + if(table_name == CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME) { doVoqSystemNeighTask(consumer); return; @@ -356,10 +358,17 @@ void NeighOrch::doTask(Consumer &consumer) if(gPortsOrch->isInbandPort(alias)) { - //This is the neigh learned due to the kernel entry added on - //Inband interface for the remote system port neighbors. Skip - it = consumer.m_toSync.erase(it); - continue; + Port ibport; + gPortsOrch->getInbandPort(ibport); + if(ibport.m_type != Port::VLAN) + { + //For "port" type Inband, the neighbors are only remote neighbors. + //Hence, this is the neigh learned due to the kernel entry added on + //Inband interface for the remote system port neighbors. Skip + it = consumer.m_toSync.erase(it); + continue; + } + //For "vlan" type inband, may identify the remote neighbors and skip } IpAddress ip_address(key.substr(found+1)); @@ -535,7 +544,7 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress if(gMySwitchType == "voq") { - //Sync the neighbor to add to the GLOBAL_APP_DB + //Sync the neighbor to add to the CHASSIS_APP_DB voqSyncAddNeigh(alias, ip_address, macAddress, neighbor_entry); } @@ -555,10 +564,10 @@ bool NeighOrch::removeNeighbor(const NeighborEntry &neighborEntry) { //For remote system ports kernel nexthops are always on inband. Change the key Port inbp; - if(gPortsOrch->getInbandPort(inbp)) - { - nexthop.alias = inbp.m_alias; - } + gPortsOrch->getInbandPort(inbp); + assert(inbp.m_alias.length()); + + nexthop.alias = inbp.m_alias; } if (m_syncdNeighbors.find(neighborEntry) == m_syncdNeighbors.end()) @@ -652,7 +661,7 @@ bool NeighOrch::removeNeighbor(const NeighborEntry &neighborEntry) if(gMySwitchType == "voq") { - //Sync the neighbor to delete from the GLOBAL_APP_DB + //Sync the neighbor to delete from the CHASSIS_APP_DB voqSyncDelNeigh(alias, ip_address); } @@ -864,20 +873,23 @@ bool NeighOrch::addVoqEncapIndex(string &alias, IpAddress &ip, vectorisRemoteSystemPortIntf(alias)) { - attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX; - attr.value.u32 = encap_index; - neighbor_attrs.push_back(attr); + if(getSystemPortNeighEncapIndex(appKey, encap_index)) + { + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX; + attr.value.u32 = encap_index; + neighbor_attrs.push_back(attr); - attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_IMPOSE_INDEX; - attr.value.booldata = true; - neighbor_attrs.push_back(attr); - } - else - { - //No Encap index available. Check if remote system port - if(gIntfsOrch->isRemoteSystemPortIntf(alias)) + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_IMPOSE_INDEX; + attr.value.booldata = true; + neighbor_attrs.push_back(attr); + + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_IS_LOCAL; + attr.value.booldata = false; + neighbor_attrs.push_back(attr); + } + else { //Encap index not available and the interface is remote. Return false to re-try SWSS_LOG_NOTICE("System port neighbor encap index is not available for remote neighbor %s. Re-try!", appKey.c_str()); @@ -888,26 +900,26 @@ bool NeighOrch::addVoqEncapIndex(string &alias, IpAddress &ip, vectorgetPort(alias, port)) { if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) { - return true; + return; } alias = port.m_system_port_info.alias; } else { SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); - return false; + return; } attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX; @@ -916,7 +928,13 @@ bool NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get neighbor attribute for %s on %s, rv:%d", ip_address.to_string().c_str(), alias.c_str(), status); - return false; + return; + } + + if (!attr.value.u32) + { + SWSS_LOG_ERROR("Invalid neighbor encap_index for %s on %s", ip_address.to_string().c_str(), alias.c_str()); + return; } vector attrs; @@ -929,33 +947,29 @@ bool NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA string key = alias + ":" + ip_address.to_string(); m_tableVoqSystemNeighTable->set(key, attrs); - - return true; } -bool NeighOrch::voqSyncDelNeigh(string &alias, IpAddress &ip_address) +void NeighOrch::voqSyncDelNeigh(string &alias, IpAddress &ip_address) { //Sync only local neigh. Confirm for the local neigh and - //get the system port alias for key for syncing to GLOBAL_APP_DB + //get the system port alias for key for syncing to CHASSIS_APP_DB Port port; if(gPortsOrch->getPort(alias, port)) { if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE) { - return true; + return; } alias = port.m_system_port_info.alias; } else { SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str()); - return false; + return; } string key = alias + ":" + ip_address.to_string(); m_tableVoqSystemNeighTable->del(key); - - return true; } bool NeighOrch::addKernelRoute(string odev, IpAddress ip_addr) @@ -968,12 +982,12 @@ bool NeighOrch::addKernelRoute(string odev, IpAddress ip_addr) if(ip_addr.isV4()) { - cmd = "ip route add " + ip_str + "/32 dev " + odev; + cmd = string("") + IP_CMD + " route add " + ip_str + "/32 dev " + odev; SWSS_LOG_NOTICE("IPv4 Route Add cmd: %s",cmd.c_str()); } else { - cmd = "ip -6 route add " + ip_str + "/128 dev " + odev; + cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev; SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str()); } @@ -1000,12 +1014,12 @@ bool NeighOrch::delKernelRoute(IpAddress ip_addr) if(ip_addr.isV4()) { - cmd = "ip route del " + ip_str + "/32"; + cmd = string("") + IP_CMD + " route del " + ip_str + "/32"; SWSS_LOG_NOTICE("IPv4 Route Del cmd: %s",cmd.c_str()); } else { - cmd = "ip -6 route del " + ip_str + "/128"; + cmd = string("") + IP_CMD + " -6 route del " + ip_str + "/128"; SWSS_LOG_NOTICE("IPv6 Route Del cmd: %s",cmd.c_str()); } @@ -1032,12 +1046,12 @@ bool NeighOrch::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_ad if(ip_addr.isV4()) { - cmd = "arp -s " + ip_str + " " + mac_str + " -i " + odev; + cmd = string("") + IP_CMD + " neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; SWSS_LOG_NOTICE("IPv4 Nbr Add cmd: %s",cmd.c_str()); } else { - cmd = "ip -6 neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; + cmd = string("") + IP_CMD + " -6 neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; SWSS_LOG_NOTICE("IPv6 Nbr Add cmd: %s",cmd.c_str()); } @@ -1064,13 +1078,13 @@ bool NeighOrch::delKernelNeigh(string odev, IpAddress ip_addr) if(ip_addr.isV4()) { - cmd = "arp -d " + ip_str + " -i " + odev; + cmd = string("") + IP_CMD + " neigh del " + ip_str + " dev " + odev; SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str()); } else { - cmd = "ip -6 neigh del " + ip_str + " dev " + odev; - SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str()); + cmd = string("") + IP_CMD + " -6 neigh del " + ip_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv6 Nbr Del cmd: %s",cmd.c_str()); } int32_t ret = swss::exec(cmd, res); diff --git a/orchagent/neighorch.h b/orchagent/neighorch.h index 87af4b6493..9cbdc078b3 100644 --- a/orchagent/neighorch.h +++ b/orchagent/neighorch.h @@ -35,7 +35,7 @@ struct NeighborUpdate class NeighOrch : public Orch, public Subject { public: - NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DBConnector *globalAppDb); + NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DBConnector *chassisAppDb); bool hasNextHop(const NextHopKey&); @@ -78,8 +78,8 @@ class NeighOrch : public Orch, public Subject bool delKernelRoute(IpAddress ip_addr); bool addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr); bool delKernelNeigh(string odev, IpAddress ip_addr); - bool voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry); - bool voqSyncDelNeigh(string &alias, IpAddress &ip_address); + void voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry); + void voqSyncDelNeigh(string &alias, IpAddress &ip_address); }; #endif /* SWSS_NEIGHORCH_H */ diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 196f805201..31e217370a 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -557,7 +557,7 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin void Orch::addConsumer(DBConnector *db, string tableName, int pri) { - if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB || db->getDbId() == GLOBAL_APP_DB) + if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB || db->getDbId() == CHASSIS_APP_DB) { addExecutor(new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this, tableName)); } diff --git a/orchagent/orch.h b/orchagent/orch.h index b921013fe9..456885491a 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -28,7 +28,6 @@ const char comma = ','; const char range_specifier = '-'; const char config_db_key_delimiter = '|'; const char state_db_key_delimiter = '|'; -const char global_app_db_key_delimiter = ':'; #define INVM_PLATFORM_SUBSTRING "innovium" #define MLNX_PLATFORM_SUBSTRING "mellanox" diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 6b0996594f..f3712634c7 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -39,11 +39,11 @@ NatOrch *gNatOrch; bool gIsNatSupported = false; -OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb, DBConnector *globalAppDb) : +OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb, DBConnector *chassisAppDb) : m_applDb(applDb), m_configDb(configDb), m_stateDb(stateDb), - m_globalAppDb(globalAppDb) + m_chassisAppDb(chassisAppDb) { SWSS_LOG_ENTER(); } @@ -125,8 +125,8 @@ bool OrchDaemon::init() ChassisOrch* chassis_frontend_orch = new ChassisOrch(m_configDb, m_applDb, chassis_frontend_tables, vnet_rt_orch); gDirectory.set(chassis_frontend_orch); - gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, vrf_orch, m_globalAppDb); - gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch, m_globalAppDb); + gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, vrf_orch, m_chassisAppDb); + gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch, m_chassisAppDb); gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, vrf_orch); TableConnector confDbSflowTable(m_configDb, CFG_SFLOW_TABLE_NAME); diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 218327f84f..41e48495bc 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -51,7 +51,7 @@ class OrchDaemon DBConnector *m_applDb; DBConnector *m_configDb; DBConnector *m_stateDb; - DBConnector *m_globalAppDb; + DBConnector *m_chassisAppDb; std::vector m_orchList; Select *m_select; diff --git a/tests/mock_tests/aclorch_ut.cpp b/tests/mock_tests/aclorch_ut.cpp index b0a4f646e5..0113edd443 100644 --- a/tests/mock_tests/aclorch_ut.cpp +++ b/tests/mock_tests/aclorch_ut.cpp @@ -182,7 +182,7 @@ namespace aclorch_test shared_ptr m_app_db; shared_ptr m_config_db; shared_ptr m_state_db; - shared_ptr m_global_app_db; + shared_ptr m_chassis_app_db; AclOrchTest() { @@ -191,7 +191,7 @@ namespace aclorch_test m_config_db = make_shared("CONFIG_DB", 0); m_state_db = make_shared("STATE_DB", 0); if(gMySwitchType == "voq") - m_global_app_db = make_shared("GLOBAL_APP_DB", 0); + m_chassis_app_db = make_shared("CHASSIS_APP_DB", 0); } static map gProfileMap; @@ -314,10 +314,10 @@ namespace aclorch_test gVrfOrch = new VRFOrch(m_app_db.get(), APP_VRF_TABLE_NAME, m_state_db.get(), STATE_VRF_OBJECT_TABLE_NAME); ASSERT_EQ(gIntfsOrch, nullptr); - gIntfsOrch = new IntfsOrch(m_app_db.get(), APP_INTF_TABLE_NAME, gVrfOrch, m_global_app_db.get()); + gIntfsOrch = new IntfsOrch(m_app_db.get(), APP_INTF_TABLE_NAME, gVrfOrch, m_chassis_app_db.get()); ASSERT_EQ(gNeighOrch, nullptr); - gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch, m_global_app_db.get()); + gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch, m_chassis_app_db.get()); ASSERT_EQ(gRouteOrch, nullptr); gRouteOrch = new RouteOrch(m_app_db.get(), APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, gVrfOrch); diff --git a/tests/mock_tests/database_config.json b/tests/mock_tests/database_config.json index 2e68bb381f..42f9989c2b 100644 --- a/tests/mock_tests/database_config.json +++ b/tests/mock_tests/database_config.json @@ -5,10 +5,10 @@ "port" : 6379, "unix_socket_path" : "/var/run/redis/redis.sock" }, - "redis-global_db":{ + "redis_chassis":{ "hostname" : "240.127.1.1", "port" : 6380, - "unix_socket_path" : "/var/run/redis/redis-global_db.sock" + "unix_socket_path" : "/var/run/redis/redis_chassis.sock" } }, "DATABASES" : { @@ -57,10 +57,10 @@ "separator": "|", "instance" : "redis" }, - "GLOBAL_APP_DB" : { - "id" : 11, - "separator": ":", - "instance" : "redis-global_db" + "CHASSIS_APP_DB" : { + "id" : 8, + "separator": "|", + "instance" : "redis_chassis" } }, "VERSION" : "1.0" From 8e235e6dca5b5966244becfb927095f76959c9e6 Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 1 Oct 2020 10:39:08 -0400 Subject: [PATCH 07/21] [swss]Code review comments fix 2 Signed-off-by: vedganes Kernel programming of static neigh and full mask static route for system neighbors is moved to nbrmgr since orchagent should not own kernel objects to avoid complication in warmboot reconciliation The orchagent programms only SAI object for the system neighbors and signals the completion of SAI programming by setting mac address in SYSTE_NEIGH table of STATE_DB. Nbrmgr subscribes to these state entries to program kernel entries corresponding to the system neighs --- cfgmgr/nbrmgr.cpp | 263 ++++++++++++++++++++++++++++++++++++++++ cfgmgr/nbrmgr.h | 7 ++ orchagent/neighorch.cpp | 230 ++++++----------------------------- orchagent/neighorch.h | 7 +- 4 files changed, 311 insertions(+), 196 deletions(-) diff --git a/cfgmgr/nbrmgr.cpp b/cfgmgr/nbrmgr.cpp index 3b919a7daa..67737d62a9 100644 --- a/cfgmgr/nbrmgr.cpp +++ b/cfgmgr/nbrmgr.cpp @@ -11,6 +11,7 @@ #include "nbrmgr.h" #include "exec.h" #include "shellcmd.h" +#include "subscriberstatetable.h" using namespace swss; @@ -59,6 +60,20 @@ NbrMgr::NbrMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, con { SWSS_LOG_ERROR("Netlink socket connect failed, error '%s'", nl_geterror(err)); } + + string swtype; + Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME); + if(cfgDeviceMetaDataTable.hget("localhost", "switch_type", swtype)) + { + //If this is voq system, let the neighbor manager subscribe to state of SYSTEM_NEIGH + //entries. This is used to program static neigh and static route in kernel for remote neighbors. + if(swtype == "voq") + { + string tableName = STATE_SYSTEM_NEIGH_TABLE_NAME; + Orch::addExecutor(new Consumer(new SubscriberStateTable(stateDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); + m_cfgVoqInbandInterfaceTable = unique_ptr
(new Table(cfgDb, CFG_VOQ_INBAND_INTERFACE_TABLE_NAME)); + } + } } bool NbrMgr::isIntfStateOk(const string &alias) @@ -189,6 +204,13 @@ void NbrMgr::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); + string table_name = consumer.getTableName(); + if(table_name == STATE_SYSTEM_NEIGH_TABLE_NAME) + { + doStateSystemNeighTask(consumer); + return; + } + auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { @@ -257,3 +279,244 @@ void NbrMgr::doTask(Consumer &consumer) it = consumer.m_toSync.erase(it); } } + +void NbrMgr::doStateSystemNeighTask(Consumer &consumer) +{ + SWSS_LOG_ENTER(); + + //Get the name of the device on which the neigh and route are + //going to be programmed. + string nbr_odev; + if(!getVoqInbandInterfaceName(nbr_odev)) + { + //The inband interface is not available yet + return; + } + + auto it = consumer.m_toSync.begin(); + while (it != consumer.m_toSync.end()) + { + KeyOpFieldsValuesTuple t = it->second; + string key = kfvKey(t); + string op = kfvOp(t); + + size_t found = key.find_last_of(state_db_key_delimiter); + if (found == string::npos) + { + SWSS_LOG_ERROR("Failed to parse key %s", key.c_str()); + it = consumer.m_toSync.erase(it); + continue; + } + + IpAddress ip_address(key.substr(found+1)); + if (op == SET_COMMAND) + { + MacAddress mac_address; + for (auto i = kfvFieldsValues(t).begin(); + i != kfvFieldsValues(t).end(); i++) + { + if (fvField(*i) == "neigh") + mac_address = MacAddress(fvValue(*i)); + } + + if (!isIntfStateOk(nbr_odev)) + { + SWSS_LOG_DEBUG("Interface %s is not ready, skipping system neigh %s'", nbr_odev.c_str(), kfvKey(t).c_str()); + it++; + continue; + } + + if (!addKernelNeigh(nbr_odev, ip_address, mac_address)) + { + SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + it++; + continue; + } + else + { + SWSS_LOG_NOTICE("Neigh entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + + if (!addKernelRoute(nbr_odev, ip_address)) + { + SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + delKernelNeigh(nbr_odev, ip_address); + it++; + continue; + } + else + { + SWSS_LOG_NOTICE("Route entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + SWSS_LOG_NOTICE("Added voq neighbor %s to kernel", kfvKey(t).c_str()); + } + else if (op == DEL_COMMAND) + { + if (!delKernelRoute(ip_address)) + { + SWSS_LOG_ERROR("Route entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + else + { + SWSS_LOG_NOTICE("Route entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + + if (!delKernelNeigh(nbr_odev, ip_address)) + { + SWSS_LOG_ERROR("Neigh entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + else + { + SWSS_LOG_NOTICE("Neigh entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); + } + SWSS_LOG_DEBUG("Deleted voq neighbor %s from kernel", kfvKey(t).c_str()); + } + + it = consumer.m_toSync.erase(it); + } +} + +bool NbrMgr::getVoqInbandInterfaceName(string &ibif) +{ + + vector keys; + m_cfgVoqInbandInterfaceTable->getKeys(keys); + + if (keys.empty()) + { + SWSS_LOG_NOTICE("Voq Inband interface is not configured!"); + return false; + } + //key:"alias" = inband interface name + vector if_keys = tokenize(keys[0], config_db_key_delimiter); + ibif = if_keys[0]; + return true; +} + +bool NbrMgr::addKernelRoute(string odev, IpAddress ip_addr) +{ + string cmd, res; + + SWSS_LOG_ENTER(); + + string ip_str = ip_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = string("") + IP_CMD + " route add " + ip_str + "/32 dev " + odev; + SWSS_LOG_NOTICE("IPv4 Route Add cmd: %s",cmd.c_str()); + } + else + { + cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev; + SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to add route for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Added route for %s on device %s", ip_str.c_str(), odev.c_str()); + return true; +} + +bool NbrMgr::delKernelRoute(IpAddress ip_addr) +{ + string cmd, res; + + SWSS_LOG_ENTER(); + + string ip_str = ip_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = string("") + IP_CMD + " route del " + ip_str + "/32"; + SWSS_LOG_NOTICE("IPv4 Route Del cmd: %s",cmd.c_str()); + } + else + { + cmd = string("") + IP_CMD + " -6 route del " + ip_str + "/128"; + SWSS_LOG_NOTICE("IPv6 Route Del cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to delete route for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Deleted route for %s", ip_str.c_str()); + return true; +} + +bool NbrMgr::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr) +{ + SWSS_LOG_ENTER(); + + string cmd, res; + string ip_str = ip_addr.to_string(); + string mac_str = mac_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = string("") + IP_CMD + " neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv4 Nbr Add cmd: %s",cmd.c_str()); + } + else + { + cmd = string("") + IP_CMD + " -6 neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv6 Nbr Add cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Added Nbr for %s on interface %s", ip_str.c_str(), odev.c_str()); + return true; +} + +bool NbrMgr::delKernelNeigh(string odev, IpAddress ip_addr) +{ + string cmd, res; + + SWSS_LOG_ENTER(); + + string ip_str = ip_addr.to_string(); + + if(ip_addr.isV4()) + { + cmd = string("") + IP_CMD + " neigh del " + ip_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str()); + } + else + { + cmd = string("") + IP_CMD + " -6 neigh del " + ip_str + " dev " + odev; + SWSS_LOG_NOTICE("IPv6 Nbr Del cmd: %s",cmd.c_str()); + } + + int32_t ret = swss::exec(cmd, res); + + if(ret) + { + /* Just log error and return */ + SWSS_LOG_ERROR("Failed to delete Nbr for %s, error: %d", ip_str.c_str(), ret); + return false; + } + + SWSS_LOG_INFO("Deleted Nbr for %s on interface %s", ip_str.c_str(), odev.c_str()); + return true; +} diff --git a/cfgmgr/nbrmgr.h b/cfgmgr/nbrmgr.h index 6b0c664c80..2c3ef47e56 100644 --- a/cfgmgr/nbrmgr.h +++ b/cfgmgr/nbrmgr.h @@ -27,6 +27,13 @@ class NbrMgr : public Orch bool setNeighbor(const std::string& alias, const IpAddress& ip, const MacAddress& mac); void doTask(Consumer &consumer); + void doStateSystemNeighTask(Consumer &consumer); + bool getVoqInbandInterfaceName(string &nbr_odev); + bool addKernelRoute(string odev, IpAddress ip_addr); + bool delKernelRoute(IpAddress ip_addr); + bool addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr); + bool delKernelNeigh(string odev, IpAddress ip_addr); + unique_ptr
m_cfgVoqInbandInterfaceTable; Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateIntfTable, m_stateNeighRestoreTable; struct nl_sock *m_nl_sock; diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index 855cfa546f..812b939558 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -5,9 +5,6 @@ #include "crmorch.h" #include "routeorch.h" #include "subscriberstatetable.h" -#include "exec.h" - -#define IP_CMD "/sbin/ip" extern sai_neighbor_api_t* sai_neighbor_api; extern sai_next_hop_api_t* sai_next_hop_api; @@ -31,6 +28,11 @@ NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch, DB tableName = CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME; Orch::addExecutor(new Consumer(new SubscriberStateTable(chassisAppDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName)); m_tableVoqSystemNeighTable = unique_ptr
(new Table(chassisAppDb, CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME)); + + //STATE DB connection for setting state of the remote neighbor SAI programming + unique_ptr stateDb; + stateDb = make_unique("STATE_DB", 0); + m_stateSystemNeighTable = unique_ptr
(new Table(stateDb.get(), STATE_SYSTEM_NEIGH_TABLE_NAME)); } } @@ -673,14 +675,12 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) SWSS_LOG_ENTER(); //Local inband port as the outgoing interface of the static neighbor and static route - Port port; - if(!gPortsOrch->getInbandPort(port)) + Port ibif; + if(!gPortsOrch->getInbandPort(ibif)) { //Inband port is not ready yet. return; } - string nbr_odev = port.m_alias; - MacAddress inband_mac = gMacAddress; auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) @@ -689,7 +689,7 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) string key = kfvKey(t); string op = kfvOp(t); - size_t found = key.find(':'); + size_t found = key.find_last_of(consumer.getConsumerTable()->getTableNameSeparator().c_str()); if (found == string::npos) { SWSS_LOG_ERROR("Failed to parse key %s", key.c_str()); @@ -710,6 +710,8 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) NeighborEntry neighbor_entry = { ip_address, alias }; + string state_key = alias + state_db_key_delimiter + ip_address.to_string(); + if (op == SET_COMMAND) { Port p; @@ -751,38 +753,27 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() || m_syncdNeighbors[neighbor_entry] != mac_address) { - if (!addKernelNeigh(nbr_odev, ip_address, inband_mac)) - { - SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - it++; - continue; - } - else - { - SWSS_LOG_NOTICE("Neigh entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - } - - if (!addKernelRoute(nbr_odev, ip_address)) - { - SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - delKernelNeigh(nbr_odev, ip_address); - it++; - continue; - } - else - { - SWSS_LOG_NOTICE("Route entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - } - SWSS_LOG_NOTICE("Added voq neighbor %s to kernel", kfvKey(t).c_str()); - //Add neigh to SAI if (addNeighbor(neighbor_entry, mac_address)) + { + //neigh successfully added to SAI. Set STATE DB to signal kernel programming by neighbor manager + + //If the inband interface type is not VLAN, same MAC can be used for the inband interface for + //kernel programming. + if(ibif.m_type != Port::VLAN) + { + mac_address = gMacAddress; + } + vector fvVector; + FieldValueTuple mac("neigh", mac_address.to_string()); + fvVector.push_back(mac); + m_stateSystemNeighTable->set(state_key, fvVector); + it = consumer.m_toSync.erase(it); + } else { SWSS_LOG_ERROR("Failed to add voq neighbor %s to SAI", kfvKey(t).c_str()); - delKernelRoute(ip_address); - delKernelNeigh(nbr_odev, ip_address); it++; } } @@ -794,28 +785,12 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) { if (m_syncdNeighbors.find(neighbor_entry) != m_syncdNeighbors.end()) { - if (!delKernelRoute(ip_address)) - { - SWSS_LOG_ERROR("Route entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - } - else - { - SWSS_LOG_NOTICE("Route entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - } - - if (!delKernelNeigh(nbr_odev, ip_address)) - { - SWSS_LOG_ERROR("Neigh entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - } - else - { - SWSS_LOG_NOTICE("Neigh entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str()); - } - SWSS_LOG_DEBUG("Deleted voq neighbor %s from kernel", kfvKey(t).c_str()); - //Remove neigh from SAI if (removeNeighbor(neighbor_entry)) { + //neigh successfully deleted from SAI. Set STATE DB to signal to remove entries from kernel + m_stateSystemNeighTable->del(state_key); + it = consumer.m_toSync.erase(it); } else @@ -839,12 +814,12 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) bool NeighOrch::addInbandNeighbor(string alias, IpAddress ip_address) { //For "port" type inband, the inband reachability info syncing can be done through static - //configureation or GLOBAL_APP_DB sync (this function) + //configureation or CHASSIS_APP_DB sync (this function) //For "vlan" type inband, the inband reachability info syncinng can be ARP learning of other - //asics inband or static configuration or through GLOBAL_APP_DB sync (this function) + //asics inband or static configuration or through CHASSIS_APP_DB sync (this function) - //May implement inband rechability info syncing through GLOBAL_APP_DB sync here + //May implement inband rechability info syncing through CHASSIS_APP_DB sync here return true; } @@ -856,10 +831,12 @@ bool NeighOrch::delInbandNeighbor(string alias, IpAddress ip_address) return true; } -bool NeighOrch::getSystemPortNeighEncapIndex(string alias, uint32_t &encap_index) +bool NeighOrch::getSystemPortNeighEncapIndex(string &alias, IpAddress &ip, uint32_t &encap_index) { string value; - if(m_tableVoqSystemNeighTable->hget(alias, "encap_index", value)) + string key = alias + m_tableVoqSystemNeighTable->getTableNameSeparator().c_str() + ip.to_string(); + + if(m_tableVoqSystemNeighTable->hget(key, "encap_index", value)) { encap_index = (uint32_t) stoul(value); return true; @@ -871,11 +848,10 @@ bool NeighOrch::addVoqEncapIndex(string &alias, IpAddress &ip, vectorisRemoteSystemPortIntf(alias)) { - if(getSystemPortNeighEncapIndex(appKey, encap_index)) + if(getSystemPortNeighEncapIndex(alias, ip, encap_index)) { attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX; attr.value.u32 = encap_index; @@ -892,7 +868,7 @@ bool NeighOrch::addVoqEncapIndex(string &alias, IpAddress &ip, vectorgetTableNameSeparator().c_str() + ip_address.to_string(); m_tableVoqSystemNeighTable->set(key, attrs); } @@ -968,134 +944,6 @@ void NeighOrch::voqSyncDelNeigh(string &alias, IpAddress &ip_address) return; } - string key = alias + ":" + ip_address.to_string(); + string key = alias + m_tableVoqSystemNeighTable->getTableNameSeparator().c_str() + ip_address.to_string(); m_tableVoqSystemNeighTable->del(key); } - -bool NeighOrch::addKernelRoute(string odev, IpAddress ip_addr) -{ - string cmd, res; - - SWSS_LOG_ENTER(); - - string ip_str = ip_addr.to_string(); - - if(ip_addr.isV4()) - { - cmd = string("") + IP_CMD + " route add " + ip_str + "/32 dev " + odev; - SWSS_LOG_NOTICE("IPv4 Route Add cmd: %s",cmd.c_str()); - } - else - { - cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev; - SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str()); - } - - int32_t ret = swss::exec(cmd, res); - - if(ret) - { - /* Just log error and return */ - SWSS_LOG_ERROR("Failed to add route for %s, error: %d", ip_str.c_str(), ret); - return false; - } - - SWSS_LOG_INFO("Added route for %s on device %s", ip_str.c_str(), odev.c_str()); - return true; -} - -bool NeighOrch::delKernelRoute(IpAddress ip_addr) -{ - string cmd, res; - - SWSS_LOG_ENTER(); - - string ip_str = ip_addr.to_string(); - - if(ip_addr.isV4()) - { - cmd = string("") + IP_CMD + " route del " + ip_str + "/32"; - SWSS_LOG_NOTICE("IPv4 Route Del cmd: %s",cmd.c_str()); - } - else - { - cmd = string("") + IP_CMD + " -6 route del " + ip_str + "/128"; - SWSS_LOG_NOTICE("IPv6 Route Del cmd: %s",cmd.c_str()); - } - - int32_t ret = swss::exec(cmd, res); - - if(ret) - { - /* Just log error and return */ - SWSS_LOG_ERROR("Failed to delete route for %s, error: %d", ip_str.c_str(), ret); - return false; - } - - SWSS_LOG_INFO("Deleted route for %s", ip_str.c_str()); - return true; -} - -bool NeighOrch::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr) -{ - SWSS_LOG_ENTER(); - - string cmd, res; - string ip_str = ip_addr.to_string(); - string mac_str = mac_addr.to_string(); - - if(ip_addr.isV4()) - { - cmd = string("") + IP_CMD + " neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; - SWSS_LOG_NOTICE("IPv4 Nbr Add cmd: %s",cmd.c_str()); - } - else - { - cmd = string("") + IP_CMD + " -6 neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev; - SWSS_LOG_NOTICE("IPv6 Nbr Add cmd: %s",cmd.c_str()); - } - - int32_t ret = swss::exec(cmd, res); - - if(ret) - { - /* Just log error and return */ - SWSS_LOG_ERROR("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret); - return false; - } - - SWSS_LOG_INFO("Added Nbr for %s on interface %s", ip_str.c_str(), odev.c_str()); - return true; -} - -bool NeighOrch::delKernelNeigh(string odev, IpAddress ip_addr) -{ - string cmd, res; - - SWSS_LOG_ENTER(); - - string ip_str = ip_addr.to_string(); - - if(ip_addr.isV4()) - { - cmd = string("") + IP_CMD + " neigh del " + ip_str + " dev " + odev; - SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str()); - } - else - { - cmd = string("") + IP_CMD + " -6 neigh del " + ip_str + " dev " + odev; - SWSS_LOG_NOTICE("IPv6 Nbr Del cmd: %s",cmd.c_str()); - } - - int32_t ret = swss::exec(cmd, res); - - if(ret) - { - /* Just log error and return */ - SWSS_LOG_ERROR("Failed to delete Nbr for %s, error: %d", ip_str.c_str(), ret); - return false; - } - - SWSS_LOG_INFO("Deleted Nbr for %s on interface %s", ip_str.c_str(), odev.c_str()); - return true; -} diff --git a/orchagent/neighorch.h b/orchagent/neighorch.h index 9cbdc078b3..a15f5c5d54 100644 --- a/orchagent/neighorch.h +++ b/orchagent/neighorch.h @@ -72,12 +72,9 @@ class NeighOrch : public Orch, public Subject void doVoqSystemNeighTask(Consumer &consumer); unique_ptr
m_tableVoqSystemNeighTable; - bool getSystemPortNeighEncapIndex(string alias, uint32_t &encap_index); + unique_ptr
m_stateSystemNeighTable; + bool getSystemPortNeighEncapIndex(string &alias, IpAddress &ip, uint32_t &encap_index); bool addVoqEncapIndex(string &alias, IpAddress &ip, vector &neighbor_attrs); - bool addKernelRoute(string odev, IpAddress ip_addr); - bool delKernelRoute(IpAddress ip_addr); - bool addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr); - bool delKernelNeigh(string odev, IpAddress ip_addr); void voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry); void voqSyncDelNeigh(string &alias, IpAddress &ip_address); }; From 8704004af24da62e91a7f2f21abe656695e6f258 Mon Sep 17 00:00:00 2001 From: vedganes Date: Sun, 11 Oct 2020 21:22:19 -0400 Subject: [PATCH 08/21] [swss] voq code review comment fix 3 Signed-off-by: vedganes --- orchagent/main.cpp | 132 +++++++++++++------------- tests/mock_tests/database_config.json | 2 +- 2 files changed, 69 insertions(+), 65 deletions(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index 8b7bc3450c..b5cade7b88 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -145,66 +145,65 @@ void init_gearbox_phys(DBConnector *applDb) delete tmpGearboxTable; } -bool getSystemPortConfigList(vector &sysportcfglist) +bool getCfgSwitchType(DBConnector *cfgDb, string &switch_type) { - DBConnector cfgDb("CONFIG_DB", 0); - DBConnector appDb("APPL_DB", 0); + Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME); - Table cfgDeviceMetaDataTable(&cfgDb, CFG_DEVICE_METADATA_TABLE_NAME); - Table cfgSystemPortTable(&cfgDb, CFG_SYSTEM_PORT_TABLE_NAME); - Table appSystemPortTable(&appDb, APP_SYSTEM_PORT_TABLE_NAME); - - //At this point of time (i.e, at the time of orchagent start), the CONFIG_DB is completely fully - //populated with the contents of config_db.json. - - string value; - //Get the swith type. - if(!cfgDeviceMetaDataTable.hget("localhost", "switch_type", value)) + if (!cfgDeviceMetaDataTable.hget("localhost", "switch_type", switch_type)) { //Switch type is not configured. Consider it default = "switch" (regular switch) - value = "switch"; + switch_type = "switch"; } - if(value != "voq" && value != "fabric" && value != "switch") + if (switch_type != "voq" && switch_type != "fabric" && switch_type != "switch") { - cout << "Invalid switch type " << value.c_str() << " configured"; + cout << "Invalid switch type " << switch_type.c_str() << " configured"; return false; } - gMySwitchType = value; - if(gMySwitchType != "voq") + return true; +} + +bool getSystemPortConfigList(DBConnector *cfgDb, DBConnector *appDb, vector &sysportcfglist) +{ + Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME); + Table cfgSystemPortTable(cfgDb, CFG_SYSTEM_PORT_TABLE_NAME); + Table appSystemPortTable(appDb, APP_SYSTEM_PORT_TABLE_NAME); + + if (gMySwitchType != "voq") { //Non VOQ switch. Nothing to read return true; } - if(!cfgDeviceMetaDataTable.hget("localhost", "switch_id", value)) + string value; + if (!cfgDeviceMetaDataTable.hget("localhost", "switch_id", value)) { //VOQ switch id is not configured. cout << "VOQ switch id is not configured"; return false; } - if(value.size()) + if (value.size()) gVoqMySwitchId = stoi(value); - if(gVoqMySwitchId < 0) + if (gVoqMySwitchId < 0) { cout << "Invalid VOQ switch id " << gVoqMySwitchId << " configured"; return false; } - if(!cfgDeviceMetaDataTable.hget("localhost", "max_cores", value)) + if (!cfgDeviceMetaDataTable.hget("localhost", "max_cores", value)) { //VOQ max cores is not configured. cout << "VOQ max cores is not configured"; return false; } - if(value.size()) + if (value.size()) gVoqMaxCores = stoi(value); - if(gVoqMaxCores == 0) + if (gVoqMaxCores == 0) { cout << "Invalid VOQ max cores " << gVoqMaxCores << " configured"; return false; @@ -216,37 +215,42 @@ bool getSystemPortConfigList(vector &sysportcfglist) //Retrieve system port configurations vector spFv; sai_system_port_config_t sysport; - for ( auto &k : spKeys ) + for (auto &k : spKeys) { cfgSystemPortTable.get(k, spFv); - for ( auto &fv : spFv ) + for (auto &fv : spFv) { - if(fv.first == "switch_id") + if (fv.first == "switch_id") { sysport.attached_switch_id = stoi(fv.second); continue; } - if(fv.first == "core_index") + if (fv.first == "core_index") { sysport.attached_core_index = stoi(fv.second); continue; } - if(fv.first == "core_port_index") + if (fv.first == "core_port_index") { sysport.attached_core_port_index = stoi(fv.second); continue; } - if(fv.first == "speed") + if (fv.first == "speed") { sysport.speed = stoi(fv.second); continue; } - if(fv.first == "system_port_id") + if (fv.first == "system_port_id") { sysport.port_id = stoi(fv.second); continue; } + if (fv.first == "num_voq") + { + sysport.num_voq = stoi(fv.second); + continue; + } } //Add to system port config list sysportcfglist.push_back(sysport); @@ -401,33 +405,44 @@ int main(int argc, char **argv) attrs.push_back(attr); } - //Get info required for VOQ system + // Instantiate database connectors + DBConnector appl_db("APPL_DB", 0); + DBConnector config_db("CONFIG_DB", 0); + DBConnector state_db("STATE_DB", 0); + + // Get Switch type + getCfgSwitchType(&config_db, gMySwitchType); + + // Get info required for VOQ system and connect to CHASSISS_APP_DB + shared_ptr chassis_app_db; vector sysportconfiglist; - if(getSystemPortConfigList(sysportconfiglist)) + if ((gMySwitchType == "voq") && + (getSystemPortConfigList(&config_db, &appl_db, sysportconfiglist))) { - if (gMySwitchType == "voq") - { - attr.id = SAI_SWITCH_ATTR_TYPE; - attr.value.u32 = SAI_SWITCH_TYPE_VOQ; - attrs.push_back(attr); + attr.id = SAI_SWITCH_ATTR_TYPE; + attr.value.u32 = SAI_SWITCH_TYPE_VOQ; + attrs.push_back(attr); - attr.id = SAI_SWITCH_ATTR_SWITCH_ID; - attr.value.u32 = gVoqMySwitchId; - attrs.push_back(attr); + attr.id = SAI_SWITCH_ATTR_SWITCH_ID; + attr.value.u32 = gVoqMySwitchId; + attrs.push_back(attr); - attr.id = SAI_SWITCH_ATTR_MAX_SYSTEM_CORES; - attr.value.u32 = gVoqMaxCores; - attrs.push_back(attr); + attr.id = SAI_SWITCH_ATTR_MAX_SYSTEM_CORES; + attr.value.u32 = gVoqMaxCores; + attrs.push_back(attr); - gCfgSystemPorts = (uint32_t) sysportconfiglist.size(); - if(gCfgSystemPorts) - { - attr.id = SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST; - attr.value.sysportconfiglist.count = gCfgSystemPorts; - attr.value.sysportconfiglist.list = sysportconfiglist.data(); - attrs.push_back(attr); - } + gCfgSystemPorts = (uint32_t) sysportconfiglist.size(); + if (gCfgSystemPorts) + { + attr.id = SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST; + attr.value.sysportconfiglist.count = gCfgSystemPorts; + attr.value.sysportconfiglist.list = sysportconfiglist.data(); + attrs.push_back(attr); } + + //Connect to CHASSIS_APP_DB in redis-server in control/supervisor card as per + //connection info in database_config.json + chassis_app_db = make_shared("CHASSIS_APP_DB", 0, true); } /* Must be last Attribute */ @@ -514,18 +529,7 @@ int main(int argc, char **argv) SWSS_LOG_NOTICE("Created underlay router interface ID %" PRIx64, gUnderlayIfId); /* Initialize orchestration components */ - DBConnector appl_db("APPL_DB", 0); - DBConnector config_db("CONFIG_DB", 0); - DBConnector state_db("STATE_DB", 0); - - shared_ptr chassis_app_db; - if(gMySwitchType == "voq") - { - //Connection for CHASSIS_APP_DB in redis-server in control/supervisor card as per - //connection info in database_config.json - chassis_app_db = make_shared("CHASSIS_APP_DB", 0, true); - } - + init_gearbox_phys(&appl_db); auto orchDaemon = make_shared(&appl_db, &config_db, &state_db, chassis_app_db.get()); diff --git a/tests/mock_tests/database_config.json b/tests/mock_tests/database_config.json index 42f9989c2b..1b6343d20e 100644 --- a/tests/mock_tests/database_config.json +++ b/tests/mock_tests/database_config.json @@ -58,7 +58,7 @@ "instance" : "redis" }, "CHASSIS_APP_DB" : { - "id" : 8, + "id" : 12, "separator": "|", "instance" : "redis_chassis" } From 8b68af47a6b77161a245284ae5fc7b7bedc054eb Mon Sep 17 00:00:00 2001 From: vedganes Date: Mon, 12 Oct 2020 20:58:38 -0400 Subject: [PATCH 09/21] [swss] voq code review comments fixes 4 Signed-off-by: vedganes --- orchagent/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index b5cade7b88..2a21334b6c 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -379,6 +379,14 @@ int main(int argc, char **argv) attr.value.ptr = (void *)on_switch_shutdown_request; attrs.push_back(attr); + // Instantiate database connectors + DBConnector appl_db("APPL_DB", 0); + DBConnector config_db("CONFIG_DB", 0); + DBConnector state_db("STATE_DB", 0); + + // Get switch_type + getCfgSwitchType(&config_db, gMySwitchType); + if (gMacAddress) { attr.id = SAI_SWITCH_ATTR_SRC_MAC_ADDRESS; @@ -405,14 +413,6 @@ int main(int argc, char **argv) attrs.push_back(attr); } - // Instantiate database connectors - DBConnector appl_db("APPL_DB", 0); - DBConnector config_db("CONFIG_DB", 0); - DBConnector state_db("STATE_DB", 0); - - // Get Switch type - getCfgSwitchType(&config_db, gMySwitchType); - // Get info required for VOQ system and connect to CHASSISS_APP_DB shared_ptr chassis_app_db; vector sysportconfiglist; From 52972b6c49b9499f0622ff2c72c6ae4ff10798c1 Mon Sep 17 00:00:00 2001 From: vedganes Date: Thu, 22 Oct 2020 12:48:50 -0400 Subject: [PATCH 10/21] [swss] Voq code review comments fixes 5 Signed-off-by: vedganes --- orchagent/main.cpp | 12 ++++++++---- orchagent/neighorch.cpp | 3 +++ orchagent/portsorch.cpp | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index 2a21334b6c..2fa3dfc0ac 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -145,7 +145,7 @@ void init_gearbox_phys(DBConnector *applDb) delete tmpGearboxTable; } -bool getCfgSwitchType(DBConnector *cfgDb, string &switch_type) +void getCfgSwitchType(DBConnector *cfgDb, string &switch_type) { Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME); @@ -158,10 +158,9 @@ bool getCfgSwitchType(DBConnector *cfgDb, string &switch_type) if (switch_type != "voq" && switch_type != "fabric" && switch_type != "switch") { cout << "Invalid switch type " << switch_type.c_str() << " configured"; - return false; + //If configured switch type is none of the supported, assume regular switch + switch_type = "switch"; } - - return true; } bool getSystemPortConfigList(DBConnector *cfgDb, DBConnector *appDb, vector &sysportcfglist) @@ -439,6 +438,11 @@ int main(int argc, char **argv) attr.value.sysportconfiglist.list = sysportconfiglist.data(); attrs.push_back(attr); } + else + { + SWSS_LOG_ERROR("Voq switch create with 0 system ports!"); + exit(EXIT_FAILURE); + } //Connect to CHASSIS_APP_DB in redis-server in control/supervisor card as per //connection info in database_config.json diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index 8b2e8d88f0..4e26132a5c 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -783,8 +783,11 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) } } else + { /* Duplicate entry */ + SWSS_LOG_INFO("System neighbor %s already exists", kfvKey(t).c_str()); it = consumer.m_toSync.erase(it); + } } else if (op == DEL_COMMAND) { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 7f1d63ff00..c7b9bdf79d 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4711,7 +4711,7 @@ bool PortsOrch::addSystemPorts() //System port does not exist in the switch //This can not happen since all the system ports are supposed to be created during switch creation itself - SWSS_LOG_NOTICE("System port %s does not exist in switch. Port not added!", alias.c_str()); + SWSS_LOG_ERROR("System port %s does not exist in switch. Port not added!", alias.c_str()); continue; } } From 34e9f682d30306bbe07db327e946b1aaa2e6c920 Mon Sep 17 00:00:00 2001 From: vedganes Date: Sun, 8 Nov 2020 21:58:29 -0500 Subject: [PATCH 11/21] [swss]VS tests for VOQ system ports Signed-off-by: vedganes VOQ Switch tests are added for VS tests. The following tests are added as part of virtual chassis tests - VOQ switch objects verification - System port object syncing with chassis app db by checking presence of system port RIFs in chassis app db in supervisor card - Creation of system port RIF record creation in ASIC_DB Following changes are done for the above tests: - SYSTEM_PORT table is added in default_config.json of line cards. These are loaded as part of config_db loading - Core and Port index mapping file is added in line card directories. This file is added to hwsku directory for processing by VS SAI --- tests/test_virtual_chassis.py | 95 +++ tests/virtual_chassis/1/coreportindexmap.ini | 32 + tests/virtual_chassis/1/default_config.json | 679 ++++++++++++++++++- tests/virtual_chassis/2/coreportindexmap.ini | 32 + tests/virtual_chassis/2/default_config.json | 679 ++++++++++++++++++- tests/virtual_chassis/3/coreportindexmap.ini | 32 + tests/virtual_chassis/3/default_config.json | 679 ++++++++++++++++++- 7 files changed, 2225 insertions(+), 3 deletions(-) create mode 100644 tests/virtual_chassis/1/coreportindexmap.ini create mode 100644 tests/virtual_chassis/2/coreportindexmap.ini create mode 100644 tests/virtual_chassis/3/coreportindexmap.ini diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index ed27e45f78..1279394c9d 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -1,4 +1,6 @@ import pytest +from swsscommon import swsscommon +import ast class TestVirtualChassis(object): def test_connectivity(self, vct): @@ -24,3 +26,96 @@ def test_connectivity(self, vct): _, out = dv.runcmd(['sh', "-c", "ping -c 5 -W 0 -q %s" % ip]) print(out) assert '5 received' in out + + def test_voq_switch(self, vct): + """ Test VOQ switch objects configuration """ + dvss = vct.dvss + for name in dvss.keys(): + if not name.startswith("supervisor"): + print("VOQ Switch test for {}".format(name)) + dvs = dvss[name] + #Get the config info + config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) + metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + + status, cfg_switch_id = metatbl.hget("localhost", "switch_id") + assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" + + status, cfg_max_cores = metatbl.hget("localhost", "max_cores") + assert status, "Got error in getting max_cores from CONFIG_DB DEVICE_METADATA" + + cfgsptbl = swsscommon.Table(config_db, "SYSTEM_PORT") + cfgspkeys = cfgsptbl.getKeys() + sp_count = len(cfgspkeys) + + asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) + tbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_SWITCH") + keys = list(tbl.getKeys()) + switch_oid_key = keys[0] + + status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_TYPE") + assert status, "Got error while getting switch type" + assert value == "SAI_SWITCH_TYPE_VOQ", "Switch type is not VOQ" + + status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_SWITCH_ID") + assert status, "Got error while getting switch id" + assert value == cfg_switch_id, "VOQ switch id is invalid" + + status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_MAX_SYSTEM_CORES") + assert status, "Got error while getting max system cores" + assert value == cfg_max_cores, "Max system cores is invalid" + + status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST") + assert status, "Got error while getting system port config list" + #Convert the spcfg string to dictionary + spcfg = ast.literal_eval(value) + assert spcfg['count'] == sp_count, "Number of systems ports configured is invalid" + + def test_chassis_app_db_sync(self, vct): + """ Test chassis app db syncing """ + dvss = vct.dvss + for name in dvss.keys(): + if name.startswith("supervisor"): + dvs = dvss[name] + chassis_app_db = swsscommon.DBConnector(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock, 0) + tbl = swsscommon.Table(chassis_app_db, "SYSTEM_INTERFACE") + keys = list(tbl.getKeys()) + assert len(keys), "No chassis app db syncing is done" + + def test_chassis_system_interface(self, vct): + """ Test RIF record creation in ASIC_DB for remote interfaces """ + dvss = vct.dvss + for name in dvss.keys(): + if not name.startswith("supervisor"): + dvs = dvss[name] + config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) + metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + status, lc_switch_id = metatbl.hget("localhost", "switch_id") + assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" + if lc_switch_id == "0": + #Testing in Linecard1, In Linecard1 there will be RIF for Ethernet12 from Linecard3 + #Note: Tesing can be done in any linecard for RIF of any system port interface + asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) + riftbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") + keys = list(riftbl.getKeys()) + assert len(keys), "No router interfaces in ASIC_DB" + + rif_port_oid = "" + for key in keys: + status, value = riftbl.hget(key, "SAI_ROUTER_INTERFACE_ATTR_TYPE") + assert status, "Got error in getting RIF type" + if value == "SAI_ROUTER_INTERFACE_TYPE_PORT": + status, value = riftbl.hget(key, "SAI_ROUTER_INTERFACE_ATTR_PORT_ID") + assert status, "Got error in getting RIF port" + if value.startswith("oid:0x5d"): + #System port RIF, this is used as key for system port config info retrieval + rif_port_oid = value + break + + assert rif_port_oid != "", "No RIF records for remote interfaces in ASIC_DB" + #Validate if the system port is from valid switch + sptbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_SYSTEM_PORT") + status, value = sptbl.hget(rif_port_oid, "SAI_SYSTEM_PORT_ATTR_CONFIG_INFO") + assert status, "Got error in getting system port config info for rif system port" + spcfginfo = ast.literal_eval(value) + assert spcfginfo["attached_switch_id"] != lc_switch_id, "RIF system port with wrong switch_id" diff --git a/tests/virtual_chassis/1/coreportindexmap.ini b/tests/virtual_chassis/1/coreportindexmap.ini new file mode 100644 index 0000000000..2445e45d00 --- /dev/null +++ b/tests/virtual_chassis/1/coreportindexmap.ini @@ -0,0 +1,32 @@ +eth1:0,1 +eth2:0,2 +eth3:0,3 +eth4:0,4 +eth5:0,5 +eth6:0,6 +eth7:0,7 +eth8:0,8 +eth9:0,9 +eth10:0,10 +eth11:0,11 +eth12:0,12 +eth13:0,13 +eth14:0,14 +eth15:0,15 +eth16:0,16 +eth17:1,1 +eth18:1,2 +eth19:1,3 +eth20:1,4 +eth21:1,5 +eth22:1,6 +eth23:1,7 +eth24:1,8 +eth25:1,9 +eth26:1,10 +eth27:1,11 +eth28:1,12 +eth29:1,13 +eth30:1,14 +eth31:1,15 +eth32:1,16 diff --git a/tests/virtual_chassis/1/default_config.json b/tests/virtual_chassis/1/default_config.json index 638843c5d5..8952380199 100644 --- a/tests/virtual_chassis/1/default_config.json +++ b/tests/virtual_chassis/1/default_config.json @@ -5,7 +5,10 @@ "instance_name": "Linecard1", "connect_to_chassis_db" : 1, "chassis_db_address" : "10.8.1.200", - "inband_address" : "10.8.1.1/24" + "inband_address" : "10.8.1.1/24", + "switch_type": "voq", + "switch_id": "0", + "max_cores": "48" } }, "INTERFACE": { @@ -21,5 +24,679 @@ "Ethernet4": { "admin_status": "up" } + }, + "SYSTEM_PORT": { + "Linecard1|Ethernet0": { + "speed": "40000", + "system_port_id": "1", + "switch_id": "0", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard1|Ethernet4": { + "speed": "40000", + "system_port_id": "2", + "switch_id": "0", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard1|Ethernet8": { + "speed": "40000", + "system_port_id": "3", + "switch_id": "0", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard1|Ethernet12": { + "speed": "40000", + "system_port_id": "4", + "switch_id": "0", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard1|Ethernet16": { + "speed": "40000", + "system_port_id": "5", + "switch_id": "0", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard1|Ethernet20": { + "speed": "40000", + "system_port_id": "6", + "switch_id": "0", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard1|Ethernet24": { + "speed": "40000", + "system_port_id": "7", + "switch_id": "0", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard1|Ethernet28": { + "speed": "40000", + "system_port_id": "8", + "switch_id": "0", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard1|Ethernet32": { + "speed": "40000", + "system_port_id": "9", + "switch_id": "0", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard1|Ethernet36": { + "speed": "40000", + "system_port_id": "10", + "switch_id": "0", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard1|Ethernet40": { + "speed": "40000", + "system_port_id": "11", + "switch_id": "0", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard1|Ethernet44": { + "speed": "40000", + "system_port_id": "12", + "switch_id": "0", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard1|Ethernet48": { + "speed": "40000", + "system_port_id": "13", + "switch_id": "0", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard1|Ethernet52": { + "speed": "40000", + "system_port_id": "14", + "switch_id": "0", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard1|Ethernet56": { + "speed": "40000", + "system_port_id": "15", + "switch_id": "0", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard1|Ethernet60": { + "speed": "40000", + "system_port_id": "16", + "switch_id": "0", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard1|Ethernet64": { + "speed": "40000", + "system_port_id": "17", + "switch_id": "0", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard1|Ethernet68": { + "speed": "40000", + "system_port_id": "18", + "switch_id": "0", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard1|Ethernet72": { + "speed": "40000", + "system_port_id": "19", + "switch_id": "0", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard1|Ethernet76": { + "speed": "40000", + "system_port_id": "20", + "switch_id": "0", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard1|Ethernet80": { + "speed": "40000", + "system_port_id": "21", + "switch_id": "0", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard1|Ethernet84": { + "speed": "40000", + "system_port_id": "22", + "switch_id": "0", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard1|Ethernet88": { + "speed": "40000", + "system_port_id": "23", + "switch_id": "0", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard1|Ethernet92": { + "speed": "40000", + "system_port_id": "24", + "switch_id": "0", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard1|Ethernet96": { + "speed": "40000", + "system_port_id": "25", + "switch_id": "0", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard1|Ethernet100": { + "speed": "40000", + "system_port_id": "26", + "switch_id": "0", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard1|Ethernet104": { + "speed": "40000", + "system_port_id": "27", + "switch_id": "0", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard1|Ethernet108": { + "speed": "40000", + "system_port_id": "28", + "switch_id": "0", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard1|Ethernet112": { + "speed": "40000", + "system_port_id": "29", + "switch_id": "0", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard1|Ethernet116": { + "speed": "40000", + "system_port_id": "30", + "switch_id": "0", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard1|Ethernet120": { + "speed": "40000", + "system_port_id": "31", + "switch_id": "0", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard1|Ethernet124": { + "speed": "40000", + "system_port_id": "32", + "switch_id": "0", + "core_index": "1", + "core_port_index": "16" + }, + "Linecard2|Ethernet0": { + "speed": "40000", + "system_port_id": "33", + "switch_id": "1", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard2|Ethernet4": { + "speed": "40000", + "system_port_id": "34", + "switch_id": "1", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard2|Ethernet8": { + "speed": "40000", + "system_port_id": "35", + "switch_id": "1", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard2|Ethernet12": { + "speed": "40000", + "system_port_id": "36", + "switch_id": "1", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard2|Ethernet16": { + "speed": "40000", + "system_port_id": "37", + "switch_id": "1", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard2|Ethernet20": { + "speed": "40000", + "system_port_id": "38", + "switch_id": "1", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard2|Ethernet24": { + "speed": "40000", + "system_port_id": "39", + "switch_id": "1", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard2|Ethernet28": { + "speed": "40000", + "system_port_id": "40", + "switch_id": "1", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard2|Ethernet32": { + "speed": "40000", + "system_port_id": "41", + "switch_id": "1", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard2|Ethernet36": { + "speed": "40000", + "system_port_id": "42", + "switch_id": "1", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard2|Ethernet40": { + "speed": "40000", + "system_port_id": "43", + "switch_id": "1", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard2|Ethernet44": { + "speed": "40000", + "system_port_id": "44", + "switch_id": "1", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard2|Ethernet48": { + "speed": "40000", + "system_port_id": "45", + "switch_id": "1", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard2|Ethernet52": { + "speed": "40000", + "system_port_id": "46", + "switch_id": "1", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard2|Ethernet56": { + "speed": "40000", + "system_port_id": "47", + "switch_id": "1", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard2|Ethernet60": { + "speed": "40000", + "system_port_id": "48", + "switch_id": "1", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard2|Ethernet64": { + "speed": "40000", + "system_port_id": "49", + "switch_id": "1", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard2|Ethernet68": { + "speed": "40000", + "system_port_id": "50", + "switch_id": "1", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard2|Ethernet72": { + "speed": "40000", + "system_port_id": "51", + "switch_id": "1", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard2|Ethernet76": { + "speed": "40000", + "system_port_id": "52", + "switch_id": "1", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard2|Ethernet80": { + "speed": "40000", + "system_port_id": "53", + "switch_id": "1", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard2|Ethernet84": { + "speed": "40000", + "system_port_id": "54", + "switch_id": "1", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard2|Ethernet88": { + "speed": "40000", + "system_port_id": "55", + "switch_id": "1", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard2|Ethernet92": { + "speed": "40000", + "system_port_id": "56", + "switch_id": "1", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard2|Ethernet96": { + "speed": "40000", + "system_port_id": "57", + "switch_id": "1", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard2|Ethernet100": { + "speed": "40000", + "system_port_id": "58", + "switch_id": "1", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard2|Ethernet104": { + "speed": "40000", + "system_port_id": "59", + "switch_id": "1", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard2|Ethernet108": { + "speed": "40000", + "system_port_id": "60", + "switch_id": "1", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard2|Ethernet112": { + "speed": "40000", + "system_port_id": "61", + "switch_id": "1", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard2|Ethernet116": { + "speed": "40000", + "system_port_id": "62", + "switch_id": "1", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard2|Ethernet120": { + "speed": "40000", + "system_port_id": "63", + "switch_id": "1", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard2|Ethernet124": { + "speed": "40000", + "system_port_id": "64", + "switch_id": "1", + "core_index": "1", + "core_port_index": "16" + }, + "Linecard3|Ethernet0": { + "speed": "40000", + "system_port_id": "65", + "switch_id": "2", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard3|Ethernet4": { + "speed": "40000", + "system_port_id": "66", + "switch_id": "2", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard3|Ethernet8": { + "speed": "40000", + "system_port_id": "67", + "switch_id": "2", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard3|Ethernet12": { + "speed": "40000", + "system_port_id": "68", + "switch_id": "2", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard3|Ethernet16": { + "speed": "40000", + "system_port_id": "69", + "switch_id": "2", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard3|Ethernet20": { + "speed": "40000", + "system_port_id": "70", + "switch_id": "2", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard3|Ethernet24": { + "speed": "40000", + "system_port_id": "71", + "switch_id": "2", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard3|Ethernet28": { + "speed": "40000", + "system_port_id": "72", + "switch_id": "2", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard3|Ethernet32": { + "speed": "40000", + "system_port_id": "73", + "switch_id": "2", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard3|Ethernet36": { + "speed": "40000", + "system_port_id": "74", + "switch_id": "2", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard3|Ethernet40": { + "speed": "40000", + "system_port_id": "75", + "switch_id": "2", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard3|Ethernet44": { + "speed": "40000", + "system_port_id": "76", + "switch_id": "2", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard3|Ethernet48": { + "speed": "40000", + "system_port_id": "77", + "switch_id": "2", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard3|Ethernet52": { + "speed": "40000", + "system_port_id": "78", + "switch_id": "2", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard3|Ethernet56": { + "speed": "40000", + "system_port_id": "79", + "switch_id": "2", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard3|Ethernet60": { + "speed": "40000", + "system_port_id": "80", + "switch_id": "2", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard3|Ethernet64": { + "speed": "40000", + "system_port_id": "81", + "switch_id": "2", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard3|Ethernet68": { + "speed": "40000", + "system_port_id": "82", + "switch_id": "2", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard3|Ethernet72": { + "speed": "40000", + "system_port_id": "83", + "switch_id": "2", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard3|Ethernet76": { + "speed": "40000", + "system_port_id": "84", + "switch_id": "2", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard3|Ethernet80": { + "speed": "40000", + "system_port_id": "85", + "switch_id": "2", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard3|Ethernet84": { + "speed": "40000", + "system_port_id": "86", + "switch_id": "2", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard3|Ethernet88": { + "speed": "40000", + "system_port_id": "87", + "switch_id": "2", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard3|Ethernet92": { + "speed": "40000", + "system_port_id": "88", + "switch_id": "2", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard3|Ethernet96": { + "speed": "40000", + "system_port_id": "89", + "switch_id": "2", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard3|Ethernet100": { + "speed": "40000", + "system_port_id": "90", + "switch_id": "2", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard3|Ethernet104": { + "speed": "40000", + "system_port_id": "91", + "switch_id": "2", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard3|Ethernet108": { + "speed": "40000", + "system_port_id": "92", + "switch_id": "2", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard3|Ethernet112": { + "speed": "40000", + "system_port_id": "93", + "switch_id": "2", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard3|Ethernet116": { + "speed": "40000", + "system_port_id": "94", + "switch_id": "2", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard3|Ethernet120": { + "speed": "40000", + "system_port_id": "95", + "switch_id": "2", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard3|Ethernet124": { + "speed": "40000", + "system_port_id": "96", + "switch_id": "2", + "core_index": "1", + "core_port_index": "16" + } } } diff --git a/tests/virtual_chassis/2/coreportindexmap.ini b/tests/virtual_chassis/2/coreportindexmap.ini new file mode 100644 index 0000000000..2445e45d00 --- /dev/null +++ b/tests/virtual_chassis/2/coreportindexmap.ini @@ -0,0 +1,32 @@ +eth1:0,1 +eth2:0,2 +eth3:0,3 +eth4:0,4 +eth5:0,5 +eth6:0,6 +eth7:0,7 +eth8:0,8 +eth9:0,9 +eth10:0,10 +eth11:0,11 +eth12:0,12 +eth13:0,13 +eth14:0,14 +eth15:0,15 +eth16:0,16 +eth17:1,1 +eth18:1,2 +eth19:1,3 +eth20:1,4 +eth21:1,5 +eth22:1,6 +eth23:1,7 +eth24:1,8 +eth25:1,9 +eth26:1,10 +eth27:1,11 +eth28:1,12 +eth29:1,13 +eth30:1,14 +eth31:1,15 +eth32:1,16 diff --git a/tests/virtual_chassis/2/default_config.json b/tests/virtual_chassis/2/default_config.json index af85811a85..b4dc1a35a0 100644 --- a/tests/virtual_chassis/2/default_config.json +++ b/tests/virtual_chassis/2/default_config.json @@ -5,7 +5,10 @@ "instance_name": "Linecard2", "connect_to_chassis_db" : 1, "chassis_db_address" : "10.8.1.200", - "inband_address" : "10.8.1.2/24" + "inband_address" : "10.8.1.2/24", + "switch_type": "voq", + "switch_id": "2", + "max_cores": "48" } }, "INTERFACE": { @@ -16,5 +19,679 @@ "Ethernet0": { "admin_status": "up" } + }, + "SYSTEM_PORT": { + "Linecard1|Ethernet0": { + "speed": "40000", + "system_port_id": "1", + "switch_id": "0", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard1|Ethernet4": { + "speed": "40000", + "system_port_id": "2", + "switch_id": "0", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard1|Ethernet8": { + "speed": "40000", + "system_port_id": "3", + "switch_id": "0", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard1|Ethernet12": { + "speed": "40000", + "system_port_id": "4", + "switch_id": "0", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard1|Ethernet16": { + "speed": "40000", + "system_port_id": "5", + "switch_id": "0", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard1|Ethernet20": { + "speed": "40000", + "system_port_id": "6", + "switch_id": "0", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard1|Ethernet24": { + "speed": "40000", + "system_port_id": "7", + "switch_id": "0", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard1|Ethernet28": { + "speed": "40000", + "system_port_id": "8", + "switch_id": "0", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard1|Ethernet32": { + "speed": "40000", + "system_port_id": "9", + "switch_id": "0", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard1|Ethernet36": { + "speed": "40000", + "system_port_id": "10", + "switch_id": "0", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard1|Ethernet40": { + "speed": "40000", + "system_port_id": "11", + "switch_id": "0", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard1|Ethernet44": { + "speed": "40000", + "system_port_id": "12", + "switch_id": "0", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard1|Ethernet48": { + "speed": "40000", + "system_port_id": "13", + "switch_id": "0", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard1|Ethernet52": { + "speed": "40000", + "system_port_id": "14", + "switch_id": "0", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard1|Ethernet56": { + "speed": "40000", + "system_port_id": "15", + "switch_id": "0", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard1|Ethernet60": { + "speed": "40000", + "system_port_id": "16", + "switch_id": "0", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard1|Ethernet64": { + "speed": "40000", + "system_port_id": "17", + "switch_id": "0", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard1|Ethernet68": { + "speed": "40000", + "system_port_id": "18", + "switch_id": "0", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard1|Ethernet72": { + "speed": "40000", + "system_port_id": "19", + "switch_id": "0", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard1|Ethernet76": { + "speed": "40000", + "system_port_id": "20", + "switch_id": "0", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard1|Ethernet80": { + "speed": "40000", + "system_port_id": "21", + "switch_id": "0", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard1|Ethernet84": { + "speed": "40000", + "system_port_id": "22", + "switch_id": "0", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard1|Ethernet88": { + "speed": "40000", + "system_port_id": "23", + "switch_id": "0", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard1|Ethernet92": { + "speed": "40000", + "system_port_id": "24", + "switch_id": "0", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard1|Ethernet96": { + "speed": "40000", + "system_port_id": "25", + "switch_id": "0", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard1|Ethernet100": { + "speed": "40000", + "system_port_id": "26", + "switch_id": "0", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard1|Ethernet104": { + "speed": "40000", + "system_port_id": "27", + "switch_id": "0", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard1|Ethernet108": { + "speed": "40000", + "system_port_id": "28", + "switch_id": "0", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard1|Ethernet112": { + "speed": "40000", + "system_port_id": "29", + "switch_id": "0", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard1|Ethernet116": { + "speed": "40000", + "system_port_id": "30", + "switch_id": "0", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard1|Ethernet120": { + "speed": "40000", + "system_port_id": "31", + "switch_id": "0", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard1|Ethernet124": { + "speed": "40000", + "system_port_id": "32", + "switch_id": "0", + "core_index": "1", + "core_port_index": "16" + }, + "Linecard2|Ethernet0": { + "speed": "40000", + "system_port_id": "33", + "switch_id": "1", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard2|Ethernet4": { + "speed": "40000", + "system_port_id": "34", + "switch_id": "1", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard2|Ethernet8": { + "speed": "40000", + "system_port_id": "35", + "switch_id": "1", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard2|Ethernet12": { + "speed": "40000", + "system_port_id": "36", + "switch_id": "1", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard2|Ethernet16": { + "speed": "40000", + "system_port_id": "37", + "switch_id": "1", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard2|Ethernet20": { + "speed": "40000", + "system_port_id": "38", + "switch_id": "1", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard2|Ethernet24": { + "speed": "40000", + "system_port_id": "39", + "switch_id": "1", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard2|Ethernet28": { + "speed": "40000", + "system_port_id": "40", + "switch_id": "1", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard2|Ethernet32": { + "speed": "40000", + "system_port_id": "41", + "switch_id": "1", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard2|Ethernet36": { + "speed": "40000", + "system_port_id": "42", + "switch_id": "1", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard2|Ethernet40": { + "speed": "40000", + "system_port_id": "43", + "switch_id": "1", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard2|Ethernet44": { + "speed": "40000", + "system_port_id": "44", + "switch_id": "1", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard2|Ethernet48": { + "speed": "40000", + "system_port_id": "45", + "switch_id": "1", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard2|Ethernet52": { + "speed": "40000", + "system_port_id": "46", + "switch_id": "1", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard2|Ethernet56": { + "speed": "40000", + "system_port_id": "47", + "switch_id": "1", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard2|Ethernet60": { + "speed": "40000", + "system_port_id": "48", + "switch_id": "1", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard2|Ethernet64": { + "speed": "40000", + "system_port_id": "49", + "switch_id": "1", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard2|Ethernet68": { + "speed": "40000", + "system_port_id": "50", + "switch_id": "1", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard2|Ethernet72": { + "speed": "40000", + "system_port_id": "51", + "switch_id": "1", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard2|Ethernet76": { + "speed": "40000", + "system_port_id": "52", + "switch_id": "1", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard2|Ethernet80": { + "speed": "40000", + "system_port_id": "53", + "switch_id": "1", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard2|Ethernet84": { + "speed": "40000", + "system_port_id": "54", + "switch_id": "1", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard2|Ethernet88": { + "speed": "40000", + "system_port_id": "55", + "switch_id": "1", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard2|Ethernet92": { + "speed": "40000", + "system_port_id": "56", + "switch_id": "1", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard2|Ethernet96": { + "speed": "40000", + "system_port_id": "57", + "switch_id": "1", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard2|Ethernet100": { + "speed": "40000", + "system_port_id": "58", + "switch_id": "1", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard2|Ethernet104": { + "speed": "40000", + "system_port_id": "59", + "switch_id": "1", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard2|Ethernet108": { + "speed": "40000", + "system_port_id": "60", + "switch_id": "1", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard2|Ethernet112": { + "speed": "40000", + "system_port_id": "61", + "switch_id": "1", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard2|Ethernet116": { + "speed": "40000", + "system_port_id": "62", + "switch_id": "1", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard2|Ethernet120": { + "speed": "40000", + "system_port_id": "63", + "switch_id": "1", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard2|Ethernet124": { + "speed": "40000", + "system_port_id": "64", + "switch_id": "1", + "core_index": "1", + "core_port_index": "16" + }, + "Linecard3|Ethernet0": { + "speed": "40000", + "system_port_id": "65", + "switch_id": "2", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard3|Ethernet4": { + "speed": "40000", + "system_port_id": "66", + "switch_id": "2", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard3|Ethernet8": { + "speed": "40000", + "system_port_id": "67", + "switch_id": "2", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard3|Ethernet12": { + "speed": "40000", + "system_port_id": "68", + "switch_id": "2", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard3|Ethernet16": { + "speed": "40000", + "system_port_id": "69", + "switch_id": "2", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard3|Ethernet20": { + "speed": "40000", + "system_port_id": "70", + "switch_id": "2", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard3|Ethernet24": { + "speed": "40000", + "system_port_id": "71", + "switch_id": "2", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard3|Ethernet28": { + "speed": "40000", + "system_port_id": "72", + "switch_id": "2", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard3|Ethernet32": { + "speed": "40000", + "system_port_id": "73", + "switch_id": "2", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard3|Ethernet36": { + "speed": "40000", + "system_port_id": "74", + "switch_id": "2", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard3|Ethernet40": { + "speed": "40000", + "system_port_id": "75", + "switch_id": "2", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard3|Ethernet44": { + "speed": "40000", + "system_port_id": "76", + "switch_id": "2", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard3|Ethernet48": { + "speed": "40000", + "system_port_id": "77", + "switch_id": "2", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard3|Ethernet52": { + "speed": "40000", + "system_port_id": "78", + "switch_id": "2", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard3|Ethernet56": { + "speed": "40000", + "system_port_id": "79", + "switch_id": "2", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard3|Ethernet60": { + "speed": "40000", + "system_port_id": "80", + "switch_id": "2", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard3|Ethernet64": { + "speed": "40000", + "system_port_id": "81", + "switch_id": "2", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard3|Ethernet68": { + "speed": "40000", + "system_port_id": "82", + "switch_id": "2", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard3|Ethernet72": { + "speed": "40000", + "system_port_id": "83", + "switch_id": "2", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard3|Ethernet76": { + "speed": "40000", + "system_port_id": "84", + "switch_id": "2", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard3|Ethernet80": { + "speed": "40000", + "system_port_id": "85", + "switch_id": "2", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard3|Ethernet84": { + "speed": "40000", + "system_port_id": "86", + "switch_id": "2", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard3|Ethernet88": { + "speed": "40000", + "system_port_id": "87", + "switch_id": "2", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard3|Ethernet92": { + "speed": "40000", + "system_port_id": "88", + "switch_id": "2", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard3|Ethernet96": { + "speed": "40000", + "system_port_id": "89", + "switch_id": "2", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard3|Ethernet100": { + "speed": "40000", + "system_port_id": "90", + "switch_id": "2", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard3|Ethernet104": { + "speed": "40000", + "system_port_id": "91", + "switch_id": "2", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard3|Ethernet108": { + "speed": "40000", + "system_port_id": "92", + "switch_id": "2", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard3|Ethernet112": { + "speed": "40000", + "system_port_id": "93", + "switch_id": "2", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard3|Ethernet116": { + "speed": "40000", + "system_port_id": "94", + "switch_id": "2", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard3|Ethernet120": { + "speed": "40000", + "system_port_id": "95", + "switch_id": "2", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard3|Ethernet124": { + "speed": "40000", + "system_port_id": "96", + "switch_id": "2", + "core_index": "1", + "core_port_index": "16" + } } } diff --git a/tests/virtual_chassis/3/coreportindexmap.ini b/tests/virtual_chassis/3/coreportindexmap.ini new file mode 100644 index 0000000000..2445e45d00 --- /dev/null +++ b/tests/virtual_chassis/3/coreportindexmap.ini @@ -0,0 +1,32 @@ +eth1:0,1 +eth2:0,2 +eth3:0,3 +eth4:0,4 +eth5:0,5 +eth6:0,6 +eth7:0,7 +eth8:0,8 +eth9:0,9 +eth10:0,10 +eth11:0,11 +eth12:0,12 +eth13:0,13 +eth14:0,14 +eth15:0,15 +eth16:0,16 +eth17:1,1 +eth18:1,2 +eth19:1,3 +eth20:1,4 +eth21:1,5 +eth22:1,6 +eth23:1,7 +eth24:1,8 +eth25:1,9 +eth26:1,10 +eth27:1,11 +eth28:1,12 +eth29:1,13 +eth30:1,14 +eth31:1,15 +eth32:1,16 diff --git a/tests/virtual_chassis/3/default_config.json b/tests/virtual_chassis/3/default_config.json index acff5b095d..d1b91de7b4 100644 --- a/tests/virtual_chassis/3/default_config.json +++ b/tests/virtual_chassis/3/default_config.json @@ -5,7 +5,10 @@ "instance_name": "Linecard3", "connect_to_chassis_db" : 1, "chassis_db_address" : "10.8.1.200", - "inband_address" : "10.8.1.3/24" + "inband_address" : "10.8.1.3/24", + "switch_type": "voq", + "switch_id": "4", + "max_cores": "48" } }, "INTERFACE": { @@ -16,5 +19,679 @@ "Ethernet0": { "admin_status": "up" } + }, + "SYSTEM_PORT": { + "Linecard1|Ethernet0": { + "speed": "40000", + "system_port_id": "1", + "switch_id": "0", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard1|Ethernet4": { + "speed": "40000", + "system_port_id": "2", + "switch_id": "0", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard1|Ethernet8": { + "speed": "40000", + "system_port_id": "3", + "switch_id": "0", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard1|Ethernet12": { + "speed": "40000", + "system_port_id": "4", + "switch_id": "0", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard1|Ethernet16": { + "speed": "40000", + "system_port_id": "5", + "switch_id": "0", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard1|Ethernet20": { + "speed": "40000", + "system_port_id": "6", + "switch_id": "0", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard1|Ethernet24": { + "speed": "40000", + "system_port_id": "7", + "switch_id": "0", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard1|Ethernet28": { + "speed": "40000", + "system_port_id": "8", + "switch_id": "0", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard1|Ethernet32": { + "speed": "40000", + "system_port_id": "9", + "switch_id": "0", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard1|Ethernet36": { + "speed": "40000", + "system_port_id": "10", + "switch_id": "0", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard1|Ethernet40": { + "speed": "40000", + "system_port_id": "11", + "switch_id": "0", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard1|Ethernet44": { + "speed": "40000", + "system_port_id": "12", + "switch_id": "0", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard1|Ethernet48": { + "speed": "40000", + "system_port_id": "13", + "switch_id": "0", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard1|Ethernet52": { + "speed": "40000", + "system_port_id": "14", + "switch_id": "0", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard1|Ethernet56": { + "speed": "40000", + "system_port_id": "15", + "switch_id": "0", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard1|Ethernet60": { + "speed": "40000", + "system_port_id": "16", + "switch_id": "0", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard1|Ethernet64": { + "speed": "40000", + "system_port_id": "17", + "switch_id": "0", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard1|Ethernet68": { + "speed": "40000", + "system_port_id": "18", + "switch_id": "0", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard1|Ethernet72": { + "speed": "40000", + "system_port_id": "19", + "switch_id": "0", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard1|Ethernet76": { + "speed": "40000", + "system_port_id": "20", + "switch_id": "0", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard1|Ethernet80": { + "speed": "40000", + "system_port_id": "21", + "switch_id": "0", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard1|Ethernet84": { + "speed": "40000", + "system_port_id": "22", + "switch_id": "0", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard1|Ethernet88": { + "speed": "40000", + "system_port_id": "23", + "switch_id": "0", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard1|Ethernet92": { + "speed": "40000", + "system_port_id": "24", + "switch_id": "0", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard1|Ethernet96": { + "speed": "40000", + "system_port_id": "25", + "switch_id": "0", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard1|Ethernet100": { + "speed": "40000", + "system_port_id": "26", + "switch_id": "0", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard1|Ethernet104": { + "speed": "40000", + "system_port_id": "27", + "switch_id": "0", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard1|Ethernet108": { + "speed": "40000", + "system_port_id": "28", + "switch_id": "0", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard1|Ethernet112": { + "speed": "40000", + "system_port_id": "29", + "switch_id": "0", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard1|Ethernet116": { + "speed": "40000", + "system_port_id": "30", + "switch_id": "0", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard1|Ethernet120": { + "speed": "40000", + "system_port_id": "31", + "switch_id": "0", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard1|Ethernet124": { + "speed": "40000", + "system_port_id": "32", + "switch_id": "0", + "core_index": "1", + "core_port_index": "16" + }, + "Linecard2|Ethernet0": { + "speed": "40000", + "system_port_id": "33", + "switch_id": "1", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard2|Ethernet4": { + "speed": "40000", + "system_port_id": "34", + "switch_id": "1", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard2|Ethernet8": { + "speed": "40000", + "system_port_id": "35", + "switch_id": "1", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard2|Ethernet12": { + "speed": "40000", + "system_port_id": "36", + "switch_id": "1", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard2|Ethernet16": { + "speed": "40000", + "system_port_id": "37", + "switch_id": "1", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard2|Ethernet20": { + "speed": "40000", + "system_port_id": "38", + "switch_id": "1", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard2|Ethernet24": { + "speed": "40000", + "system_port_id": "39", + "switch_id": "1", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard2|Ethernet28": { + "speed": "40000", + "system_port_id": "40", + "switch_id": "1", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard2|Ethernet32": { + "speed": "40000", + "system_port_id": "41", + "switch_id": "1", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard2|Ethernet36": { + "speed": "40000", + "system_port_id": "42", + "switch_id": "1", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard2|Ethernet40": { + "speed": "40000", + "system_port_id": "43", + "switch_id": "1", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard2|Ethernet44": { + "speed": "40000", + "system_port_id": "44", + "switch_id": "1", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard2|Ethernet48": { + "speed": "40000", + "system_port_id": "45", + "switch_id": "1", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard2|Ethernet52": { + "speed": "40000", + "system_port_id": "46", + "switch_id": "1", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard2|Ethernet56": { + "speed": "40000", + "system_port_id": "47", + "switch_id": "1", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard2|Ethernet60": { + "speed": "40000", + "system_port_id": "48", + "switch_id": "1", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard2|Ethernet64": { + "speed": "40000", + "system_port_id": "49", + "switch_id": "1", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard2|Ethernet68": { + "speed": "40000", + "system_port_id": "50", + "switch_id": "1", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard2|Ethernet72": { + "speed": "40000", + "system_port_id": "51", + "switch_id": "1", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard2|Ethernet76": { + "speed": "40000", + "system_port_id": "52", + "switch_id": "1", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard2|Ethernet80": { + "speed": "40000", + "system_port_id": "53", + "switch_id": "1", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard2|Ethernet84": { + "speed": "40000", + "system_port_id": "54", + "switch_id": "1", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard2|Ethernet88": { + "speed": "40000", + "system_port_id": "55", + "switch_id": "1", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard2|Ethernet92": { + "speed": "40000", + "system_port_id": "56", + "switch_id": "1", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard2|Ethernet96": { + "speed": "40000", + "system_port_id": "57", + "switch_id": "1", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard2|Ethernet100": { + "speed": "40000", + "system_port_id": "58", + "switch_id": "1", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard2|Ethernet104": { + "speed": "40000", + "system_port_id": "59", + "switch_id": "1", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard2|Ethernet108": { + "speed": "40000", + "system_port_id": "60", + "switch_id": "1", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard2|Ethernet112": { + "speed": "40000", + "system_port_id": "61", + "switch_id": "1", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard2|Ethernet116": { + "speed": "40000", + "system_port_id": "62", + "switch_id": "1", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard2|Ethernet120": { + "speed": "40000", + "system_port_id": "63", + "switch_id": "1", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard2|Ethernet124": { + "speed": "40000", + "system_port_id": "64", + "switch_id": "1", + "core_index": "1", + "core_port_index": "16" + }, + "Linecard3|Ethernet0": { + "speed": "40000", + "system_port_id": "65", + "switch_id": "2", + "core_index": "0", + "core_port_index": "1" + }, + "Linecard3|Ethernet4": { + "speed": "40000", + "system_port_id": "66", + "switch_id": "2", + "core_index": "0", + "core_port_index": "2" + }, + "Linecard3|Ethernet8": { + "speed": "40000", + "system_port_id": "67", + "switch_id": "2", + "core_index": "0", + "core_port_index": "3" + }, + "Linecard3|Ethernet12": { + "speed": "40000", + "system_port_id": "68", + "switch_id": "2", + "core_index": "0", + "core_port_index": "4" + }, + "Linecard3|Ethernet16": { + "speed": "40000", + "system_port_id": "69", + "switch_id": "2", + "core_index": "0", + "core_port_index": "5" + }, + "Linecard3|Ethernet20": { + "speed": "40000", + "system_port_id": "70", + "switch_id": "2", + "core_index": "0", + "core_port_index": "6" + }, + "Linecard3|Ethernet24": { + "speed": "40000", + "system_port_id": "71", + "switch_id": "2", + "core_index": "0", + "core_port_index": "7" + }, + "Linecard3|Ethernet28": { + "speed": "40000", + "system_port_id": "72", + "switch_id": "2", + "core_index": "0", + "core_port_index": "8" + }, + "Linecard3|Ethernet32": { + "speed": "40000", + "system_port_id": "73", + "switch_id": "2", + "core_index": "0", + "core_port_index": "9" + }, + "Linecard3|Ethernet36": { + "speed": "40000", + "system_port_id": "74", + "switch_id": "2", + "core_index": "0", + "core_port_index": "10" + }, + "Linecard3|Ethernet40": { + "speed": "40000", + "system_port_id": "75", + "switch_id": "2", + "core_index": "0", + "core_port_index": "11" + }, + "Linecard3|Ethernet44": { + "speed": "40000", + "system_port_id": "76", + "switch_id": "2", + "core_index": "0", + "core_port_index": "12" + }, + "Linecard3|Ethernet48": { + "speed": "40000", + "system_port_id": "77", + "switch_id": "2", + "core_index": "0", + "core_port_index": "13" + }, + "Linecard3|Ethernet52": { + "speed": "40000", + "system_port_id": "78", + "switch_id": "2", + "core_index": "0", + "core_port_index": "14" + }, + "Linecard3|Ethernet56": { + "speed": "40000", + "system_port_id": "79", + "switch_id": "2", + "core_index": "0", + "core_port_index": "15" + }, + "Linecard3|Ethernet60": { + "speed": "40000", + "system_port_id": "80", + "switch_id": "2", + "core_index": "0", + "core_port_index": "16" + }, + "Linecard3|Ethernet64": { + "speed": "40000", + "system_port_id": "81", + "switch_id": "2", + "core_index": "1", + "core_port_index": "1" + }, + "Linecard3|Ethernet68": { + "speed": "40000", + "system_port_id": "82", + "switch_id": "2", + "core_index": "1", + "core_port_index": "2" + }, + "Linecard3|Ethernet72": { + "speed": "40000", + "system_port_id": "83", + "switch_id": "2", + "core_index": "1", + "core_port_index": "3" + }, + "Linecard3|Ethernet76": { + "speed": "40000", + "system_port_id": "84", + "switch_id": "2", + "core_index": "1", + "core_port_index": "4" + }, + "Linecard3|Ethernet80": { + "speed": "40000", + "system_port_id": "85", + "switch_id": "2", + "core_index": "1", + "core_port_index": "5" + }, + "Linecard3|Ethernet84": { + "speed": "40000", + "system_port_id": "86", + "switch_id": "2", + "core_index": "1", + "core_port_index": "6" + }, + "Linecard3|Ethernet88": { + "speed": "40000", + "system_port_id": "87", + "switch_id": "2", + "core_index": "1", + "core_port_index": "7" + }, + "Linecard3|Ethernet92": { + "speed": "40000", + "system_port_id": "88", + "switch_id": "2", + "core_index": "1", + "core_port_index": "8" + }, + "Linecard3|Ethernet96": { + "speed": "40000", + "system_port_id": "89", + "switch_id": "2", + "core_index": "1", + "core_port_index": "9" + }, + "Linecard3|Ethernet100": { + "speed": "40000", + "system_port_id": "90", + "switch_id": "2", + "core_index": "1", + "core_port_index": "10" + }, + "Linecard3|Ethernet104": { + "speed": "40000", + "system_port_id": "91", + "switch_id": "2", + "core_index": "1", + "core_port_index": "11" + }, + "Linecard3|Ethernet108": { + "speed": "40000", + "system_port_id": "92", + "switch_id": "2", + "core_index": "1", + "core_port_index": "12" + }, + "Linecard3|Ethernet112": { + "speed": "40000", + "system_port_id": "93", + "switch_id": "2", + "core_index": "1", + "core_port_index": "13" + }, + "Linecard3|Ethernet116": { + "speed": "40000", + "system_port_id": "94", + "switch_id": "2", + "core_index": "1", + "core_port_index": "14" + }, + "Linecard3|Ethernet120": { + "speed": "40000", + "system_port_id": "95", + "switch_id": "2", + "core_index": "1", + "core_port_index": "15" + }, + "Linecard3|Ethernet124": { + "speed": "40000", + "system_port_id": "96", + "switch_id": "2", + "core_index": "1", + "core_port_index": "16" + } } } From a42d3f5afb50be85c900d2546006572387356863 Mon Sep 17 00:00:00 2001 From: vedganes Date: Fri, 20 Nov 2020 18:00:13 -0500 Subject: [PATCH 12/21] [vstest]Voq switch test - removed chassis_db.json Signed-off-by: vedganes Since the system port configs are moved to config_db.json, this file is no longer used in virtual chasiss test. --- tests/virtual_chassis/0/chassis_db.json | 674 ------------------------ 1 file changed, 674 deletions(-) delete mode 100644 tests/virtual_chassis/0/chassis_db.json diff --git a/tests/virtual_chassis/0/chassis_db.json b/tests/virtual_chassis/0/chassis_db.json deleted file mode 100644 index a80ff2c7b6..0000000000 --- a/tests/virtual_chassis/0/chassis_db.json +++ /dev/null @@ -1,674 +0,0 @@ -{ - "SYSTEM_PORT|Linecard1|Ethernet0": { - "speed": "40000", - "system_port_id": "1", - "switch_id": "0", - "core_id": "0", - "core_port_id": "1" - }, - "SYSTEM_PORT|Linecard1|Ethernet4": { - "speed": "40000", - "system_port_id": "2", - "switch_id": "0", - "core_id": "0", - "core_port_id": "2" - }, - "SYSTEM_PORT|Linecard1|Ethernet8": { - "speed": "40000", - "system_port_id": "3", - "switch_id": "0", - "core_id": "0", - "core_port_id": "3" - }, - "SYSTEM_PORT|Linecard1|Ethernet12": { - "speed": "40000", - "system_port_id": "4", - "switch_id": "0", - "core_id": "0", - "core_port_id": "4" - }, - "SYSTEM_PORT|Linecard1|Ethernet16": { - "speed": "40000", - "system_port_id": "5", - "switch_id": "0", - "core_id": "0", - "core_port_id": "5" - }, - "SYSTEM_PORT|Linecard1|Ethernet20": { - "speed": "40000", - "system_port_id": "6", - "switch_id": "0", - "core_id": "0", - "core_port_id": "6" - }, - "SYSTEM_PORT|Linecard1|Ethernet24": { - "speed": "40000", - "system_port_id": "7", - "switch_id": "0", - "core_id": "0", - "core_port_id": "7" - }, - "SYSTEM_PORT|Linecard1|Ethernet28": { - "speed": "40000", - "system_port_id": "8", - "switch_id": "0", - "core_id": "0", - "core_port_id": "8" - }, - "SYSTEM_PORT|Linecard1|Ethernet32": { - "speed": "40000", - "system_port_id": "9", - "switch_id": "0", - "core_id": "0", - "core_port_id": "9" - }, - "SYSTEM_PORT|Linecard1|Ethernet36": { - "speed": "40000", - "system_port_id": "10", - "switch_id": "0", - "core_id": "0", - "core_port_id": "10" - }, - "SYSTEM_PORT|Linecard1|Ethernet40": { - "speed": "40000", - "system_port_id": "11", - "switch_id": "0", - "core_id": "0", - "core_port_id": "11" - }, - "SYSTEM_PORT|Linecard1|Ethernet44": { - "speed": "40000", - "system_port_id": "12", - "switch_id": "0", - "core_id": "0", - "core_port_id": "12" - }, - "SYSTEM_PORT|Linecard1|Ethernet48": { - "speed": "40000", - "system_port_id": "13", - "switch_id": "0", - "core_id": "0", - "core_port_id": "13" - }, - "SYSTEM_PORT|Linecard1|Ethernet52": { - "speed": "40000", - "system_port_id": "14", - "switch_id": "0", - "core_id": "0", - "core_port_id": "14" - }, - "SYSTEM_PORT|Linecard1|Ethernet56": { - "speed": "40000", - "system_port_id": "15", - "switch_id": "0", - "core_id": "0", - "core_port_id": "15" - }, - "SYSTEM_PORT|Linecard1|Ethernet60": { - "speed": "40000", - "system_port_id": "16", - "switch_id": "0", - "core_id": "0", - "core_port_id": "16" - }, - "SYSTEM_PORT|Linecard1|Ethernet64": { - "speed": "40000", - "system_port_id": "17", - "switch_id": "0", - "core_id": "1", - "core_port_id": "1" - }, - "SYSTEM_PORT|Linecard1|Ethernet68": { - "speed": "40000", - "system_port_id": "18", - "switch_id": "0", - "core_id": "1", - "core_port_id": "2" - }, - "SYSTEM_PORT|Linecard1|Ethernet72": { - "speed": "40000", - "system_port_id": "19", - "switch_id": "0", - "core_id": "1", - "core_port_id": "3" - }, - "SYSTEM_PORT|Linecard1|Ethernet76": { - "speed": "40000", - "system_port_id": "20", - "switch_id": "0", - "core_id": "1", - "core_port_id": "4" - }, - "SYSTEM_PORT|Linecard1|Ethernet80": { - "speed": "40000", - "system_port_id": "21", - "switch_id": "0", - "core_id": "1", - "core_port_id": "5" - }, - "SYSTEM_PORT|Linecard1|Ethernet84": { - "speed": "40000", - "system_port_id": "22", - "switch_id": "0", - "core_id": "1", - "core_port_id": "6" - }, - "SYSTEM_PORT|Linecard1|Ethernet88": { - "speed": "40000", - "system_port_id": "23", - "switch_id": "0", - "core_id": "1", - "core_port_id": "7" - }, - "SYSTEM_PORT|Linecard1|Ethernet92": { - "speed": "40000", - "system_port_id": "24", - "switch_id": "0", - "core_id": "1", - "core_port_id": "8" - }, - "SYSTEM_PORT|Linecard1|Ethernet96": { - "speed": "40000", - "system_port_id": "25", - "switch_id": "0", - "core_id": "1", - "core_port_id": "9" - }, - "SYSTEM_PORT|Linecard1|Ethernet100": { - "speed": "40000", - "system_port_id": "26", - "switch_id": "0", - "core_id": "1", - "core_port_id": "10" - }, - "SYSTEM_PORT|Linecard1|Ethernet104": { - "speed": "40000", - "system_port_id": "27", - "switch_id": "0", - "core_id": "1", - "core_port_id": "11" - }, - "SYSTEM_PORT|Linecard1|Ethernet108": { - "speed": "40000", - "system_port_id": "28", - "switch_id": "0", - "core_id": "1", - "core_port_id": "12" - }, - "SYSTEM_PORT|Linecard1|Ethernet112": { - "speed": "40000", - "system_port_id": "29", - "switch_id": "0", - "core_id": "1", - "core_port_id": "13" - }, - "SYSTEM_PORT|Linecard1|Ethernet116": { - "speed": "40000", - "system_port_id": "30", - "switch_id": "0", - "core_id": "1", - "core_port_id": "14" - }, - "SYSTEM_PORT|Linecard1|Ethernet120": { - "speed": "40000", - "system_port_id": "31", - "switch_id": "0", - "core_id": "1", - "core_port_id": "15" - }, - "SYSTEM_PORT|Linecard1|Ethernet124": { - "speed": "40000", - "system_port_id": "32", - "switch_id": "0", - "core_id": "1", - "core_port_id": "16" - }, - "SYSTEM_PORT|Linecard2|Ethernet0": { - "speed": "40000", - "system_port_id": "33", - "switch_id": "1", - "core_id": "0", - "core_port_id": "1" - }, - "SYSTEM_PORT|Linecard2|Ethernet4": { - "speed": "40000", - "system_port_id": "34", - "switch_id": "1", - "core_id": "0", - "core_port_id": "2" - }, - "SYSTEM_PORT|Linecard2|Ethernet8": { - "speed": "40000", - "system_port_id": "35", - "switch_id": "1", - "core_id": "0", - "core_port_id": "3" - }, - "SYSTEM_PORT|Linecard2|Ethernet12": { - "speed": "40000", - "system_port_id": "36", - "switch_id": "1", - "core_id": "0", - "core_port_id": "4" - }, - "SYSTEM_PORT|Linecard2|Ethernet16": { - "speed": "40000", - "system_port_id": "37", - "switch_id": "1", - "core_id": "0", - "core_port_id": "5" - }, - "SYSTEM_PORT|Linecard2|Ethernet20": { - "speed": "40000", - "system_port_id": "38", - "switch_id": "1", - "core_id": "0", - "core_port_id": "6" - }, - "SYSTEM_PORT|Linecard2|Ethernet24": { - "speed": "40000", - "system_port_id": "39", - "switch_id": "1", - "core_id": "0", - "core_port_id": "7" - }, - "SYSTEM_PORT|Linecard2|Ethernet28": { - "speed": "40000", - "system_port_id": "40", - "switch_id": "1", - "core_id": "0", - "core_port_id": "8" - }, - "SYSTEM_PORT|Linecard2|Ethernet32": { - "speed": "40000", - "system_port_id": "41", - "switch_id": "1", - "core_id": "0", - "core_port_id": "9" - }, - "SYSTEM_PORT|Linecard2|Ethernet36": { - "speed": "40000", - "system_port_id": "42", - "switch_id": "1", - "core_id": "0", - "core_port_id": "10" - }, - "SYSTEM_PORT|Linecard2|Ethernet40": { - "speed": "40000", - "system_port_id": "43", - "switch_id": "1", - "core_id": "0", - "core_port_id": "11" - }, - "SYSTEM_PORT|Linecard2|Ethernet44": { - "speed": "40000", - "system_port_id": "44", - "switch_id": "1", - "core_id": "0", - "core_port_id": "12" - }, - "SYSTEM_PORT|Linecard2|Ethernet48": { - "speed": "40000", - "system_port_id": "45", - "switch_id": "1", - "core_id": "0", - "core_port_id": "13" - }, - "SYSTEM_PORT|Linecard2|Ethernet52": { - "speed": "40000", - "system_port_id": "46", - "switch_id": "1", - "core_id": "0", - "core_port_id": "14" - }, - "SYSTEM_PORT|Linecard2|Ethernet56": { - "speed": "40000", - "system_port_id": "47", - "switch_id": "1", - "core_id": "0", - "core_port_id": "15" - }, - "SYSTEM_PORT|Linecard2|Ethernet60": { - "speed": "40000", - "system_port_id": "48", - "switch_id": "1", - "core_id": "0", - "core_port_id": "16" - }, - "SYSTEM_PORT|Linecard2|Ethernet64": { - "speed": "40000", - "system_port_id": "49", - "switch_id": "1", - "core_id": "1", - "core_port_id": "1" - }, - "SYSTEM_PORT|Linecard2|Ethernet68": { - "speed": "40000", - "system_port_id": "50", - "switch_id": "1", - "core_id": "1", - "core_port_id": "2" - }, - "SYSTEM_PORT|Linecard2|Ethernet72": { - "speed": "40000", - "system_port_id": "51", - "switch_id": "1", - "core_id": "1", - "core_port_id": "3" - }, - "SYSTEM_PORT|Linecard2|Ethernet76": { - "speed": "40000", - "system_port_id": "52", - "switch_id": "1", - "core_id": "1", - "core_port_id": "4" - }, - "SYSTEM_PORT|Linecard2|Ethernet80": { - "speed": "40000", - "system_port_id": "53", - "switch_id": "1", - "core_id": "1", - "core_port_id": "5" - }, - "SYSTEM_PORT|Linecard2|Ethernet84": { - "speed": "40000", - "system_port_id": "54", - "switch_id": "1", - "core_id": "1", - "core_port_id": "6" - }, - "SYSTEM_PORT|Linecard2|Ethernet88": { - "speed": "40000", - "system_port_id": "55", - "switch_id": "1", - "core_id": "1", - "core_port_id": "7" - }, - "SYSTEM_PORT|Linecard2|Ethernet92": { - "speed": "40000", - "system_port_id": "56", - "switch_id": "1", - "core_id": "1", - "core_port_id": "8" - }, - "SYSTEM_PORT|Linecard2|Ethernet96": { - "speed": "40000", - "system_port_id": "57", - "switch_id": "1", - "core_id": "1", - "core_port_id": "9" - }, - "SYSTEM_PORT|Linecard2|Ethernet100": { - "speed": "40000", - "system_port_id": "58", - "switch_id": "1", - "core_id": "1", - "core_port_id": "10" - }, - "SYSTEM_PORT|Linecard2|Ethernet104": { - "speed": "40000", - "system_port_id": "59", - "switch_id": "1", - "core_id": "1", - "core_port_id": "11" - }, - "SYSTEM_PORT|Linecard2|Ethernet108": { - "speed": "40000", - "system_port_id": "60", - "switch_id": "1", - "core_id": "1", - "core_port_id": "12" - }, - "SYSTEM_PORT|Linecard2|Ethernet112": { - "speed": "40000", - "system_port_id": "61", - "switch_id": "1", - "core_id": "1", - "core_port_id": "13" - }, - "SYSTEM_PORT|Linecard2|Ethernet116": { - "speed": "40000", - "system_port_id": "62", - "switch_id": "1", - "core_id": "1", - "core_port_id": "14" - }, - "SYSTEM_PORT|Linecard2|Ethernet120": { - "speed": "40000", - "system_port_id": "63", - "switch_id": "1", - "core_id": "1", - "core_port_id": "15" - }, - "SYSTEM_PORT|Linecard2|Ethernet124": { - "speed": "40000", - "system_port_id": "64", - "switch_id": "1", - "core_id": "1", - "core_port_id": "16" - }, - "SYSTEM_PORT|Linecard3|Ethernet0": { - "speed": "40000", - "system_port_id": "65", - "switch_id": "2", - "core_id": "0", - "core_port_id": "1" - }, - "SYSTEM_PORT|Linecard3|Ethernet4": { - "speed": "40000", - "system_port_id": "66", - "switch_id": "2", - "core_id": "0", - "core_port_id": "2" - }, - "SYSTEM_PORT|Linecard3|Ethernet8": { - "speed": "40000", - "system_port_id": "67", - "switch_id": "2", - "core_id": "0", - "core_port_id": "3" - }, - "SYSTEM_PORT|Linecard3|Ethernet12": { - "speed": "40000", - "system_port_id": "68", - "switch_id": "2", - "core_id": "0", - "core_port_id": "4" - }, - "SYSTEM_PORT|Linecard3|Ethernet16": { - "speed": "40000", - "system_port_id": "69", - "switch_id": "2", - "core_id": "0", - "core_port_id": "5" - }, - "SYSTEM_PORT|Linecard3|Ethernet20": { - "speed": "40000", - "system_port_id": "70", - "switch_id": "2", - "core_id": "0", - "core_port_id": "6" - }, - "SYSTEM_PORT|Linecard3|Ethernet24": { - "speed": "40000", - "system_port_id": "71", - "switch_id": "2", - "core_id": "0", - "core_port_id": "7" - }, - "SYSTEM_PORT|Linecard3|Ethernet28": { - "speed": "40000", - "system_port_id": "72", - "switch_id": "2", - "core_id": "0", - "core_port_id": "8" - }, - "SYSTEM_PORT|Linecard3|Ethernet32": { - "speed": "40000", - "system_port_id": "73", - "switch_id": "2", - "core_id": "0", - "core_port_id": "9" - }, - "SYSTEM_PORT|Linecard3|Ethernet36": { - "speed": "40000", - "system_port_id": "74", - "switch_id": "2", - "core_id": "0", - "core_port_id": "10" - }, - "SYSTEM_PORT|Linecard3|Ethernet40": { - "speed": "40000", - "system_port_id": "75", - "switch_id": "2", - "core_id": "0", - "core_port_id": "11" - }, - "SYSTEM_PORT|Linecard3|Ethernet44": { - "speed": "40000", - "system_port_id": "76", - "switch_id": "2", - "core_id": "0", - "core_port_id": "12" - }, - "SYSTEM_PORT|Linecard3|Ethernet48": { - "speed": "40000", - "system_port_id": "77", - "switch_id": "2", - "core_id": "0", - "core_port_id": "13" - }, - "SYSTEM_PORT|Linecard3|Ethernet52": { - "speed": "40000", - "system_port_id": "78", - "switch_id": "2", - "core_id": "0", - "core_port_id": "14" - }, - "SYSTEM_PORT|Linecard3|Ethernet56": { - "speed": "40000", - "system_port_id": "79", - "switch_id": "2", - "core_id": "0", - "core_port_id": "15" - }, - "SYSTEM_PORT|Linecard3|Ethernet60": { - "speed": "40000", - "system_port_id": "80", - "switch_id": "2", - "core_id": "0", - "core_port_id": "16" - }, - "SYSTEM_PORT|Linecard3|Ethernet64": { - "speed": "40000", - "system_port_id": "81", - "switch_id": "2", - "core_id": "1", - "core_port_id": "1" - }, - "SYSTEM_PORT|Linecard3|Ethernet68": { - "speed": "40000", - "system_port_id": "82", - "switch_id": "2", - "core_id": "1", - "core_port_id": "2" - }, - "SYSTEM_PORT|Linecard3|Ethernet72": { - "speed": "40000", - "system_port_id": "83", - "switch_id": "2", - "core_id": "1", - "core_port_id": "3" - }, - "SYSTEM_PORT|Linecard3|Ethernet76": { - "speed": "40000", - "system_port_id": "84", - "switch_id": "2", - "core_id": "1", - "core_port_id": "4" - }, - "SYSTEM_PORT|Linecard3|Ethernet80": { - "speed": "40000", - "system_port_id": "85", - "switch_id": "2", - "core_id": "1", - "core_port_id": "5" - }, - "SYSTEM_PORT|Linecard3|Ethernet84": { - "speed": "40000", - "system_port_id": "86", - "switch_id": "2", - "core_id": "1", - "core_port_id": "6" - }, - "SYSTEM_PORT|Linecard3|Ethernet88": { - "speed": "40000", - "system_port_id": "87", - "switch_id": "2", - "core_id": "1", - "core_port_id": "7" - }, - "SYSTEM_PORT|Linecard3|Ethernet92": { - "speed": "40000", - "system_port_id": "88", - "switch_id": "2", - "core_id": "1", - "core_port_id": "8" - }, - "SYSTEM_PORT|Linecard3|Ethernet96": { - "speed": "40000", - "system_port_id": "89", - "switch_id": "2", - "core_id": "1", - "core_port_id": "9" - }, - "SYSTEM_PORT|Linecard3|Ethernet100": { - "speed": "40000", - "system_port_id": "90", - "switch_id": "2", - "core_id": "1", - "core_port_id": "10" - }, - "SYSTEM_PORT|Linecard3|Ethernet104": { - "speed": "40000", - "system_port_id": "91", - "switch_id": "2", - "core_id": "1", - "core_port_id": "11" - }, - "SYSTEM_PORT|Linecard3|Ethernet108": { - "speed": "40000", - "system_port_id": "92", - "switch_id": "2", - "core_id": "1", - "core_port_id": "12" - }, - "SYSTEM_PORT|Linecard3|Ethernet112": { - "speed": "40000", - "system_port_id": "93", - "switch_id": "2", - "core_id": "1", - "core_port_id": "13" - }, - "SYSTEM_PORT|Linecard3|Ethernet116": { - "speed": "40000", - "system_port_id": "94", - "switch_id": "2", - "core_id": "1", - "core_port_id": "14" - }, - "SYSTEM_PORT|Linecard3|Ethernet120": { - "speed": "40000", - "system_port_id": "95", - "switch_id": "2", - "core_id": "1", - "core_port_id": "15" - }, - "SYSTEM_PORT|Linecard3|Ethernet124": { - "speed": "40000", - "system_port_id": "96", - "switch_id": "2", - "core_id": "1", - "core_port_id": "16" - } -} From 8922f461bd82f7e0232782f7f039adf0f753810e Mon Sep 17 00:00:00 2001 From: vedganes Date: Sat, 21 Nov 2020 16:51:13 -0500 Subject: [PATCH 13/21] [vstest]VOQ switch system ports test Signed-off-by: vedganes Code review comments fix 1. --- tests/test_virtual_chassis.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index 1279394c9d..a98d42b930 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -31,13 +31,17 @@ def test_voq_switch(self, vct): """ Test VOQ switch objects configuration """ dvss = vct.dvss for name in dvss.keys(): - if not name.startswith("supervisor"): - print("VOQ Switch test for {}".format(name)) - dvs = dvss[name] - #Get the config info - config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) - metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + dvs = dvss[name] + #Get the config info + config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) + metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + cfg_switch_type = "" + status, cfg_switch_type = metatbl.hget("localhost", "switch_type") + + #Test only for line cards + if cfg_switch_type == "voq": + print("VOQ Switch test for {}".format(name)) status, cfg_switch_id = metatbl.hget("localhost", "switch_id") assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" @@ -86,15 +90,21 @@ def test_chassis_system_interface(self, vct): """ Test RIF record creation in ASIC_DB for remote interfaces """ dvss = vct.dvss for name in dvss.keys(): - if not name.startswith("supervisor"): - dvs = dvss[name] - config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) - metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + dvs = dvss[name] + config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) + metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + + cfg_switch_type = "" + status, cfg_switch_type = metatbl.hget("localhost", "switch_type") + + #Test only for line cards + if cfg_switch_type == "voq": status, lc_switch_id = metatbl.hget("localhost", "switch_id") assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" if lc_switch_id == "0": #Testing in Linecard1, In Linecard1 there will be RIF for Ethernet12 from Linecard3 - #Note: Tesing can be done in any linecard for RIF of any system port interface + #Note: Tesing can be done in any linecard for RIF of any system port interface. + # Here testing is done on linecard with switch id 0 asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) riftbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") keys = list(riftbl.getKeys()) @@ -118,4 +128,5 @@ def test_chassis_system_interface(self, vct): status, value = sptbl.hget(rif_port_oid, "SAI_SYSTEM_PORT_ATTR_CONFIG_INFO") assert status, "Got error in getting system port config info for rif system port" spcfginfo = ast.literal_eval(value) + #Remote system ports's switch id should not match local switch id assert spcfginfo["attached_switch_id"] != lc_switch_id, "RIF system port with wrong switch_id" From d9df7814f19b949e131298e19ab15e6a6e13f1d0 Mon Sep 17 00:00:00 2001 From: vedganes Date: Sat, 21 Nov 2020 18:09:21 -0500 Subject: [PATCH 14/21] [swss]VOQ Code review comments fix 6 Signed-off-by: vedganes Change cout to SWSS_LOG_ for error logging --- orchagent/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index 2fa3dfc0ac..c6958ea30b 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -157,7 +157,7 @@ void getCfgSwitchType(DBConnector *cfgDb, string &switch_type) if (switch_type != "voq" && switch_type != "fabric" && switch_type != "switch") { - cout << "Invalid switch type " << switch_type.c_str() << " configured"; + SWSS_LOG_ERROR("Invalid switch type %s configured", switch_type.c_str()); //If configured switch type is none of the supported, assume regular switch switch_type = "switch"; } @@ -179,7 +179,7 @@ bool getSystemPortConfigList(DBConnector *cfgDb, DBConnector *appDb, vector Date: Wed, 2 Dec 2020 22:02:38 -0500 Subject: [PATCH 15/21] [swss]vs test for voq neighbor Signed-off-by: vedganes Test case added for testing voq neighbor. --- tests/test_virtual_chassis.py | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index a98d42b930..2062174f43 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -130,3 +130,80 @@ def test_chassis_system_interface(self, vct): spcfginfo = ast.literal_eval(value) #Remote system ports's switch id should not match local switch id assert spcfginfo["attached_switch_id"] != lc_switch_id, "RIF system port with wrong switch_id" + + def test_chassis_system_neigh(self, vct): + """ Test neigh record creation and syncing to chassis app db """ + + """ + This test validates that: + (i) Local neighbor entry is created with encap index + (ii) Local neighbor is synced to chassis ap db with assigned encap index + TODO: (iii) Remote neighbor entry is created in ASIC_DB with received encap index + """ + + dvss = vct.dvss + for name in dvss.keys(): + dvs = dvss[name] + config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) + metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + + cfg_switch_type = "" + status, cfg_switch_type = metatbl.hget("localhost", "switch_type") + + #Neighbor record verifiation done in line card + if cfg_switch_type == "voq": + status, lc_switch_id = metatbl.hget("localhost", "switch_id") + assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" + if lc_switch_id == "0": + + # Add a static neighbor + _, res = dvs.runcmd(['sh', "-c", "ip neigh add 10.8.101.2 lladdr 00:01:02:03:04:05 dev Ethernet0"]) + assert res == "", "Error configuring static neigh" + + asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) + neightbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") + neighkeys = list(neightbl.getKeys()) + assert len(neighkeys), "No neigh entries in ASIC_DB" + + #Check for presence of the neighbor in ASIC_DB + test_neigh = "" + for nkey in neighkeys: + ne = ast.literal_eval(nkey) + if ne['ip'] == '10.8.101.2': + test_neigh = nkey + break + + assert test_neigh != "", "Neigh not found in ASIC_DB" + + #Check for presence of encap index, retrieve and store it for sync verification + status, encap_index = neightbl.hget(test_neigh,"SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX") + assert status, "VOQ encap index is not programmed in ASIC_DB" + + break + + #Verify neighbor record syncing with encap index + dvss = vct.dvss + for name in dvss.keys(): + if name.startswith("supervisor"): + dvs = dvss[name] + chassis_app_db = swsscommon.DBConnector(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock, 0) + sysneightbl = swsscommon.Table(chassis_app_db, "SYSTEM_NEIGH") + sysneighkeys = list(sysneightbl.getKeys()) + assert len(sysneighkeys), "No system neighbor entries in chassis app db" + + test_sysneigh = "" + for sysnk in sysneighkeys: + sysnk_tok = sysnk.split("|") + assert len(sysnk_tok) == 3, "Invalid system neigh key in chassis app db" + if sysnk_tok[2] == "10.8.101.2": + test_sysneigh = sysnk + break + + assert test_sysneigh != "", "Neigh is not sync-ed to chassis app db" + + status, sys_neigh_encap_index = sysneightbl.hget(test_sysneigh,"encap_index") + assert status, "System neigh in chassis app db does not have encap index" + + assert encap_index == sys_neigh_encap_index, "Encap index not sync-ed correctly" + + break From e9fc9505a5f74c47a5d68a79d1179d9944fd7078 Mon Sep 17 00:00:00 2001 From: vedganes Date: Mon, 7 Dec 2020 19:49:25 -0500 Subject: [PATCH 16/21] [swss]vs test for voq nbr review comments fix 1 Signed-off-by: vedganes Fixed review comments to use dvs_database.py lib to connect to redis databases instead of using raw connection via swsscommon DBConnectors. --- tests/test_virtual_chassis.py | 115 +++++++++++++++++----------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index 2062174f43..e9615bb823 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -1,5 +1,6 @@ import pytest from swsscommon import swsscommon +from dvslib.dvs_database import DVSDatabase import ast class TestVirtualChassis(object): @@ -33,44 +34,40 @@ def test_voq_switch(self, vct): for name in dvss.keys(): dvs = dvss[name] #Get the config info - config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) - metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") + config_db = DVSDatabase(swsscommon.CONFIG_DB, dvs.redis_sock) + metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") - cfg_switch_type = "" - status, cfg_switch_type = metatbl.hget("localhost", "switch_type") + cfg_switch_type = metatbl.get("switch_type") #Test only for line cards if cfg_switch_type == "voq": print("VOQ Switch test for {}".format(name)) - status, cfg_switch_id = metatbl.hget("localhost", "switch_id") - assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" + cfg_switch_id = metatbl.get("switch_id") + assert cfg_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" - status, cfg_max_cores = metatbl.hget("localhost", "max_cores") - assert status, "Got error in getting max_cores from CONFIG_DB DEVICE_METADATA" + cfg_max_cores = metatbl.get("max_cores") + assert cfg_max_cores != "", "Got error in getting max_cores from CONFIG_DB DEVICE_METADATA" - cfgsptbl = swsscommon.Table(config_db, "SYSTEM_PORT") - cfgspkeys = cfgsptbl.getKeys() + cfgspkeys = config_db.get_keys("SYSTEM_PORT") sp_count = len(cfgspkeys) - asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) - tbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_SWITCH") - keys = list(tbl.getKeys()) + asic_db = DVSDatabase(swsscommon.ASIC_DB, dvs.redis_sock) + keys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_SWITCH") switch_oid_key = keys[0] + + switch_entry = asic_db.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_SWITCH", switch_oid_key) - status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_TYPE") - assert status, "Got error while getting switch type" + value = switch_entry.get("SAI_SWITCH_ATTR_TYPE") assert value == "SAI_SWITCH_TYPE_VOQ", "Switch type is not VOQ" - status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_SWITCH_ID") - assert status, "Got error while getting switch id" + value = switch_entry.get("SAI_SWITCH_ATTR_SWITCH_ID") assert value == cfg_switch_id, "VOQ switch id is invalid" - status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_MAX_SYSTEM_CORES") - assert status, "Got error while getting max system cores" + value = switch_entry.get("SAI_SWITCH_ATTR_MAX_SYSTEM_CORES") assert value == cfg_max_cores, "Max system cores is invalid" - status, value = tbl.hget(switch_oid_key, "SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST") - assert status, "Got error while getting system port config list" + value = switch_entry.get("SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST") + assert value != "", "Empty system port config list" #Convert the spcfg string to dictionary spcfg = ast.literal_eval(value) assert spcfg['count'] == sp_count, "Number of systems ports configured is invalid" @@ -81,9 +78,8 @@ def test_chassis_app_db_sync(self, vct): for name in dvss.keys(): if name.startswith("supervisor"): dvs = dvss[name] - chassis_app_db = swsscommon.DBConnector(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock, 0) - tbl = swsscommon.Table(chassis_app_db, "SYSTEM_INTERFACE") - keys = list(tbl.getKeys()) + chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock) + keys = chassis_app_db.get_keys("SYSTEM_INTERFACE") assert len(keys), "No chassis app db syncing is done" def test_chassis_system_interface(self, vct): @@ -91,32 +87,32 @@ def test_chassis_system_interface(self, vct): dvss = vct.dvss for name in dvss.keys(): dvs = dvss[name] - config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) - metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") - cfg_switch_type = "" - status, cfg_switch_type = metatbl.hget("localhost", "switch_type") + config_db = DVSDatabase(swsscommon.CONFIG_DB, dvs.redis_sock) + metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") + + cfg_switch_type = metatbl.get("switch_type") #Test only for line cards if cfg_switch_type == "voq": - status, lc_switch_id = metatbl.hget("localhost", "switch_id") - assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" + lc_switch_id = metatbl.get("switch_id") + assert lc_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" if lc_switch_id == "0": #Testing in Linecard1, In Linecard1 there will be RIF for Ethernet12 from Linecard3 #Note: Tesing can be done in any linecard for RIF of any system port interface. # Here testing is done on linecard with switch id 0 - asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) - riftbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") - keys = list(riftbl.getKeys()) + asic_db = DVSDatabase(swsscommon.ASIC_DB, dvs.redis_sock) + keys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") assert len(keys), "No router interfaces in ASIC_DB" rif_port_oid = "" for key in keys: - status, value = riftbl.hget(key, "SAI_ROUTER_INTERFACE_ATTR_TYPE") - assert status, "Got error in getting RIF type" + rif_entry = asic_db.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", key) + value = rif_entry.get("SAI_ROUTER_INTERFACE_ATTR_TYPE") + assert value != "", "Got error in getting RIF type" if value == "SAI_ROUTER_INTERFACE_TYPE_PORT": - status, value = riftbl.hget(key, "SAI_ROUTER_INTERFACE_ATTR_PORT_ID") - assert status, "Got error in getting RIF port" + value = rif_entry.get("SAI_ROUTER_INTERFACE_ATTR_PORT_ID") + assert value != "", "Got error in getting RIF port" if value.startswith("oid:0x5d"): #System port RIF, this is used as key for system port config info retrieval rif_port_oid = value @@ -124,9 +120,9 @@ def test_chassis_system_interface(self, vct): assert rif_port_oid != "", "No RIF records for remote interfaces in ASIC_DB" #Validate if the system port is from valid switch - sptbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_SYSTEM_PORT") - status, value = sptbl.hget(rif_port_oid, "SAI_SYSTEM_PORT_ATTR_CONFIG_INFO") - assert status, "Got error in getting system port config info for rif system port" + sp_entry = asic_db.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_SYSTEM_PORT", rif_port_oid) + value = sp_entry.get("SAI_SYSTEM_PORT_ATTR_CONFIG_INFO") + assert value != "", "Got error in getting system port config info for rif system port" spcfginfo = ast.literal_eval(value) #Remote system ports's switch id should not match local switch id assert spcfginfo["attached_switch_id"] != lc_switch_id, "RIF system port with wrong switch_id" @@ -144,25 +140,24 @@ def test_chassis_system_neigh(self, vct): dvss = vct.dvss for name in dvss.keys(): dvs = dvss[name] - config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) - metatbl = swsscommon.Table(config_db, "DEVICE_METADATA") - cfg_switch_type = "" - status, cfg_switch_type = metatbl.hget("localhost", "switch_type") + config_db = DVSDatabase(swsscommon.CONFIG_DB, dvs.redis_sock) + metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") + + cfg_switch_type = metatbl.get("switch_type") #Neighbor record verifiation done in line card if cfg_switch_type == "voq": - status, lc_switch_id = metatbl.hget("localhost", "switch_id") - assert status, "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" + lc_switch_id = metatbl.get("switch_id") + assert lc_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" if lc_switch_id == "0": # Add a static neighbor _, res = dvs.runcmd(['sh', "-c", "ip neigh add 10.8.101.2 lladdr 00:01:02:03:04:05 dev Ethernet0"]) assert res == "", "Error configuring static neigh" - asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) - neightbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") - neighkeys = list(neightbl.getKeys()) + asic_db = DVSDatabase(swsscommon.ASIC_DB, dvs.redis_sock) + neighkeys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") assert len(neighkeys), "No neigh entries in ASIC_DB" #Check for presence of the neighbor in ASIC_DB @@ -176,8 +171,9 @@ def test_chassis_system_neigh(self, vct): assert test_neigh != "", "Neigh not found in ASIC_DB" #Check for presence of encap index, retrieve and store it for sync verification - status, encap_index = neightbl.hget(test_neigh,"SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX") - assert status, "VOQ encap index is not programmed in ASIC_DB" + test_neigh_entry = asic_db.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", test_neigh) + encap_index = test_neigh_entry.get("SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX") + assert encap_index != "", "VOQ encap index is not programmed in ASIC_DB" break @@ -186,9 +182,8 @@ def test_chassis_system_neigh(self, vct): for name in dvss.keys(): if name.startswith("supervisor"): dvs = dvss[name] - chassis_app_db = swsscommon.DBConnector(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock, 0) - sysneightbl = swsscommon.Table(chassis_app_db, "SYSTEM_NEIGH") - sysneighkeys = list(sysneightbl.getKeys()) + chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock) + sysneighkeys = chassis_app_db.get_keys("SYSTEM_NEIGH") assert len(sysneighkeys), "No system neighbor entries in chassis app db" test_sysneigh = "" @@ -200,10 +195,16 @@ def test_chassis_system_neigh(self, vct): break assert test_sysneigh != "", "Neigh is not sync-ed to chassis app db" - - status, sys_neigh_encap_index = sysneightbl.hget(test_sysneigh,"encap_index") - assert status, "System neigh in chassis app db does not have encap index" + + test_sysneigh_entry = chassis_app_db.get_entry("SYSTEM_NEIGH", test_sysneigh) + sys_neigh_encap_index = test_sysneigh_entry.get("encap_index") + assert sys_neigh_encap_index != "", "System neigh in chassis app db does not have encap index" assert encap_index == sys_neigh_encap_index, "Encap index not sync-ed correctly" break + +# Add Dummy always-pass test at end as workaroud +# for issue when Flaky fail on final test it invokes module tear-down before retrying +def test_nonflaky_dummy(): + pass From ae86130c2927e10bd1087e7851258805e848a464 Mon Sep 17 00:00:00 2001 From: vedganes Date: Wed, 9 Dec 2020 17:47:24 -0500 Subject: [PATCH 17/21] [swss]vs test for voq nbr review comments fix 2 Signed-off-by: vedganes Changed to call dvs apis to get access to databases for the local redis instances. Changed comments format as suggested --- tests/test_virtual_chassis.py | 73 ++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index e9615bb823..4bdbc6d397 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -11,7 +11,7 @@ def test_connectivity(self, vct): nbrs = vct.get_topo_neigh() for name in dvss.keys(): dv = dvss[name] - #ping all vs's inband address + # ping all vs's inband address for ctn in vct.inbands.keys(): ip = vct.inbands[ctn]["inband_address"] ip = ip.split("/")[0] @@ -29,17 +29,24 @@ def test_connectivity(self, vct): assert '5 received' in out def test_voq_switch(self, vct): - """ Test VOQ switch objects configuration """ + """Test VOQ switch objects configuration. + + This test validates configuration of switch creation objects required for + VOQ switches. The switch_type, max_cores and switch_id attributes configuration + are verified. For the System port config list, it is verified that all the + configured system ports are avaiable in the asic db by checking the count. + """ + dvss = vct.dvss for name in dvss.keys(): dvs = dvss[name] - #Get the config info - config_db = DVSDatabase(swsscommon.CONFIG_DB, dvs.redis_sock) + # Get the config info + config_db = dvs.get_config_db() metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") cfg_switch_type = metatbl.get("switch_type") - #Test only for line cards + # Test only for line cards if cfg_switch_type == "voq": print("VOQ Switch test for {}".format(name)) cfg_switch_id = metatbl.get("switch_id") @@ -51,7 +58,7 @@ def test_voq_switch(self, vct): cfgspkeys = config_db.get_keys("SYSTEM_PORT") sp_count = len(cfgspkeys) - asic_db = DVSDatabase(swsscommon.ASIC_DB, dvs.redis_sock) + asic_db = dvs.get_asic_db() keys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_SWITCH") switch_oid_key = keys[0] @@ -68,12 +75,19 @@ def test_voq_switch(self, vct): value = switch_entry.get("SAI_SWITCH_ATTR_SYSTEM_PORT_CONFIG_LIST") assert value != "", "Empty system port config list" - #Convert the spcfg string to dictionary + # Convert the spcfg string to dictionary spcfg = ast.literal_eval(value) assert spcfg['count'] == sp_count, "Number of systems ports configured is invalid" def test_chassis_app_db_sync(self, vct): - """ Test chassis app db syncing """ + """Test chassis app db syncing. + + This test is for verifying the database sync mechanism. With the virtual chassis + setup, it is verified that at least one database entry is synced from line card to + supervisor card. An interface entry is used as sample database entry for verification + of syncing mechanism. + """ + dvss = vct.dvss for name in dvss.keys(): if name.startswith("supervisor"): @@ -83,25 +97,33 @@ def test_chassis_app_db_sync(self, vct): assert len(keys), "No chassis app db syncing is done" def test_chassis_system_interface(self, vct): - """ Test RIF record creation in ASIC_DB for remote interfaces """ + """Test RIF record creation in ASIC_DB for remote interfaces. + + This test verifies RIF programming in ASIC_DB for remote interface. The orchagent + creates RIF record for system port interfaces from other line cards. It is verified + by retrieving a RIF record from local ASIC_DB that corresponds to a remote system port + and checking that the switch id of that remote system port does not match the local asic + switch id. + """ + dvss = vct.dvss for name in dvss.keys(): dvs = dvss[name] - config_db = DVSDatabase(swsscommon.CONFIG_DB, dvs.redis_sock) + config_db = dvs.get_config_db() metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") cfg_switch_type = metatbl.get("switch_type") - #Test only for line cards + # Test only for line cards if cfg_switch_type == "voq": lc_switch_id = metatbl.get("switch_id") assert lc_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" if lc_switch_id == "0": - #Testing in Linecard1, In Linecard1 there will be RIF for Ethernet12 from Linecard3 - #Note: Tesing can be done in any linecard for RIF of any system port interface. - # Here testing is done on linecard with switch id 0 - asic_db = DVSDatabase(swsscommon.ASIC_DB, dvs.redis_sock) + # Testing in Linecard1, In Linecard1 there will be RIF for Ethernet12 from Linecard3 + # Note: Tesing can be done in any linecard for RIF of any system port interface. + # Here testing is done on linecard with switch id 0 + asic_db = dvs.get_asic_db() keys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") assert len(keys), "No router interfaces in ASIC_DB" @@ -114,23 +136,22 @@ def test_chassis_system_interface(self, vct): value = rif_entry.get("SAI_ROUTER_INTERFACE_ATTR_PORT_ID") assert value != "", "Got error in getting RIF port" if value.startswith("oid:0x5d"): - #System port RIF, this is used as key for system port config info retrieval + # System port RIF, this is used as key for system port config info retrieval rif_port_oid = value break assert rif_port_oid != "", "No RIF records for remote interfaces in ASIC_DB" - #Validate if the system port is from valid switch + # Validate if the system port is from valid switch sp_entry = asic_db.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_SYSTEM_PORT", rif_port_oid) value = sp_entry.get("SAI_SYSTEM_PORT_ATTR_CONFIG_INFO") assert value != "", "Got error in getting system port config info for rif system port" spcfginfo = ast.literal_eval(value) - #Remote system ports's switch id should not match local switch id + # Remote system ports's switch id should not match local switch id assert spcfginfo["attached_switch_id"] != lc_switch_id, "RIF system port with wrong switch_id" def test_chassis_system_neigh(self, vct): - """ Test neigh record creation and syncing to chassis app db """ + """Test neigh record creation and syncing to chassis app db. - """ This test validates that: (i) Local neighbor entry is created with encap index (ii) Local neighbor is synced to chassis ap db with assigned encap index @@ -141,12 +162,12 @@ def test_chassis_system_neigh(self, vct): for name in dvss.keys(): dvs = dvss[name] - config_db = DVSDatabase(swsscommon.CONFIG_DB, dvs.redis_sock) + config_db = dvs.get_config_db() metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") cfg_switch_type = metatbl.get("switch_type") - #Neighbor record verifiation done in line card + # Neighbor record verifiation done in line card if cfg_switch_type == "voq": lc_switch_id = metatbl.get("switch_id") assert lc_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA" @@ -156,11 +177,11 @@ def test_chassis_system_neigh(self, vct): _, res = dvs.runcmd(['sh', "-c", "ip neigh add 10.8.101.2 lladdr 00:01:02:03:04:05 dev Ethernet0"]) assert res == "", "Error configuring static neigh" - asic_db = DVSDatabase(swsscommon.ASIC_DB, dvs.redis_sock) + asic_db = dvs.get_asic_db() neighkeys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") assert len(neighkeys), "No neigh entries in ASIC_DB" - #Check for presence of the neighbor in ASIC_DB + # Check for presence of the neighbor in ASIC_DB test_neigh = "" for nkey in neighkeys: ne = ast.literal_eval(nkey) @@ -170,14 +191,14 @@ def test_chassis_system_neigh(self, vct): assert test_neigh != "", "Neigh not found in ASIC_DB" - #Check for presence of encap index, retrieve and store it for sync verification + # Check for presence of encap index, retrieve and store it for sync verification test_neigh_entry = asic_db.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", test_neigh) encap_index = test_neigh_entry.get("SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX") assert encap_index != "", "VOQ encap index is not programmed in ASIC_DB" break - #Verify neighbor record syncing with encap index + # Verify neighbor record syncing with encap index dvss = vct.dvss for name in dvss.keys(): if name.startswith("supervisor"): From d93ea798b495491f2679423e586db99d1d8528a8 Mon Sep 17 00:00:00 2001 From: vedganes Date: Tue, 22 Dec 2020 09:06:55 -0500 Subject: [PATCH 18/21] [systemport]VOQ system port code review comments fix - 7 Signed-off-by: vedganes Code review comments fixed for - Default handling for speed of the system port is removed in addSystemPorts() - Comment added to clarify types of rif-s synced to chassis app db - vs tests: connection to chassis app dp uses chassis app db id defined in dvs lib instead of using the id from swsscommon --- orchagent/intfsorch.cpp | 4 ++-- orchagent/portsorch.cpp | 11 ----------- tests/conftest.py | 1 + tests/test_virtual_chassis.py | 4 ++-- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index eb47332c79..a9c5279d02 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -1069,7 +1069,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port) if(gMySwitchType == "voq") { - //Sync the interface to add to the SYSTEM_INTERFACE table of CHASSIS_APP_DB + // Sync the interface of local port/LAG to the SYSTEM_INTERFACE table of CHASSIS_APP_DB voqSyncAddIntf(port.m_alias); } @@ -1105,7 +1105,7 @@ bool IntfsOrch::removeRouterIntfs(Port &port) if(gMySwitchType == "voq") { - //Sync the interface to del from the SYSTEM_INTERFACE table of CHASSIS_APP_DB + // Sync the removal of interface of local port/LAG to the SYSTEM_INTERFACE table of CHASSIS_APP_DB voqSyncDelIntf(port.m_alias); } diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 8e014f8f98..afde1afd6c 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4769,7 +4769,6 @@ bool PortsOrch::addSystemPorts() int32_t switch_id = -1; int32_t core_index = -1; int32_t core_port_index = -1; - int32_t speed = -1; for ( auto &fv : spFv ) { @@ -4788,11 +4787,6 @@ bool PortsOrch::addSystemPorts() core_port_index = stoi(fv.second); continue; } - if(fv.first == "speed") - { - speed = stoi(fv.second); - continue; - } if(fv.first == "system_port_id") { system_port_id = stoi(fv.second); @@ -4807,11 +4801,6 @@ bool PortsOrch::addSystemPorts() continue; } - if(speed < 0) - { - speed = 400000; - } - tuple sp_key(switch_id, core_index, core_port_index); if(m_systemPortOidMap.find(sp_key) != m_systemPortOidMap.end()) diff --git a/tests/conftest.py b/tests/conftest.py index fe86b58053..a5541f5007 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -225,6 +225,7 @@ class DockerVirtualSwitch: CONFIG_DB_ID = 4 FLEX_COUNTER_DB_ID = 5 STATE_DB_ID = 6 + CHASSIS_APP_DB_ID = 12 # FIXME: Should be broken up into helper methods in a later PR. def __init__( diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index 4bdbc6d397..513328cffc 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -92,7 +92,7 @@ def test_chassis_app_db_sync(self, vct): for name in dvss.keys(): if name.startswith("supervisor"): dvs = dvss[name] - chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock) + chassis_app_db = DVSDatabase(dvs.CHASSIS_APP_DB_ID, dvs.redis_chassis_sock) keys = chassis_app_db.get_keys("SYSTEM_INTERFACE") assert len(keys), "No chassis app db syncing is done" @@ -203,7 +203,7 @@ def test_chassis_system_neigh(self, vct): for name in dvss.keys(): if name.startswith("supervisor"): dvs = dvss[name] - chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock) + chassis_app_db = DVSDatabase(dvs.CHASSIS_APP_DB_ID, dvs.redis_chassis_sock) sysneighkeys = chassis_app_db.get_keys("SYSTEM_NEIGH") assert len(sysneighkeys), "No system neighbor entries in chassis app db" From 40fb3fc34520468711af5c23f5b85626b113509a Mon Sep 17 00:00:00 2001 From: vedganes Date: Tue, 22 Dec 2020 11:31:34 -0500 Subject: [PATCH 19/21] [systemport] VS test chgs in code review comments fix - 7 reverted Signed-off-by: vedganes Reverted changes done in vs test to use chassis app db id from dvd lib. Using the chassis app db id from swsscommon. This is to avoid python lgtm alert and test failure. --- tests/conftest.py | 1 - tests/test_virtual_chassis.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a5541f5007..fe86b58053 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -225,7 +225,6 @@ class DockerVirtualSwitch: CONFIG_DB_ID = 4 FLEX_COUNTER_DB_ID = 5 STATE_DB_ID = 6 - CHASSIS_APP_DB_ID = 12 # FIXME: Should be broken up into helper methods in a later PR. def __init__( diff --git a/tests/test_virtual_chassis.py b/tests/test_virtual_chassis.py index 513328cffc..4bdbc6d397 100644 --- a/tests/test_virtual_chassis.py +++ b/tests/test_virtual_chassis.py @@ -92,7 +92,7 @@ def test_chassis_app_db_sync(self, vct): for name in dvss.keys(): if name.startswith("supervisor"): dvs = dvss[name] - chassis_app_db = DVSDatabase(dvs.CHASSIS_APP_DB_ID, dvs.redis_chassis_sock) + chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock) keys = chassis_app_db.get_keys("SYSTEM_INTERFACE") assert len(keys), "No chassis app db syncing is done" @@ -203,7 +203,7 @@ def test_chassis_system_neigh(self, vct): for name in dvss.keys(): if name.startswith("supervisor"): dvs = dvss[name] - chassis_app_db = DVSDatabase(dvs.CHASSIS_APP_DB_ID, dvs.redis_chassis_sock) + chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock) sysneighkeys = chassis_app_db.get_keys("SYSTEM_NEIGH") assert len(sysneighkeys), "No system neighbor entries in chassis app db" From 96d5a71ff90d41e1ca38f2d794fad9fe960e9334 Mon Sep 17 00:00:00 2001 From: vedganes Date: Wed, 23 Dec 2020 15:35:37 -0500 Subject: [PATCH 20/21] [systemport] Rebase to master, neighorch conflict fix Signed-off-by: vedganes Conflict resolution fix in neighorch.cpp while rebasing to master --- orchagent/neighorch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index 01a9463e67..246d044a8b 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -629,7 +629,6 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress status = sai_neighbor_api->create_neighbor_entry(&neighbor_entry, (uint32_t)neighbor_attrs.size(), neighbor_attrs.data()); - if (status != SAI_STATUS_SUCCESS) { if (status == SAI_STATUS_ITEM_ALREADY_EXISTS) @@ -1034,7 +1033,8 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer) continue; } - if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() || m_syncdNeighbors[neighbor_entry] != mac_address) + if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() || + m_syncdNeighbors[neighbor_entry].mac != mac_address) { //Add neigh to SAI if (addNeighbor(neighbor_entry, mac_address)) From 08b256b3413217e7e388125203342341a543e61d Mon Sep 17 00:00:00 2001 From: vedganes Date: Fri, 15 Jan 2021 16:19:01 -0500 Subject: [PATCH 21/21] [voq] azure-pipeline armhf build error fix Signed-off-by: vedganes --- orchagent/portsorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index cd3e257159..104aeb57f4 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4742,7 +4742,7 @@ bool PortsOrch::getSystemPorts() return false; } - SWSS_LOG_NOTICE("SystemPort(0x%lx) - port_id:%u, switch_id:%u, core:%u, core_port:%u, speed:%u, voqs:%u", + SWSS_LOG_NOTICE("SystemPort(0x%" PRIx64 ") - port_id:%u, switch_id:%u, core:%u, core_port:%u, speed:%u, voqs:%u", system_port_list[i], attr.value.sysportconfig.port_id, attr.value.sysportconfig.attached_switch_id,