From d92578d30b6790592abcfde260608b4463cc69e9 Mon Sep 17 00:00:00 2001 From: Zhenggen Xu Date: Fri, 31 May 2019 14:59:04 -0700 Subject: [PATCH] Fix the timing issue could be hit in portmgrd --- orchagent/portsorch.cpp | 10 +++++----- portsyncd/linksync.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 70edecf52c..e35d6bf9d1 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1323,13 +1323,14 @@ bool PortsOrch::removePort(sai_object_id_t port_id) notify(SUBJECT_TYPE_PORT_CHANGE, static_cast(&update)); } + removeAclTableGroup(p); + sai_status_t status = sai_port_api->remove_port(port_id); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to remove port %" PRIx64 ", rv:%d", port_id, status); return false; } - removeAclTableGroup(p); m_portCount--; SWSS_LOG_NOTICE("Remove port %" PRIx64, port_id); @@ -1441,11 +1442,7 @@ void PortsOrch::deinitport(string alias, sai_object_id_t port_id) string key = getPortFlexCounterTableKey(sai_serialize_object_id(port_id)); m_flexCounterTable->del(key); - /* Delete port from port list */ - m_portList.erase(alias); - SWSS_LOG_NOTICE("De-Initialized port %s", alias.c_str()); - } @@ -2014,6 +2011,9 @@ void PortsOrch::doPortTask(Consumer &consumer) } removePortFromLanesMap(alias); removePortFromPortListMap(port_id); + + /* Delete port from port list */ + m_portList.erase(alias); } it = consumer.m_toSync.erase(it); diff --git a/portsyncd/linksync.cpp b/portsyncd/linksync.cpp index 20d41b7b8d..da7e3a5e12 100644 --- a/portsyncd/linksync.cpp +++ b/portsyncd/linksync.cpp @@ -222,6 +222,13 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj) /* Insert or update the ifindex to key map */ m_ifindexNameMap[ifindex] = key; + /* TODO: When port is removed from the kernel */ + if (nlmsg_type == RTM_DELLINK) + { + m_statePortTable.del(key); + SWSS_LOG_NOTICE("Delete %s(ok) from state db", key.c_str()); + } + /* front panel interfaces: Check if the port is in the PORT_TABLE * non-front panel interfaces such as eth0, lo which are not in the * PORT_TABLE are ignored. */ @@ -242,7 +249,7 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj) vector vector; vector.push_back(tuple); m_statePortTable.set(key, vector); - SWSS_LOG_INFO("Publish %s(ok) to state db", key.c_str()); + SWSS_LOG_NOTICE("Publish %s(ok) to state db", key.c_str()); } } }