Skip to content

Commit

Permalink
Fix the timing issue could be hit in portmgrd
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenggen-xu committed Aug 30, 2019
1 parent aa92fd6 commit d92578d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,13 +1323,14 @@ bool PortsOrch::removePort(sai_object_id_t port_id)
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&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);
Expand Down Expand Up @@ -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());

}


Expand Down Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion portsyncd/linksync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -242,7 +249,7 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)
vector<FieldValueTuple> 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());
}
}
}

0 comments on commit d92578d

Please sign in to comment.