From 371eaa301b1b12085a1b250169eed999be752fff Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Mon, 22 Aug 2016 12:46:02 -0700 Subject: [PATCH] Moving portsOrch to global and refactoring intfsOrch - Moving portsOrch to global - Adding intfsOrch dependency check - Adding struct IntfsEntry - Adding increase/decrease reference count functions - Multiple IPs support - Removing trailing \n in logs --- orchagent/bufferorch.cpp | 17 +- orchagent/bufferorch.h | 3 +- orchagent/intfsorch.cpp | 297 +++++++++++++++++++--------------- orchagent/intfsorch.h | 30 +++- orchagent/main.cpp | 33 ++-- orchagent/neighorch.cpp | 67 ++++---- orchagent/neighorch.h | 11 +- orchagent/orch.cpp | 55 ++++--- orchagent/orchdaemon.cpp | 31 ++-- orchagent/orchdaemon.h | 3 +- orchagent/portsorch.cpp | 82 +++++----- orchagent/qosorch.cpp | 13 +- orchagent/qosorch.h | 47 +++--- orchagent/routeorch.cpp | 16 +- orchagent/routeorch.h | 5 +- orchagent/tunneldecaporch.cpp | 6 +- orchagent/tunneldecaporch.h | 1 - portsyncd/linksync.cpp | 2 +- 18 files changed, 388 insertions(+), 331 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 01d85108da0..8bc764fab17 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -11,6 +11,8 @@ extern sai_queue_api_t *sai_queue_api; extern sai_switch_api_t *sai_switch_api; extern sai_buffer_api_t *sai_buffer_api; +extern PortsOrch *gPortsOrch; + using namespace std; type_map BufferOrch::m_buffer_type_maps = { @@ -22,8 +24,7 @@ type_map BufferOrch::m_buffer_type_maps = { {APP_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME, new object_map()} }; -BufferOrch::BufferOrch(DBConnector *db, vector &tableNames, PortsOrch *portsOrch) : - Orch(db, tableNames), m_portsOrch(portsOrch) +BufferOrch::BufferOrch(DBConnector *db, vector &tableNames) : Orch(db, tableNames) { SWSS_LOG_ENTER(); initTableHandlers(); @@ -323,7 +324,7 @@ task_process_status BufferOrch::processQueue(Consumer &consumer) { Port port; SWSS_LOG_DEBUG("processing port:%s", port_name.c_str()); - if (!m_portsOrch->getPort(port_name, port)) + if (!gPortsOrch->getPort(port_name, port)) { SWSS_LOG_ERROR("Port with alias:%s not found\n", port_name.c_str()); return task_process_status::task_invalid_entry; @@ -395,7 +396,7 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer) { Port port; SWSS_LOG_DEBUG("processing port:%s", port_name.c_str()); - if (!m_portsOrch->getPort(port_name, port)) + if (!gPortsOrch->getPort(port_name, port)) { SWSS_LOG_ERROR("Port with alias:%s not found\n", port_name.c_str()); return task_process_status::task_invalid_entry; @@ -459,7 +460,7 @@ task_process_status BufferOrch::processIngressBufferProfileList(Consumer &consum attr.value.objlist.list = profile_list.data(); for (string port_name : port_names) { - if (!m_portsOrch->getPort(port_name, port)) + if (!gPortsOrch->getPort(port_name, port)) { SWSS_LOG_ERROR("Port with alias:%s not found\n", port_name.c_str()); return task_process_status::task_invalid_entry; @@ -505,7 +506,7 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume attr.value.objlist.list = profile_list.data(); for (string port_name : port_names) { - if (!m_portsOrch->getPort(port_name, port)) + if (!gPortsOrch->getPort(port_name, port)) { SWSS_LOG_ERROR("Port with alias:%s not found\n", port_name.c_str()); return task_process_status::task_invalid_entry; @@ -523,10 +524,6 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume void BufferOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!m_portsOrch->isInitDone()) - { - return; - } auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { diff --git a/orchagent/bufferorch.h b/orchagent/bufferorch.h index bf71712daf0..31895e92ae3 100644 --- a/orchagent/bufferorch.h +++ b/orchagent/bufferorch.h @@ -23,7 +23,7 @@ const string buffer_profile_list_field_name = "profile_list"; class BufferOrch : public Orch { public: - BufferOrch(DBConnector *db, vector &tableNames, PortsOrch *portsOrch); + BufferOrch(DBConnector *db, vector &tableNames); static type_map m_buffer_type_maps; private: typedef task_process_status (BufferOrch::*buffer_table_handler)(Consumer& consumer); @@ -39,7 +39,6 @@ class BufferOrch : public Orch task_process_status processIngressBufferProfileList(Consumer &consumer); task_process_status processEgressBufferProfileList(Consumer &consumer); - PortsOrch *m_portsOrch; buffer_table_handler_map m_bufferHandlerMap; }; #endif /* SWSS_BUFFORCH_H */ diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index a75140456af..d905d32de6c 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -8,195 +8,140 @@ #include "ipprefix.h" #include "logger.h" #include "swssnet.h" +#include "tokenize.h" extern sai_object_id_t gVirtualRouterId; extern sai_router_interface_api_t* sai_router_intfs_api; extern sai_route_api_t* sai_route_api; -IntfsOrch::IntfsOrch(DBConnector *db, string tableName, PortsOrch *portsOrch) : - Orch(db, tableName), m_portsOrch(portsOrch) +extern PortsOrch *gPortsOrch; + +IntfsOrch::IntfsOrch(DBConnector *db, string tableName) : + Orch(db, tableName) +{ + SWSS_LOG_ENTER(); +} + +sai_object_id_t IntfsOrch::getRouterIntfsId(string alias) +{ + Port port; + assert(gPortsOrch->getPort(alias, port)); + assert(port.m_rif_id); + return port.m_rif_id; +} + +void IntfsOrch::increaseRouterIntfsRefCount(const string alias) { + m_syncdIntfses[alias].ref_count++; +} + +void IntfsOrch::decreaseRouterIntfsRefCount(const string alias) +{ + m_syncdIntfses[alias].ref_count--; } void IntfsOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!m_portsOrch->isInitDone()) - return; - auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { KeyOpFieldsValuesTuple t = it->second; - string key = kfvKey(t); - size_t found = key.find(':'); - if (found == string::npos) - { - SWSS_LOG_ERROR("Failed to parse task key %s\n", key.c_str()); - it = consumer.m_toSync.erase(it); - continue; - } - string alias = key.substr(0, found); + vector keys = tokenize(kfvKey(t), ':'); + string alias(keys[0]); + IpPrefix ip_prefix(kfvKey(t).substr(kfvKey(t).find(':')+1)); - /* TODO: Sync loopback address and trap all IP packets to loopback addressy */ + /* TODO: Sync loopback address and trap all IP packets to loopback address */ if (alias == "lo" || alias == "eth0" || alias == "docker0") { it = consumer.m_toSync.erase(it); continue; } - IpPrefix ip_prefix(key.substr(found+1)); - if (!ip_prefix.isV4()) - { - it = consumer.m_toSync.erase(it); - continue; - } - string op = kfvOp(t); - if (op == SET_COMMAND) { - /* Duplicate entry */ - if (m_intfs.find(alias) != m_intfs.end() && m_intfs[alias].contains(ip_prefix.getIp())) - { - it = consumer.m_toSync.erase(it); - continue; - } - Port port; - if (!m_portsOrch->getPort(alias, port)) - { - SWSS_LOG_ERROR("Failed to locate interface %s\n", alias.c_str()); - it = consumer.m_toSync.erase(it); - continue; - } - - if (!port.m_rif_id) + if (!gPortsOrch->getPort(alias, port)) { - addRouterIntfs(port); - m_intfs[alias] = IpAddresses(); - } - - sai_unicast_route_entry_t unicast_route_entry; - unicast_route_entry.vr_id = gVirtualRouterId; - copy(unicast_route_entry.destination, ip_prefix); - subnet(unicast_route_entry.destination, unicast_route_entry.destination); - - sai_attribute_t attr; - vector attrs; - - attr.id = SAI_ROUTE_ATTR_PACKET_ACTION; - attr.value.s32 = SAI_PACKET_ACTION_FORWARD; - attrs.push_back(attr); - - attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID; - attr.value.oid = port.m_rif_id; - attrs.push_back(attr); - - sai_status_t status = sai_route_api->create_route(&unicast_route_entry, attrs.size(), attrs.data()); - if (status != SAI_STATUS_SUCCESS) - { - SWSS_LOG_ERROR("Failed to create subnet route pre:%s %d\n", ip_prefix.to_string().c_str(), status); + SWSS_LOG_INFO("Failed to locate interface %s\n", alias.c_str()); it++; continue; } - else - { - SWSS_LOG_NOTICE("Create subnet route pre:%s\n", ip_prefix.to_string().c_str()); - } - - vector ip2me_attrs; - sai_attribute_t ip2me_attr; - ip2me_attr.id = SAI_ROUTE_ATTR_PACKET_ACTION; - ip2me_attr.value.s32 = SAI_PACKET_ACTION_FORWARD; - ip2me_attrs.push_back(ip2me_attr); - ip2me_attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID; - ip2me_attr.value.oid = m_portsOrch->getCpuPort(); - ip2me_attrs.push_back(ip2me_attr); + if (m_syncdIntfses.find(alias) == m_syncdIntfses.end() || + !m_syncdIntfses[alias].ip_addresses.contains(ip_prefix.getIp())) + { + if (addRouterIntfs(port)) + { + IntfsEntry intfs_entry; + m_syncdIntfses[alias] = intfs_entry; - unicast_route_entry.vr_id = gVirtualRouterId; - copy(unicast_route_entry.destination, ip_prefix.getIp()); + addSubnetRoute(port, ip_prefix); + addIp2MeRoute(port, ip_prefix); - status = sai_route_api->create_route(&unicast_route_entry, ip2me_attrs.size(), ip2me_attrs.data()); - if (status != SAI_STATUS_SUCCESS) - { - SWSS_LOG_ERROR("Failed to create packet action trap route ip:%s %d\n", ip_prefix.getIp().to_string().c_str(), status); - it++; + m_syncdIntfses[alias].ip_addresses.add(ip_prefix.getIp()); + it = consumer.m_toSync.erase(it); + } + else + it++; } else - { - SWSS_LOG_NOTICE("Create packet action trap route ip:%s\n", ip_prefix.getIp().to_string().c_str()); - m_intfs[alias].add(ip_prefix.getIp()); + /* Duplicate entry */ it = consumer.m_toSync.erase(it); - } } else if (op == DEL_COMMAND) { - assert(m_intfs.find(alias) != m_intfs.end() && m_intfs[alias].contains(ip_prefix.getIp())); - Port port; - if (!m_portsOrch->getPort(alias, port)) + if (!gPortsOrch->getPort(alias, port)) { SWSS_LOG_ERROR("Failed to locate interface %s\n", alias.c_str()); - it = consumer.m_toSync.erase(it); - continue; + throw logic_error("Failed to locate interface."); } - sai_unicast_route_entry_t unicast_route_entry; - unicast_route_entry.vr_id = gVirtualRouterId; - copy(unicast_route_entry.destination, ip_prefix); - subnet(unicast_route_entry.destination, unicast_route_entry.destination); - - sai_status_t status = sai_route_api->remove_route(&unicast_route_entry); - if (status != SAI_STATUS_SUCCESS) + if (m_syncdIntfses.find(alias) != m_syncdIntfses.end()) { - SWSS_LOG_ERROR("Failed to remove subnet route pre:%s %d\n", ip_prefix.to_string().c_str(), status); - it++; - continue; - } + if (m_syncdIntfses[alias].ip_addresses.contains(ip_prefix.getIp())) + { + removeSubnetRoute(port, ip_prefix); + removeIp2MeRoute(port, ip_prefix); - unicast_route_entry.vr_id = gVirtualRouterId; - copy(unicast_route_entry.destination, ip_prefix); + m_syncdIntfses[alias].ip_addresses.remove(ip_prefix.getIp()); + } - status = sai_route_api->remove_route(&unicast_route_entry); - if (status != SAI_STATUS_SUCCESS) - { - SWSS_LOG_ERROR("Failed to remove action trap route ip:%s %d\n", ip_prefix.getIp().to_string().c_str(), status); - it++; + if (removeRouterIntfs(port)) + it = consumer.m_toSync.erase(it); + else + it++; } else - { - SWSS_LOG_NOTICE("Remove packet action trap route ip:%s\n", ip_prefix.getIp().to_string().c_str()); - m_intfs[alias].remove(ip_prefix.getIp()); + /* Cannot locate the interface */ it = consumer.m_toSync.erase(it); - - if (!m_intfs[alias].getSize()) - { - removeRouterIntfs(port); - m_intfs.erase(alias); - } - } } } } -bool IntfsOrch::addRouterIntfs(Port &port, sai_object_id_t virtual_router_id, MacAddress mac_address) +bool IntfsOrch::addRouterIntfs(Port &port) { SWSS_LOG_ENTER(); + /* Return true if the router interface exists */ + if (port.m_rif_id) + return true; + + /* Create router interface if the router interface doesn't exist */ sai_attribute_t attr; vector attrs; attr.id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID; - attr.value.oid = virtual_router_id; + attr.value.oid = gVirtualRouterId; attrs.push_back(attr); attr.id = SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS; - memcpy(attr.value.mac, mac_address.getMac(), sizeof(sai_mac_t)); + memcpy(attr.value.mac, gMacAddress.getMac(), sizeof(sai_mac_t)); attrs.push_back(attr); attr.id = SAI_ROUTER_INTERFACE_ATTR_TYPE; @@ -233,7 +178,6 @@ bool IntfsOrch::addRouterIntfs(Port &port, sai_object_id_t virtual_router_id, Ma SWSS_LOG_ERROR("Unsupported port type: %d", port.m_type); break; } - attrs.push_back(attr); sai_status_t status = sai_router_intfs_api->create_router_interface(&port.m_rif_id, attrs.size(), attrs.data()); @@ -243,7 +187,7 @@ bool IntfsOrch::addRouterIntfs(Port &port, sai_object_id_t virtual_router_id, Ma return false; } - m_portsOrch->setPort(port.m_alias, port); + gPortsOrch->setPort(port.m_alias, port); SWSS_LOG_NOTICE("Create router interface for port %s", port.m_alias.c_str()); @@ -254,16 +198,115 @@ bool IntfsOrch::removeRouterIntfs(Port &port) { SWSS_LOG_ENTER(); + if (m_syncdIntfses[port.m_alias].ref_count > 0) + { + SWSS_LOG_NOTICE("Router interface is still referenced"); + return false; + } + sai_status_t status = sai_router_intfs_api->remove_router_interface(port.m_rif_id); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to remove router interface for port %s", port.m_alias.c_str()); - return false; + throw runtime_error("Failed to remove router interface."); } port.m_rif_id = 0; - m_portsOrch->setPort(port.m_alias, port); + gPortsOrch->setPort(port.m_alias, port); + + SWSS_LOG_NOTICE("Remove router interface for port %s", port.m_alias.c_str()); return true; } +void IntfsOrch::addSubnetRoute(const Port &port, const IpPrefix &ip_prefix) +{ + sai_unicast_route_entry_t unicast_route_entry; + unicast_route_entry.vr_id = gVirtualRouterId; + copy(unicast_route_entry.destination, ip_prefix); + subnet(unicast_route_entry.destination, unicast_route_entry.destination); + + sai_attribute_t attr; + vector attrs; + + attr.id = SAI_ROUTE_ATTR_PACKET_ACTION; + attr.value.s32 = SAI_PACKET_ACTION_FORWARD; + attrs.push_back(attr); + + attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID; + attr.value.oid = port.m_rif_id; + attrs.push_back(attr); + + sai_status_t status = sai_route_api->create_route(&unicast_route_entry, attrs.size(), attrs.data()); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to create subnet route pre:%s %d\n", ip_prefix.to_string().c_str(), status); + throw runtime_error("Failed to create subnet route."); + } + + SWSS_LOG_NOTICE("Create subnet route pre:%s\n", ip_prefix.to_string().c_str()); + increaseRouterIntfsRefCount(port.m_alias); +} + +void IntfsOrch::removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix) +{ + sai_unicast_route_entry_t unicast_route_entry; + unicast_route_entry.vr_id = gVirtualRouterId; + copy(unicast_route_entry.destination, ip_prefix); + subnet(unicast_route_entry.destination, unicast_route_entry.destination); + + sai_status_t status = sai_route_api->remove_route(&unicast_route_entry); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to remove subnet route pre:%s %d\n", ip_prefix.to_string().c_str(), status); + throw runtime_error("Failed to remove subnet route."); + } + + SWSS_LOG_NOTICE("Remove subnet route with prefix:%s", ip_prefix.to_string().c_str()); + decreaseRouterIntfsRefCount(port.m_alias); +} + +void IntfsOrch::addIp2MeRoute(const Port &port, const IpPrefix &ip_prefix) +{ + sai_unicast_route_entry_t unicast_route_entry; + unicast_route_entry.vr_id = gVirtualRouterId; + copy(unicast_route_entry.destination, ip_prefix.getIp()); + + sai_attribute_t attr; + vector attrs; + + attr.id = SAI_ROUTE_ATTR_PACKET_ACTION; + attr.value.s32 = SAI_PACKET_ACTION_FORWARD; + attrs.push_back(attr); + + attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID; + attr.value.oid = gPortsOrch->getCpuPort(); + attrs.push_back(attr); + + sai_status_t status = sai_route_api->create_route(&unicast_route_entry, attrs.size(), attrs.data()); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to create IP2me route ip:%s %d\n", ip_prefix.getIp().to_string().c_str(), status); + throw runtime_error("Failed to create IP2me route."); + } + + SWSS_LOG_NOTICE("Create packet create IP2me route ip:%s\n", ip_prefix.getIp().to_string().c_str()); + increaseRouterIntfsRefCount(port.m_alias); +} + +void IntfsOrch::removeIp2MeRoute(const Port &port, const IpPrefix &ip_prefix) +{ + sai_unicast_route_entry_t unicast_route_entry; + unicast_route_entry.vr_id = gVirtualRouterId; + copy(unicast_route_entry.destination, ip_prefix.getIp()); + + sai_status_t status = sai_route_api->remove_route(&unicast_route_entry); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to remove IP2me route ip:%s %d\n", ip_prefix.getIp().to_string().c_str(), status); + throw runtime_error("Failed to remove IP2me route."); + } + + SWSS_LOG_NOTICE("Remove packet action trap route ip:%s\n", ip_prefix.getIp().to_string().c_str()); + decreaseRouterIntfsRefCount(port.m_alias); +} diff --git a/orchagent/intfsorch.h b/orchagent/intfsorch.h index 5d5e82f3500..2f7c8d20bf4 100644 --- a/orchagent/intfsorch.h +++ b/orchagent/intfsorch.h @@ -5,6 +5,7 @@ #include "portsorch.h" #include "ipaddresses.h" +#include "ipprefix.h" #include "macaddress.h" #include @@ -12,20 +13,37 @@ extern sai_object_id_t gVirtualRouterId; extern MacAddress gMacAddress; -typedef map IntfsTable; +struct IntfsEntry +{ + IpAddresses ip_addresses; + int ref_count; +}; + +typedef map IntfsTable; class IntfsOrch : public Orch { public: - IntfsOrch(DBConnector *db, string tableName, PortsOrch *portsOrch); + IntfsOrch(DBConnector *db, string tableName); + + sai_object_id_t getRouterIntfsId(string); + + void increaseRouterIntfsRefCount(const string); + void decreaseRouterIntfsRefCount(const string); private: - PortsOrch *m_portsOrch; - IntfsTable m_intfs; + IntfsTable m_syncdIntfses; void doTask(Consumer &consumer); - bool addRouterIntfs(Port &port, sai_object_id_t virtual_router_id = gVirtualRouterId, - MacAddress mac_address = gMacAddress); + int getRouterIntfsRefCount(string); + + bool addRouterIntfs(Port &port); bool removeRouterIntfs(Port &port); + + void addSubnetRoute(const Port &port, const IpPrefix &ip_prefix); + void removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix); + + void addIp2MeRoute(const Port &port, const IpPrefix &ip_prefix); + void removeIp2MeRoute(const Port &port, const IpPrefix &ip_prefix); }; #endif /* SWSS_INTFSORCH_H */ diff --git a/orchagent/main.cpp b/orchagent/main.cpp index bad77290230..9606fe77d67 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -40,9 +40,10 @@ sai_wred_api_t* sai_wred_api; sai_qos_map_api_t* sai_qos_map_api; sai_buffer_api_t* sai_buffer_api; +/* Global variables */ map gProfileMap; sai_object_id_t gVirtualRouterId; -sai_object_id_t underlayIfId; +sai_object_id_t gUnderlayIfId; MacAddress gMacAddress; const char *test_profile_get_value ( @@ -146,15 +147,15 @@ int main(int argc, char **argv) } } - SWSS_LOG_NOTICE("--- Starting Orchestration Agent ---\n"); + SWSS_LOG_NOTICE("--- Starting Orchestration Agent ---"); initSaiApi(); - SWSS_LOG_NOTICE("sai_switch_api: initializing switch\n"); + SWSS_LOG_NOTICE("sai_switch_api: initializing switch"); status = sai_switch_api->initialize_switch(0, "", "", &switch_notifications); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to initialize switch %d\n", status); + SWSS_LOG_ERROR("Failed to initialize switch %d", status); exit(EXIT_FAILURE); } @@ -165,7 +166,7 @@ int main(int argc, char **argv) status = sai_switch_api->get_switch_attribute(1, &attr); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get MAC address from switch %d\n", status); + SWSS_LOG_ERROR("Failed to get MAC address from switch %d", status); exit(EXIT_FAILURE); } else @@ -179,11 +180,12 @@ int main(int argc, char **argv) status = sai_switch_api->set_switch_attribute(&attr); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to set MAC address to switch %d\n", status); + SWSS_LOG_ERROR("Failed to set MAC address to switch %d", status); exit(EXIT_FAILURE); } } + /* Get the default virtual router ID */ attr.id = SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID; status = sai_switch_api->get_switch_attribute(1, &attr); if (status != SAI_STATUS_SUCCESS) @@ -193,29 +195,30 @@ int main(int argc, char **argv) } gVirtualRouterId = attr.value.oid; + SWSS_LOG_NOTICE("Get switch virtual router ID %llx", gVirtualRouterId); - SWSS_LOG_NOTICE("Get switch virtual router ID %llx\n", gVirtualRouterId); - - // create the underlay router interface to create a LOOPBACK type router interface (encap) + /* Create a loopback underlay router interface */ sai_attribute_t underlay_intf_attrs[2]; underlay_intf_attrs[0].id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID; underlay_intf_attrs[0].value.oid = gVirtualRouterId; underlay_intf_attrs[1].id = SAI_ROUTER_INTERFACE_ATTR_TYPE; underlay_intf_attrs[1].value.s32 = SAI_ROUTER_INTERFACE_TYPE_LOOPBACK; - status = sai_router_intfs_api->create_router_interface(&underlayIfId, 2, underlay_intf_attrs); + status = sai_router_intfs_api->create_router_interface(&gUnderlayIfId, 2, underlay_intf_attrs); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create underlay router interface %d", status); return false; } - SWSS_LOG_NOTICE("Created underlay router interface ID %llx\n", underlayIfId); + SWSS_LOG_NOTICE("Created underlay router interface ID %llx", gUnderlayIfId); - OrchDaemon *orchDaemon = new OrchDaemon(); + /* Initialize orchestration components */ + DBConnector *appl_db = new DBConnector(APPL_DB, "localhost", 6379, 0); + OrchDaemon *orchDaemon = new OrchDaemon(appl_db); if (!orchDaemon->init()) { - SWSS_LOG_ERROR("Failed to initialize orchstration daemon\n"); + SWSS_LOG_ERROR("Failed to initialize orchstration daemon"); exit(EXIT_FAILURE); } @@ -224,11 +227,11 @@ int main(int argc, char **argv) } catch (char const *e) { - SWSS_LOG_ERROR("Exception: %s\n", e); + SWSS_LOG_ERROR("Exception: %s", e); } catch (exception& e) { - SWSS_LOG_ERROR("Failed due to exception: %s\n", e.what()); + SWSS_LOG_ERROR("Failed due to exception: %s", e.what()); } return 0; diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index 2a3921185fb..df11ed64fb8 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -6,19 +6,25 @@ extern sai_neighbor_api_t* sai_neighbor_api; extern sai_next_hop_api_t* sai_next_hop_api; +extern PortsOrch *gPortsOrch; + +NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch) : + Orch(db, tableName), m_intfsOrch(intfsOrch) +{ + SWSS_LOG_ENTER(); +} + bool NeighOrch::hasNextHop(IpAddress ipAddress) { return m_syncdNextHops.find(ipAddress) != m_syncdNextHops.end(); } -bool NeighOrch::addNextHop(IpAddress ipAddress, Port port) +bool NeighOrch::addNextHop(IpAddress ipAddress, string alias) { SWSS_LOG_ENTER(); assert(!hasNextHop(ipAddress)); - - if (port.m_rif_id == 0) - return false; + sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(alias); sai_attribute_t next_hop_attrs[3]; next_hop_attrs[0].id = SAI_NEXT_HOP_ATTR_TYPE; @@ -26,26 +32,31 @@ bool NeighOrch::addNextHop(IpAddress ipAddress, Port port) next_hop_attrs[1].id = SAI_NEXT_HOP_ATTR_IP; copy(next_hop_attrs[1].value.ipaddr, ipAddress); next_hop_attrs[2].id = SAI_NEXT_HOP_ATTR_ROUTER_INTERFACE_ID; - next_hop_attrs[2].value.oid = port.m_rif_id; + next_hop_attrs[2].value.oid = rif_id; sai_object_id_t next_hop_id; sai_status_t status = sai_next_hop_api->create_next_hop(&next_hop_id, 3, next_hop_attrs); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to create next hop entry ip:%s rid%llx\n", - ipAddress.to_string().c_str(), port.m_rif_id); + SWSS_LOG_ERROR("Failed to create next hop entry ip:%s rid:%llx", + ipAddress.to_string().c_str(), rif_id); return false; } + SWSS_LOG_NOTICE("Create next hop entry id:%llx, ip:%s, rid:%llx\n", + next_hop_id, ipAddress.to_string().c_str(), rif_id); + NextHopEntry next_hop_entry; next_hop_entry.next_hop_id = next_hop_id; next_hop_entry.ref_count = 0; m_syncdNextHops[ipAddress] = next_hop_entry; + m_intfsOrch->increaseRouterIntfsRefCount(alias); + return true; } -bool NeighOrch::removeNextHop(IpAddress ipAddress) +bool NeighOrch::removeNextHop(IpAddress ipAddress, string alias) { SWSS_LOG_ENTER(); @@ -59,6 +70,7 @@ bool NeighOrch::removeNextHop(IpAddress ipAddress) } m_syncdNextHops.erase(ipAddress); + m_intfsOrch->decreaseRouterIntfsRefCount(alias); return true; } @@ -90,9 +102,6 @@ void NeighOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!m_portsOrch->isInitDone()) - return; - auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { @@ -110,7 +119,7 @@ void NeighOrch::doTask(Consumer &consumer) string alias = key.substr(0, found); Port p; - if (!m_portsOrch->getPort(alias, p)) + if (!gPortsOrch->getPort(alias, p)) { it = consumer.m_toSync.erase(it); continue; @@ -140,6 +149,7 @@ void NeighOrch::doTask(Consumer &consumer) it++; } else + /* Duplicate entry */ it = consumer.m_toSync.erase(it); } else if (op == DEL_COMMAND) @@ -171,14 +181,10 @@ bool NeighOrch::addNeighbor(NeighborEntry neighborEntry, MacAddress macAddress) IpAddress ip_address = neighborEntry.ip_address; string alias = neighborEntry.alias; - Port p; - m_portsOrch->getPort(alias, p); - - if (p.m_rif_id == 0) - return false; + sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(alias); sai_neighbor_entry_t neighbor_entry; - neighbor_entry.rif_id = p.m_rif_id; + neighbor_entry.rif_id = rif_id; copy(neighbor_entry.ip_address, ip_address); sai_attribute_t neighbor_attr; @@ -194,15 +200,18 @@ bool NeighOrch::addNeighbor(NeighborEntry neighborEntry, MacAddress macAddress) return false; } - SWSS_LOG_NOTICE("Create neighbor entry rid:%llx alias:%s ip:%s\n", p.m_rif_id, alias.c_str(), ip_address.to_string().c_str()); + SWSS_LOG_NOTICE("Create neighbor entry rid:%llx alias:%s ip:%s\n", rif_id, alias.c_str(), ip_address.to_string().c_str()); + m_intfsOrch->increaseRouterIntfsRefCount(alias); - if (!addNextHop(ip_address, p)) + if (!addNextHop(ip_address, alias)) { status = sai_neighbor_api->remove_neighbor_entry(&neighbor_entry); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to remove neighbor entry rid:%llx alias:%s ip:%s\n", p.m_rif_id, alias.c_str(), ip_address.to_string().c_str()); + SWSS_LOG_ERROR("Failed to remove neighbor entry rid:%llx alias:%s ip:%s\n", rif_id, alias.c_str(), ip_address.to_string().c_str()); + return false; } + m_intfsOrch->decreaseRouterIntfsRefCount(alias); return false; } @@ -234,15 +243,10 @@ bool NeighOrch::removeNeighbor(NeighborEntry neighborEntry) return false; } - Port p; - if (!m_portsOrch->getPort(alias, p)) - { - SWSS_LOG_ERROR("Failed to locate port alias:%s\n", alias.c_str()); - return false; - } + sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(alias); sai_neighbor_entry_t neighbor_entry; - neighbor_entry.rif_id = p.m_rif_id; + neighbor_entry.rif_id = rif_id; copy(neighbor_entry.ip_address, ip_address); sai_object_id_t next_hop_id = m_syncdNextHops[ip_address].next_hop_id; @@ -266,16 +270,17 @@ bool NeighOrch::removeNeighbor(NeighborEntry neighborEntry) { if (status == SAI_STATUS_ITEM_NOT_FOUND) { - SWSS_LOG_ERROR("Failed to locate neigbor entry rid:%llx ip:%s\n", p.m_rif_id, ip_address.to_string().c_str()); + SWSS_LOG_ERROR("Failed to locate neigbor entry rid:%llx ip:%s\n", rif_id, ip_address.to_string().c_str()); return true; } - SWSS_LOG_ERROR("Failed to remove neighbor entry rid:%llx ip:%s\n", p.m_rif_id, ip_address.to_string().c_str()); + SWSS_LOG_ERROR("Failed to remove neighbor entry rid:%llx ip:%s\n", rif_id, ip_address.to_string().c_str()); return false; } m_syncdNeighbors.erase(neighborEntry); - removeNextHop(ip_address); + m_intfsOrch->decreaseRouterIntfsRefCount(alias); + removeNextHop(ip_address, alias); return true; } diff --git a/orchagent/neighorch.h b/orchagent/neighorch.h index ac129eef36e..735f401718b 100644 --- a/orchagent/neighorch.h +++ b/orchagent/neighorch.h @@ -3,6 +3,7 @@ #include "orch.h" #include "portsorch.h" +#include "intfsorch.h" #include "ipaddress.h" @@ -31,9 +32,7 @@ typedef map NextHopTable; class NeighOrch : public Orch { public: - NeighOrch(DBConnector *db, string tableName, PortsOrch *portsOrch) : - Orch(db, tableName), - m_portsOrch(portsOrch) {}; + NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch); bool hasNextHop(IpAddress); @@ -44,13 +43,13 @@ class NeighOrch : public Orch void decreaseNextHopRefCount(IpAddress); private: - PortsOrch *m_portsOrch; + IntfsOrch *m_intfsOrch; NeighborTable m_syncdNeighbors; NextHopTable m_syncdNextHops; - bool addNextHop(IpAddress, Port); - bool removeNextHop(IpAddress); + bool addNextHop(IpAddress, string); + bool removeNextHop(IpAddress, string); bool addNeighbor(NeighborEntry, MacAddress); bool removeNeighbor(NeighborEntry); diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index c3b2b8bef62..c016d12f4cf 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -1,10 +1,14 @@ +#include + #include "orch.h" +#include "portsorch.h" #include "tokenize.h" #include "logger.h" -#include using namespace swss; +extern PortsOrch *gPortsOrch; + Orch::Orch(DBConnector *db, string tableName) : m_db(db) { @@ -41,7 +45,7 @@ vector Orch::getSelectables() bool Orch::hasSelectable(ConsumerTable *selectable) const { for(auto it : m_consumerMap) { - if(it.second.m_consumer == selectable) { + if (it.second.m_consumer == selectable) { return true; } } @@ -53,7 +57,7 @@ bool Orch::execute(string tableName) SWSS_LOG_ENTER(); auto consumer_it = m_consumerMap.find(tableName); - if(consumer_it == m_consumerMap.end()) + if (consumer_it == m_consumerMap.end()) { SWSS_LOG_ERROR("Unrecognized tableName:%s\n", tableName.c_str()); return false; @@ -69,7 +73,7 @@ bool Orch::execute(string tableName) dumpTuple(consumer, new_data); /* If a new task comes or if a DEL task comes, we directly put it into consumer.m_toSync map */ - if(consumer.m_toSync.find(key) == consumer.m_toSync.end() || op == DEL_COMMAND) + if (consumer.m_toSync.find(key) == consumer.m_toSync.end() || op == DEL_COMMAND) { consumer.m_toSync[key] = new_data; } @@ -91,7 +95,7 @@ bool Orch::execute(string tableName) while (iu != existing_values.end()) { string ofield = fvField(*iu); - if(field == ofield) + if (field == ofield) iu = existing_values.erase(iu); else iu++; @@ -101,7 +105,7 @@ bool Orch::execute(string tableName) consumer.m_toSync[key] = KeyOpFieldsValuesTuple(key, op, existing_values); } - if(!consumer.m_toSync.empty()) + if (!consumer.m_toSync.empty()) doTask(consumer); return true; @@ -116,12 +120,12 @@ bool Orch::parseReference(type_map &type_maps, string &ref_in, string &type_name { SWSS_LOG_ENTER(); SWSS_LOG_DEBUG("input:%s", ref_in.c_str()); - if(ref_in.size() < 3) + if (ref_in.size() < 3) { SWSS_LOG_ERROR("invalid reference received:%s\n", ref_in.c_str()); return false; } - if((ref_in[0] != ref_start) && (ref_in[ref_in.size()-1] != ref_end)) + if ((ref_in[0] != ref_start) && (ref_in[ref_in.size()-1] != ref_end)) { SWSS_LOG_ERROR("malformed reference:%s. Must be surrounded by [ ]\n", ref_in.c_str()); return false; @@ -129,20 +133,20 @@ bool Orch::parseReference(type_map &type_maps, string &ref_in, string &type_name string ref_content = ref_in.substr(1, ref_in.size() - 2); vector tokens; tokens = tokenize(ref_content, delimiter); - if(tokens.size() != 2) + if (tokens.size() != 2) { SWSS_LOG_ERROR("malformed reference:%s. Must contain 2 tokens\n", ref_content.c_str()); return false; } auto type_it = type_maps.find(tokens[0]); - if(type_it == type_maps.end()) + if (type_it == type_maps.end()) { SWSS_LOG_ERROR("not recognized type:%s\n", tokens[0].c_str()); return false; } auto obj_map = type_maps[tokens[0]]; auto obj_it = obj_map->find(tokens[1]); - if(obj_it == obj_map->end()) + if (obj_it == obj_map->end()) { SWSS_LOG_ERROR("map:%s does not contain object with name:%s\n", tokens[0].c_str(), tokens[1].c_str()); return false; @@ -163,16 +167,16 @@ ref_resolve_status Orch::resolveFieldRefValue( size_t count = 0; for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) { - if(fvField(*i) == field_name) + if (fvField(*i) == field_name) { SWSS_LOG_DEBUG("field:%s, value:%s", fvField(*i).c_str(), fvValue(*i).c_str()); - if(count > 1) + if (count > 1) { SWSS_LOG_ERROR("Singleton field with name:%s must have only 1 instance, actual count:%d\n", field_name.c_str(), count); return ref_resolve_status::multiple_instances; } string ref_type_name, object_name; - if(!parseReference(type_maps, fvValue(*i), ref_type_name, object_name)) + if (!parseReference(type_maps, fvValue(*i), ref_type_name, object_name)) { return ref_resolve_status::not_resolved; } @@ -180,7 +184,7 @@ ref_resolve_status Orch::resolveFieldRefValue( count++; } } - if(0 == count) + if (0 == count) { SWSS_LOG_NOTICE("field with name:%s not found\n", field_name.c_str()); return ref_resolve_status::field_not_found; @@ -190,9 +194,12 @@ ref_resolve_status Orch::resolveFieldRefValue( void Orch::doTask() { + if (!gPortsOrch->isInitDone()) + return; + for(auto &it : m_consumerMap) { - if(!it.second.m_toSync.empty()) + if (!it.second.m_toSync.empty()) doTask(it.second); } } @@ -219,9 +226,9 @@ ref_resolve_status Orch::resolveFieldRefArray( sai_object_arr.clear(); for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) { - if(fvField(*i) == field_name) + if (fvField(*i) == field_name) { - if(count > 1) + if (count > 1) { SWSS_LOG_ERROR("Singleton field with name:%s must have only 1 instance, actual count:%d\n", field_name.c_str(), count); return ref_resolve_status::multiple_instances; @@ -229,7 +236,7 @@ ref_resolve_status Orch::resolveFieldRefArray( string ref_type_name, object_name; string list = fvValue(*i); vector list_items; - if(list.find(list_item_delimiter) != string::npos) + if (list.find(list_item_delimiter) != string::npos) { list_items = tokenize(list, list_item_delimiter); } @@ -239,7 +246,7 @@ ref_resolve_status Orch::resolveFieldRefArray( } for (size_t ind = 0; ind < list_items.size(); ind++) { - if(!parseReference(type_maps, list_items[ind], ref_type_name, object_name)) + if (!parseReference(type_maps, list_items[ind], ref_type_name, object_name)) { SWSS_LOG_ERROR("Failed to parse profile reference:%s\n", list_items[ind].c_str()); return ref_resolve_status::not_resolved; @@ -251,7 +258,7 @@ ref_resolve_status Orch::resolveFieldRefArray( count++; } } - if(0 == count) + if (0 == count) { SWSS_LOG_NOTICE("field with name:%s not found\n", field_name.c_str()); return ref_resolve_status::field_not_found; @@ -263,18 +270,18 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin { SWSS_LOG_ENTER(); SWSS_LOG_DEBUG("input:%s", input.c_str()); - if(input.find(range_specifier) != string::npos) + if (input.find(range_specifier) != string::npos) { vector range_values; range_values = tokenize(input, range_specifier); - if(range_values.size() != 2) + if (range_values.size() != 2) { SWSS_LOG_ERROR("malformed index range in:%s. Must contain 2 tokens\n", input.c_str()); return false; } range_low = stoul(range_values[0]); range_high = stoul(range_values[1]); - if(range_low >= range_high) + if (range_low >= range_high) { SWSS_LOG_ERROR("malformed index range in:%s. left value must be less than righ value.\n", input.c_str()); return false; diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 9a32a4dee3e..81327a9ef1a 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -7,20 +7,18 @@ using namespace std; using namespace swss; -OrchDaemon::OrchDaemon() +/* Global variable gPortsOrch declared */ +PortsOrch *gPortsOrch; + +OrchDaemon::OrchDaemon(DBConnector *applDb) : + m_applDb(applDb) { - m_applDb = nullptr; - m_asicDb = nullptr; + SWSS_LOG_ENTER(); } OrchDaemon::~OrchDaemon() { - if (m_applDb) - delete(m_applDb); - - if (m_asicDb) - delete(m_asicDb); - + SWSS_LOG_ENTER(); for (Orch *o : m_orchList) delete(o); } @@ -28,7 +26,6 @@ OrchDaemon::~OrchDaemon() bool OrchDaemon::init() { SWSS_LOG_ENTER(); - m_applDb = new DBConnector(APPL_DB, "localhost", 6379, 0); vector ports_tables = { APP_PORT_TABLE_NAME, @@ -36,10 +33,10 @@ bool OrchDaemon::init() APP_LAG_TABLE_NAME }; - PortsOrch *ports_orch = new PortsOrch(m_applDb, ports_tables); - IntfsOrch *intfs_orch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, ports_orch); - NeighOrch *neigh_orch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, ports_orch); - RouteOrch *route_orch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, ports_orch, neigh_orch); + gPortsOrch = new PortsOrch(m_applDb, ports_tables); + IntfsOrch *intfs_orch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME); + NeighOrch *neigh_orch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, intfs_orch); + RouteOrch *route_orch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, neigh_orch); CoppOrch *copp_orch = new CoppOrch(m_applDb, APP_COPP_TABLE_NAME); TunnelDecapOrch *tunnel_decap_orch = new TunnelDecapOrch(m_applDb, APP_TUNNEL_DECAP_TABLE_NAME); @@ -54,7 +51,7 @@ bool OrchDaemon::init() APP_PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_NAME, APP_PFC_PRIORITY_TO_QUEUE_MAP_NAME }; - QosOrch *qos_orch = new QosOrch(m_applDb, qos_tables, ports_orch); + QosOrch *qos_orch = new QosOrch(m_applDb, qos_tables); vector buffer_tables = { APP_BUFFER_POOL_TABLE_NAME, @@ -64,10 +61,10 @@ bool OrchDaemon::init() APP_BUFFER_PORT_INGRESS_PROFILE_LIST_NAME, APP_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME }; - BufferOrch *buffer_orch = new BufferOrch(m_applDb, buffer_tables, ports_orch); + BufferOrch *buffer_orch = new BufferOrch(m_applDb, buffer_tables); + m_orchList = { gPortsOrch, intfs_orch, neigh_orch, route_orch, copp_orch, tunnel_decap_orch, qos_orch, buffer_orch }; m_select = new Select(); - m_orchList = { ports_orch, intfs_orch, neigh_orch, route_orch, copp_orch, tunnel_decap_orch, qos_orch, buffer_orch }; return true; } diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 0968edf4d5b..c92b7bdf5a1 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -20,14 +20,13 @@ using namespace swss; class OrchDaemon { public: - OrchDaemon(); + OrchDaemon(DBConnector *); ~OrchDaemon(); bool init(); void start(); private: DBConnector *m_applDb; - DBConnector *m_asicDb; std::vector m_orchList; Select *m_select; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 6b30cad43ce..40ef35ecbd1 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1,9 +1,9 @@ #include "portsorch.h" +#include #include #include #include -#include "assert.h" #include "net/if.h" @@ -38,7 +38,8 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : status = sai_switch_api->get_switch_attribute(1, &attr); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get CPU port\n"); + SWSS_LOG_ERROR("Failed to get CPU port"); + throw "PortsOrch initialization failure"; } m_cpuPort = attr.value.oid; @@ -49,12 +50,13 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : status = sai_switch_api->get_switch_attribute(1, &attr); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get port number\n"); + SWSS_LOG_ERROR("Failed to get port number"); + throw "PortsOrch initialization failure"; } m_portCount = attr.value.u32; - SWSS_LOG_NOTICE("Get port number : %d\n", m_portCount); + SWSS_LOG_NOTICE("Get port number : %d", m_portCount); /* Get port list */ sai_object_id_t *port_list = new sai_object_id_t[m_portCount]; @@ -66,6 +68,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get port list"); + throw "PortsOrch initialization failure"; } /* Get port hardware lane info */ @@ -79,7 +82,8 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : status = sai_port_api->get_port_attribute(port_list[i], 1, &attr); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get hardware lane list pid:%llx\n", port_list[i]); + SWSS_LOG_ERROR("Failed to get hardware lane list pid:%llx", port_list[i]); + throw "PortsOrch initialization failure"; } set tmp_lane_set; @@ -93,7 +97,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : } tmp_lane_str = tmp_lane_str.substr(0, tmp_lane_str.size()-1); - SWSS_LOG_NOTICE("Get port with lanes pid:%llx lanes:%s\n", port_list[i], tmp_lane_str.c_str()); + SWSS_LOG_NOTICE("Get port with lanes pid:%llx lanes:%s", port_list[i], tmp_lane_str.c_str()); m_portListLaneMap[tmp_lane_set] = port_list[i]; } @@ -106,8 +110,10 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : status = sai_port_api->set_port_attribute(port_list[i], &attr); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to set port to hardware learn mode pid:%llx\n", port_list[i]); + SWSS_LOG_ERROR("Failed to set port to hardware learn mode pid:%llx", port_list[i]); + throw "PortsOrch initialization failure"; } + SWSS_LOG_NOTICE("Set port to hardware learn mode pid:%llx", port_list[i]); } /* Get default VLAN member list */ @@ -120,6 +126,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get default VLAN member list"); + throw "PortsOrch initialization failure"; } /* Remove port from default VLAN */ @@ -129,6 +136,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to remove port from default VLAN %d", i); + throw "PortsOrch initialization failure"; } } } @@ -199,7 +207,7 @@ void PortsOrch::doPortTask(Consumer &consumer) if (!m_initDone) { m_initDone = true; - SWSS_LOG_INFO("Get ConfigDone notification from portsyncd.\n"); + SWSS_LOG_INFO("Get ConfigDone notification from portsyncd."); } it = consumer.m_toSync.erase(it); @@ -241,7 +249,7 @@ void PortsOrch::doPortTask(Consumer &consumer) /* Determin if the port has already been initialized before */ if (m_portList.find(alias) != m_portList.end() && m_portList[alias].m_port_id == id) - SWSS_LOG_NOTICE("Port has already been initialized before alias:%s\n", alias.c_str()); + SWSS_LOG_NOTICE("Port has already been initialized before alias:%s", alias.c_str()); else { Port p(alias, Port::PHY); @@ -262,15 +270,15 @@ void PortsOrch::doPortTask(Consumer &consumer) vector.push_back(tuple); m_counterTable->set("", vector); - SWSS_LOG_NOTICE("Port is initialized alias:%s\n", alias.c_str()); + SWSS_LOG_NOTICE("Port is initialized alias:%s", alias.c_str()); } else - SWSS_LOG_ERROR("Failed to initialize port alias:%s\n", alias.c_str()); + SWSS_LOG_ERROR("Failed to initialize port alias:%s", alias.c_str()); } } else - SWSS_LOG_ERROR("Failed to locate port lane combination alias:%s\n", alias.c_str()); + SWSS_LOG_ERROR("Failed to locate port lane combination alias:%s", alias.c_str()); } if (admin_status != "") @@ -279,20 +287,20 @@ void PortsOrch::doPortTask(Consumer &consumer) if (getPort(alias, p)) { if (setPortAdminStatus(p.m_port_id, admin_status == "up")) - SWSS_LOG_NOTICE("Port is set to admin %s alias:%s\n", admin_status.c_str(), alias.c_str()); + SWSS_LOG_NOTICE("Port is set to admin %s alias:%s", admin_status.c_str(), alias.c_str()); else { - SWSS_LOG_ERROR("Failed to set port to admin %s alias:%s\n", admin_status.c_str(), alias.c_str()); + SWSS_LOG_ERROR("Failed to set port to admin %s alias:%s", admin_status.c_str(), alias.c_str()); it++; continue; } } else - SWSS_LOG_ERROR("Failed to get port id by alias:%s\n", alias.c_str()); + SWSS_LOG_ERROR("Failed to get port id by alias:%s", alias.c_str()); } } else - SWSS_LOG_ERROR("Unknown operation type %s\n", op.c_str()); + SWSS_LOG_ERROR("Unknown operation type %s", op.c_str()); it = consumer.m_toSync.erase(it); } @@ -340,7 +348,6 @@ void PortsOrch::doVlanTask(Consumer &consumer) /* Duplicate entry */ if (m_portList.find(vlan_alias) != m_portList.end()) { - SWSS_LOG_ERROR("Duplicate VLAN entry alias:%s", vlan_alias.c_str()); it = consumer.m_toSync.erase(it); continue; } @@ -353,7 +360,7 @@ void PortsOrch::doVlanTask(Consumer &consumer) else if (op == DEL_COMMAND) { Port vlan; - assert(getPort(vlan_alias, vlan)); + getPort(vlan_alias, vlan); if (removeVlan(vlan)) it = consumer.m_toSync.erase(it); @@ -371,16 +378,14 @@ void PortsOrch::doVlanTask(Consumer &consumer) { assert(m_portList.find(vlan_alias) != m_portList.end()); Port vlan, port; - assert(getPort(vlan_alias, vlan)); - assert(getPort(port_alias, port)); + getPort(vlan_alias, vlan); + getPort(port_alias, port); if (op == SET_COMMAND) { /* Duplicate entry */ if (vlan.m_members.find(port_alias) != vlan.m_members.end()) { - SWSS_LOG_ERROR("Duplicate VLAN member entry vlan:%s port:%s", - vlan_alias.c_str(), port_alias.c_str()); it = consumer.m_toSync.erase(it); continue; } @@ -411,7 +416,7 @@ void PortsOrch::doVlanTask(Consumer &consumer) } else { - SWSS_LOG_ERROR("Unknown operation type %s\n", op.c_str()); + SWSS_LOG_ERROR("Unknown operation type %s", op.c_str()); it = consumer.m_toSync.erase(it); } } @@ -449,7 +454,6 @@ void PortsOrch::doLagTask(Consumer &consumer) /* Duplicate entry */ if (m_portList.find(lag_alias) != m_portList.end()) { - SWSS_LOG_ERROR("Duplicate LAG entry alias:%s", lag_alias.c_str()); it = consumer.m_toSync.erase(it); continue; } @@ -462,7 +466,7 @@ void PortsOrch::doLagTask(Consumer &consumer) else if (op == DEL_COMMAND) { Port lag; - assert(getPort(lag_alias, lag)); + getPort(lag_alias, lag); if (removeLag(lag)) it = consumer.m_toSync.erase(it); @@ -471,7 +475,7 @@ void PortsOrch::doLagTask(Consumer &consumer) } else { - SWSS_LOG_ERROR("Unknown operation type %s\n", op.c_str()); + SWSS_LOG_ERROR("Unknown operation type %s", op.c_str()); it = consumer.m_toSync.erase(it); } } @@ -480,16 +484,14 @@ void PortsOrch::doLagTask(Consumer &consumer) { assert(m_portList.find(lag_alias) != m_portList.end()); Port lag, port; - assert(getPort(lag_alias, lag)); - assert(getPort(port_alias, port)); + getPort(lag_alias, lag); + getPort(port_alias, port); if (op == SET_COMMAND) { /* Duplicate entry */ if (lag.m_members.find(port_alias) != lag.m_members.end()) { - SWSS_LOG_ERROR("Duplicate LAG member entry lag:%s port:%s", - lag_alias.c_str(), port_alias.c_str()); it = consumer.m_toSync.erase(it); continue; } @@ -516,7 +518,7 @@ void PortsOrch::doLagTask(Consumer &consumer) } else { - SWSS_LOG_ERROR("Unknown operation type %s\n", op.c_str()); + SWSS_LOG_ERROR("Unknown operation type %s", op.c_str()); it = consumer.m_toSync.erase(it); } } @@ -595,7 +597,7 @@ bool PortsOrch::initializePort(Port &p) { SWSS_LOG_ENTER(); - SWSS_LOG_NOTICE("Initializing port alias:%s pid:%llx\n", p.m_alias.c_str(), p.m_port_id); + SWSS_LOG_NOTICE("Initializing port alias:%s pid:%llx", p.m_alias.c_str(), p.m_port_id); if (!initializePriorityGroups(p)) { @@ -612,7 +614,7 @@ bool PortsOrch::initializePort(Port &p) /* Set up host interface */ if (!addHostIntfs(p.m_port_id, p.m_alias, p.m_hif_id)) { - SWSS_LOG_ERROR("Failed to set up host interface pid:%llx alias:%s\n", p.m_port_id, p.m_alias.c_str()); + SWSS_LOG_ERROR("Failed to set up host interface pid:%llx alias:%s", p.m_port_id, p.m_alias.c_str()); return false; } @@ -623,7 +625,7 @@ bool PortsOrch::initializePort(Port &p) p.m_ifindex = if_nametoindex(p.m_alias.c_str()); if (p.m_ifindex == 0) { - SWSS_LOG_ERROR("Failed to get netdev index alias:%s\n", p.m_alias.c_str()); + SWSS_LOG_ERROR("Failed to get netdev index alias:%s", p.m_alias.c_str()); return false; } #endif @@ -631,7 +633,7 @@ bool PortsOrch::initializePort(Port &p) /* Set port admin status UP */ if (!setPortAdminStatus(p.m_port_id, true)) { - SWSS_LOG_ERROR("Failed to set port admin status UP pid:%llx\n", p.m_port_id); + SWSS_LOG_ERROR("Failed to set port admin status UP pid:%llx", p.m_port_id); return false; } return true; @@ -659,7 +661,7 @@ bool PortsOrch::addHostIntfs(sai_object_id_t id, string alias, sai_object_id_t & sai_status_t status = sai_hostif_api->create_hostif(&host_intfs_id, attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to create host interface\n"); + SWSS_LOG_ERROR("Failed to create host interface"); return false; } @@ -840,11 +842,11 @@ bool PortsOrch::removeLag(Port lag) sai_status_t status = sai_lag_api->remove_lag(lag.m_lag_id); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to remove LAG %s lid:%llx\n", lag.m_alias.c_str(), lag.m_lag_id); + SWSS_LOG_ERROR("Failed to remove LAG %s lid:%llx", lag.m_alias.c_str(), lag.m_lag_id); return false; } - SWSS_LOG_NOTICE("Remove LAG %s lid:%llx\n", lag.m_alias.c_str(), lag.m_lag_id); + SWSS_LOG_NOTICE("Remove LAG %s lid:%llx", lag.m_alias.c_str(), lag.m_lag_id); m_portList.erase(lag.m_alias); @@ -871,12 +873,12 @@ bool PortsOrch::addLagMember(Port lag, Port port) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to add member %s to LAG %s lid:%llx pid:%llx\n", + SWSS_LOG_ERROR("Failed to add member %s to LAG %s lid:%llx pid:%llx", port.m_alias.c_str(), lag.m_alias.c_str(), lag.m_lag_id, port.m_port_id); return false; } - SWSS_LOG_NOTICE("Add member %s to LAG %s lid:%llx pid:%llx\n", + SWSS_LOG_NOTICE("Add member %s to LAG %s lid:%llx pid:%llx", port.m_alias.c_str(), lag.m_alias.c_str(), lag.m_lag_id, port.m_port_id); port.m_lag_id = lag.m_lag_id; diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 1a83cc8b64b..cd30343b616 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -16,6 +16,8 @@ extern sai_qos_map_api_t *sai_qos_map_api; extern sai_scheduler_group_api_t *sai_scheduler_group_api; extern sai_switch_api_t *sai_switch_api; +extern PortsOrch *gPortsOrch; + map ecn_map = { {"ecn_none", SAI_ECN_MARK_MODE_NONE}, {"ecn_green", SAI_ECN_MARK_MODE_GREEN}, @@ -551,8 +553,7 @@ task_process_status QosOrch::handlePfcToQueueTable(Consumer& consumer) return pfc_to_queue_handler.processWorkItem(consumer); } -QosOrch::QosOrch(DBConnector *db, vector &tableNames, PortsOrch *portsOrch) : - Orch(db, tableNames), m_portsOrch(portsOrch) +QosOrch::QosOrch(DBConnector *db, vector &tableNames) : Orch(db, tableNames) { SWSS_LOG_ENTER(); initTableHandlers(); @@ -847,7 +848,7 @@ task_process_status QosOrch::handleQueueTable(Consumer& consumer) { Port port; SWSS_LOG_DEBUG("processing port:%s", port_name.c_str()); - if (!m_portsOrch->getPort(port_name, port)) + if (!gPortsOrch->getPort(port_name, port)) { SWSS_LOG_ERROR("Port with alias:%s not found\n", port_name.c_str()); return task_process_status::task_invalid_entry; @@ -1031,7 +1032,7 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer) { Port port; SWSS_LOG_DEBUG("processing port:%s", port_name.c_str()); - if (!m_portsOrch->getPort(port_name, port)) + if (!gPortsOrch->getPort(port_name, port)) { SWSS_LOG_ERROR("Port with alias:%s not found\n", port_name.c_str()); return task_process_status::task_invalid_entry; @@ -1082,10 +1083,6 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer) void QosOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!m_portsOrch->isInitDone()) - { - return; - } auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { diff --git a/orchagent/qosorch.h b/orchagent/qosorch.h index 402539d0a98..67d0183aade 100644 --- a/orchagent/qosorch.h +++ b/orchagent/qosorch.h @@ -5,20 +5,21 @@ #include "orch.h" #include "portsorch.h" -const string tc_to_pg_map_field_name = "tc_to_pg_map"; +const string dscp_to_tc_field_name = "dscp_to_tc_map"; const string pfc_to_pg_map_name = "pfc_to_pg_map"; const string pfc_to_queue_map_name = "pfc_to_queue_map"; const string pfc_enable_name = "pfc_enable"; +const string tc_to_pg_map_field_name = "tc_to_pg_map"; const string tc_to_queue_field_name = "tc_to_queue_map"; -const string dscp_to_tc_field_name = "dscp_to_tc_map"; const string scheduler_field_name = "scheduler"; -const string wred_profile_field_name = "wred_profile"; +const string red_max_threshold_field_name = "red_max_threshold"; const string yellow_max_threshold_field_name = "yellow_max_threshold"; const string green_max_threshold_field_name = "green_max_threshold"; -const string red_max_threshold_field_name = "red_max_threshold"; -const string wred_green_enable_field_name = "wred_green_enable"; -const string wred_yellow_enable_field_name = "wred_yellow_enable"; + +const string wred_profile_field_name = "wred_profile"; const string wred_red_enable_field_name = "wred_red_enable"; +const string wred_yellow_enable_field_name = "wred_yellow_enable"; +const string wred_green_enable_field_name = "wred_green_enable"; const string scheduler_algo_type_field_name = "type"; const string scheduler_algo_DWRR = "DWRR"; @@ -29,12 +30,12 @@ const string scheduler_priority_field_name = "priority"; const string ecn_field_name = "ecn"; const string ecn_none = "ecn_none"; -const string ecn_green = "ecn_green"; -const string ecn_yellow = "ecn_yellow"; const string ecn_red = "ecn_red"; -const string ecn_green_yellow = "ecn_green_yellow"; -const string ecn_green_red = "ecn_green_red"; +const string ecn_yellow = "ecn_yellow"; const string ecn_yellow_red = "ecn_yellow_red"; +const string ecn_green = "ecn_green"; +const string ecn_green_red = "ecn_green_red"; +const string ecn_green_yellow = "ecn_green_yellow"; const string ecn_all = "ecn_all"; class QosMapHandler @@ -100,7 +101,7 @@ class PfcToQueueHandler : public QosMapHandler class QosOrch : public Orch { public: - QosOrch(DBConnector *db, vector &tableNames, PortsOrch *portsOrch); + QosOrch(DBConnector *db, vector &tableNames); static type_map& getTypeMap(); static type_map m_qos_type_maps; @@ -112,28 +113,24 @@ class QosOrch : public Orch typedef pair qos_handler_pair; void initTableHandlers(); + task_process_status handleDscpToTcTable(Consumer& consumer); + task_process_status handlePfcPrioToPgTable(Consumer& consumer); + task_process_status handlePfcToQueueTable(Consumer& consumer); + task_process_status handlePortQosMapTable(Consumer& consumer); + task_process_status handleTcToPgTable(Consumer& consumer); task_process_status handleTcToQueueTable(Consumer& consumer); task_process_status handleSchedulerTable(Consumer& consumer); task_process_status handleQueueTable(Consumer& consumer); - bool applyWredProfileToQueue(Port &port, size_t queue_ind, sai_object_id_t sai_wred_profile); - bool applySchedulerToQueueSchedulerGroup(Port &port, size_t queue_ind, sai_object_id_t scheduler_profile_id); - task_process_status handlePortQosMapTable(Consumer& consumer); - bool applyMapToPort(Port &port, sai_attr_id_t attr_id, sai_object_id_t sai_dscp_to_tc_map); task_process_status handleWredProfileTable(Consumer& consumer); - task_process_status ResolveMapAndApplyToPort( - Port &port, - sai_port_attr_t port_attr, - string field_name, - KeyOpFieldsValuesTuple &tuple, - string op); - task_process_status handleTcToPgTable(Consumer& consumer); - task_process_status handlePfcPrioToPgTable(Consumer& consumer); - task_process_status handlePfcToQueueTable(Consumer& consumer); + bool applyMapToPort(Port &port, sai_attr_id_t attr_id, sai_object_id_t sai_dscp_to_tc_map); + bool applySchedulerToQueueSchedulerGroup(Port &port, size_t queue_ind, sai_object_id_t scheduler_profile_id); + bool applyWredProfileToQueue(Port &port, size_t queue_ind, sai_object_id_t sai_wred_profile); + task_process_status ResolveMapAndApplyToPort(Port &port,sai_port_attr_t port_attr, + string field_name, KeyOpFieldsValuesTuple &tuple, string op); private: - PortsOrch *m_portsOrch; qos_table_handler_map m_qos_handler_map; }; #endif /* SWSS_QOSORCH_H */ diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index a0a30aa141b..289640e6462 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -3,10 +3,12 @@ #include "logger.h" #include "swssnet.h" +extern sai_object_id_t gVirtualRouterId; + extern sai_next_hop_group_api_t* sai_next_hop_group_api; extern sai_route_api_t* sai_route_api; -extern sai_object_id_t gVirtualRouterId; +extern PortsOrch *gPortsOrch; bool RouteOrch::hasNextHopGroup(IpAddresses ipAddresses) { @@ -17,9 +19,6 @@ void RouteOrch::doTask(Consumer& consumer) { SWSS_LOG_ENTER(); - if (!m_portsOrch->isInitDone()) - return; - auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { @@ -131,7 +130,6 @@ void RouteOrch::doTask(Consumer& consumer) void RouteOrch::increaseNextHopRefCount(IpAddresses ipAddresses) { - if (ipAddresses.getSize() == 1) { IpAddress ip_address(ipAddresses.to_string()); @@ -176,7 +174,7 @@ bool RouteOrch::addNextHopGroup(IpAddresses ipAddresses) { if (!m_neighOrch->hasNextHop(it)) { - SWSS_LOG_NOTICE("Failed to get next hop entry ip:%s", + SWSS_LOG_INFO("Failed to get next hop entry ip:%s", it.to_string().c_str()); return false; } @@ -257,6 +255,8 @@ bool RouteOrch::removeNextHopGroup(IpAddresses ipAddresses) void RouteOrch::addTempRoute(IpPrefix ipPrefix, IpAddresses nextHops) { + SWSS_LOG_ENTER(); + bool to_add = false; auto it_route = m_syncdRoutes.find(ipPrefix); auto next_hop_set = nextHops.getIpAddresses(); @@ -285,7 +285,7 @@ void RouteOrch::addTempRoute(IpPrefix ipPrefix, IpAddresses nextHops) { if (!m_neighOrch->hasNextHop(*it)) { - SWSS_LOG_NOTICE("Failed to get next hop entry ip:%s", + SWSS_LOG_INFO("Failed to get next hop entry ip:%s", (*it).to_string().c_str()); it = next_hop_set.erase(it); } @@ -325,7 +325,7 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops) } else { - SWSS_LOG_NOTICE("Failed to get next hop entry ip:%s", + SWSS_LOG_INFO("Failed to get next hop entry ip:%s", nextHops.to_string().c_str()); return false; } diff --git a/orchagent/routeorch.h b/orchagent/routeorch.h index e5b2d66133d..1dee7a0382b 100644 --- a/orchagent/routeorch.h +++ b/orchagent/routeorch.h @@ -31,10 +31,8 @@ typedef map RouteTable; class RouteOrch : public Orch { public: - RouteOrch(DBConnector *db, string tableName, - PortsOrch *portsOrch, NeighOrch *neighOrch) : + RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) : Orch(db, tableName), - m_portsOrch(portsOrch), m_neighOrch(neighOrch), m_nextHopGroupCount(0), m_resync(false) {}; @@ -42,7 +40,6 @@ class RouteOrch : public Orch bool hasNextHopGroup(IpAddresses); private: - PortsOrch *m_portsOrch; NeighOrch *m_neighOrch; int m_nextHopGroupCount; diff --git a/orchagent/tunneldecaporch.cpp b/orchagent/tunneldecaporch.cpp index 8caf22452bf..6d7744c8826 100644 --- a/orchagent/tunneldecaporch.cpp +++ b/orchagent/tunneldecaporch.cpp @@ -7,7 +7,7 @@ extern sai_tunnel_api_t* sai_tunnel_api; extern sai_router_interface_api_t* sai_router_intfs_api; extern sai_object_id_t gVirtualRouterId; -extern sai_object_id_t underlayIfId; +extern sai_object_id_t gUnderlayIfId; TunnelDecapOrch::TunnelDecapOrch(DBConnector *db, string tableName) : Orch(db, tableName) { @@ -20,9 +20,7 @@ TunnelDecapOrch::TunnelDecapOrch(DBConnector *db, string tableName) : Orch(db, t */ void TunnelDecapOrch::doTask(Consumer& consumer) { - auto it = consumer.m_toSync.begin(); - while (it != consumer.m_toSync.end()) { KeyOpFieldsValuesTuple t = it->second; @@ -195,7 +193,7 @@ bool TunnelDecapOrch::addDecapTunnel(string key, string type, IpAddresses dst_ip attr.value.oid = overlayIfId; tunnel_attrs.push_back(attr); attr.id = SAI_TUNNEL_ATTR_UNDERLAY_INTERFACE; - attr.value.oid = underlayIfId; + attr.value.oid = gUnderlayIfId; tunnel_attrs.push_back(attr); // decap ecn mode (copy from outer/standard) diff --git a/orchagent/tunneldecaporch.h b/orchagent/tunneldecaporch.h index 9fd86a2784d..1cfe1bf6b63 100644 --- a/orchagent/tunneldecaporch.h +++ b/orchagent/tunneldecaporch.h @@ -33,7 +33,6 @@ class TunnelDecapOrch : public Orch TunnelDecapOrch(DBConnector *db, string tableName); private: - TunnelTable tunnelTable; ExistingIps existingIps; diff --git a/portsyncd/linksync.cpp b/portsyncd/linksync.cpp index e6073389f97..bd942b70d61 100644 --- a/portsyncd/linksync.cpp +++ b/portsyncd/linksync.cpp @@ -95,7 +95,7 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj) if (nlmsg_type == RTM_DELLINK) m_vlanTableProducer.del(key); - else + else /* RTM_NEWLINK */ { FieldValueTuple t("tagging_mode", "untagged"); fvVector.push_back(t);